Skip to content
This repository has been archived by the owner on Dec 6, 2024. It is now read-only.

Stabilize messaging semantic conventions for tracing #192

Closed
wants to merge 39 commits into from
Closed
Changes from 1 commit
Commits
Show all changes
39 commits
Select commit Hold shift + click to select a range
03d8291
Messaging semantic conventions for tracing, first draft
pyohannes Dec 1, 2021
13c975d
Change name to PR request id
pyohannes Dec 2, 2021
8f4349f
Update text/trace/0192-messaging-semantic-conventions-spec.md
pyohannes Dec 6, 2021
98cf8f3
PR comments
pyohannes Dec 6, 2021
2d8f25c
PR comments
pyohannes Dec 6, 2021
f48379f
Add first draft for consumer instrumentation span structure
pyohannes Dec 10, 2021
5e67b1f
Fix spelling
pyohannes Dec 10, 2021
7b2dbe9
PR comments
pyohannes Dec 15, 2021
f23c5ac
Rename the "Receive" span to "Deliver"
pyohannes Dec 16, 2021
51501ce
Push and pull based consumer scenarios
pyohannes Feb 3, 2022
20f272c
Remove obsolete text
pyohannes Feb 3, 2022
1e14ff0
Clarify context propagation
pyohannes Feb 3, 2022
b87adf6
Fix markdownlint errors
pyohannes Feb 3, 2022
20887d2
Add links
pyohannes Feb 3, 2022
2ae923d
PR comments
pyohannes Feb 4, 2022
0e8f824
Producer scenarios
pyohannes Mar 16, 2022
161392e
Remove trailing whitespace
pyohannes Mar 16, 2022
f40ff57
Fix wording
pyohannes Mar 16, 2022
523c435
Add examples
pyohannes Mar 16, 2022
4d341f6
Fix examples
pyohannes Mar 16, 2022
4615994
Add draft for settlement instrumentation
pyohannes Apr 5, 2022
71e5ab8
Complete settlement section
pyohannes Apr 7, 2022
b316b1a
Add details about span kinds and names
pyohannes Apr 22, 2022
bcd328e
Fix markdown lint error
pyohannes Apr 22, 2022
0e4a777
Update text/trace/0192-messaging-semantic-conventions-spec.md
pyohannes May 4, 2022
d91ac98
Update text/trace/0192-messaging-semantic-conventions-spec.md
pyohannes May 4, 2022
40c1d13
Add first attributes
pyohannes May 4, 2022
e2738c6
Avoid using the term "client"
pyohannes May 4, 2022
9055167
Add TOC
pyohannes May 4, 2022
8e663f0
Add more attributes
pyohannes May 16, 2022
7c1d84c
Add network transport attributes
pyohannes Jun 15, 2022
38dc813
Update text/trace/0192-messaging-semantic-conventions-spec.md
pyohannes Jul 1, 2022
92a1dd5
Update text/trace/0192-messaging-semantic-conventions-spec.md
pyohannes Jul 12, 2022
8dc5b9f
Apply suggestions from code review
pyohannes Jul 12, 2022
72e1215
PR comments
pyohannes Jul 12, 2022
e4ccef0
Merge branch 'main' into conventions-messaging
joaopgrassi Aug 2, 2022
5fa715d
PR suggestions and grammar fixes
joaopgrassi Aug 2, 2022
8b4461a
Make messaging.system attribute level required
joaopgrassi Aug 2, 2022
964d65e
Set requirement level for destination.temporary and anonymous
joaopgrassi Aug 5, 2022
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
Prev Previous commit
Next Next commit
Push and pull based consumer scenarios
  • Loading branch information
pyohannes committed Apr 7, 2022
commit 51501cec4e3188967333a20b1527a6f169ced01a
140 changes: 105 additions & 35 deletions text/trace/0192-messaging-semantic-conventions-spec.md
Original file line number Diff line number Diff line change
Expand Up @@ -94,29 +94,29 @@ traces, how to propagate context, and how to enrich traces with attributes.

### Context propagation

Two layers of context propagation need to be distinguished for messaging
workflows:

1. The _creation context layer_ allows correlating the producer with the
consumers of a message, regardless of intermediary instrumentation. The
creation context is created by the producer and must be propagated to the
consumers. It must not be altered by intermediaries.

This layer helps to model dependencies between producers and consumers,
regardless of the underlying messaging transport mechanism and its
instrumentation.
2. The _transport context layer_ allows correlating the producer and the
consumer with an intermediary. It also allows to correlate multiple
intermediaries among each other. The transport context can be changed by
intermediaries, according to intermediary instrumentations. Intermediaries
that are not instrumented might simply drop the transport context.

This layer helps to gain insights into details of the message transport.

A producer SHOULD attach a creation context to each message. The creation context
SHOULD be attached in a way so that it is not changed by intermediaries. A
producer MAY propagate a transport context to an intermediary. An
intermediary MAY propagate a transport context to a consumer.
A message may pass many different components and layers in one or more
intermediaries when it is propagated from the producer to the consumer. It
cannot be assumed, and in many cases it is not even desired, that all those
components and layers are instrumented and propagate context according to
OpenTelemetry requirements.

A _creation context_ allows correlating the producer with the consumers of a
message, regardless of intermediary instrumentation. The creation context is
created by the producer and must be propagated to the consumers. It must not be
altered by intermediaries.

This context helps to model dependencies between producers and consumers,
regardless of the underlying messaging transport mechanism and its
instrumentation.

Several attempts exist to standardize the propagation of a creation context for
different messaging protocols:
* [AMQP](https://w3c.github.io/trace-context-amqp/)
* [MQTT](https://w3c.github.io/trace-context-mqtt/)
* [CloudEvents via HTTP](https://github.com/cloudevents/spec/blob/v1.0.1/extensions/distributed-tracing.md)

> A producer SHOULD attach a creation context to each message. The creation context
> SHOULD be attached in a way so that it is not changed by intermediaries.
pyohannes marked this conversation as resolved.
Show resolved Hide resolved

### Trace structure, names, and attributes

pyohannes marked this conversation as resolved.
Show resolved Hide resolved
Expand All @@ -135,10 +135,19 @@ processing callbacks, which can then be instrumented by the libraries or SDKs).
While it is possible to create "Process" spans and correlate those with
consumer traces in certain cases, this is not something that can be generally
required. Therefore, it is more feasible to require the creation of "Deliver"
pyohannes marked this conversation as resolved.
Show resolved Hide resolved
spans to correlate producer with consumer traces. A "Deliver" span must link
to the "Create" spans of all messages that are handled by the respective
"Deliver" operation. Depending on the use case, "Deliver" spans can correlate
with "Process" spans or other spans modelling processing operations.
spans (for push-based APIs) or "Receive" spans (for pull-based APIs) to
correlate producer with consumer traces.

##### Instrumenting push-based scenarios

In push-based consumer scenarios, the delivery of messages is not initiated by
the application code. Instead, callbacks or handlers are registered and then
called by messaging SDKs to forward messages to the application.

A "Deliver" span covers the call of such a callback or handler, and should link
to the "Create" spans of all messages that are forwarded via the respective
call. Depending on the use case, "Deliver" spans can correlate with "Process"
spans or other spans modelling processing operations.

The operation modelled by the "Deliver" span does not strictly refer to
receiving the message from intermediaries, but instead refers to the
Expand All @@ -149,17 +158,78 @@ from intermediaries and cache those messages, and only forward messages to the
application at a later time. In this case, the operation of pre-fetching and
caching should not be covered by the "Deliver" span.

"Deliver" spans SHOULD be created for all messages obtained by or passed to the
application for processing. "Deliver" spans MUST NOT be created for messages
not forwarded to the application, but pre-fetched or cached by messaging
libraries or SDKs. A single "Deliver" span can account for a single message,
for multiple messages (in case messages are passed for processing as batches),
or for no message at all (in it is signalled that no messages were received).
For each message it accounts for, a "Deliver" span SHOULD link to the "Create"
span for the message.
> "Deliver" spans SHOULD be created for operations of passing messages to the
> application, when the those operations are not initiated by the application
> code. A single "Deliver" span can account for a single message, for multiple
> messages (in case messages are passed for processing as batches), or for no
> message at all (if it is signalled that no messages were received). For each
> message it accounts for, a "Deliver" span SHOULD link to the "Create" span for
> the message.

##### Instrumenting pull-based scenarios
pyohannes marked this conversation as resolved.
Show resolved Hide resolved

In pull-based consumer scenarios, the delivery of messages is requested by the
application code. This usually involves a blocking call, which returns zero or
pyohannes marked this conversation as resolved.
Show resolved Hide resolved
more messages on completion.

A "Receive" span covers such calls, and should link
to the "Create" spans of all messages that are forwarded via the respective
call. Depending on the use case, "Receive" spans can correlate with "Process"
spans or other spans modelling processing operations.

> "Receive" spans SHOULD be created for operations of passing messages to the
> application, when the those operations are initiated by the application code.
pyohannes marked this conversation as resolved.
Show resolved Hide resolved
> A single "Receive" span can account for a single message, for multiple messages
> (in case messages are passed for processing as batches), or for no message at
> all (if it is signalled that no messages were received). For each message it
> accounts for, a "Receive" span SHOULD link to the "Create" span for the
> message.

##### General considerations

The operations modelled by "Deliver" or "Receive" spans do not strictly refer
to receiving the message from intermediaries, but instead refer to the
application receiving messages for processing. If messages are fetched from the
pyohannes marked this conversation as resolved.
Show resolved Hide resolved
intermediary and forwarded to the application in one go, the whole operation
might be covered by a "Deliver" or "Receive" span. However, clients might
pyohannes marked this conversation as resolved.
Show resolved Hide resolved
pre-fetch messages from intermediaries and cache those messages, and only
forward messages to the application at a later time. In this case, the
operation of pre-fetching and caching should not be covered by the "Deliver" or
"Receive" spans.

pyohannes marked this conversation as resolved.
Show resolved Hide resolved
> "Deliver" or "Receive" spans MUST NOT be created for messages which are not
> forwarded to the application, but are pre-fetched or cached by messaging
> libraries or SDKs.

### System-specific extensions

### Examples

## Future possibilities

### Context propagation

One possibility to seamlessly integrate producer/consumer and intermediary
instrumentation in a flexible and extensible way would be the introduction of a
second transport context layer in addition to the creation context layer.

1. The _creation context layer_ allows correlating the producer with the
consumers of a message, regardless of intermediary instrumentation. The
creation context is created by the producer and must be propagated to the
consumers. It must not be altered by intermediaries.

Choose a reason for hiding this comment

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

"It Should not be altered by intermediaries."
Because we are going to discuss intermediaries later.


This layer helps to model dependencies between producers and consumers,
regardless of the underlying messaging transport mechanism and its
instrumentation.
2. An additional _transport context layer_ allows correlating the producer and
the consumer with an intermediary. It also allows to correlate multiple
intermediaries among each other. The transport context can be changed by

Choose a reason for hiding this comment

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

The correlation should be message based. "Correlating intermediaries" sounds like broker framework related work. Do we want to provide tools to make that easier? Which ones?

intermediaries, according to intermediary instrumentations. Intermediaries that
are not instrumented might simply drop the transport context.

This layer helps to gain insights into details of the message transport.

This would keep the existing correlation between producers and consumer intact,
while allowing intermediaries to use the transport context to correlate
intermediary instrumentation with existing producer and consumer
instrumentations.