Repository navigation
[API] Skip exception formatting on unrecorded spans - #7669
martincostello merged 3 commits into
Conversation
b9db024 to
c6e98ad
Compare
Pull request dashboard statusMerged · refreshed 2026-08-20 16:07 UTC Status above doesn't look right?
|
| return this; | ||
| } | ||
|
|
||
| if (!this.IsRecording) |
There was a problem hiding this comment.
Could this cause data to be lost if the value of Activity.IsAllDataRequested is changed later?
There was a problem hiding this comment.
Though I did just spot this
The best practice for the library authors is not try to set this property. This property is automatically set when creating the Activity. The setter is useful only in the case of Activity objects created using the Activity constructor and want to override the default value. Activity objects created using StartActivity automatically have this property set to the right value.
There was a problem hiding this comment.
Yes, data could be lost, but that is already happening in some cases.
RecordException always attempts to set some attributes and following by a call to AddEvent - which does respect IsRecording.
The wrapper already is checking IsRecording ater calling SetAttribute, AddEvent, or AddLink.
Terminal methods for each of those:
https://github.com/open-telemetry/opentelemetry-dotnet/blob/coreunstable-1.17.0-beta.1/src/OpenTelemetry.Api/Trace/TelemetrySpan.cs#L355
In theory this aligns RecordException with the other methods, but it's possible the difference in handling is intentional.
There was a problem hiding this comment.
Ah OK, if it's being thrown away by the things it calls anyway then I guess it's fine.
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #7669 +/- ##
==========================================
- Coverage 91.42% 91.41% -0.01%
==========================================
Files 318 318
Lines 17707 17711 +4
==========================================
+ Hits 16188 16190 +2
- Misses 1519 1521 +2
Flags with carried forward coverage won't be shown. Click here to find out more.
|
Changes
Skips extracting and formatting exception fields, generating a stack trace, and creating span attributes when the span is not recorded.
Merge requirement checklist
CHANGELOG.mdfiles updated for non-trivial changes