I'm trying to get to grips with OpenTelemetry and AzureMonitor in an ASP.NET Core service.
I've covered the documentation a few times but cannot find definitive answers (yet)...
I have a shared library with an extension method to register itself as follows:
public static IServiceCollection RegisterMetrics(this IServiceCollection services, string appInsightsConnectionString, string serviceName)
{
var meterName = $"{serviceName}.Meters";
services.AddOpenTelemetry()
.WithMetrics(options =>
{
options.SetResourceBuilder(ResourceBuilder.CreateEmpty().AddService(serviceName));
options.AddMeter(meterName);
})
.UseAzureMonitor((options) =>
{
options.ConnectionString = appInsightsConnectionString;
});
services.TryAddSingleton<IMetricsFactory>(x => new MetricsFactory(meterName, x.GetRequiredService<IMeterFactory>()));
return services;
}
This works in as much as I can later grab and use a MetricsFactory
(my own wrapper around a MeterFactory
) to create a counter and see the data being sent to App Insights.
All good.
What I'm struggling with is (what I think is) some of the 'autoinstrumentation' (StatsBeat?) data being send too (see image).
It's not clear how to turn this off. The documentation mentions setting an environment variable:
APPLICATIONINSIGHTS_STATSBEAT_DISABLED=true
I've done this, but the data still seems to be being sent...
Questions
Is the data seen in the image (HeartBeatState
, http.client.xxxx
, http.server.xxxx
) actually the 'StatsBeat' data?
If it is StatsBeat data, then is it correct that this is zero cost as this page alludes to https://learn.microsoft.com/en-us/azure/azure-monitor/app/statsbeat?tabs=dotnet ? (in which case I probably don't care about it being there)
Should setting the environment variable mentioned turn it off?
Is there a way, in code, to turn it off / disable it when registering?
- Is the data seen in the image (
HeartBeatState
,http.client.xxxx
,http.server.xxxx
) actually the 'StatsBeat' data?
The metrics http.client.xxxx
, http.server.xxxx
are OpenTelemetry auto-instrumentation metrics
, not StatsBeat
.
As per this Ms Documentation Statsbeat is doesn't affect the cost
and customers monitoring volume
it is collected data for Microsoft's internal usage to improve the service and ensure reliability.
APPLICATIONINSIGHTS_STATSBEAT_DISABLED=true
is only stops the Statsbeat data not OpenTelemetry metrics http.client.xxxx
, http.server.xxxx
.
After Configuring APPLICATIONINSIGHTS_STATSBEAT_DISABLED=true
in my Program.cs
class, I didn't find any Statsbeat
metrics.
Below logs are completely related to OpenTelemetry metrics
.