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

Allow samplers to modify tracestate #988

Merged
merged 6 commits into from
Sep 25, 2020

Conversation

lmolkova
Copy link
Contributor

Fixes #856

Changes

Added Tracestate to SamplingResult

Related oteps open-telemetry/oteps#135

@lmolkova lmolkova requested review from a team September 22, 2020 17:38
@lmolkova lmolkova changed the title Allow samplers to modify tracestate, fix #856 Allow samplers to modify tracestate Sep 22, 2020
@iNikem
Copy link
Contributor

iNikem commented Sep 22, 2020

This seems to me to contradict this:

Please note, since SpanContext is immutable, it is not possible to update SpanContext with a new TraceState. Such changes then make sense only right before SpanContext propagation or telemetry data exporting. In both cases, Propagators and SpanExporters may create a modified TraceState copy before serializing it to the wire.

By W3C Trace Context specification, Tracestate is immutable. So is SpanContext. How can samplers change immutable object inside another immutable object?

specification/trace/sdk.md Outdated Show resolved Hide resolved
@lmolkova
Copy link
Contributor Author

lmolkova commented Sep 22, 2020

@iNikem

By W3C Trace Context specification, Tracestate is immutable. So is SpanContext. How can samplers change immutable object inside another immutable object?

Tracestate can be mutated.

This change enables following scenario

  • propagator parses trace-context (with tracestate)
  • sampler is invoked
    • it can read a parent tracestate (possible today)
    • make a copy and modify it
    • add it to sampling result (not possible today)
  • open-telemetry sdk creates a new SpanContext with a tracestate from sampling result (not from parent context)

Let me know if this helps.

@iNikem
Copy link
Contributor

iNikem commented Sep 22, 2020

Workflow does make sense, thank you. I still worry about implementation.

Does this mean that a new instance of SpanContext has to always be created after receiving sampling decision? Or SDK has to detect changes in TraceState?

@Oberon00
Copy link
Member

@iNikem Because of the new SpaId, a new SpanContext has to be created anyway. I expect implementation here to be trivial, replacing parent.tracestate with decision.tracestate

@carlosalberto carlosalberto self-requested a review September 24, 2020 00:19
Copy link
Member

@Oberon00 Oberon00 left a comment

Choose a reason for hiding this comment

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

I think the new spec is quite confusing and unclear on what the sampler needs to do to use the parent tracestate without modification vs when the tracestate will be cleared. See my comment #988 (comment)

@lmolkova
Copy link
Contributor Author

@Oberon00 I changed the wording as you suggested, thank you. Please have a look.

@Oberon00
Copy link
Member

Thank you for addressing my comments! I approved your PR, it looks great now!

@Oberon00 Oberon00 added area:sampling Related to trace sampling area:sdk Related to the SDK spec:trace Related to the specification/trace directory labels Sep 25, 2020
@@ -29,6 +29,8 @@ New:
* `exception.escaped` semantic span event attribute was added
([#784](https://github.com/open-telemetry/opentelemetry-specification/pull/784),
[#946](https://github.com/open-telemetry/opentelemetry-specification/pull/946))
- Allow samplers to modify tracestate
([#856](https://github.com/open-telemetry/opentelemetry-specification/pull/988/))
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
([#856](https://github.com/open-telemetry/opentelemetry-specification/pull/988/))
([#988](https://github.com/open-telemetry/opentelemetry-specification/pull/988/))

* A `Tracestate` that will be associated with the `Span` through the new
`SpanContext`.
Note: If the sampler returns an empty `Tracestate` here, the `Tracestate` will be cleared,
so samplers should normally return the passed-in `Tracestate` if they do not intend
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
so samplers should normally return the passed-in `Tracestate` if they do not intend
so samplers SHOULD return the `Tracestate` passed to them, if they do not intend

Copy link
Member

@Oberon00 Oberon00 Sep 25, 2020

Choose a reason for hiding this comment

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

In a Note, we should not have upper-case requirements. If you want reword it, also drop the "Note:", and probably make it a MUST

Copy link
Member

@arminru arminru left a comment

Choose a reason for hiding this comment

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

@lmolkova Please add an entry in spec-compliance-matrix.md to keep track of implementations adopting the change.

@@ -29,6 +29,8 @@ New:
* `exception.escaped` semantic span event attribute was added
([#784](https://github.com/open-telemetry/opentelemetry-specification/pull/784),
[#946](https://github.com/open-telemetry/opentelemetry-specification/pull/946))
- Allow samplers to modify tracestate
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
- Allow samplers to modify tracestate
- Add (modified) Tracestate to the return value of Samplers

Otherwise it sounds like something optional but this actually changed the interface and SIGs will have to implement this.

@andrewhsu
Copy link
Member

andrewhsu commented Sep 25, 2020

from the issue triage meeting today with TC, this looks desirable, just needs changelog update which can be a followup @carlosalberto

@tigrannajaryan
Copy link
Member

Merging as agreed during triage session since it has sufficient approvals.

@tigrannajaryan tigrannajaryan merged commit 5f4f92b into open-telemetry:master Sep 25, 2020
carlosalberto added a commit to carlosalberto/opentelemetry-specification that referenced this pull request Sep 29, 2020
- Fix CHANGELOG entry.
- Use SHOULD for the tracestate change.
- Add it to the compliance matrix.
lmolkova pushed a commit to lmolkova/oteps that referenced this pull request Sep 29, 2020
carlosalberto added a commit that referenced this pull request Sep 30, 2020
TommyCpp added a commit to TommyCpp/opentelemetry-rust that referenced this pull request Oct 2, 2020
jtescher pushed a commit to open-telemetry/opentelemetry-rust that referenced this pull request Oct 2, 2020
Gmanboy added a commit to Gmanboy/opentelemetry-rust that referenced this pull request Aug 12, 2024
carlosalberto pushed a commit to carlosalberto/opentelemetry-specification that referenced this pull request Oct 31, 2024
carlosalberto added a commit to carlosalberto/opentelemetry-specification that referenced this pull request Oct 31, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area:sampling Related to trace sampling area:sdk Related to the SDK spec:trace Related to the specification/trace directory
Projects
None yet
Development

Successfully merging this pull request may close these issues.

SDK: Samplers should be able to modify tracestate
10 participants