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

[console] Support ActivitySource.Tags #5935

Merged
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 8 additions & 3 deletions src/OpenTelemetry.Exporter.Console/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,11 @@ Notes](../../RELEASENOTES.md).
([#5874](https://github.com/open-telemetry/opentelemetry-dotnet/pull/5874),
[#5891](https://github.com/open-telemetry/opentelemetry-dotnet/pull/5891))

* Added support for Instrumentation Scope Attributes (i.e
[ActivitySource.Tags](https://learn.microsoft.com/dotnet/api/system.diagnostics.activitysource.tags))
when writing traces to the console.
([#5935](https://github.com/open-telemetry/opentelemetry-dotnet/pull/5935))

## 1.10.0-beta.1

Released 2024-Sep-30
Expand Down Expand Up @@ -61,9 +66,9 @@ Released 2023-Dec-08

Released 2023-Nov-29

* Add support for Instrumentation Scope Attributes (i.e [Meter
Tags](https://learn.microsoft.com/dotnet/api/system.diagnostics.metrics.meter.tags)),
fixing issue
* Added support for Instrumentation Scope Attributes (i.e
[Meter.Tags](https://learn.microsoft.com/dotnet/api/system.diagnostics.metrics.meter.tags)),
when writing metrics to the console, fixing issue
[#4563](https://github.com/open-telemetry/opentelemetry-dotnet/issues/4563).
([#5089](https://github.com/open-telemetry/opentelemetry-dotnet/pull/5089))

Expand Down
16 changes: 14 additions & 2 deletions src/OpenTelemetry.Exporter.Console/ConsoleActivityExporter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,22 @@ public override ExportResult Export(in Batch<Activity> batch)
this.WriteLine($"Activity.ParentSpanId: {activity.ParentSpanId}");
}

this.WriteLine($"Activity.ActivitySourceName: {activity.Source.Name}");
this.WriteLine($"Activity.ActivitySource.Name: {activity.Source.Name}");
if (!string.IsNullOrEmpty(activity.Source.Version))
{
this.WriteLine($"Activity.ActivitySourceVersion: {activity.Source.Version}");
this.WriteLine($"Activity.ActivitySource.Version: {activity.Source.Version}");
}

if (activity.Source.Tags?.Any() == true)
{
this.WriteLine("Activity.ActivitySource.Tags:");
CodeBlanch marked this conversation as resolved.
Show resolved Hide resolved
foreach (var activitySourceTag in activity.Source.Tags)
{
if (this.TagWriter.TryTransformTag(activitySourceTag, out var result))
{
this.WriteLine($" {result.Key}: {result.Value}");
}
}
}

this.WriteLine($"Activity.DisplayName: {activity.DisplayName}");
Expand Down
4 changes: 2 additions & 2 deletions src/OpenTelemetry.Exporter.Console/ConsoleMetricExporter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -62,11 +62,11 @@ public override ExportResult Export(in Batch<Metric> batch)

this.WriteLine(msg.ToString());

if (metric.MeterTags != null)
if (metric.MeterTags?.Any() == true)
{
this.WriteLine("\tMeter Tags:");
CodeBlanch marked this conversation as resolved.
Show resolved Hide resolved
foreach (var meterTag in metric.MeterTags)
{
this.WriteLine("\tMeter Tags:");
if (this.TagWriter.TryTransformTag(meterTag, out var result))
{
this.WriteLine($"\t\t{result.Key}: {result.Value}");
Expand Down
Loading