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: Fix bug in distributed tracing when excludeNewrelicHeader is set to true #2457

Merged
merged 2 commits into from
Apr 30, 2024

Conversation

nr-ahemsath
Copy link
Member

When the agent is configured to exclude the newrelic proprietary distributed tracing header on outbound traces (and rely solely on the W3C trace context headers instead), an exception could occur which would show up in agent logs like this:

NewRelic  ERROR: [pid: 5412, tid: 73] InsertDistributedTraceHeaders() failed
System.InvalidOperationException: Nullable object must have a value.
at System.ThrowHelper.ThrowInvalidOperationException(ExceptionResource resource)
at NewRelic.Agent.Core.DistributedTracing.DistributedTracePayloadHandler.BuildTraceParent(IInternalTransaction transaction)
at NewRelic.Agent.Core.DistributedTracing.DistributedTracePayloadHandler.GetOutboundHeader(DistributedTraceHeaderType headerType, IInternalTransaction transaction, DateTime timestamp)
at NewRelic.Agent.Core.DistributedTracing.DistributedTracePayloadHandler.InsertDistributedTraceHeaders[T](IInternalTransaction transaction, T carrier, Action`3 setter)

This is because the value of Transaction.Sampled was not being set in this scenario.

This PR fixes that issue and adds integration tests to test both configuration options.

@codecov-commenter
Copy link

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 80.46%. Comparing base (eea6704) to head (ef98dd9).
Report is 1 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #2457   +/-   ##
=======================================
  Coverage   80.46%   80.46%           
=======================================
  Files         450      450           
  Lines       27942    27945    +3     
  Branches     3023     3023           
=======================================
+ Hits        22483    22486    +3     
  Misses       4686     4686           
  Partials      773      773           
Flag Coverage Δ
Agent 81.44% <100.00%> (+<0.01%) ⬆️
Profiler 71.93% <ø> (ø)

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

Files Coverage Δ
...stributedTracing/DistributedTracePayloadHandler.cs 80.66% <100.00%> (+0.21%) ⬆️

Copy link
Member

@chynesNR chynesNR left a comment

Choose a reason for hiding this comment

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

Thanks for finishing this up!

@nr-ahemsath nr-ahemsath merged commit 1f95c9c into main Apr 30, 2024
78 checks passed
@nr-ahemsath nr-ahemsath deleted the fix/dt-without-nr-header branch April 30, 2024 23: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.

4 participants