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

Randomness requirements following W3C Trace Context level 2 #4162

Open
wants to merge 25 commits into
base: main
Choose a base branch
from

Conversation

jmacd
Copy link
Contributor

@jmacd jmacd commented Jul 25, 2024

Changes

Updates Trace SDK and Propagator specifications with

  • List W3C propagator requirements (e.g., should propagate tracestate)
  • Introduce W3C Trace Context Level 2 w/ the Random flag
  • Define explicit randomness feature from OTEP 235, OTEP 261
  • Trace SDK default ID generator should include 56 bits of randomness in the correct location
  • Trace SDK for root spans: either set the random flag to confirm the above, or use an explicit randomness value.

Part of #1413.
Part of #3602.

Product of the Sampling SIG members @kentquirk @kalyanaj @oertl @PeterF778 and myself.

@jmacd jmacd changed the title Draft rules for span context in Trace Context level 2 Randomness requirements for W3C Trace Context level 2 Jul 26, 2024
@jmacd jmacd changed the title Randomness requirements for W3C Trace Context level 2 Randomness requirements following W3C Trace Context level 2 Jul 26, 2024
@jmacd jmacd marked this pull request as ready for review July 29, 2024 23:24
@jmacd jmacd requested review from a team July 29, 2024 23:24
Copy link
Member

@marcalff marcalff left a comment

Choose a reason for hiding this comment

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

See nit comment about text formatting, for diff

specification/trace/sdk.md Outdated Show resolved Hide resolved
Copy link
Member

@marcalff marcalff left a comment

Choose a reason for hiding this comment

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

LGTM.

specification/trace/sdk.md Outdated Show resolved Hide resolved
specification/context/api-propagators.md Outdated Show resolved Hide resolved
specification/trace/tracestate-handling.md Outdated Show resolved Hide resolved
specification/trace/tracestate-handling.md Show resolved Hide resolved
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 Aug 15, 2024
@jmacd jmacd removed the Stale label Aug 15, 2024
specification/trace/sdk.md Outdated Show resolved Hide resolved
specification/trace/sdk.md Show resolved Hide resolved
Copy link
Member

@jpkrohling jpkrohling left a comment

Choose a reason for hiding this comment

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

Overall, LGTM, only a question about being more explicit in how SDKs can accept the randomness values set by API users.

spec-compliance-matrix.md Outdated Show resolved Hide resolved
specification/trace/api.md Show resolved Hide resolved
specification/trace/sdk.md Show resolved Hide resolved
specification/trace/sdk.md Show resolved Hide resolved
specification/trace/sdk.md Outdated Show resolved Hide resolved
specification/trace/tracestate-handling.md Show resolved Hide resolved
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 Sep 27, 2024
@jmacd jmacd removed the Stale label Oct 2, 2024
@jmacd jmacd requested review from a team as code owners October 2, 2024 22:50
specification/trace/sdk.md Outdated Show resolved Hide resolved
CHANGELOG.md Outdated Show resolved Hide resolved
@jmacd jmacd dismissed tsloughter’s stale review October 4, 2024 21:11

Please take another look, this should be fixed :-)

hexdigit = DIGIT ; a-f
```

The explicit randomness value is meant to be used instead of extracting randomness from TraceIDs, therefore it contains the same number of bits as a W3C Trace Context Level 2 recommends for TraceIDs.
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
The explicit randomness value is meant to be used instead of extracting randomness from TraceIDs, therefore it contains the same number of bits as a W3C Trace Context Level 2 recommends for TraceIDs.
The explicit randomness value is meant to be used instead of extracting randomness from TraceIDs, therefore it contains the same number of bits as W3C Trace Context Level 2 recommends for TraceIDs.


#### Explicit trace randomness

For root span contexts, the when the SDK generates a TraceID that does not meet the [W3C Trace Context Level 2 randomness requirements][W3CCONTEXTTRACEID], and when the initial `TraceState` does not already define the [`rv` sub-key of the OpenTelemetry TraceState][OTELRVALUE], the SDK SHOULD insert an explicit trace randomness value into the OpenTelemetry TraceState value containing 56 random bits.
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
For root span contexts, the when the SDK generates a TraceID that does not meet the [W3C Trace Context Level 2 randomness requirements][W3CCONTEXTTRACEID], and when the initial `TraceState` does not already define the [`rv` sub-key of the OpenTelemetry TraceState][OTELRVALUE], the SDK SHOULD insert an explicit trace randomness value into the OpenTelemetry TraceState value containing 56 random bits.
For root span contexts, when the SDK generates a TraceID that does not meet the [W3C Trace Context Level 2 randomness requirements][W3CCONTEXTTRACEID], and when the initial `TraceState` does not already define the [`rv` sub-key of the OpenTelemetry TraceState][OTELRVALUE], the SDK SHOULD insert an explicit trace randomness value into the OpenTelemetry TraceState value containing 56 random bits.


The OTLP representation for Span and Span Link includes a 32-bit field declared as Span Flags.

Bits 0-7 of the Span Flags field are reserved for the 8 bits of Trace Context flags,
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
Bits 0-7 of the Span Flags field are reserved for the 8 bits of Trace Context flags,
Bits 0-7 (8 least significant bits) of the Span Flags field are reserved for the 8 bits of Trace Context flags,

Comment on lines +483 to +484
### Sampling Requirements

Copy link
Member

Choose a reason for hiding this comment

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

this doc is marked "stable except where otherwise specified", is this section intentionally going straight to stable?

@@ -530,6 +592,13 @@ public interface IdGenerator {
}
```

Custom implementations of the `IdGenerator` SHOULD support setting the
Copy link
Contributor

Choose a reason for hiding this comment

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

nit:

SHOULD support setting

it seems the SDK would be responsible to set the random flag based on some IdGenerator property, and the IdGenerator would only expose some information about itself.


#### Explicit trace randomness

For root span contexts, the when the SDK generates a TraceID that does not meet the [W3C Trace Context Level 2 randomness requirements][W3CCONTEXTTRACEID], and when the initial `TraceState` does not already define the [`rv` sub-key of the OpenTelemetry TraceState][OTELRVALUE], the SDK SHOULD insert an explicit trace randomness value into the OpenTelemetry TraceState value containing 56 random bits.
Copy link
Contributor

@lmolkova lmolkova Oct 11, 2024

Choose a reason for hiding this comment

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

the SDK SHOULD insert an explicit trace randomness value into the OpenTelemetry TraceState

should it be an SDK responsibility? I assume that all OTel SDKs would (if not already) generate random trace-ids and rv would only be needed when custom id generator is used.
The distro/application that uses custom generator can be responsible for setting rv if they use non-random trace-ids and only if they need consistent sampling.

If we ask SDKs to do it, the concern is that at least initially, while most of systems don't support W3C Trace-Context level 2 and random flag, updated OTel SDKs will start generating rv (and start widely using tracestate).

@carlosalberto
Copy link
Contributor

Overall LGTM (once some of the latest feedback comments have been addressed).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.