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

Store parent context in span builder #399

Merged
merged 3 commits into from Dec 28, 2020
Merged

Conversation

jtescher
Copy link
Member

The span builder currently holds a parent SpanContext, and Context information is passed separately when starting a span directly or via a builder. This poses a few problems, first you can assign a context which contains an active span as well as a builder with a parent span context, which can lead to confusion, and secondly we have to construct a wrapper context when sampling even in cases when the passed in context already contains an active span.

This patch resolves this by changing the span builder's parent context to instead store a Context directly. This allows the builder methods to have a single context to look at when searching for parent span contexts, and allows the wrapper context to only be created for sampling when it is facilitating a remote parent.

The span builder currently holds a parent `SpanContext`, and `Context`
information is passed separately when starting a span directly or via a
builder. This poses a few problems, first you can assign a context which
contains an active span _as well as_ a builder with a parent span
context, which can lead to confusion, and secondly we have to construct
a wrapper context when sampling even in cases when the passed in context
already contains an active span.

This patch resolves this by changing the span builder's parent context
to instead store a `Context` directly. This allows the builder methods
to have a sigle context to look at when searchig for parent span
contexts, and allows the wrapper context to onlly be created for
sampling when it is facilitating a remote parent.
@jtescher jtescher requested a review from a team as a code owner December 27, 2020 20:04
Copy link
Contributor

@TommyCpp TommyCpp left a comment

Choose a reason for hiding this comment

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

I feel a little confusing that parent_span_context is kind of part of the parent_ctx, and it feels like we pass the duplicate element into the make_sample_decision function. But overall I think it looks good.

opentelemetry/src/sdk/trace/tracer.rs Outdated Show resolved Hide resolved
opentelemetry/src/sdk/trace/tracer.rs Show resolved Hide resolved
@codecov
Copy link

codecov bot commented Dec 27, 2020

Codecov Report

Merging #399 (9d38492) into master (006f475) will decrease coverage by 0.01%.
The diff coverage is 77.02%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #399      +/-   ##
==========================================
- Coverage   49.12%   49.11%   -0.02%     
==========================================
  Files          66       66              
  Lines        5394     5400       +6     
==========================================
+ Hits         2650     2652       +2     
- Misses       2744     2748       +4     
Impacted Files Coverage Δ
opentelemetry/src/sdk/trace/tracer.rs 69.94% <64.28%> (-1.99%) ⬇️
opentelemetry/src/api/trace/tracer.rs 35.21% <66.66%> (-2.63%) ⬇️
opentelemetry/src/sdk/trace/sampler.rs 87.27% <68.42%> (+1.13%) ⬆️
opentelemetry/src/api/trace/noop.rs 68.26% <100.00%> (ø)
opentelemetry/src/global/trace.rs 60.00% <100.00%> (ø)
opentelemetry/src/sdk/trace/span_processor.rs 81.78% <100.00%> (-0.13%) ⬇️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 006f475...9d38492. Read the comment docs.

Copy link
Contributor

@TommyCpp TommyCpp left a comment

Choose a reason for hiding this comment

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

LGTM 👍

@jtescher jtescher merged commit 601d297 into master Dec 28, 2020
@jtescher jtescher deleted the builder-parent-context branch December 28, 2020 00:37
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.

None yet

2 participants