Skip to content

Leverage ActivityListener.AutoGenerateRootContextTraceId - #1007

Merged
cijothomas merged 8 commits into
open-telemetry:masterfrom
cijothomas:cijothomas/samplingtraceidtobecreatedfix
Aug 5, 2020
Merged

Leverage ActivityListener.AutoGenerateRootContextTraceId#1007
cijothomas merged 8 commits into
open-telemetry:masterfrom
cijothomas:cijothomas/samplingtraceidtobecreatedfix

Conversation

@cijothomas

Copy link
Copy Markdown
Member

Fixes portions of #941 #953

Changes

Leverage ActivityListener.AutoGenerateRootContextTraceId so that sampling callbacks can get the actual TraceId of the to-be-created Activity and make decision based on TraceId.
Before this PR, Samplers generated a random TraceId, and made sampling decision. But this generated TraceID was not actually used when the Activity is created, leading to broken traces, if samplers made decision based on the TraceId.

Added Tests. There are TODOs which require follow up.

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

For significant contributions please make sure you have completed the following items:

  • Design discussion issue #
  • Changes in public API reviewed

@cijothomas
cijothomas requested a review from a team August 5, 2020 06:59
@codecov

codecov Bot commented Aug 5, 2020

Copy link
Copy Markdown

Codecov Report

Merging #1007 into master will decrease coverage by 0.05%.
The diff coverage is 100.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #1007      +/-   ##
==========================================
- Coverage   68.91%   68.86%   -0.06%     
==========================================
  Files         220      220              
  Lines        5999     5999              
  Branches      984      983       -1     
==========================================
- Hits         4134     4131       -3     
- Misses       1596     1599       +3     
  Partials      269      269              
Impacted Files Coverage Δ
src/OpenTelemetry/Sdk.cs 89.28% <100.00%> (+1.19%) ⬆️
src/OpenTelemetry/Metrics/CounterMetricSdkBase.cs 80.00% <0.00%> (-13.34%) ⬇️

disposes the containing exporter.
* `BroadcastActivityProcessor`is disposable and it disposes the processors.

* Samplers now get the actual TraceId of the Activity to be created.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I guess we need an empty line here.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Your favourite tool caught it as well!

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

🚨

@alanwest

alanwest commented Aug 5, 2020

Copy link
Copy Markdown
Member

Just want to clarify my understanding, next OTel release will coincide with preview 8. So, will preview 8 will not contain the removal of AutoGenerateRootContextTraceId? Or is this just getting the functionality/tests in place and then the plan is to change this prior to release?

@cijothomas

Copy link
Copy Markdown
Member Author

Just want to clarify my understanding, next OTel release will coincide with preview 8. So, will preview 8 will not contain the removal of AutoGenerateRootContextTraceId? Or is this just getting the functionality/tests in place and then the plan is to change this prior to release?

Preview8 won't remove AutoGenerateRootContextTraceId. It'll be RC1 or RC2.

@cijothomas
cijothomas merged commit d0e8484 into open-telemetry:master Aug 5, 2020
@cijothomas
cijothomas deleted the cijothomas/samplingtraceidtobecreatedfix branch August 5, 2020 14:59
@CodeBlanch

Copy link
Copy Markdown
Member

@cijothomas @reyang Hey I just noticed something, this broke the ParentOrElse sampler.

            var parentContext = samplingParameters.ParentContext;
            if (parentContext == default)

parentContext == default will now never be true, because a TraceId is always generated. Not sure how to detect "no parent" case now. Check SpanId = all 0s?

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