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

Only create a sibling activity when trace id, span id or trace state differ #5136

Merged
merged 22 commits into from
Jan 16, 2024

Conversation

ngruson
Copy link
Contributor

@ngruson ngruson commented Dec 6, 2023

Fixes #4466

Only create a sibling activity when trace id, span id or trace state differ in the extracted activity context.
Traceflags are excluded from the comparison.

Changes

  • Changed OnStartActivity in HttpInListener
  • Added unit test

@ngruson ngruson requested a review from a team December 6, 2023 15:23
Copy link

codecov bot commented Dec 6, 2023

Codecov Report

All modified and coverable lines are covered by tests ✅

Comparison is base (6250307) 83.38% compared to head (f842030) 83.10%.
Report is 10 commits behind head on main.

Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main    #5136      +/-   ##
==========================================
- Coverage   83.38%   83.10%   -0.28%     
==========================================
  Files         297      271      -26     
  Lines       12531    11958     -573     
==========================================
- Hits        10449     9938     -511     
+ Misses       2082     2020      -62     
Flag Coverage Δ
unittests ?
unittests-Instrumentation-Experimental 25.10% <11.42%> (?)
unittests-Instrumentation-Stable 25.10% <11.42%> (?)
unittests-Solution-Experimental 83.05% <100.00%> (?)
unittests-Solution-Stable 83.08% <100.00%> (?)

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

Files Coverage Δ
src/OpenTelemetry.Api/Baggage.cs 100.00% <100.00%> (ø)
...tation.AspNetCore/Implementation/HttpInListener.cs 89.72% <100.00%> (+0.14%) ⬆️

... and 31 files with indirect coverage changes

@ngruson
Copy link
Contributor Author

ngruson commented Dec 6, 2023

@vishweshbankwar : Something like this?
The unit test covers the scenario where creating the new activity is skipped.
The existing unit test SuccessfulTemplateControllerCallUsesParentContext handles the scenario where the new activity is being created.

@@ -1035,6 +1038,43 @@ public async Task DiagnosticSourceExceptionCallBackIsNotReceivedForExceptionsHan
Assert.Equal(2, numberOfSubscribedEvents);
}

#if NET7_0_OR_GREATER
Copy link
Member

Choose a reason for hiding this comment

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

This should be NET6_0_OR_GREATER? IHttpActivityFeature is available in net6.0.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I had to add the Microsoft.Extensions.Features package to the test app to be able to build with net6.0.
See the project file.
Should this be made conditional in the project file?
I didn't succeed right off the bat.

Copy link
Member

Choose a reason for hiding this comment

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

Try this

context.Features.Get<IHttpActivityFeature>()?.Activity;

@ngruson ngruson changed the title Do not create sibling activity when format is W3C Only create a sibling activity when trace id, span id or trace state differ Dec 7, 2023
Copy link
Member

@cijothomas cijothomas left a comment

Choose a reason for hiding this comment

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

Please changelog entry before merge.

Copy link
Contributor

This PR was marked stale due to lack of activity and will be closed in 7 days. Commenting or Pushing will instruct the bot to automatically remove the label. This bot runs once per day.

@github-actions github-actions bot added the Stale Issues and pull requests which have been flagged for closing due to inactivity label Dec 16, 2023
@ngruson
Copy link
Contributor Author

ngruson commented Dec 19, 2023

Who needs to review this next? The PR was marked stale.

@utpilla utpilla removed the Stale Issues and pull requests which have been flagged for closing due to inactivity label Dec 19, 2023
@cijothomas
Copy link
Member

Who needs to review this next? The PR was marked stale.

Apologies. Vishwesh is travelling and will be back in Jan only. One of the other approvers will re-review this. Thanks for waiting!

Copy link
Member

@alanwest alanwest left a comment

Choose a reason for hiding this comment

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

@ngruson When you have a chance, please add a changelog entry #5136 (comment) and I'll get this PR merged.

@alanwest alanwest merged commit 18ccd87 into open-telemetry:main Jan 16, 2024
49 checks passed
@ngruson ngruson deleted the 4466-bug-httpactivityfeature branch January 17, 2024 11:15
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.

IHttpActivityFeature.Activity and Activity.Current don't return the same activity
7 participants