From add7eee59cb86fafec1896dd5ce54714348b5ae4 Mon Sep 17 00:00:00 2001 From: Yun-Ting Lin Date: Tue, 29 Mar 2022 15:53:32 -0700 Subject: [PATCH] [Part3] Support Activity Status and status description in OTLP Exporter. (#3100) --- .../CHANGELOG.md | 10 ++ .../Implementation/ActivityExtensions.cs | 38 +++++-- .../OtlpTraceExporterTests.cs | 107 ++++++++++++++++++ 3 files changed, 145 insertions(+), 10 deletions(-) diff --git a/src/OpenTelemetry.Exporter.OpenTelemetryProtocol/CHANGELOG.md b/src/OpenTelemetry.Exporter.OpenTelemetryProtocol/CHANGELOG.md index 5e348666eef..d4bf9c4ac26 100644 --- a/src/OpenTelemetry.Exporter.OpenTelemetryProtocol/CHANGELOG.md +++ b/src/OpenTelemetry.Exporter.OpenTelemetryProtocol/CHANGELOG.md @@ -2,6 +2,16 @@ ## Unreleased +* Added support for Activity Status and StatusDescription which were + added to Activity from `System.Diagnostics.DiagnosticSource` version 6.0. + Prior to version 6.0, setting the status of an Activity was provided by the + .NET OpenTelemetry API via the `Activity.SetStatus` extension method in the + `OpenTelemetry.Trace` namespace. Internally, this extension method added the + status as tags on the Activity: `otel.status_code` and `otel.status_description`. + Therefore, to maintain backward compatibility, the exporter falls back to using + these tags to infer status. + ([#3100](https://github.com/open-telemetry/opentelemetry-dotnet/pull/3100)) + * Fixed OTLP metric exporter to default to a periodic 60 second export cycle. A bug was introduced in #2717 that caused the OTLP metric export to default to a manual export cycle (i.e., requiring an explicit flush). A workaround diff --git a/src/OpenTelemetry.Exporter.OpenTelemetryProtocol/Implementation/ActivityExtensions.cs b/src/OpenTelemetry.Exporter.OpenTelemetryProtocol/Implementation/ActivityExtensions.cs index a5bd1c90f88..330e0b140d7 100644 --- a/src/OpenTelemetry.Exporter.OpenTelemetryProtocol/Implementation/ActivityExtensions.cs +++ b/src/OpenTelemetry.Exporter.OpenTelemetryProtocol/Implementation/ActivityExtensions.cs @@ -178,7 +178,7 @@ internal static OtlpTrace.Span ToOtlpSpan(this Activity activity) otlpTags.Tags.Return(); } - otlpSpan.Status = ToOtlpStatus(ref otlpTags); + otlpSpan.Status = activity.ToOtlpStatus(ref otlpTags); EventEnumerationState otlpEvents = default; activity.EnumerateEvents(ref otlpEvents); @@ -237,24 +237,42 @@ internal static OtlpCommon.KeyValue ToOtlpAttribute(this KeyValuePair