-
Notifications
You must be signed in to change notification settings - Fork 785
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 ConsoleExporter fails silently when exporting an ActivityLink
without Tags.
#3932
Conversation
test/OpenTelemetry.Tests/Shared/VerifyNoEventSourceErrorsLoggedTestAttribute.cs
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
UnitTestEventListener
is beyond the scope of the issue/PR.
@@ -116,11 +116,14 @@ public override ExportResult Export(in Batch<Activity> batch) | |||
foreach (var activityLink in activity.Links) | |||
{ | |||
this.WriteLine($" {activityLink.Context.TraceId} {activityLink.Context.SpanId}"); | |||
foreach (var attribute in activityLink.Tags) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@TimothyMothra FYI you could re-write this as:
foreach (ref readonly var attribute in activityLink.EnumerateTagObjects())
More efficient and it will handle the null case for you 😄
Might be worth re-writing all of the foreach loops in here to use the newer pattern just to have a good reference doing it correctly. Follow-up thing if you are interested 😉
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'll take this as a follow up after this PR merges. :)
…orter in try/catch
Codecov Report
Additional details and impacted files@@ Coverage Diff @@
## main #3932 +/- ##
==========================================
+ Coverage 85.30% 85.50% +0.19%
==========================================
Files 287 288 +1
Lines 11026 11059 +33
==========================================
+ Hits 9406 9456 +50
+ Misses 1620 1603 -17
|
test/OpenTelemetry.Exporter.Console.Tests/ConsoleActivityExporterTest.cs
Outdated
Show resolved
Hide resolved
test/OpenTelemetry.Exporter.Console.Tests/ConsoleActivityExporterTest.cs
Outdated
Show resolved
Hide resolved
test/OpenTelemetry.Exporter.Console.Tests/ConsoleActivityExporterTest.cs
Outdated
Show resolved
Hide resolved
This comment was marked as resolved.
This comment was marked as resolved.
test/OpenTelemetry.Exporter.Console.Tests/ConsoleActivityExporterTest.cs
Show resolved
Hide resolved
@@ -2,6 +2,10 @@ | |||
|
|||
## Unreleased | |||
|
|||
* Bug fix, ConsoleExporter fails silently when exporting an `ActivityLink` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: Reword this to something like:
Bug fix to prevent ConsoleExporter from failing when exporting an ActivityLink
without tags.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not a blocker.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixes #3863 .
ConsoleExporter fails silently when exporting an
ActivityLink
without Tags.Changes
ConsoleActivityExporter
ConsoleActivityExporterTest
to reproduce reported issueBecause the new test project has
nullable enable
, the Utils class needed to be fixed.I used
Debug.Assert
to check for null and used the null-forgiving operator to dismiss the build error.Please provide a brief description of the changes here.
For significant contributions please make sure you have completed the following items:
CHANGELOG.md
updated for non-trivial changes