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

[Instrumentation.AspNetCore] [.NET7.0] Activity is not exported when used with custom propagator/sampler #4626

Closed
vishweshbankwar opened this issue Jun 29, 2023 · 0 comments · Fixed by #4637
Assignees
Labels
bug Something isn't working

Comments

@vishweshbankwar
Copy link
Member

Runtime version .NET7.0

Symptom

Background
In case of custom propagation a new activity is created with the context extracted from the propagator. Starting .NET7.0 we use the ActivitySource on the activity created by ASP.NET Core to create and start this new activity. The activity is then later identified and stopped by checking the first tag.

Issue
As the activity is created using ActivitySource, the assumption that the tag IsCreatedByInstrumentation will be the first one is not correct. Custom samplers can add tags to activity during sampling which is done before the activity is started. In such cases the added tag IsCreatedByInstrumentation by instrumentation will not be the first one preventing the activity to get stopped. We need to update the logic to check the first occurrence of that tag for .NET7.0+.

Reproduce

Set the following sampler on this test and run it for .NET7.0

public class MyCustomSampler : Sampler
{
    public override SamplingResult ShouldSample(in SamplingParameters samplingParameters)
    {
        return new SamplingResult(
        SamplingDecision.RecordAndSample,
        new Dictionary<string, object>
            {
                { "SomeTag", "SomeKey" },
            });
    }
}
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
2 participants