Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Filter Processor causes exported spans to lose ResourceDefinition information in Jaeger #3603

Closed
Aaronontheweb opened this issue Aug 24, 2022 · 3 comments
Labels
bug Something isn't working

Comments

@Aaronontheweb
Copy link
Contributor

Bug Report

<PackageReference Include="OpenTelemetry.Extensions.Hosting" Version="1.0.0-rc9.4" />
<PackageReference Include="OpenTelemetry.Instrumentation.AspNetCore" Version="1.0.0-rc9.4" />
<PackageReference Include="OpenTelemetry.Instrumentation.Http" Version="1.0.0-rc9.4" />
<PackageReference Include="OpenTelemetry.Exporter.Jaeger" Version="1.0.1" />
<PackageReference Include="OpenTelemetry.Exporter.Prometheus" Version="1.2.0-rc5" />

Runtime version: .NET 6.0

Symptom

When using the a filter CompositeProcessor<Activity> that is nearly identical to what's included in the OpenTelemetry .NET documentation:

internal sealed class MyFilteringProcessor : CompositeProcessor<Activity>
{
private readonly Func<Activity, bool> filter;
public MyFilteringProcessor(BaseProcessor<Activity> processor, Func<Activity, bool> filter)
: base(new[] { processor })
{
this.filter = filter ?? throw new ArgumentNullException(nameof(filter));
}
public override void OnEnd(Activity activity)
{
// Call the underlying processor
// only if the Filter returns true.
if (this.filter(activity))
{
base.OnEnd(activity);
}
}
}

I compose my OpenTelemetry tracing integration like so:

var resource = ResourceBuilder.CreateDefault()
            .AddService(Assembly.GetEntryAssembly().GetName().Name, serviceInstanceId: $"{Dns.GetHostName()}");

        // enables OpenTelemetry for ASP.NET / .NET Core
        services.AddOpenTelemetryTracing(builder =>
        {
            builder
                .SetResourceBuilder(resource)
                .AddPhobosInstrumentation()
                .AddHttpClientInstrumentation()
                .AddAspNetCoreInstrumentation()
                .AddProcessor(new ExcludeShardingProcessor(new[]
                    { new SimpleActivityExportProcessor(new JaegerExporter(new JaegerExporterOptions())) }));
        });

The filter works as expected - however, I lose all of my ResourceBuilder information and see this instead:

image

What is the expected behavior?

I expected to see my resource data, which I could see before I added the CompositeProcessor<Activity> to my pipeline:

image

What is the actual behavior?

image - none of my ResourceDefinition data is present on the traces.

Reproduce

Run

public class Program
{
private static readonly ActivitySource DemoSource = new("OTel.Demo");
public static void Main()
{
using var tracerProvider = Sdk.CreateTracerProviderBuilder()
.SetSampler(new MySampler())
.AddSource("OTel.Demo")
.SetResourceBuilder(ResourceBuilder.CreateEmpty().AddDetector(new MyResourceDetector()))
.AddProcessor(new MyProcessor("ProcessorA"))
.AddProcessor(new MyProcessor("ProcessorB"))
.AddProcessor(new SimpleActivityExportProcessor(new MyExporter("ExporterX")))
.AddMyExporter()
.Build();
using (var foo = DemoSource.StartActivity("Foo"))
{
using (var bar = DemoSource.StartActivity("Bar"))
{
using (var baz = DemoSource.StartActivity("Baz"))
{
}
}
}
}
}
with the MyFilteringProcessor wrapped around a JaegerExporter.

@cijothomas
Copy link
Member

#3241 same? Has a fix in latest alpha.

@Aaronontheweb
Copy link
Contributor Author

#3241 same? Has a fix in latest alpha.

totally missed that issue - I can check

@cijothomas
Copy link
Member

Closing as this is expected to be fixed. Feel free to reopen if that was not the issue here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants