Skip to content

traces_sampler receives always "generic ASGI request" as transaction name. #2262

Description

@antonpirker

How do you use Sentry?

Sentry Saas (sentry.io)

Version

1.11.1

Steps to Reproduce

I have manually instrumented traces_sampler counted on transaction name in sampling context. At some point with sentry-sdk version upgrade, it stopped work - there is always "generic ASGI request" in transaction name. But at the performance page, transaction has a proper name.

How we initiate sentry FastAPI integration:

sentry_sdk.init(
    dsn=SENTRY_DSN,
    environment="dev",
    traces_sampler=sentry_traces_sampler,
    integrations=[
        starlette.StarletteIntegration(transaction_style="endpoint"),
        fastapi.FastApiIntegration(transaction_style="endpoint"),`
    ]
)

The traces_sampler function:

def sentry_traces_sampler(sampling_context):
    transaction_sampling_mapper = {
        "app.api.api_v1.routers.users.some_name": 0.1,
        "app.api.api_v1.routers.messages.some_name_2": 0.5,
    }
    return transaction_sampling_mapper.get(
        sampling_context["transaction_context"]["name"], 1.0
    )

Expected Result

Actual Result

Possible solution: Give the plain URL of the request instead of "generic ASGI request" as the transaction name to traces_sampler.

Metadata

Metadata

Assignees

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions