diff --git a/OpenTelemetry.sln b/OpenTelemetry.sln
index d345ee94283..a16555d39ce 100644
--- a/OpenTelemetry.sln
+++ b/OpenTelemetry.sln
@@ -239,14 +239,10 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "OpenTelemetry.Exporter.Prom
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "OpenTelemetry.Exporter.Prometheus.HttpListener", "src\OpenTelemetry.Exporter.Prometheus.HttpListener\OpenTelemetry.Exporter.Prometheus.HttpListener.csproj", "{6B0232B7-5F29-4FB5-B383-1AA02DFE1089}"
EndProject
-Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "OpenTelemetry.Exporter.Prometheus.Shared", "src\OpenTelemetry.Exporter.Prometheus.Shared\OpenTelemetry.Exporter.Prometheus.Shared.csproj", "{4AD27517-BAFC-413B-A8F0-988C3CEDC662}"
-EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "OpenTelemetry.Exporter.Prometheus.AspNetCore.Tests", "test\OpenTelemetry.Exporter.Prometheus.AspNetCore.Tests\OpenTelemetry.Exporter.Prometheus.AspNetCore.Tests.csproj", "{FBD12B0B-6731-4DD4-9C13-86F34593E974}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "OpenTelemetry.Exporter.Prometheus.HttpListener.Tests", "test\OpenTelemetry.Exporter.Prometheus.HttpListener.Tests\OpenTelemetry.Exporter.Prometheus.HttpListener.Tests.csproj", "{4EF4364F-6E64-43CE-BED1-E6FE01024899}"
EndProject
-Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "OpenTelemetry.Exporter.Prometheus.Shared.Tests", "test\OpenTelemetry.Exporter.Prometheus.Shared.Tests\OpenTelemetry.Exporter.Prometheus.Shared.Tests.csproj", "{8E75AEE2-017B-474F-A96D-035DF76A1C9E}"
-EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
@@ -501,10 +497,6 @@ Global
{6B0232B7-5F29-4FB5-B383-1AA02DFE1089}.Debug|Any CPU.Build.0 = Debug|Any CPU
{6B0232B7-5F29-4FB5-B383-1AA02DFE1089}.Release|Any CPU.ActiveCfg = Release|Any CPU
{6B0232B7-5F29-4FB5-B383-1AA02DFE1089}.Release|Any CPU.Build.0 = Release|Any CPU
- {4AD27517-BAFC-413B-A8F0-988C3CEDC662}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
- {4AD27517-BAFC-413B-A8F0-988C3CEDC662}.Debug|Any CPU.Build.0 = Debug|Any CPU
- {4AD27517-BAFC-413B-A8F0-988C3CEDC662}.Release|Any CPU.ActiveCfg = Release|Any CPU
- {4AD27517-BAFC-413B-A8F0-988C3CEDC662}.Release|Any CPU.Build.0 = Release|Any CPU
{FBD12B0B-6731-4DD4-9C13-86F34593E974}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{FBD12B0B-6731-4DD4-9C13-86F34593E974}.Debug|Any CPU.Build.0 = Debug|Any CPU
{FBD12B0B-6731-4DD4-9C13-86F34593E974}.Release|Any CPU.ActiveCfg = Release|Any CPU
@@ -513,10 +505,6 @@ Global
{4EF4364F-6E64-43CE-BED1-E6FE01024899}.Debug|Any CPU.Build.0 = Debug|Any CPU
{4EF4364F-6E64-43CE-BED1-E6FE01024899}.Release|Any CPU.ActiveCfg = Release|Any CPU
{4EF4364F-6E64-43CE-BED1-E6FE01024899}.Release|Any CPU.Build.0 = Release|Any CPU
- {8E75AEE2-017B-474F-A96D-035DF76A1C9E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
- {8E75AEE2-017B-474F-A96D-035DF76A1C9E}.Debug|Any CPU.Build.0 = Debug|Any CPU
- {8E75AEE2-017B-474F-A96D-035DF76A1C9E}.Release|Any CPU.ActiveCfg = Release|Any CPU
- {8E75AEE2-017B-474F-A96D-035DF76A1C9E}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
diff --git a/src/OpenTelemetry.Exporter.Prometheus.AspNetCore/OpenTelemetry.Exporter.Prometheus.AspNetCore.csproj b/src/OpenTelemetry.Exporter.Prometheus.AspNetCore/OpenTelemetry.Exporter.Prometheus.AspNetCore.csproj
index e7453e0bf52..33a00e05f1a 100644
--- a/src/OpenTelemetry.Exporter.Prometheus.AspNetCore/OpenTelemetry.Exporter.Prometheus.AspNetCore.csproj
+++ b/src/OpenTelemetry.Exporter.Prometheus.AspNetCore/OpenTelemetry.Exporter.Prometheus.AspNetCore.csproj
@@ -19,12 +19,12 @@
-
-
-
-
-
-
+
+
+
+
+
+
diff --git a/src/OpenTelemetry.Exporter.Prometheus.AspNetCore/PrometheusExporterMeterProviderBuilderExtensions.cs b/src/OpenTelemetry.Exporter.Prometheus.AspNetCore/PrometheusExporterMeterProviderBuilderExtensions.cs
index fd6809d68ee..d230d03d042 100644
--- a/src/OpenTelemetry.Exporter.Prometheus.AspNetCore/PrometheusExporterMeterProviderBuilderExtensions.cs
+++ b/src/OpenTelemetry.Exporter.Prometheus.AspNetCore/PrometheusExporterMeterProviderBuilderExtensions.cs
@@ -16,7 +16,7 @@
using System;
using OpenTelemetry.Exporter.Prometheus.AspNetCore;
-using OpenTelemetry.Exporter.Prometheus.Shared;
+using OpenTelemetry.Exporter.Prometheus.HttpListener.Shared;
using OpenTelemetry.Internal;
namespace OpenTelemetry.Metrics
diff --git a/src/OpenTelemetry.Exporter.Prometheus.AspNetCore/PrometheusExporterMiddleware.cs b/src/OpenTelemetry.Exporter.Prometheus.AspNetCore/PrometheusExporterMiddleware.cs
index bebf084ce33..d76a85d44d3 100644
--- a/src/OpenTelemetry.Exporter.Prometheus.AspNetCore/PrometheusExporterMiddleware.cs
+++ b/src/OpenTelemetry.Exporter.Prometheus.AspNetCore/PrometheusExporterMiddleware.cs
@@ -19,7 +19,7 @@
using System.Diagnostics;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Http;
-using OpenTelemetry.Exporter.Prometheus.Shared;
+using OpenTelemetry.Exporter.Prometheus.HttpListener.Shared;
using OpenTelemetry.Internal;
using OpenTelemetry.Metrics;
diff --git a/src/OpenTelemetry.Exporter.Prometheus.HttpListener/.publicApi/net462/PublicAPI.Unshipped.txt b/src/OpenTelemetry.Exporter.Prometheus.HttpListener/.publicApi/net462/PublicAPI.Unshipped.txt
index a8f01b6d787..5f48f2c7562 100644
--- a/src/OpenTelemetry.Exporter.Prometheus.HttpListener/.publicApi/net462/PublicAPI.Unshipped.txt
+++ b/src/OpenTelemetry.Exporter.Prometheus.HttpListener/.publicApi/net462/PublicAPI.Unshipped.txt
@@ -1,12 +1,12 @@
-OpenTelemetry.Exporter.Prometheus.HttpListener.PrometheusExporterOptions
-OpenTelemetry.Exporter.Prometheus.HttpListener.PrometheusExporterOptions.PrometheusExporterOptions() -> void
-OpenTelemetry.Exporter.Prometheus.HttpListener.PrometheusExporterOptions.ScrapeEndpointPath.get -> string
-OpenTelemetry.Exporter.Prometheus.HttpListener.PrometheusExporterOptions.ScrapeEndpointPath.set -> void
-OpenTelemetry.Exporter.Prometheus.HttpListener.PrometheusExporterOptions.ScrapeResponseCacheDurationMilliseconds.get -> int
-OpenTelemetry.Exporter.Prometheus.HttpListener.PrometheusExporterOptions.ScrapeResponseCacheDurationMilliseconds.set -> void
OpenTelemetry.Exporter.Prometheus.HttpListener.PrometheusHttpListenerOptions
OpenTelemetry.Exporter.Prometheus.HttpListener.PrometheusHttpListenerOptions.Prefixes.get -> System.Collections.Generic.IReadOnlyCollection
OpenTelemetry.Exporter.Prometheus.HttpListener.PrometheusHttpListenerOptions.Prefixes.set -> void
OpenTelemetry.Exporter.Prometheus.HttpListener.PrometheusHttpListenerOptions.PrometheusHttpListenerOptions() -> void
+OpenTelemetry.Exporter.Prometheus.HttpListener.Shared.PrometheusExporterOptions
+OpenTelemetry.Exporter.Prometheus.HttpListener.Shared.PrometheusExporterOptions.PrometheusExporterOptions() -> void
+OpenTelemetry.Exporter.Prometheus.HttpListener.Shared.PrometheusExporterOptions.ScrapeEndpointPath.get -> string
+OpenTelemetry.Exporter.Prometheus.HttpListener.Shared.PrometheusExporterOptions.ScrapeEndpointPath.set -> void
+OpenTelemetry.Exporter.Prometheus.HttpListener.Shared.PrometheusExporterOptions.ScrapeResponseCacheDurationMilliseconds.get -> int
+OpenTelemetry.Exporter.Prometheus.HttpListener.Shared.PrometheusExporterOptions.ScrapeResponseCacheDurationMilliseconds.set -> void
OpenTelemetry.Metrics.PrometheusExporterHttpListenerMeterProviderBuilderExtensions
-static OpenTelemetry.Metrics.PrometheusExporterHttpListenerMeterProviderBuilderExtensions.AddPrometheusHttpListener(this OpenTelemetry.Metrics.MeterProviderBuilder builder, System.Action configureExporterOptions = null, System.Action configureListenerOptions = null) -> OpenTelemetry.Metrics.MeterProviderBuilder
+static OpenTelemetry.Metrics.PrometheusExporterHttpListenerMeterProviderBuilderExtensions.AddPrometheusHttpListener(this OpenTelemetry.Metrics.MeterProviderBuilder builder, System.Action configureExporterOptions = null, System.Action configureListenerOptions = null) -> OpenTelemetry.Metrics.MeterProviderBuilder
diff --git a/src/OpenTelemetry.Exporter.Prometheus.HttpListener/.publicApi/netstandard2.0/PublicAPI.Unshipped.txt b/src/OpenTelemetry.Exporter.Prometheus.HttpListener/.publicApi/netstandard2.0/PublicAPI.Unshipped.txt
index a8f01b6d787..5f48f2c7562 100644
--- a/src/OpenTelemetry.Exporter.Prometheus.HttpListener/.publicApi/netstandard2.0/PublicAPI.Unshipped.txt
+++ b/src/OpenTelemetry.Exporter.Prometheus.HttpListener/.publicApi/netstandard2.0/PublicAPI.Unshipped.txt
@@ -1,12 +1,12 @@
-OpenTelemetry.Exporter.Prometheus.HttpListener.PrometheusExporterOptions
-OpenTelemetry.Exporter.Prometheus.HttpListener.PrometheusExporterOptions.PrometheusExporterOptions() -> void
-OpenTelemetry.Exporter.Prometheus.HttpListener.PrometheusExporterOptions.ScrapeEndpointPath.get -> string
-OpenTelemetry.Exporter.Prometheus.HttpListener.PrometheusExporterOptions.ScrapeEndpointPath.set -> void
-OpenTelemetry.Exporter.Prometheus.HttpListener.PrometheusExporterOptions.ScrapeResponseCacheDurationMilliseconds.get -> int
-OpenTelemetry.Exporter.Prometheus.HttpListener.PrometheusExporterOptions.ScrapeResponseCacheDurationMilliseconds.set -> void
OpenTelemetry.Exporter.Prometheus.HttpListener.PrometheusHttpListenerOptions
OpenTelemetry.Exporter.Prometheus.HttpListener.PrometheusHttpListenerOptions.Prefixes.get -> System.Collections.Generic.IReadOnlyCollection
OpenTelemetry.Exporter.Prometheus.HttpListener.PrometheusHttpListenerOptions.Prefixes.set -> void
OpenTelemetry.Exporter.Prometheus.HttpListener.PrometheusHttpListenerOptions.PrometheusHttpListenerOptions() -> void
+OpenTelemetry.Exporter.Prometheus.HttpListener.Shared.PrometheusExporterOptions
+OpenTelemetry.Exporter.Prometheus.HttpListener.Shared.PrometheusExporterOptions.PrometheusExporterOptions() -> void
+OpenTelemetry.Exporter.Prometheus.HttpListener.Shared.PrometheusExporterOptions.ScrapeEndpointPath.get -> string
+OpenTelemetry.Exporter.Prometheus.HttpListener.Shared.PrometheusExporterOptions.ScrapeEndpointPath.set -> void
+OpenTelemetry.Exporter.Prometheus.HttpListener.Shared.PrometheusExporterOptions.ScrapeResponseCacheDurationMilliseconds.get -> int
+OpenTelemetry.Exporter.Prometheus.HttpListener.Shared.PrometheusExporterOptions.ScrapeResponseCacheDurationMilliseconds.set -> void
OpenTelemetry.Metrics.PrometheusExporterHttpListenerMeterProviderBuilderExtensions
-static OpenTelemetry.Metrics.PrometheusExporterHttpListenerMeterProviderBuilderExtensions.AddPrometheusHttpListener(this OpenTelemetry.Metrics.MeterProviderBuilder builder, System.Action configureExporterOptions = null, System.Action configureListenerOptions = null) -> OpenTelemetry.Metrics.MeterProviderBuilder
+static OpenTelemetry.Metrics.PrometheusExporterHttpListenerMeterProviderBuilderExtensions.AddPrometheusHttpListener(this OpenTelemetry.Metrics.MeterProviderBuilder builder, System.Action configureExporterOptions = null, System.Action configureListenerOptions = null) -> OpenTelemetry.Metrics.MeterProviderBuilder
diff --git a/src/OpenTelemetry.Exporter.Prometheus.Shared/AssemblyInfo.cs b/src/OpenTelemetry.Exporter.Prometheus.HttpListener/AssemblyInfo.cs
similarity index 77%
rename from src/OpenTelemetry.Exporter.Prometheus.Shared/AssemblyInfo.cs
rename to src/OpenTelemetry.Exporter.Prometheus.HttpListener/AssemblyInfo.cs
index d4361cf0913..e05d6714457 100644
--- a/src/OpenTelemetry.Exporter.Prometheus.Shared/AssemblyInfo.cs
+++ b/src/OpenTelemetry.Exporter.Prometheus.HttpListener/AssemblyInfo.cs
@@ -17,9 +17,9 @@
using System.Runtime.CompilerServices;
#if SIGNED
+[assembly: InternalsVisibleTo("OpenTelemetry.Exporter.Prometheus.HttpListener.Tests, PublicKey=002400000480000094000000060200000024000052534131000400000100010051c1562a090fb0c9f391012a32198b5e5d9a60e9b80fa2d7b434c9e5ccb7259bd606e66f9660676afc6692b8cdc6793d190904551d2103b7b22fa636dcbb8208839785ba402ea08fc00c8f1500ccef28bbf599aa64ffb1e1d5dc1bf3420a3777badfe697856e9d52070a50c3ea5821c80bef17ca3acffa28f89dd413f096f898")]
[assembly: InternalsVisibleTo("Benchmarks, PublicKey=002400000480000094000000060200000024000052534131000400000100010051c1562a090fb0c9f391012a32198b5e5d9a60e9b80fa2d7b434c9e5ccb7259bd606e66f9660676afc6692b8cdc6793d190904551d2103b7b22fa636dcbb8208839785ba402ea08fc00c8f1500ccef28bbf599aa64ffb1e1d5dc1bf3420a3777badfe697856e9d52070a50c3ea5821c80bef17ca3acffa28f89dd413f096f898")]
-[assembly: InternalsVisibleTo("OpenTelemetry.Exporter.Prometheus.Shared.Tests, PublicKey=002400000480000094000000060200000024000052534131000400000100010051c1562a090fb0c9f391012a32198b5e5d9a60e9b80fa2d7b434c9e5ccb7259bd606e66f9660676afc6692b8cdc6793d190904551d2103b7b22fa636dcbb8208839785ba402ea08fc00c8f1500ccef28bbf599aa64ffb1e1d5dc1bf3420a3777badfe697856e9d52070a50c3ea5821c80bef17ca3acffa28f89dd413f096f898")]
#else
+[assembly: InternalsVisibleTo("OpenTelemetry.Exporter.Prometheus.HttpListener.Tests")]
[assembly: InternalsVisibleTo("Benchmarks")]
-[assembly: InternalsVisibleTo("OpenTelemetry.Exporter.Prometheus.Shared.Tests")]
#endif
diff --git a/src/OpenTelemetry.Exporter.Prometheus.HttpListener/OpenTelemetry.Exporter.Prometheus.HttpListener.csproj b/src/OpenTelemetry.Exporter.Prometheus.HttpListener/OpenTelemetry.Exporter.Prometheus.HttpListener.csproj
index 7769147c0f6..ff00ef3db79 100644
--- a/src/OpenTelemetry.Exporter.Prometheus.HttpListener/OpenTelemetry.Exporter.Prometheus.HttpListener.csproj
+++ b/src/OpenTelemetry.Exporter.Prometheus.HttpListener/OpenTelemetry.Exporter.Prometheus.HttpListener.csproj
@@ -14,21 +14,11 @@
false
-
- $(DefineConstants);PROMETHEUS_HTTPLISTENER
-
-
-
-
-
-
-
-
diff --git a/src/OpenTelemetry.Exporter.Prometheus.HttpListener/PrometheusExporterHttpListenerMeterProviderBuilderExtensions.cs b/src/OpenTelemetry.Exporter.Prometheus.HttpListener/PrometheusExporterHttpListenerMeterProviderBuilderExtensions.cs
index 9ab648b6be0..8c53f09837d 100644
--- a/src/OpenTelemetry.Exporter.Prometheus.HttpListener/PrometheusExporterHttpListenerMeterProviderBuilderExtensions.cs
+++ b/src/OpenTelemetry.Exporter.Prometheus.HttpListener/PrometheusExporterHttpListenerMeterProviderBuilderExtensions.cs
@@ -16,7 +16,7 @@
using System;
using OpenTelemetry.Exporter.Prometheus.HttpListener;
-using OpenTelemetry.Exporter.Prometheus.Shared;
+using OpenTelemetry.Exporter.Prometheus.HttpListener.Shared;
using OpenTelemetry.Internal;
namespace OpenTelemetry.Metrics
diff --git a/src/OpenTelemetry.Exporter.Prometheus.HttpListener/PrometheusHttpListener.cs b/src/OpenTelemetry.Exporter.Prometheus.HttpListener/PrometheusHttpListener.cs
index 28700603b1b..6badb4d5337 100644
--- a/src/OpenTelemetry.Exporter.Prometheus.HttpListener/PrometheusHttpListener.cs
+++ b/src/OpenTelemetry.Exporter.Prometheus.HttpListener/PrometheusHttpListener.cs
@@ -18,7 +18,7 @@
using System.Net;
using System.Threading;
using System.Threading.Tasks;
-using OpenTelemetry.Exporter.Prometheus.Shared;
+using OpenTelemetry.Exporter.Prometheus.HttpListener.Shared;
using OpenTelemetry.Internal;
namespace OpenTelemetry.Exporter.Prometheus.HttpListener
diff --git a/src/OpenTelemetry.Exporter.Prometheus.Shared/PrometheusCollectionManager.cs b/src/OpenTelemetry.Exporter.Prometheus.HttpListener/Shared/PrometheusCollectionManager.cs
similarity index 96%
rename from src/OpenTelemetry.Exporter.Prometheus.Shared/PrometheusCollectionManager.cs
rename to src/OpenTelemetry.Exporter.Prometheus.HttpListener/Shared/PrometheusCollectionManager.cs
index 87f3d6bff02..43da102246f 100644
--- a/src/OpenTelemetry.Exporter.Prometheus.Shared/PrometheusCollectionManager.cs
+++ b/src/OpenTelemetry.Exporter.Prometheus.HttpListener/Shared/PrometheusCollectionManager.cs
@@ -20,7 +20,7 @@
using System.Threading.Tasks;
using OpenTelemetry.Metrics;
-namespace OpenTelemetry.Exporter.Prometheus.Shared
+namespace OpenTelemetry.Exporter.Prometheus.HttpListener.Shared
{
internal sealed class PrometheusCollectionManager
{
@@ -91,7 +91,7 @@ public Task EnterCollect()
this.ExitGlobalLock();
CollectionResponse response;
- bool result = this.ExecuteCollect();
+ var result = this.ExecuteCollect();
if (result)
{
this.previousDataViewGeneratedAtUtc = DateTime.UtcNow;
@@ -169,14 +169,14 @@ private void WaitForReadersToComplete()
private bool ExecuteCollect()
{
this.exporter.OnExport = this.onCollectRef;
- bool result = this.exporter.Collect(Timeout.Infinite);
+ var result = this.exporter.Collect(Timeout.Infinite);
this.exporter.OnExport = null;
return result;
}
private ExportResult OnCollect(Batch metrics)
{
- int cursor = 0;
+ var cursor = 0;
try
{
@@ -191,7 +191,7 @@ private ExportResult OnCollect(Batch metrics)
}
catch (IndexOutOfRangeException)
{
- int bufferSize = this.buffer.Length * 2;
+ var bufferSize = this.buffer.Length * 2;
// there are two cases we might run into the following condition:
// 1. we have many metrics to be exported - in this case we probably want
diff --git a/src/OpenTelemetry.Exporter.Prometheus.Shared/PrometheusExporter.cs b/src/OpenTelemetry.Exporter.Prometheus.HttpListener/Shared/PrometheusExporter.cs
similarity index 95%
rename from src/OpenTelemetry.Exporter.Prometheus.Shared/PrometheusExporter.cs
rename to src/OpenTelemetry.Exporter.Prometheus.HttpListener/Shared/PrometheusExporter.cs
index 25cd97c7a4b..ec2dbf0467b 100644
--- a/src/OpenTelemetry.Exporter.Prometheus.Shared/PrometheusExporter.cs
+++ b/src/OpenTelemetry.Exporter.Prometheus.HttpListener/Shared/PrometheusExporter.cs
@@ -17,12 +17,10 @@
using System;
#if PROMETHEUS_ASPNETCORE
using OpenTelemetry.Exporter.Prometheus.AspNetCore;
-#elif PROMETHEUS_HTTPLISTENER
-using OpenTelemetry.Exporter.Prometheus.HttpListener;
#endif
using OpenTelemetry.Metrics;
-namespace OpenTelemetry.Exporter.Prometheus.Shared
+namespace OpenTelemetry.Exporter.Prometheus.HttpListener.Shared
{
///
/// Exporter of OpenTelemetry metrics to Prometheus.
diff --git a/src/OpenTelemetry.Exporter.Prometheus.Shared/PrometheusExporterEventSource.cs b/src/OpenTelemetry.Exporter.Prometheus.HttpListener/Shared/PrometheusExporterEventSource.cs
similarity index 97%
rename from src/OpenTelemetry.Exporter.Prometheus.Shared/PrometheusExporterEventSource.cs
rename to src/OpenTelemetry.Exporter.Prometheus.HttpListener/Shared/PrometheusExporterEventSource.cs
index 34f296c4451..6cdbf9a9024 100644
--- a/src/OpenTelemetry.Exporter.Prometheus.Shared/PrometheusExporterEventSource.cs
+++ b/src/OpenTelemetry.Exporter.Prometheus.HttpListener/Shared/PrometheusExporterEventSource.cs
@@ -18,7 +18,7 @@
using System.Diagnostics.Tracing;
using OpenTelemetry.Internal;
-namespace OpenTelemetry.Exporter.Prometheus.Shared
+namespace OpenTelemetry.Exporter.Prometheus.HttpListener.Shared
{
///
/// EventSource events emitted from the project.
diff --git a/src/OpenTelemetry.Exporter.Prometheus.Shared/PrometheusExporterOptions.cs b/src/OpenTelemetry.Exporter.Prometheus.HttpListener/Shared/PrometheusExporterOptions.cs
similarity index 93%
rename from src/OpenTelemetry.Exporter.Prometheus.Shared/PrometheusExporterOptions.cs
rename to src/OpenTelemetry.Exporter.Prometheus.HttpListener/Shared/PrometheusExporterOptions.cs
index 6c5cbd53db5..4662ee3e263 100644
--- a/src/OpenTelemetry.Exporter.Prometheus.Shared/PrometheusExporterOptions.cs
+++ b/src/OpenTelemetry.Exporter.Prometheus.HttpListener/Shared/PrometheusExporterOptions.cs
@@ -19,10 +19,8 @@
#if PROMETHEUS_ASPNETCORE
namespace OpenTelemetry.Exporter.Prometheus.AspNetCore
-#elif PROMETHEUS_HTTPLISTENER
-namespace OpenTelemetry.Exporter.Prometheus.HttpListener
#else
-namespace OpenTelemetry.Exporter.Prometheus.Shared
+namespace OpenTelemetry.Exporter.Prometheus.HttpListener.Shared
#endif
{
///
diff --git a/src/OpenTelemetry.Exporter.Prometheus.Shared/PrometheusSerializer.cs b/src/OpenTelemetry.Exporter.Prometheus.HttpListener/Shared/PrometheusSerializer.cs
similarity index 99%
rename from src/OpenTelemetry.Exporter.Prometheus.Shared/PrometheusSerializer.cs
rename to src/OpenTelemetry.Exporter.Prometheus.HttpListener/Shared/PrometheusSerializer.cs
index a8738d1853d..ac8bd042c62 100644
--- a/src/OpenTelemetry.Exporter.Prometheus.Shared/PrometheusSerializer.cs
+++ b/src/OpenTelemetry.Exporter.Prometheus.HttpListener/Shared/PrometheusSerializer.cs
@@ -22,7 +22,7 @@
using System.Runtime.CompilerServices;
using OpenTelemetry.Internal;
-namespace OpenTelemetry.Exporter.Prometheus.Shared
+namespace OpenTelemetry.Exporter.Prometheus
{
///
/// Basic PrometheusSerializer which has no OpenTelemetry dependency.
diff --git a/src/OpenTelemetry.Exporter.Prometheus.Shared/PrometheusSerializerExt.cs b/src/OpenTelemetry.Exporter.Prometheus.HttpListener/Shared/PrometheusSerializerExt.cs
similarity index 99%
rename from src/OpenTelemetry.Exporter.Prometheus.Shared/PrometheusSerializerExt.cs
rename to src/OpenTelemetry.Exporter.Prometheus.HttpListener/Shared/PrometheusSerializerExt.cs
index 1178c3069b6..805a51a2488 100644
--- a/src/OpenTelemetry.Exporter.Prometheus.Shared/PrometheusSerializerExt.cs
+++ b/src/OpenTelemetry.Exporter.Prometheus.HttpListener/Shared/PrometheusSerializerExt.cs
@@ -16,7 +16,7 @@
using OpenTelemetry.Metrics;
-namespace OpenTelemetry.Exporter.Prometheus.Shared
+namespace OpenTelemetry.Exporter.Prometheus
{
///
/// OpenTelemetry additions to the PrometheusSerializer.
diff --git a/src/OpenTelemetry.Exporter.Prometheus.Shared/.publicApi/net462/PublicAPI.Shipped.txt b/src/OpenTelemetry.Exporter.Prometheus.Shared/.publicApi/net462/PublicAPI.Shipped.txt
deleted file mode 100644
index e69de29bb2d..00000000000
diff --git a/src/OpenTelemetry.Exporter.Prometheus.Shared/.publicApi/net462/PublicAPI.Unshipped.txt b/src/OpenTelemetry.Exporter.Prometheus.Shared/.publicApi/net462/PublicAPI.Unshipped.txt
deleted file mode 100644
index d61e4fb9ed9..00000000000
--- a/src/OpenTelemetry.Exporter.Prometheus.Shared/.publicApi/net462/PublicAPI.Unshipped.txt
+++ /dev/null
@@ -1,6 +0,0 @@
-OpenTelemetry.Exporter.Prometheus.Shared.PrometheusExporterOptions
-OpenTelemetry.Exporter.Prometheus.Shared.PrometheusExporterOptions.PrometheusExporterOptions() -> void
-OpenTelemetry.Exporter.Prometheus.Shared.PrometheusExporterOptions.ScrapeEndpointPath.get -> string
-OpenTelemetry.Exporter.Prometheus.Shared.PrometheusExporterOptions.ScrapeEndpointPath.set -> void
-OpenTelemetry.Exporter.Prometheus.Shared.PrometheusExporterOptions.ScrapeResponseCacheDurationMilliseconds.get -> int
-OpenTelemetry.Exporter.Prometheus.Shared.PrometheusExporterOptions.ScrapeResponseCacheDurationMilliseconds.set -> void
diff --git a/src/OpenTelemetry.Exporter.Prometheus.Shared/.publicApi/netcoreapp3.1/PublicAPI.Shipped.txt b/src/OpenTelemetry.Exporter.Prometheus.Shared/.publicApi/netcoreapp3.1/PublicAPI.Shipped.txt
deleted file mode 100644
index e69de29bb2d..00000000000
diff --git a/src/OpenTelemetry.Exporter.Prometheus.Shared/.publicApi/netcoreapp3.1/PublicAPI.Unshipped.txt b/src/OpenTelemetry.Exporter.Prometheus.Shared/.publicApi/netcoreapp3.1/PublicAPI.Unshipped.txt
deleted file mode 100644
index 539467ab62d..00000000000
--- a/src/OpenTelemetry.Exporter.Prometheus.Shared/.publicApi/netcoreapp3.1/PublicAPI.Unshipped.txt
+++ /dev/null
@@ -1,6 +0,0 @@
-OpenTelemetry.Exporter.Prometheus.Shared.PrometheusExporterOptions
-OpenTelemetry.Exporter.Prometheus.Shared.PrometheusExporterOptions.PrometheusExporterOptions() -> void
-OpenTelemetry.Exporter.Prometheus.Shared.PrometheusExporterOptions.ScrapeEndpointPath.get -> string
-OpenTelemetry.Exporter.Prometheus.Shared.PrometheusExporterOptions.ScrapeEndpointPath.set -> void
-OpenTelemetry.Exporter.Prometheus.Shared.PrometheusExporterOptions.ScrapeResponseCacheDurationMilliseconds.get -> int
-OpenTelemetry.Exporter.Prometheus.Shared.PrometheusExporterOptions.ScrapeResponseCacheDurationMilliseconds.set -> void
diff --git a/src/OpenTelemetry.Exporter.Prometheus.Shared/OpenTelemetry.Exporter.Prometheus.Shared.csproj b/src/OpenTelemetry.Exporter.Prometheus.Shared/OpenTelemetry.Exporter.Prometheus.Shared.csproj
deleted file mode 100644
index 169e97169c4..00000000000
--- a/src/OpenTelemetry.Exporter.Prometheus.Shared/OpenTelemetry.Exporter.Prometheus.Shared.csproj
+++ /dev/null
@@ -1,29 +0,0 @@
-
-
-
-
- netcoreapp3.1;net462
- Prometheus exporter shared code for both Prometheus exporter HttpListener and Prometheus exporter AspNetCore
- $(PackageTags);prometheus;metrics
-
-
-
-
- false
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/test/Benchmarks/Benchmarks.csproj b/test/Benchmarks/Benchmarks.csproj
index 3a3cc739d91..20ee4fb7456 100644
--- a/test/Benchmarks/Benchmarks.csproj
+++ b/test/Benchmarks/Benchmarks.csproj
@@ -29,6 +29,6 @@
-
+
diff --git a/test/Benchmarks/Exporter/PrometheusSerializerBenchmarks.cs b/test/Benchmarks/Exporter/PrometheusSerializerBenchmarks.cs
index efd31fa6f86..c08d069bb50 100644
--- a/test/Benchmarks/Exporter/PrometheusSerializerBenchmarks.cs
+++ b/test/Benchmarks/Exporter/PrometheusSerializerBenchmarks.cs
@@ -18,7 +18,7 @@
using System.Diagnostics.Metrics;
using BenchmarkDotNet.Attributes;
using OpenTelemetry;
-using OpenTelemetry.Exporter.Prometheus.Shared;
+using OpenTelemetry.Exporter.Prometheus;
using OpenTelemetry.Metrics;
using OpenTelemetry.Tests;
diff --git a/test/OpenTelemetry.Exporter.Prometheus.AspNetCore.Tests/PrometheusCollectionManagerTests.cs b/test/OpenTelemetry.Exporter.Prometheus.AspNetCore.Tests/PrometheusCollectionManagerTests.cs
index adeb3ac29c0..aa680d6495c 100644
--- a/test/OpenTelemetry.Exporter.Prometheus.AspNetCore.Tests/PrometheusCollectionManagerTests.cs
+++ b/test/OpenTelemetry.Exporter.Prometheus.AspNetCore.Tests/PrometheusCollectionManagerTests.cs
@@ -21,7 +21,7 @@
#endif
using System.Threading;
using System.Threading.Tasks;
-using OpenTelemetry.Exporter.Prometheus.Shared;
+using OpenTelemetry.Exporter.Prometheus.HttpListener.Shared;
using OpenTelemetry.Metrics;
using OpenTelemetry.Tests;
using Xunit;
diff --git a/test/OpenTelemetry.Exporter.Prometheus.HttpListener.Tests/OpenTelemetry.Exporter.Prometheus.HttpListener.Tests.csproj b/test/OpenTelemetry.Exporter.Prometheus.HttpListener.Tests/OpenTelemetry.Exporter.Prometheus.HttpListener.Tests.csproj
index 22b68c4e9ea..4588d2168b5 100644
--- a/test/OpenTelemetry.Exporter.Prometheus.HttpListener.Tests/OpenTelemetry.Exporter.Prometheus.HttpListener.Tests.csproj
+++ b/test/OpenTelemetry.Exporter.Prometheus.HttpListener.Tests/OpenTelemetry.Exporter.Prometheus.HttpListener.Tests.csproj
@@ -20,6 +20,7 @@
+
diff --git a/test/OpenTelemetry.Exporter.Prometheus.HttpListener.Tests/PrometheusSerializerTests.cs b/test/OpenTelemetry.Exporter.Prometheus.HttpListener.Tests/PrometheusSerializerTests.cs
new file mode 100644
index 00000000000..e6c0865cc3a
--- /dev/null
+++ b/test/OpenTelemetry.Exporter.Prometheus.HttpListener.Tests/PrometheusSerializerTests.cs
@@ -0,0 +1,387 @@
+//
+// Copyright The OpenTelemetry Authors
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+using System.Collections.Generic;
+using System.Diagnostics.Metrics;
+using System.Text;
+using OpenTelemetry.Metrics;
+using OpenTelemetry.Tests;
+using Xunit;
+
+namespace OpenTelemetry.Exporter.Prometheus
+{
+ public sealed class PrometheusSerializerTests
+ {
+ [Fact]
+ public void GaugeZeroDimension()
+ {
+ var buffer = new byte[85000];
+ var metrics = new List();
+
+ using var meter = new Meter(Utils.GetCurrentMethodName());
+ using var provider = Sdk.CreateMeterProviderBuilder()
+ .AddMeter(meter.Name)
+ .AddInMemoryExporter(metrics)
+ .Build();
+
+ meter.CreateObservableGauge("test_gauge", () => 123);
+
+ provider.ForceFlush();
+
+ var cursor = PrometheusSerializer.WriteMetric(buffer, 0, metrics[0]);
+ Assert.Matches(
+ ("^"
+ + "# TYPE test_gauge gauge\n"
+ + "test_gauge 123 \\d+\n"
+ + "$").Replace('\'', '"'),
+ Encoding.UTF8.GetString(buffer, 0, cursor));
+ }
+
+ [Fact]
+ public void GaugeZeroDimensionWithDescription()
+ {
+ var buffer = new byte[85000];
+ var metrics = new List();
+
+ using var meter = new Meter(Utils.GetCurrentMethodName());
+ using var provider = Sdk.CreateMeterProviderBuilder()
+ .AddMeter(meter.Name)
+ .AddInMemoryExporter(metrics)
+ .Build();
+
+ meter.CreateObservableGauge("test_gauge", () => 123, description: "Hello, world!");
+
+ provider.ForceFlush();
+
+ var cursor = PrometheusSerializer.WriteMetric(buffer, 0, metrics[0]);
+ Assert.Matches(
+ ("^"
+ + "# HELP test_gauge Hello, world!\n"
+ + "# TYPE test_gauge gauge\n"
+ + "test_gauge 123 \\d+\n"
+ + "$").Replace('\'', '"'),
+ Encoding.UTF8.GetString(buffer, 0, cursor));
+ }
+
+ [Fact]
+ public void GaugeZeroDimensionWithUnit()
+ {
+ var buffer = new byte[85000];
+ var metrics = new List();
+
+ using var meter = new Meter(Utils.GetCurrentMethodName());
+ using var provider = Sdk.CreateMeterProviderBuilder()
+ .AddMeter(meter.Name)
+ .AddInMemoryExporter(metrics)
+ .Build();
+
+ meter.CreateObservableGauge("test_gauge", () => 123, unit: "seconds");
+
+ provider.ForceFlush();
+
+ var cursor = PrometheusSerializer.WriteMetric(buffer, 0, metrics[0]);
+ Assert.Matches(
+ ("^"
+ + "# TYPE test_gauge_seconds gauge\n"
+ + "test_gauge_seconds 123 \\d+\n"
+ + "$").Replace('\'', '"'),
+ Encoding.UTF8.GetString(buffer, 0, cursor));
+ }
+
+ [Fact]
+ public void GaugeOneDimension()
+ {
+ var buffer = new byte[85000];
+ var metrics = new List();
+
+ using var meter = new Meter(Utils.GetCurrentMethodName());
+ using var provider = Sdk.CreateMeterProviderBuilder()
+ .AddMeter(meter.Name)
+ .AddInMemoryExporter(metrics)
+ .Build();
+
+ meter.CreateObservableGauge(
+ "test_gauge",
+ () => new Measurement(123, new KeyValuePair("tagKey", "tagValue")));
+
+ provider.ForceFlush();
+
+ var cursor = PrometheusSerializer.WriteMetric(buffer, 0, metrics[0]);
+ Assert.Matches(
+ ("^"
+ + "# TYPE test_gauge gauge\n"
+ + "test_gauge{tagKey='tagValue'} 123 \\d+\n"
+ + "$").Replace('\'', '"'),
+ Encoding.UTF8.GetString(buffer, 0, cursor));
+ }
+
+ [Fact]
+ public void GaugeDoubleSubnormal()
+ {
+ var buffer = new byte[85000];
+ var metrics = new List();
+
+ using var meter = new Meter(Utils.GetCurrentMethodName());
+ using var provider = Sdk.CreateMeterProviderBuilder()
+ .AddMeter(meter.Name)
+ .AddInMemoryExporter(metrics)
+ .Build();
+
+ meter.CreateObservableGauge("test_gauge", () => new List>
+ {
+ new(double.NegativeInfinity, new("x", "1"), new("y", "2")),
+ new(double.PositiveInfinity, new("x", "3"), new("y", "4")),
+ new(double.NaN, new("x", "5"), new("y", "6")),
+ });
+
+ provider.ForceFlush();
+
+ var cursor = PrometheusSerializer.WriteMetric(buffer, 0, metrics[0]);
+ Assert.Matches(
+ ("^"
+ + "# TYPE test_gauge gauge\n"
+ + "test_gauge{x='1',y='2'} -Inf \\d+\n"
+ + "test_gauge{x='3',y='4'} \\+Inf \\d+\n"
+ + "test_gauge{x='5',y='6'} Nan \\d+\n"
+ + "$").Replace('\'', '"'),
+ Encoding.UTF8.GetString(buffer, 0, cursor));
+ }
+
+ [Fact]
+ public void SumDoubleInfinites()
+ {
+ var buffer = new byte[85000];
+ var metrics = new List();
+
+ using var meter = new Meter(Utils.GetCurrentMethodName());
+ using var provider = Sdk.CreateMeterProviderBuilder()
+ .AddMeter(meter.Name)
+ .AddInMemoryExporter(metrics)
+ .Build();
+
+ var counter = meter.CreateCounter("test_counter");
+ counter.Add(1.0E308);
+ counter.Add(1.0E308);
+
+ provider.ForceFlush();
+
+ var cursor = PrometheusSerializer.WriteMetric(buffer, 0, metrics[0]);
+ Assert.Matches(
+ ("^"
+ + "# TYPE test_counter counter\n"
+ + "test_counter \\+Inf \\d+\n"
+ + "$").Replace('\'', '"'),
+ Encoding.UTF8.GetString(buffer, 0, cursor));
+ }
+
+ [Fact]
+ public void HistogramZeroDimension()
+ {
+ var buffer = new byte[85000];
+ var metrics = new List();
+
+ using var meter = new Meter(Utils.GetCurrentMethodName());
+ using var provider = Sdk.CreateMeterProviderBuilder()
+ .AddMeter(meter.Name)
+ .AddInMemoryExporter(metrics)
+ .Build();
+
+ var histogram = meter.CreateHistogram("test_histogram");
+ histogram.Record(18);
+ histogram.Record(100);
+
+ provider.ForceFlush();
+
+ var cursor = PrometheusSerializer.WriteMetric(buffer, 0, metrics[0]);
+ Assert.Matches(
+ ("^"
+ + "# TYPE test_histogram histogram\n"
+ + "test_histogram_bucket{le='0'} 0 \\d+\n"
+ + "test_histogram_bucket{le='5'} 0 \\d+\n"
+ + "test_histogram_bucket{le='10'} 0 \\d+\n"
+ + "test_histogram_bucket{le='25'} 1 \\d+\n"
+ + "test_histogram_bucket{le='50'} 1 \\d+\n"
+ + "test_histogram_bucket{le='75'} 1 \\d+\n"
+ + "test_histogram_bucket{le='100'} 2 \\d+\n"
+ + "test_histogram_bucket{le='250'} 2 \\d+\n"
+ + "test_histogram_bucket{le='500'} 2 \\d+\n"
+ + "test_histogram_bucket{le='1000'} 2 \\d+\n"
+ + "test_histogram_bucket{le='\\+Inf'} 2 \\d+\n"
+ + "test_histogram_sum 118 \\d+\n"
+ + "test_histogram_count 2 \\d+\n"
+ + "$").Replace('\'', '"'),
+ Encoding.UTF8.GetString(buffer, 0, cursor));
+ }
+
+ [Fact]
+ public void HistogramOneDimension()
+ {
+ var buffer = new byte[85000];
+ var metrics = new List();
+
+ using var meter = new Meter(Utils.GetCurrentMethodName());
+ using var provider = Sdk.CreateMeterProviderBuilder()
+ .AddMeter(meter.Name)
+ .AddInMemoryExporter(metrics)
+ .Build();
+
+ var histogram = meter.CreateHistogram("test_histogram");
+ histogram.Record(18, new KeyValuePair("x", "1"));
+ histogram.Record(100, new KeyValuePair("x", "1"));
+
+ provider.ForceFlush();
+
+ var cursor = PrometheusSerializer.WriteMetric(buffer, 0, metrics[0]);
+ Assert.Matches(
+ ("^"
+ + "# TYPE test_histogram histogram\n"
+ + "test_histogram_bucket{x='1',le='0'} 0 \\d+\n"
+ + "test_histogram_bucket{x='1',le='5'} 0 \\d+\n"
+ + "test_histogram_bucket{x='1',le='10'} 0 \\d+\n"
+ + "test_histogram_bucket{x='1',le='25'} 1 \\d+\n"
+ + "test_histogram_bucket{x='1',le='50'} 1 \\d+\n"
+ + "test_histogram_bucket{x='1',le='75'} 1 \\d+\n"
+ + "test_histogram_bucket{x='1',le='100'} 2 \\d+\n"
+ + "test_histogram_bucket{x='1',le='250'} 2 \\d+\n"
+ + "test_histogram_bucket{x='1',le='500'} 2 \\d+\n"
+ + "test_histogram_bucket{x='1',le='1000'} 2 \\d+\n"
+ + "test_histogram_bucket{x='1',le='\\+Inf'} 2 \\d+\n"
+ + "test_histogram_sum{x='1'} 118 \\d+\n"
+ + "test_histogram_count{x='1'} 2 \\d+\n"
+ + "$").Replace('\'', '"'),
+ Encoding.UTF8.GetString(buffer, 0, cursor));
+ }
+
+ [Fact]
+ public void HistogramTwoDimensions()
+ {
+ var buffer = new byte[85000];
+ var metrics = new List();
+
+ using var meter = new Meter(Utils.GetCurrentMethodName());
+ using var provider = Sdk.CreateMeterProviderBuilder()
+ .AddMeter(meter.Name)
+ .AddInMemoryExporter(metrics)
+ .Build();
+
+ var histogram = meter.CreateHistogram("test_histogram");
+ histogram.Record(18, new("x", "1"), new("y", "2"));
+ histogram.Record(100, new("x", "1"), new("y", "2"));
+
+ provider.ForceFlush();
+
+ var cursor = PrometheusSerializer.WriteMetric(buffer, 0, metrics[0]);
+ Assert.Matches(
+ ("^"
+ + "# TYPE test_histogram histogram\n"
+ + "test_histogram_bucket{x='1',y='2',le='0'} 0 \\d+\n"
+ + "test_histogram_bucket{x='1',y='2',le='5'} 0 \\d+\n"
+ + "test_histogram_bucket{x='1',y='2',le='10'} 0 \\d+\n"
+ + "test_histogram_bucket{x='1',y='2',le='25'} 1 \\d+\n"
+ + "test_histogram_bucket{x='1',y='2',le='50'} 1 \\d+\n"
+ + "test_histogram_bucket{x='1',y='2',le='75'} 1 \\d+\n"
+ + "test_histogram_bucket{x='1',y='2',le='100'} 2 \\d+\n"
+ + "test_histogram_bucket{x='1',y='2',le='250'} 2 \\d+\n"
+ + "test_histogram_bucket{x='1',y='2',le='500'} 2 \\d+\n"
+ + "test_histogram_bucket{x='1',y='2',le='1000'} 2 \\d+\n"
+ + "test_histogram_bucket{x='1',y='2',le='\\+Inf'} 2 \\d+\n"
+ + "test_histogram_sum{x='1',y='2'} 118 \\d+\n"
+ + "test_histogram_count{x='1',y='2'} 2 \\d+\n"
+ + "$").Replace('\'', '"'),
+ Encoding.UTF8.GetString(buffer, 0, cursor));
+ }
+
+ [Fact]
+ public void HistogramInfinites()
+ {
+ var buffer = new byte[85000];
+ var metrics = new List();
+
+ using var meter = new Meter(Utils.GetCurrentMethodName());
+ using var provider = Sdk.CreateMeterProviderBuilder()
+ .AddMeter(meter.Name)
+ .AddInMemoryExporter(metrics)
+ .Build();
+
+ var histogram = meter.CreateHistogram("test_histogram");
+ histogram.Record(18);
+ histogram.Record(double.PositiveInfinity);
+ histogram.Record(double.PositiveInfinity);
+
+ provider.ForceFlush();
+
+ var cursor = PrometheusSerializer.WriteMetric(buffer, 0, metrics[0]);
+ Assert.Matches(
+ ("^"
+ + "# TYPE test_histogram histogram\n"
+ + "test_histogram_bucket{le='0'} 0 \\d+\n"
+ + "test_histogram_bucket{le='5'} 0 \\d+\n"
+ + "test_histogram_bucket{le='10'} 0 \\d+\n"
+ + "test_histogram_bucket{le='25'} 1 \\d+\n"
+ + "test_histogram_bucket{le='50'} 1 \\d+\n"
+ + "test_histogram_bucket{le='75'} 1 \\d+\n"
+ + "test_histogram_bucket{le='100'} 1 \\d+\n"
+ + "test_histogram_bucket{le='250'} 1 \\d+\n"
+ + "test_histogram_bucket{le='500'} 1 \\d+\n"
+ + "test_histogram_bucket{le='1000'} 1 \\d+\n"
+ + "test_histogram_bucket{le='\\+Inf'} 3 \\d+\n"
+ + "test_histogram_sum \\+Inf \\d+\n"
+ + "test_histogram_count 3 \\d+\n"
+ + "$").Replace('\'', '"'),
+ Encoding.UTF8.GetString(buffer, 0, cursor));
+ }
+
+ [Fact]
+ public void HistogramNaN()
+ {
+ var buffer = new byte[85000];
+ var metrics = new List();
+
+ using var meter = new Meter(Utils.GetCurrentMethodName());
+ using var provider = Sdk.CreateMeterProviderBuilder()
+ .AddMeter(meter.Name)
+ .AddInMemoryExporter(metrics)
+ .Build();
+
+ var histogram = meter.CreateHistogram("test_histogram");
+ histogram.Record(18);
+ histogram.Record(double.PositiveInfinity);
+ histogram.Record(double.NaN);
+
+ provider.ForceFlush();
+
+ var cursor = PrometheusSerializer.WriteMetric(buffer, 0, metrics[0]);
+ Assert.Matches(
+ ("^"
+ + "# TYPE test_histogram histogram\n"
+ + "test_histogram_bucket{le='0'} 0 \\d+\n"
+ + "test_histogram_bucket{le='5'} 0 \\d+\n"
+ + "test_histogram_bucket{le='10'} 0 \\d+\n"
+ + "test_histogram_bucket{le='25'} 1 \\d+\n"
+ + "test_histogram_bucket{le='50'} 1 \\d+\n"
+ + "test_histogram_bucket{le='75'} 1 \\d+\n"
+ + "test_histogram_bucket{le='100'} 1 \\d+\n"
+ + "test_histogram_bucket{le='250'} 1 \\d+\n"
+ + "test_histogram_bucket{le='500'} 1 \\d+\n"
+ + "test_histogram_bucket{le='1000'} 1 \\d+\n"
+ + "test_histogram_bucket{le='\\+Inf'} 3 \\d+\n"
+ + "test_histogram_sum Nan \\d+\n"
+ + "test_histogram_count 3 \\d+\n"
+ + "$").Replace('\'', '"'),
+ Encoding.UTF8.GetString(buffer, 0, cursor));
+ }
+ }
+}