diff --git a/src/OpenTelemetry.Exporter.Console/CHANGELOG.md b/src/OpenTelemetry.Exporter.Console/CHANGELOG.md index 4968318fccc..cff84ecd183 100644 --- a/src/OpenTelemetry.Exporter.Console/CHANGELOG.md +++ b/src/OpenTelemetry.Exporter.Console/CHANGELOG.md @@ -2,8 +2,10 @@ ## Unreleased -Added StatusCode, StatusDescription support to -`ConsoleActivityExporter`. +* Added StatusCode, StatusDescription support to + `ConsoleActivityExporter`. + ([#2929](https://github.com/open-telemetry/opentelemetry-dotnet/pull/2929) + [#3061](https://github.com/open-telemetry/opentelemetry-dotnet/pull/3061)) ## 1.2.0-rc3 diff --git a/src/OpenTelemetry.Exporter.Console/ConsoleActivityExporter.cs b/src/OpenTelemetry.Exporter.Console/ConsoleActivityExporter.cs index f5d582443ef..b715d71904f 100644 --- a/src/OpenTelemetry.Exporter.Console/ConsoleActivityExporter.cs +++ b/src/OpenTelemetry.Exporter.Console/ConsoleActivityExporter.cs @@ -71,9 +71,7 @@ public override ExportResult Export(in Batch batch) continue; } - var array = tag.Value as Array; - - if (array == null) + if (tag.Value is not Array array) { this.WriteLine($" {tag.Key}: {tag.Value}"); continue; @@ -81,15 +79,22 @@ public override ExportResult Export(in Batch batch) this.WriteLine($" {tag.Key}: [{string.Join(", ", array.Cast())}]"); } + } - if (!string.IsNullOrEmpty(statusCode)) + if (activity.Status != ActivityStatusCode.Unset) + { + this.WriteLine($"StatusCode : {activity.Status}"); + if (!string.IsNullOrEmpty(activity.StatusDescription)) { - this.WriteLine($" StatusCode : {statusCode}"); + this.WriteLine($"Error : {activity.StatusDescription}"); } - + } + else if (!string.IsNullOrEmpty(statusCode)) + { + this.WriteLine($" StatusCode : {statusCode}"); if (!string.IsNullOrEmpty(statusDesc)) { - this.WriteLine($" StatusDescription : {statusDesc}"); + this.WriteLine($" Error : {statusDesc}"); } }