From 5a9d564405f1c86bc2b25db746a8f114237dc493 Mon Sep 17 00:00:00 2001 From: Cijo Thomas Date: Wed, 2 Feb 2022 15:58:39 -0800 Subject: [PATCH] ConsoleExporter to print Activity(Span) Links (#2849) --- src/OpenTelemetry.Exporter.Console/CHANGELOG.md | 1 + .../ConsoleActivityExporter.cs | 9 +++++++++ 2 files changed, 10 insertions(+) diff --git a/src/OpenTelemetry.Exporter.Console/CHANGELOG.md b/src/OpenTelemetry.Exporter.Console/CHANGELOG.md index 343846afe6d..7c45dfebf35 100644 --- a/src/OpenTelemetry.Exporter.Console/CHANGELOG.md +++ b/src/OpenTelemetry.Exporter.Console/CHANGELOG.md @@ -3,6 +3,7 @@ ## Unreleased Fix MetricExporter to respect Console and Debug flags. +Added `Activity.Links` support to `ConsoleActivityExporter`. ## 1.2.0-rc1 diff --git a/src/OpenTelemetry.Exporter.Console/ConsoleActivityExporter.cs b/src/OpenTelemetry.Exporter.Console/ConsoleActivityExporter.cs index e52497ba6a5..d24317b1f16 100644 --- a/src/OpenTelemetry.Exporter.Console/ConsoleActivityExporter.cs +++ b/src/OpenTelemetry.Exporter.Console/ConsoleActivityExporter.cs @@ -73,6 +73,15 @@ public override ExportResult Export(in Batch batch) } } + if (activity.Links.Any()) + { + this.WriteLine("Activity.Links:"); + foreach (var activityLink in activity.Links) + { + this.WriteLine($" {activityLink.Context.TraceId} {activityLink.Context.SpanId}"); + } + } + var resource = this.ParentProvider.GetResource(); if (resource != Resource.Empty) {