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?

