I am working to instrument a .NET Core windows service by adding custom metrics. Here listed in this official documentation are the things that Azure Monitor supports attaching to a custom metric. My goal is to construct a Meter instance and have that meter's name used as the metric namespace within Azure Monitor.
By default my custom metric telemetry that is exported to Azure Monitor when using the Azure.Monitor.OpenTelemetry.Exporter package has this unhelpful metric namespace of "azure.applicationinsights".
Absurdly, when looking at the raw meter data within azure monitor, it appears that the meter name doesn't appear to have been sent or persisted at all.
Here's how I am setting things up early in my application:
builder.Services.AddOpenTelemetry()
.WithMetrics(metrics => metrics.AddMeter(MyTelemetryConstants.SomeMeterName))
.UseAzureMonitor(o =>
{
o.ConnectionString = builder.Configuration.GetConnectionString("AzureMonitor");
});
And here's generally how I'm creating metrics:
public class MyAppMeter
{
// metric sources can use this instrument directly: `appMeter.SomeCounter.Add(1);`
public Counter<int> SomeCounter { get; }
public MyAppMeter(IMeterFactory meterFactory)
{
// I want `MyTelemetryConstants.SomeMeterName`'s value to be the Metric Namespace within Azure Monitor
var meter = meterFactory.Create(MyTelemetryConstants.SomeMeterName);
SomeCounter = meter.CreateCounter<int>("some_counter");
}
}
What am I missing?
