From 64a55fe700f9ab7499721f85f6239178e80e28c3 Mon Sep 17 00:00:00 2001 From: Utkarsh Umesan Pillai <66651184+utpilla@users.noreply.github.com> Date: Wed, 7 Jun 2023 19:42:34 -0700 Subject: [PATCH 1/4] Update EventSource implementation of GenevaMetricExporter to be a singleton --- .../Metrics/GenevaMetricExporter.cs | 2 +- .../Metrics/Transport/MetricEtwDataTransport.cs | 9 ++++++++- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/src/OpenTelemetry.Exporter.Geneva/Metrics/GenevaMetricExporter.cs b/src/OpenTelemetry.Exporter.Geneva/Metrics/GenevaMetricExporter.cs index ccac1bddfa..6cf233a685 100644 --- a/src/OpenTelemetry.Exporter.Geneva/Metrics/GenevaMetricExporter.cs +++ b/src/OpenTelemetry.Exporter.Geneva/Metrics/GenevaMetricExporter.cs @@ -87,7 +87,7 @@ public GenevaMetricExporter(GenevaMetricExporterOptions options) case TransportProtocol.Unspecified: if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) { - this.metricDataTransport = new MetricEtwDataTransport(); + this.metricDataTransport = MetricEtwDataTransport.Shared; break; } else diff --git a/src/OpenTelemetry.Exporter.Geneva/Metrics/Transport/MetricEtwDataTransport.cs b/src/OpenTelemetry.Exporter.Geneva/Metrics/Transport/MetricEtwDataTransport.cs index 9d825ce249..0b0498b38f 100644 --- a/src/OpenTelemetry.Exporter.Geneva/Metrics/Transport/MetricEtwDataTransport.cs +++ b/src/OpenTelemetry.Exporter.Geneva/Metrics/Transport/MetricEtwDataTransport.cs @@ -24,7 +24,14 @@ internal sealed class MetricEtwDataTransport : EventSource, IMetricDataTransport { private readonly int fixedPayloadEndIndex; - public MetricEtwDataTransport() + static MetricEtwDataTransport() + { + Shared = new(); + } + + public static readonly MetricEtwDataTransport Shared; + + private MetricEtwDataTransport() { unsafe { From da19d0e93fc5122865bec3f84e651298bc2672f0 Mon Sep 17 00:00:00 2001 From: Utkarsh Umesan Pillai <66651184+utpilla@users.noreply.github.com> Date: Wed, 7 Jun 2023 19:47:19 -0700 Subject: [PATCH 2/4] Update CHANGELOG --- src/OpenTelemetry.Exporter.Geneva/CHANGELOG.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/OpenTelemetry.Exporter.Geneva/CHANGELOG.md b/src/OpenTelemetry.Exporter.Geneva/CHANGELOG.md index be1bc1cd30..4e782cbc7d 100644 --- a/src/OpenTelemetry.Exporter.Geneva/CHANGELOG.md +++ b/src/OpenTelemetry.Exporter.Geneva/CHANGELOG.md @@ -11,6 +11,10 @@ [RS0026](https://github.com/dotnet/roslyn-analyzers/blob/main/src/PublicApiAnalyzers/Microsoft.CodeAnalysis.PublicApiAnalyzers.md#rs0026-do-not-add-multiple-public-overloads-with-optional-parameters). ([#1218](https://github.com/open-telemetry/opentelemetry-dotnet-contrib/pull/1218)) +* Update `MetricEtwDataTransport` which is the `EventSource` implementation for + `GenevaMetricExporter` to be a singleton. + ([#1225](https://github.com/open-telemetry/opentelemetry-dotnet-contrib/pull/1225)) + ## 1.5.0-rc.1 Released 2023-Jun-05 From 0a5c5c68c63cf9559eb601d5b139a82f3b2ff1a6 Mon Sep 17 00:00:00 2001 From: Utkarsh Umesan Pillai <66651184+utpilla@users.noreply.github.com> Date: Wed, 7 Jun 2023 21:53:53 -0700 Subject: [PATCH 3/4] Update CHANGELOG --- src/OpenTelemetry.Exporter.Geneva/CHANGELOG.md | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/OpenTelemetry.Exporter.Geneva/CHANGELOG.md b/src/OpenTelemetry.Exporter.Geneva/CHANGELOG.md index 4e782cbc7d..de373f1f19 100644 --- a/src/OpenTelemetry.Exporter.Geneva/CHANGELOG.md +++ b/src/OpenTelemetry.Exporter.Geneva/CHANGELOG.md @@ -11,8 +11,10 @@ [RS0026](https://github.com/dotnet/roslyn-analyzers/blob/main/src/PublicApiAnalyzers/Microsoft.CodeAnalysis.PublicApiAnalyzers.md#rs0026-do-not-add-multiple-public-overloads-with-optional-parameters). ([#1218](https://github.com/open-telemetry/opentelemetry-dotnet-contrib/pull/1218)) -* Update `MetricEtwDataTransport` which is the `EventSource` implementation for - `GenevaMetricExporter` to be a singleton. +* Fix the issue of running into the `ArgumentException`: `An instance of + EventSource with Guid edc24920-e004-40f6-a8e1-0e6e48f39d84 already exists.` + when using multiple instances of `GenevaMetricExporter` by updating + `MetricEtwDataTransport` to be a singleton. ([#1225](https://github.com/open-telemetry/opentelemetry-dotnet-contrib/pull/1225)) ## 1.5.0-rc.1 From 5da566327b8b1a0bc338612c5767240c294f96e0 Mon Sep 17 00:00:00 2001 From: Utkarsh Umesan Pillai <66651184+utpilla@users.noreply.github.com> Date: Thu, 8 Jun 2023 09:56:16 -0700 Subject: [PATCH 4/4] Update CHANGELOG --- src/OpenTelemetry.Exporter.Geneva/CHANGELOG.md | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/OpenTelemetry.Exporter.Geneva/CHANGELOG.md b/src/OpenTelemetry.Exporter.Geneva/CHANGELOG.md index de373f1f19..d4d8ce95b3 100644 --- a/src/OpenTelemetry.Exporter.Geneva/CHANGELOG.md +++ b/src/OpenTelemetry.Exporter.Geneva/CHANGELOG.md @@ -13,8 +13,7 @@ * Fix the issue of running into the `ArgumentException`: `An instance of EventSource with Guid edc24920-e004-40f6-a8e1-0e6e48f39d84 already exists.` - when using multiple instances of `GenevaMetricExporter` by updating - `MetricEtwDataTransport` to be a singleton. + when using multiple instances of `GenevaMetricExporter`. ([#1225](https://github.com/open-telemetry/opentelemetry-dotnet-contrib/pull/1225)) ## 1.5.0-rc.1