Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Common event attribute names #397

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
65 changes: 65 additions & 0 deletions specification/data-events.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
# Semantic conventions for events

Event types are identified by the event name. Library and application implementors
are free to define any event name that make sense with the exception of the
following reserved names.

## Reserved event names

| Event name | Notes and examples |
| :---------- | :----------------------------------------------------------------- |
| `"message"` | Event with the details of a single message within a span. |

## Message event attributes

Each message sent/received within a span should be recorded as an event. In the
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm inclined to say that messages "MAY" be recorded as events. For a gRPC stream, in particular, I'm not sure that message events are always desired. I'd like the semantic convention to apply when the decision is made to record message events, but not to specify when you SHOULD record message events.

case of synchronous RPC calls there will be one sent and one received event per
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should the recommended limit on number of messages associated with the span defined?

span. In case of a stream span such as a gRPC stream, WebSocket or HTTP
server-sent events, there could be multiple messages with each message recorded
as an individual event.

Event `"name"` MUST be `"message"`.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is missing a description of what a message event is even supposed to describe, i.e. when should I add message events to my span.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@arminru 29 days ago:

I don't quite understand what the proposed message event is about. When would I use this one and when would I create a (child) span with the attributes defined in #395?

@kbrockhoff please help :-)


Message events MUST be associated with a tracing span.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I feel there needs to be some guidance as to when we add these attributes on an event vs on a span. It's fine to say that they should always be an event, even when the span only have one "event" such as an http request.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes we should always use them as event attributes even though we know only one event can occur per Span.


| Attribute name | Notes and examples | Required? |
| :------------- | :------------------------------------- | --------- |
| `message.type` | Either `"SENT"` or `"RECEIVED"`. | Yes |
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should it be boolean or more types are expected?

| `message.id` | Unique identifier within a span and `message.type` for the individual message. Further specifications for common protocols are discussed below. | No |
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

specify the attribute type. string?

| `message.compressed_size` | Compressed size in bytes. | No |
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is it always known that the message was compressed? Perhaps size will be size of a message, and than two separate sizes for compressed and uncompressed be specified.

| `message.uncompressed_size` | Uncompressed size in bytes. | No |
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

just as an idea, maybe we should think about a bit shorter names :) if you have any suggestion I would be happy to hear :)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You don't really need the word "uncompressed" in my opinion.

  • message.size - uncompressed size
  • message.compressed or message.compressed_size - compressed size

| `message.content` | The body or main contents of the message. If binary, then message should be Base64 encoded. | No |
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should there be an attribute for the metadata/headers? May be more valuable than the content of the message and cheaper to collect.


To conserve bandwith and/or storage, exporters MAY drop the `message.content`
attribute if present. Logging-only exporters bundled with default OpenTelemetry
SDKs SHOULD provide affordances for logging this information as it is highly
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In case of instrumentation adapters passing an additional configuration may sounds ok. However if messaging SDK is pre-instrumented with OpenTelemetry - it will be a setting on messaging SDK itself. Perhaps this paragraph can be rephrased to express this

useful during the early stages of developing a new application.

### Representative message.id attribute values

#### gRPC

For [gRPC], `message.id` MUST be calculated as two different counters starting
from `1`, the first for sent messages and the second for received messages.
This way we guarantee that the values will be consistent between different
implementations. Server streaming, client streaming and bidirectional streaming
RPCs provided gRPC all guarantee message ordering so there should be no
discrepencies between the sender and receiver spans.

#### Server-Sent Events

For [Server-Sent Events] included in the HTML5 specification, `message.id` MUST
match the `id` field of an event if it does not contain U+0000 NULL. Otherwise,
the attribute should not be populated. This is equivalent to what gets populated
to the last event ID buffer of the `EventSource` object specified in the SSE
specification.

#### Java Message Service (JMS)

For JMS, `message.id` SHOULD be set to the value of the `JMSMessageID`field
exposed by [JMS Message]. This value uniquely identifies each message sent by
a provider.

[gRPC]: https://www.grpc.io/docs/guides/concepts/
[Server-Sent Events]: https://html.spec.whatwg.org/multipage/server-sent-events.html
[JMS Message]: https://docs.oracle.com/javaee/7/api/javax/jms/Message.html
1 change: 1 addition & 0 deletions specification/data-semantic-conventions.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,3 +30,4 @@ The following semantic conventions for spans are defined:
* [Database](data-database.md): Spans for SQL and NoSQL client calls.
* [RPC/RMI](data-rpc.md): Spans for remote procedure calls (e.g., gRPC).
* [General](data-span-general.md): General semantic attributes that may be used in describing different kinds of operations.
* [Event](data-events.md): Attributes for events.