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

Initial relocation of ContextUtils classes. #904

Merged

Conversation

carlosalberto
Copy link
Contributor

@carlosalberto carlosalberto commented Feb 21, 2020

Now they will live within their own child propagation package (instead of unsafe), with a prefix based on their cross-cutting concern, to be referenced easily.

NOTE: Context.Key instances now don't have a default value, and we provide an actual default when they return null. The reason for this is that, upon Injection, we want to detect whether there's an actual value in Context:

// Inject
Span span = CONTEXT_SPAN_KEY.get(Context.current());
if (span == null) {
  // Nothing to inject.
  return;
}

An alternative would be to check against DefaultSpan.getInvalid() if we offer such default value along the key.

Because of this, we offer getSpan() and getSpanWithDefault() variants (SpanBuilderSdk uses the former to easily check that Span is not a no-op instance, for example).

I'm open to discuss this detail though.

This has been split from #720

Now they will live within the child `propagation` package,
with a prefix based on their cross-cutting concern, to be
referenced easily.
@carlosalberto
Copy link
Contributor Author

Updated ;)

@bogdandrutu Left a comment, please review.

@codecov-io
Copy link

codecov-io commented Mar 5, 2020

Codecov Report

Merging #904 into master will decrease coverage by 0.1%.
The diff coverage is 100%.

Impacted file tree graph

@@             Coverage Diff              @@
##             master     #904      +/-   ##
============================================
- Coverage     84.39%   84.28%   -0.11%     
+ Complexity      893      890       -3     
============================================
  Files           119      118       -1     
  Lines          3165     3163       -2     
  Branches        271      273       +2     
============================================
- Hits           2671     2666       -5     
- Misses          379      380       +1     
- Partials        115      117       +2
Impacted Files Coverage Δ Complexity Δ
...va/io/opentelemetry/trace/TracingContextUtils.java 100% <100%> (ø) 7 <7> (?)
...ava/io/opentelemetry/sdk/trace/SpanBuilderSdk.java 93.93% <100%> (ø) 36 <4> (ø) ⬇️
...ationcontext/DefaultCorrelationContextManager.java 69.23% <100%> (ø) 7 <2> (ø) ⬇️
.../opentelemetry/contrib/trace/CurrentSpanUtils.java 85.71% <100%> (ø) 4 <0> (ø) ⬇️
...y/correlationcontext/CorrelationsContextUtils.java 100% <100%> (ø) 7 <7> (?)
...in/java/io/opentelemetry/context/ContextUtils.java 100% <100%> (ø) 2 <2> (?)
...ain/java/io/opentelemetry/sdk/trace/TracerSdk.java 100% <100%> (ø) 8 <2> (ø) ⬇️
...rrelationcontext/CorrelationContextManagerSdk.java 100% <100%> (ø) 5 <2> (ø) ⬇️
...ain/java/io/opentelemetry/trace/DefaultTracer.java 95.23% <100%> (ø) 6 <2> (ø) ⬇️
...ntelemetry/sdk/trace/RecordEventsReadableSpan.java 90.3% <0%> (-1.22%) 44% <0%> (-1%)
... and 4 more

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 01189f3...da1a7e9. Read the comment docs.

@carlosalberto
Copy link
Contributor Author

@open-telemetry/java-approvers This PR has been updated:

  • Have the default versions return a no-op instance if none was found, and having an extra get[value]WithoutDefault() to return no default values (used mostly by propagators).
  • Removed for now the SpanContext bits to also store/retrieve it from Context.

@carlosalberto
Copy link
Contributor Author

Thanks for the feedback @bogdandrutu Please review the latest questions I left, and I will iterate ASAP ;)

Copy link
Member

@bogdandrutu bogdandrutu left a comment

Choose a reason for hiding this comment

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

Only one comment left to remove the version of the withSpan without the context (same for correlation).

@carlosalberto carlosalberto merged commit 1d913cb into open-telemetry:master Mar 8, 2020
MikeGoldsmith pushed a commit to MikeGoldsmith/opentelemetry-java that referenced this pull request Mar 13, 2020
* Initial relocation of ContextUtils classes.

Now they will live within the child `propagation` package,
with a prefix based on their cross-cutting concern, to be
referenced easily.
davebarda pushed a commit to davebarda/opentelemetry-java that referenced this pull request Apr 24, 2020
* Initial relocation of ContextUtils classes.

Now they will live within the child `propagation` package,
with a prefix based on their cross-cutting concern, to be
referenced easily.
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.

4 participants