Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Instrumentation.AspNetCore] Use static Meter and Histogram #5112

Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ internal sealed class AspNetCoreMetrics : IDisposable
internal static readonly string InstrumentationName = AssemblyName.Name;
internal static readonly string InstrumentationVersion = AssemblyName.Version.ToString();

private static readonly Meter InstrumentationMeter = new(InstrumentationName, InstrumentationVersion);

private static readonly HashSet<string> DiagnosticSourceEvents = new()
{
"Microsoft.AspNetCore.Hosting.HttpRequestIn",
Expand All @@ -43,12 +45,10 @@ internal sealed class AspNetCoreMetrics : IDisposable
=> DiagnosticSourceEvents.Contains(eventName);

private readonly DiagnosticSourceSubscriber diagnosticSourceSubscriber;
private readonly Meter meter;

internal AspNetCoreMetrics()
{
this.meter = new Meter(InstrumentationName, InstrumentationVersion);
var metricsListener = new HttpInMetricsListener("Microsoft.AspNetCore", this.meter);
var metricsListener = new HttpInMetricsListener("Microsoft.AspNetCore", InstrumentationMeter);
this.diagnosticSourceSubscriber = new DiagnosticSourceSubscriber(metricsListener, this.isEnabled, AspNetCoreInstrumentationEventSource.Log.UnknownErrorProcessingEvent);
this.diagnosticSourceSubscriber.Subscribe();
}
Expand All @@ -57,7 +57,6 @@ internal AspNetCoreMetrics()
public void Dispose()
{
this.diagnosticSourceSubscriber?.Dispose();
this.meter?.Dispose();
}
}
#endif
Loading