opentelemetry-dotnet icon indicating copy to clipboard operation
opentelemetry-dotnet copied to clipboard

Adding filter processor after also filter previous processor

Open andrew-at-v opened this issue 1 year ago • 5 comments

What is the question?

The first registration

builder.Services.AddOpenTelemetry()
    .WithMetrics(metrics =>
    {
        metrics.AddAspNetCoreInstrumentation()
            .AddHttpClientInstrumentation()
            .AddRuntimeInstrumentation();
    })
    .WithTracing(tracing =>
    {
        tracing.AddAspNetCoreInstrumentation()
            // Uncomment the following line to enable gRPC instrumentation (requires the OpenTelemetry.Instrumentation.GrpcNetClient package)
            //.AddGrpcClientInstrumentation()
            .AddHttpClientInstrumentation()
            .AddSqlClientInstrumentation()
            .AddRedisInstrumentation();
    });

next

builder.Services.AddOpenTelemetry().WithTracing(tracing =>
{
   tracing.AddProcessor(new MyFilterProcessor())

tracing.AddProcessor(new MyProcessor());
});

I was expecting "MyProcessor" should be filtered but what happened is AspNetCoreInstrumentation also filtered

Is this expected?

Additional context

No response

andrew-at-v avatar Jun 05 '24 16:06 andrew-at-v

@abratv - could you please elaborate on what you are trying to do?

I was expecting "MyProcessor" should be filtered but what happened is AspNetCoreInstrumentation also filtered

This statement is not clear to me.

vishweshbankwar avatar Jun 07 '24 15:06 vishweshbankwar

Let's say I have following processors

  • Processor A
  • Processor B
  • Processor Filter
  • Processor C

Expectation: "Processor Filter" only apply to "Processor C" Actual: "Processor Filter" also applied to "Processor A", "Processor B" and "Processor C"

andrew-at-v avatar Jun 10 '24 07:06 andrew-at-v

Let's say I have following processors

  • Processor A
  • Processor B
  • Processor Filter
  • Processor C

Expectation: "Processor Filter" only apply to "Processor C" Actual: "Processor Filter" also applied to "Processor A", "Processor B" and "Processor C"

This would be a bug, if ProcessorFilter applied to things before it! Can you share a minimal repro or a unittest to show the behavior you are seeing?

cijothomas avatar Jun 10 '24 15:06 cijothomas

I'm bit tight right now

You can check quickly if the traces over the dashboard also got filtered

image

or the way I configure it wrong some how?

this is the way i configure my filter

    public static IHostApplicationBuilder ConfigureMyTelemetry(this IHostApplicationBuilder builder, Action<TracerProviderBuilder> configure)
    {
        builder.Services.AddOpenTelemetry().WithTracing(tracing =>
        {
            configure(tracing);
        });

        return builder;
    }

and in program.cs

//these 2 lines below come from github example
builder.ConfigureOpenTelemetry(); 
builder.AddDefaultHealthChecks();

//My own telemetry, filter and processor
builder.ConfigureMyTelemetry(trace =>
{
    trace.AddProcessor<MyFilterProcessor>();
    trace.AddProcessor<MyProcessor>();
});

So MyFilterProcessor also filter configuration in "ConfigurationOpenTelemetry"

andrew-at-v avatar Jun 11 '24 07:06 andrew-at-v

https://github.com/open-telemetry/opentelemetry-dotnet/tree/main/docs/trace/extending-the-sdk Please use a minimal example and share the repro code, so it'll be easy for us to confirm you are adding processors correctly.

cijothomas avatar Jun 11 '24 13:06 cijothomas

This issue was marked stale due to lack of activity and will be closed in 7 days. Commenting will instruct the bot to automatically remove the label. This bot runs once per day.

github-actions[bot] avatar Apr 08 '25 03:04 github-actions[bot]

Closed as inactive. Feel free to reopen if this issue is still a concern.

github-actions[bot] avatar Apr 15 '25 03:04 github-actions[bot]