Skip to content

DynamicSamplingContext Exceptions: Attempted to set the DynamicSamplingContext but the context exists already #2591

@ian-a-anderson

Description

@ian-a-anderson

Package

Sentry.AspNetCore

.NET Flavor

.NET Core

.NET Version

6.0.0

OS

Linux

SDK Version

3.36.0

Self-Hosted Sentry Version

No response

Steps to Reproduce

These errors seem to have begun at the beginning of August, after the following PR landed:
#2493

They fire intermittently as the result of cross-api backend calls where we are forwarding sentry headers along to another request (for distributed tracing). As a result I don't have a consistent repro. Mainly I would like a way to disable these from throwing until a resolution can be found, but since this is an exception coming from Sentry internals I'm not sure how best to avoid it.

It appears this functionality is tied to Dynamic Sampling so I assumed that disabling Performance tracing would prevent the issue. But it appears that you can't disable backend/API performance tracing if it is enabled on an incoming request from a frontend client that has it enabled (for distributed tracing).

Expected Result

No exception thrown (possibly a logged error instead?)

Actual Result

image

Metadata

Metadata

Assignees

No one assigned

    Labels

    BugSomething isn't working
    No fields configured for issues without a type.

    Projects

    Status

    No status

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions