Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Reduce the amount of OpenTelemetry data sent to Azure Application Insights

After switching from Azure TelemetryClient to OpenTelemetry we are seeing a tonne of CustomMetrics in Application Insights, so many in fact that we fill up our quote in less than one hour.

Looking inside Application Insights > Logs, I can see this: https://imgur.com/a/afu4aCM that shows at least 25 entries all in the same millisecond. So I would like to start by filtering out these logs, but being new to OpenTelemetry I am struggling with the documentation.

The application running is an asp.net core website and our OpenTelemetry configuration is quite basic:

public static void RegisterOpenTelemetry(this IServiceCollection service, IConfiguration configuration)
{
    service.AddOpenTelemetry()
           .UseAzureMonitor(options =>
           {
               options.ConnectionString = configuration["ApplicationInsights:ConnectionString"];
               options.EnableLiveMetrics = true;
           })
           .WithTracing(x =>
           {
               x.AddSqlClientInstrumentation(options =>
               {
                   options.SetDbStatementForText = true;
                   options.RecordException = true;
               });
           })
           .WithMetrics(x =>
           {
               x.AddSqlClientInstrumentation();
           });

     service.Configure<AspNetCoreTraceInstrumentationOptions>(options =>
     {
         options.RecordException = true;
     });
}

tl;dr: If I want to filter away all the 'http.client_open_connections', how can I do that?

Thanks in advance

like image 557
Thomas Avatar asked Dec 02 '25 18:12

Thomas


1 Answers

https://github.com/open-telemetry/opentelemetry-dotnet/tree/main/docs/metrics/customizing-the-sdk#drop-an-instrument

The following should do the trick!

.WithMetrics(x =>
           {
               x.AddView(instrumentName: "http.client_open_connections", MetricStreamConfiguration.Drop)
               x.AddSqlClientInstrumentation();
           });
like image 124
cijothomas Avatar answered Dec 04 '25 07:12

cijothomas



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!