C
C#2w ago
ewilliams

Aspnet Instrumentation OTEL Filters

I ran into an interesting problem using the Open Telemetry packages in a dotnet 8 application. We have a service that gets hammered, roughly 3b events a month so I created a custom filter to sample specific routes. After deploying the update I noticed my should be 90% reduction only went down by about half. I did some local testing and reviewed the data only to find the filter predicate was never even invoked from a specific appliance we have out in the field. It’s an old windows CE device using HTTP 1.1. Aside from that I don’t notice anything different about the request. Unfortunately these devices can’t be updated or at least not quickly as there are several thousand out in the field. Is there a different filter mechanism I can use as apposed to the packages OTEL middleware that may happen further down stream?
builder.Services
.AddOpenTelemetry()
.ConfigureResource(resource => resource.AddService(DiagnosticsConfiguration.ServiceName))
.WithTracing(tracing =>
{
tracing
.AddSource(DiagnosticsConfiguration.ServiceName)
.AddAspNetCoreInstrumentation(ops =>
{
//// code here is never invoked with old http client
ops.Filter = new RootSpanEndpointFilter("POST").Filter;
})
.AddSqlClientInstrumentation(o =>
{
o.SetDbStatementForText = true;
o.Filter = @object =>
{

/// ….
};
})
.AddHttpClientInstrumentation();

tracing.AddOtlpExporter();
})
.WithLogging(logging =>
{
logging.ConfigureResource(re => re.AddService(DiagnosticsConfiguration.ServiceName));
});
builder.Services
.AddOpenTelemetry()
.ConfigureResource(resource => resource.AddService(DiagnosticsConfiguration.ServiceName))
.WithTracing(tracing =>
{
tracing
.AddSource(DiagnosticsConfiguration.ServiceName)
.AddAspNetCoreInstrumentation(ops =>
{
//// code here is never invoked with old http client
ops.Filter = new RootSpanEndpointFilter("POST").Filter;
})
.AddSqlClientInstrumentation(o =>
{
o.SetDbStatementForText = true;
o.Filter = @object =>
{

/// ….
};
})
.AddHttpClientInstrumentation();

tracing.AddOtlpExporter();
})
.WithLogging(logging =>
{
logging.ConfigureResource(re => re.AddService(DiagnosticsConfiguration.ServiceName));
});
1 Reply
ewilliams
ewilliamsOP2w ago
<PackageReference Include="OpenTelemetry.Instrumentation.AspNetCore" Version="1.11.1" />
<PackageReference Include="OpenTelemetry.Instrumentation.AspNetCore" Version="1.11.1" />

Did you find this page helpful?