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

Add table summarizing sampler properties and processing #871

Merged
merged 22 commits into from
Aug 26, 2020

Conversation

cijothomas
Copy link
Member

@cijothomas cijothomas commented Aug 25, 2020

Fixes #782
No change to existing behavior. Just clarifying when does SpanProcessor and SpanExporters get Span, based on IsRecording and Sampled flag, with a table to make it very obvious.

Please provide a brief description of the changes here. Update the
CHANGELOG.md for non-trivial changes.

Related issues #

Related oteps #

@cijothomas cijothomas requested review from a team August 25, 2020 05:44
@carlosalberto
Copy link
Contributor

LGTM - although, at least in Java, SpanProcessors can be configured to also export Spans without the Sampled flag set. Maybe worth a follow up to clarify this possibility?

specification/trace/sdk.md Outdated Show resolved Hide resolved
specification/trace/sdk.md Outdated Show resolved Hide resolved
specification/trace/sdk.md Outdated Show resolved Hide resolved
specification/trace/sdk.md Outdated Show resolved Hide resolved
trace events can be avoided. [Span Processors](#span-processor) will receive
all spans with this flag set. However, [Span Exporter](#span-exporter) will
not receive them unless the `Sampled` flag was set.
* `IsRecording` field of a `Span`. If `true` the current `Span` records tracing
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
* `IsRecording` field of a `Span`. If `true` the current `Span` records tracing
* `IsRecording` field of a `Span`. If `true` the current `Span` records in memory tracing

Copy link
Member

@Oberon00 Oberon00 Aug 25, 2020

Choose a reason for hiding this comment

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

What is "in memory data"? I think the current wording (== the old wording) is more clear here. What would be more clear IMHO would be:

Suggested change
* `IsRecording` field of a `Span`. If `true` the current `Span` records tracing
* `IsRecording` field of a `Span`. If `false` the current `Span` discards all tracing

and remove the "otherwise ...".

specification/trace/sdk.md Outdated Show resolved Hide resolved
specification/trace/sdk.md Outdated Show resolved Hide resolved
specification/trace/sdk.md Outdated Show resolved Hide resolved
specification/trace/sdk.md Outdated Show resolved Hide resolved
cijothomas and others added 6 commits August 25, 2020 07:05
Co-authored-by: Yuri Shkuro <yurishkuro@users.noreply.github.com>
Co-authored-by: Yuri Shkuro <yurishkuro@users.noreply.github.com>
Co-authored-by: Yuri Shkuro <yurishkuro@users.noreply.github.com>
Co-authored-by: Christian Neumüller <christian+github@neumueller.me>
Co-authored-by: Yuri Shkuro <yurishkuro@users.noreply.github.com>
Co-authored-by: Christian Neumüller <christian+github@neumueller.me>
processing.
specification](https://www.w3.org/TR/trace-context/#sampled-flag). This flag indicates that the `Span` has been
`sampled` and will be exported. [Span Exporters](#span-exporter) MUST
receive those spans which have `Sampled` flag set to true and they SHOULD NOT receive the ones
Copy link
Member Author

Choose a reason for hiding this comment

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

Since the text here is "SHOULD NOT" - it means the recommendation is to not call Exporters for Spans without Sampled flag set. Processors could still do it, and spec is not prohibiting it.
As we used "SHOULD NOT" here, do we still require additional explicit clarification here, or in the table that "Depending on the Processor, Exporter may still get span without Sampled flag set? @carlosalberto @Oberon00

Copy link
Member

Choose a reason for hiding this comment

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

I don't think it's necessary but it would be nice. If you want, you can add a sentence to the built in span processors section that they MUST NOT call exporters for unsampled spans (unless explicitly requested).

Copy link
Member Author

Choose a reason for hiding this comment

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

Let me address that as a follow up PR. I fear adding it might delay this PRs progress.

(Meanwhile I'll to figure out under what scenarios a user want to sent unsampled spans to exporter).

Copy link
Contributor

@lzchen lzchen left a comment

Choose a reason for hiding this comment

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

Just curious, is IsRecording something that can be explicitly set by the user/instrumentations? I don't see anywhere in the API that actually gives the ability to change it. It doesn't seem to be a "must have" in span [creation](https://github.com/open-telemetry/opentelemetry-specification/blob/master/specification/trace/api.md#span-creation either.

@Oberon00
Copy link
Member

Oberon00 commented Aug 25, 2020

IsRecording is set according to the sampling decision, see the spec of ShouldSample's return value.

@cijothomas
Copy link
Member Author

Just curious, is IsRecording something that can be explicitly set by the user/instrumentations? I don't see anywhere in the API that actually gives the ability to change it. It doesn't seem to be a "must have" in span [creation](https://github.com/open-telemetry/opentelemetry-specification/blob/master/specification/trace/api.md#span-creation either.

The only place which can set the IsRecording is Sampler as @Oberon00 pointed out. After that point, its a "read-only" property. Users can use IsRecording to know what was the relevant part of the sampling decision, but not change it.

@lzchen
Copy link
Contributor

lzchen commented Aug 25, 2020

@Oberon00
I see, so the Decision returned is up to the discretion of the sampler? Reading the specs I was confused because I thought that the combination of isRecording and sampledFlag was the thing that DETERMINED the Decision, not the other way around.

@Oberon00
Copy link
Member

It goes both ways a bit. The sampler gets the parent SpanContext, which includes the parent Sampled flag, as input and can use that to influence the Decision it returns (see ParentBased sampler). But that decision, as you said, then determines the sampled+recorded flags of the child span.

The following table summarizes the expected behavior for each combination of
`IsRecording` and `SampledFlag`.

| `IsRecording` | `Sampled` Flag | Span Processor receives Span? | Span Exporter receives Span? |
Copy link
Member

Choose a reason for hiding this comment

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

Actually the third column is a change / additional specification, but I think it's good.

@cijothomas Can you add "Fixes #782" to the PR description?

CC @alolita (you have #782 assigned currently).

processing.
specification](https://www.w3.org/TR/trace-context/#sampled-flag). This flag indicates that the `Span` has been
`sampled` and will be exported. [Span Exporters](#span-exporter) MUST
receive those spans which have `Sampled` flag set to true and they SHOULD NOT receive the ones
Copy link
Member

Choose a reason for hiding this comment

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

I don't think it's necessary but it would be nice. If you want, you can add a sentence to the built in span processors section that they MUST NOT call exporters for unsampled spans (unless explicitly requested).

@Oberon00 Oberon00 added area:sampling Related to trace sampling area:sdk Related to the SDK spec:trace Related to the specification/trace directory labels Aug 25, 2020
@Oberon00 Oberon00 added priority:p3 Lowest priority level release:required-for-ga Must be resolved before GA release, or nice to have before GA labels Aug 25, 2020
@cijothomas cijothomas requested a review from yurishkuro August 25, 2020 23:21
@cijothomas
Copy link
Member Author

@yurishkuro I made more refactoring after initial approval- So re-requested review from you. (Also saw you as the assigned owner)

@cijothomas
Copy link
Member Author

@yurishkuro Please merge.

@yurishkuro yurishkuro merged commit 9750495 into open-telemetry:master Aug 26, 2020
@cijothomas cijothomas deleted the cijothomas/sdksamper1 branch August 26, 2020 21:14
carlosalberto added a commit to carlosalberto/opentelemetry-specification that referenced this pull request Oct 31, 2024
…ry#871)

* Add table summarizing sampler properties and processing

* markdownlink

* event -> data to avoid confusion with Event

Co-authored-by: Yuri Shkuro <yurishkuro@users.noreply.github.com>

* events -> data

Co-authored-by: Yuri Shkuro <yurishkuro@users.noreply.github.com>

* plural

Co-authored-by: Yuri Shkuro <yurishkuro@users.noreply.github.com>

* use MUST

Co-authored-by: Christian Neumüller <christian+github@neumueller.me>

* Update specification/trace/sdk.md

Co-authored-by: Yuri Shkuro <yurishkuro@users.noreply.github.com>

* Update specification/trace/sdk.md

Co-authored-by: Christian Neumüller <christian+github@neumueller.me>

* reword

* spacing

* more links fix

* markdownl

* Update specification/trace/sdk.md

Co-authored-by: Christian Neumüller <christian+github@neumueller.me>

Co-authored-by: Yuri Shkuro <yurishkuro@users.noreply.github.com>
Co-authored-by: Christian Neumüller <christian+github@neumueller.me>
Co-authored-by: Carlos Alberto Cortez <calberto.cortez@gmail.com>
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 priority:p3 Lowest priority level release:required-for-ga Must be resolved before GA release, or nice to have before GA spec:trace Related to the specification/trace directory
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Should SpanProcessor.OnStart/OnEnd be called for non-recording Spans?
7 participants