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

Fix TraceContextPropagator behavior when trace parent flags contain… #4893

Conversation

Kielek
Copy link
Contributor

@Kielek Kielek commented Sep 27, 2023

Fixes test_traceparent_trace_flags_illegal_characters from w3c test suite
Design discussion issue #

Changes

Fix TraceContextPropagator behavior when trace parent flags contains illegal characters.

Merge requirement checklist

  • CONTRIBUTING guidelines followed (nullable enabled, static analysis, etc.)
  • Unit tests added/updated
  • Appropriate CHANGELOG.md files updated for non-trivial changes
  • [ ] Changes in public API reviewed (if applicable)

@Kielek Kielek force-pushed the fix-test_traceparent_trace_flags_illegal_characters branch 2 times, most recently from 258e8e0 to cf29bfb Compare September 27, 2023 08:50
…s illegal characters.

fixes: test_traceparent_trace_flags_illegal_characters
@Kielek Kielek force-pushed the fix-test_traceparent_trace_flags_illegal_characters branch from cf29bfb to 7fe4d2d Compare September 27, 2023 08:53
@Kielek Kielek marked this pull request as ready for review September 27, 2023 08:58
@Kielek Kielek requested a review from a team September 27, 2023 08:58
@codecov
Copy link

codecov bot commented Sep 27, 2023

Codecov Report

Merging #4893 (726c499) into main (f01db2b) will increase coverage by 0.04%.
Report is 1 commits behind head on main.
The diff coverage is 100.00%.

❗ Current head 726c499 differs from pull request most recent head e2cefb6. Consider uploading reports for the commit e2cefb6 to get more accurate results

Impacted file tree graph

@@            Coverage Diff             @@
##             main    #4893      +/-   ##
==========================================
+ Coverage   83.26%   83.30%   +0.04%     
==========================================
  Files         295      295              
  Lines       12324    12325       +1     
==========================================
+ Hits        10261    10267       +6     
+ Misses       2063     2058       -5     
Flag Coverage Δ
unittests 83.30% <100.00%> (+0.04%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Files Coverage Δ
....Api/Context/Propagation/TraceContextPropagator.cs 89.47% <100.00%> (+1.82%) ⬆️

... and 4 files with indirect coverage changes

@Kielek
Copy link
Contributor Author

Kielek commented Oct 5, 2023

@open-telemetry/dotnet-approvers, I have 2 more tests fixes ready to review on separate branch. As it touches some internal implementation/decision it is worth to make separate reviews. If you think otherwise I can bring all of them in one PR. Finally it passes all W3c tests on .NET7+.

2 other fixes on the top of branch: https://github.com/Kielek/opentelemetry-dotnet/commits/tace-context-propagator-other-fixes

try
{
spanId = ActivitySpanId.CreateFromString(traceparent.AsSpan().Slice(VersionAndTraceIdLength, SpanIdLength));
options1 = HexCharToByte(traceparent[VersionAndTraceIdAndSpanIdLength + 1]);
_ = HexCharToByte(traceparent[VersionAndTraceIdAndSpanIdLength]); // to verify if there is no bad chars on options position
optionsLowByte = HexCharToByte(traceparent[VersionAndTraceIdAndSpanIdLength + 1]);
}
catch (ArgumentOutOfRangeException)
Copy link
Contributor

Choose a reason for hiding this comment

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

This is outside the scope of this PR but we don't use the exception in any way. We could simply update HexCharToByte method to return false instead of throwing an unused exception.

Copy link
Contributor

Choose a reason for hiding this comment

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

@Kielek Would you mind updating this follow-up PRs?

@utpilla utpilla merged commit 3c2bb7c into open-telemetry:main Oct 6, 2023
66 checks passed
@Kielek Kielek deleted the fix-test_traceparent_trace_flags_illegal_characters branch October 7, 2023 16:35
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