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

Refactor description of span kind #4088

Closed
wants to merge 2 commits into from

Conversation

pyohannes
Copy link
Contributor

Fixes #3172

Changes

This PR provides some re-wording for the SpanKind section of the tracing API specification.

The current wording has caused some confusion, in particular related to consumer and producer spans. Some readers have assumed that a consumer span needs to be a child of the producer span it relates to, however, this is not the case. In particular the wording "logical remote child or parent" has been confusing.

The PR adds clarifications around span links as valid way to correlate spans, as well it avoids the misleading wording of logical child or parents.

This PR just adds clarifications, it doesn't involve any functional changes.

Copy link
Contributor

@lmolkova lmolkova left a comment

Choose a reason for hiding this comment

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

It seems we don't have clear boundaries between span kinds and rely on the context to explain what they should be (which is confusing to me).

I wonder if we can simplify this section to state that

  • operations that are requested externally are SERVER/CONSUMER
  • operations that are requesting work somewhere else are CLIENT/PRODUCER
  • for everything else we don't know and suggest defining it on case-by-cases basis in the semconv
  • (non-normative) it's common to describe logical operations as client spans

@@ -749,36 +749,36 @@ This functionality MUST be fully implemented in the API, and SHOULD NOT be overr

## SpanKind

`SpanKind` describes the relationship between the Span, its parents,
and its children in a Trace. `SpanKind` describes two independent
`SpanKind` describes the relationship between Spans that are correlated via
Copy link
Contributor

Choose a reason for hiding this comment

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

nitpicking.

maybe

Suggested change
`SpanKind` describes the relationship between Spans that are correlated via
`SpanKind` clarifies the relationship between Spans that are correlated via

it does not really describe the relationship

Comment on lines +756 to +757
The first property described by `SpanKind` reflects whether, from the point of
view of the library that is being instrumented, a Span sends a message or
Copy link
Contributor

Choose a reason for hiding this comment

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

more nitpicking:

Suggested change
The first property described by `SpanKind` reflects whether, from the point of
view of the library that is being instrumented, a Span sends a message or
The first property described by `SpanKind` reflects whether, from the instrumentation point of
view, a Span sends a message or

(it's not necessarily a library, it could be FaaS or another piece of infra)

the functionality are built and instrumented. These scenarios, when they occur,
The first property described by `SpanKind` reflects whether, from the point of
view of the library that is being instrumented, a Span sends a message or
request (CLIENT and PRODUCER spans), or whether a Span receives or handles
Copy link
Contributor

Choose a reason for hiding this comment

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

more nit:
Span sends/span receives -> span describes an operations that (?)

request (CLIENT and PRODUCER spans), or whether a Span receives or handles
a message or request (SERVER and CONSUMER spans). Spans with a remote
parent or remote incoming link are interesting because they are sources of
external load. Spans with a remote child remote ougoing links are interesting
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
external load. Spans with a remote child remote ougoing links are interesting
external load. Spans with a remote child or remote ougoing links are interesting

Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
external load. Spans with a remote child remote ougoing links are interesting
external load. Spans with a remote child or remote outgoing links are interesting

In order for `SpanKind` to be meaningful, callers SHOULD arrange that a single
Span does not serve more than one purpose. For example, a server-side span
SHOULD NOT be used directly as the parent of another remote span. As a simple
guideline, instrumentation should create a new Span prior to extracting and
Copy link
Contributor

Choose a reason for hiding this comment

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

I know it was here before, but it does not look right:

Suggested change
guideline, instrumentation should create a new Span prior to extracting and
guideline, instrumentation should create a new Span prior to injecting and

individual messages requires a new `PRODUCER` span per message to
be created.
* `CONSUMER` Indicates that the span describes a child of an
* `CONSUMER` Indicates that the span describes the receiving or handling of an
asynchronous `PRODUCER` request.
* `INTERNAL` Default value. Indicates that the span represents an
Copy link
Contributor

@lmolkova lmolkova Jun 27, 2024

Choose a reason for hiding this comment

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

I think the table ("To summarize the interpretation of these kinds:") is not up to date and should be updated as well:

client is not necessarily remote outgoing, but also logical as note on line 778 indicates (or there are no means to propagate context)

guideline, instrumentation should create a new Span prior to extracting and
serializing the SpanContext for a remote call.

Note: there are complex scenarios where a CLIENT span may have a child that is
Copy link
Contributor

@lmolkova lmolkova Jun 27, 2024

Choose a reason for hiding this comment

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

since we clarified that DB, messaging, GenAI and potentially other conventions generate client spans which are logical operations that may or may not have transport-level spans and it's actually a common scenario to have nested client spans, could we rephrase it? E.g.

Suggested change
Note: there are complex scenarios where a CLIENT span may have a child that is
Note: CLIENT span may have a child that is

request (CLIENT and PRODUCER spans), or whether a Span receives or handles
a message or request (SERVER and CONSUMER spans). Spans with a remote
parent or remote incoming link are interesting because they are sources of
external load. Spans with a remote child remote ougoing links are interesting
Copy link
Contributor

@lmolkova lmolkova Jun 27, 2024

Choose a reason for hiding this comment

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

I feel using context propagation to express span kinds is not helpful:

  • initiating a connection can be captured as a CLIENT span, but there are no means to pass the context around.
  • same with DNS, TLS, streaming calls, which are leaf spans

I wonder if we could rephrase it like

Suggested change
external load. Spans with a remote child remote ougoing links are interesting
external load. It'd useful to distinguish CLIENT spans as such that describe logical or physical calls to external systems or components.

The first property described by `SpanKind` reflects whether, from the point of
view of the library that is being instrumented, a Span sends a message or
request (CLIENT and PRODUCER spans), or whether a Span receives or handles
a message or request (SERVER and CONSUMER spans). Spans with a remote
Copy link
Contributor

@lmolkova lmolkova Jun 27, 2024

Choose a reason for hiding this comment

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

Similar to a client concern, context is not really helping to clarify server/consumer kind:

  • if upstream is not instrumented or my protocol does not support propagation, I have no remote context
  • if I'm not using upstream context (on a public boundary), it does not mean I should create INTERNAL spans
    ...

Could we describe SERVER/CONSUMER spans as those that process external load?

Copy link

github-actions bot commented Jul 5, 2024

This PR was marked stale due to lack of activity. It will be closed in 7 days.

Copy link

This PR was marked stale due to lack of activity. It will be closed in 7 days.

@github-actions github-actions bot added the Stale label Jul 16, 2024
Copy link

Closed as inactive. Feel free to reopen if this PR is still being worked on.

@github-actions github-actions bot closed this Jul 23, 2024
@lmolkova lmolkova mentioned this pull request Aug 6, 2024
2 tasks
lmolkova added a commit that referenced this pull request Sep 3, 2024
Fixes #3172

(Built on top of #4088)

## Changes

- Explains kinds without assuming presence of parent/children 
- Adds links as another correlation mechanism
- Normalizes nested client spans even further - database, messaging,
RPC, and LLM semantic conventions require CLIENT kind for logical client
operation.
- Does not touch INTERNAL kind yet -
#4179

* [x] Related issues #3172,
open-telemetry/semantic-conventions#674,
open-telemetry/oteps#172,
open-telemetry/semantic-conventions#1315
* ~~[ ] Related [OTEP(s)](https://github.com/open-telemetry/oteps) #~~
* ~~[ ] Links to the prototypes (when adding or changing features)~~
* [x]
[`CHANGELOG.md`](https://github.com/open-telemetry/opentelemetry-specification/blob/main/CHANGELOG.md)
file updated for non-trivial changes
* ~~[ ]
[`spec-compliance-matrix.md`](https://github.com/open-telemetry/opentelemetry-specification/blob/main/spec-compliance-matrix.md)
updated if necessary~~

---------

Co-authored-by: Tigran Najaryan <4194920+tigrannajaryan@users.noreply.github.com>
Co-authored-by: Yuri Shkuro <yurishkuro@users.noreply.github.com>
Co-authored-by: Trask Stalnaker <trask.stalnaker@gmail.com>
carlosalberto pushed a commit to carlosalberto/opentelemetry-specification that referenced this pull request Oct 31, 2024
Fixes open-telemetry#3172

(Built on top of open-telemetry#4088)

## Changes

- Explains kinds without assuming presence of parent/children 
- Adds links as another correlation mechanism
- Normalizes nested client spans even further - database, messaging,
RPC, and LLM semantic conventions require CLIENT kind for logical client
operation.
- Does not touch INTERNAL kind yet -
open-telemetry#4179

* [x] Related issues open-telemetry#3172,
open-telemetry/semantic-conventions#674,
open-telemetry/oteps#172,
open-telemetry/semantic-conventions#1315
* ~~[ ] Related [OTEP(s)](https://github.com/open-telemetry/oteps) #~~
* ~~[ ] Links to the prototypes (when adding or changing features)~~
* [x]
[`CHANGELOG.md`](https://github.com/open-telemetry/opentelemetry-specification/blob/main/CHANGELOG.md)
file updated for non-trivial changes
* ~~[ ]
[`spec-compliance-matrix.md`](https://github.com/open-telemetry/opentelemetry-specification/blob/main/spec-compliance-matrix.md)
updated if necessary~~

---------

Co-authored-by: Tigran Najaryan <4194920+tigrannajaryan@users.noreply.github.com>
Co-authored-by: Yuri Shkuro <yurishkuro@users.noreply.github.com>
Co-authored-by: Trask Stalnaker <trask.stalnaker@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Clarify semantic of SpanKind regarding parent/child relationships
4 participants