Skip to content

[ETW Exporter] - Add Trace flags in SpanContext#1618

Merged
ThomsonTan merged 8 commits into
open-telemetry:mainfrom
lalitb:etw-sampler-fix
Sep 19, 2022
Merged

[ETW Exporter] - Add Trace flags in SpanContext#1618
ThomsonTan merged 8 commits into
open-telemetry:mainfrom
lalitb:etw-sampler-fix

Conversation

@lalitb

@lalitb lalitb commented Sep 15, 2022

Copy link
Copy Markdown
Member

Changes

ETW exporter doesn't preserve trace flags while creating span. The trace flags contain the IsSampled flag based on the sampling decision. This result in incorrect sampling logic execution.

Also added code to copy the tracer_id from parent span to child span.

The code is taken from the sdk implementation, and a unit test is added to validate it.

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

  • CHANGELOG.md updated for non-trivial changes
  • Unit tests have been added
  • Changes in public API reviewed

@lalitb lalitb requested a review from a team September 15, 2022 20:56
@lalitb lalitb changed the title [ETW Exporter] - Add sampling flags. [ETW Exporter] - Add sampling flags in SpanContext Sep 15, 2022
@codecov

codecov Bot commented Sep 15, 2022

Copy link
Copy Markdown

Codecov Report

Merging #1618 (5fb17a0) into main (ed9f583) will decrease coverage by 0.07%.
The diff coverage is n/a.

Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main    #1618      +/-   ##
==========================================
- Coverage   85.28%   85.22%   -0.06%     
==========================================
  Files         156      156              
  Lines        4978     4978              
==========================================
- Hits         4245     4242       -3     
- Misses        733      736       +3     
Impacted Files Coverage Δ
...include/opentelemetry/sdk/common/circular_buffer.h 98.00% <0.00%> (-2.00%) ⬇️
ext/src/http/client/curl/http_client_curl.cc 80.31% <0.00%> (-1.13%) ⬇️
sdk/src/trace/batch_span_processor.cc 91.41% <0.00%> (+0.79%) ⬆️

@lalitb lalitb changed the title [ETW Exporter] - Add sampling flags in SpanContext [ETW Exporter] - Add Trace flags in SpanContext Sep 16, 2022
@lalitb

lalitb commented Sep 16, 2022

Copy link
Copy Markdown
Member Author

@ThomsonTan Can you please help review it? Thanks.

auto traceId = parentContext.IsValid() ? parentContext.trace_id() : traceId_;

// Sampling based on attributes is not supported for now, so passing empty below.
std::map<std::string, int> empty_attributes = {{}};

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.

cosmetic: It seems this file has mixed camel case and snake case.
It would be good if you could unify at least the parts you are changing.

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.

Thanks good comment. I gave it a thought, and using snake-case now, to make it consistent with the existing ETW exporter naming style. We will eventually move this component out of the core library.

Comment thread exporters/etw/include/opentelemetry/exporters/etw/etw_tracer.h
@ThomsonTan ThomsonTan merged commit 2142d00 into open-telemetry:main Sep 19, 2022
yxue pushed a commit to yxue/opentelemetry-cpp that referenced this pull request Dec 5, 2022
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.

3 participants