From 5b06d2a6065015ad6bfb96f341484c942c463799 Mon Sep 17 00:00:00 2001 From: Utkarsh Umesan Pillai <66651184+utpilla@users.noreply.github.com> Date: Mon, 12 Jul 2021 14:00:19 -0700 Subject: [PATCH] Add support for IDeferredTracerProviderBuilder for InMemoryExporter (#2129) * Add support for IDeferredTracerProviderBuilder * Update CHANGELOG.md --- src/OpenTelemetry.Exporter.InMemory/CHANGELOG.md | 3 +++ .../InMemoryExporterHelperExtensions.cs | 8 ++++++++ 2 files changed, 11 insertions(+) diff --git a/src/OpenTelemetry.Exporter.InMemory/CHANGELOG.md b/src/OpenTelemetry.Exporter.InMemory/CHANGELOG.md index 44f832dd0e1..6b0a9859581 100644 --- a/src/OpenTelemetry.Exporter.InMemory/CHANGELOG.md +++ b/src/OpenTelemetry.Exporter.InMemory/CHANGELOG.md @@ -9,6 +9,9 @@ please check the latest changes ## Unreleased +* Supports OpenTelemetry.Extensions.Hosting based configuration for `InMemoryExporter` + ([#2129](https://github.com/open-telemetry/opentelemetry-dotnet/pull/2129)) + ## 1.1.0-rc1 Released 2021-Jun-25 diff --git a/src/OpenTelemetry.Exporter.InMemory/InMemoryExporterHelperExtensions.cs b/src/OpenTelemetry.Exporter.InMemory/InMemoryExporterHelperExtensions.cs index 885362afb5e..47babe1f435 100644 --- a/src/OpenTelemetry.Exporter.InMemory/InMemoryExporterHelperExtensions.cs +++ b/src/OpenTelemetry.Exporter.InMemory/InMemoryExporterHelperExtensions.cs @@ -42,6 +42,14 @@ public static TracerProviderBuilder AddInMemoryExporter(this TracerProviderBuild throw new ArgumentNullException(nameof(exportedItems)); } + if (builder is IDeferredTracerProviderBuilder deferredTracerProviderBuilder) + { + return deferredTracerProviderBuilder.Configure((sp, builder) => + { + builder.AddProcessor(new SimpleActivityExportProcessor(new InMemoryExporter(exportedItems))); + }); + } + return builder.AddProcessor(new SimpleActivityExportProcessor(new InMemoryExporter(exportedItems))); } }