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

Fix transaction name in Starlette and FastAPI #2341

Merged

Conversation

antonpirker
Copy link
Member

@antonpirker antonpirker commented Sep 1, 2023

Set the url as a transaction name instead of 'generic ASGI request' in the beginning, so traces_sampler has something to work with that is more meaningful than 'generic ASGI request'.

Closes #2262
Closes #2263

New Behaviour:

Note: transaction names can be two styles, "url" or "endpoint". (set by the transaction_style parameter of the Integrations)

Note 2: See also @pytest.mark.parametrize decorator in the new tests as reference.

  • vanilla ASGI: set URL instead of always "generic ASGI request"
  • Starlette:
    1. normal request: transaction name is function name or route (depending on transaction_style setting)
    2. traces_sampler: always receives the raw URL as the transaction name (no matter the transaction_style setting. because we do not know more at the time the traces_sampler is called.)
    3. requests that end in a middleware (like 404, CORS): the functions name or the raw URL (depending on transaction_style setting)
  • FastAPI
    1. normal request: transaction name is function name or route (depending on transaction_style setting)
    2. traces_sampler: always receives the raw URL as the transaction name (no matter the transaction_style setting. because we do not know more at the time the traces_sampler is called.)
    3. requests that end in a middleware (like 404, CORS): the functions name or the raw URL (depending on transaction_style setting)
  • There used to be "generic ASGI request" transactions being created at the server startup (when a "lifespan" ASGI message was received.) Those transactions are not created anymore. (we can think of creating propper "Server was started/stopped" transactions in the future)

@antonpirker antonpirker changed the title Fix transaction name in starlette and fastapi Fix transaction name in Starlette and FastAPI Sep 1, 2023
@antonpirker antonpirker marked this pull request as ready for review September 4, 2023 10:43
Copy link
Contributor

@sentrivana sentrivana left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM! 🎖️

@antonpirker antonpirker merged commit 80cd1f1 into master Sep 6, 2023
@antonpirker antonpirker deleted the antonpirker/fix-transaction-name-in-starlette-and-fastapi branch September 6, 2023 07:55
sentrivana pushed a commit that referenced this pull request Sep 18, 2023
Set the url as a transaction name instead of 'generic ASGI request' in the beginning, so traces_sampler has something to work with that is more meaningful than 'generic ASGI request'.

Closes #2262
Closes #2263
New Behaviour:

Note: transaction names can be two styles, "url" or "endpoint". (set by the transaction_style parameter of the Integrations)

Note 2: See also @pytest.mark.parametrize decorator in the new tests as reference.

    vanilla ASGI: set URL instead of always "generic ASGI request"
    Starlette:
        normal request: transaction name is function name or route (depending on transaction_style setting)
        traces_sampler: always receives the raw URL as the transaction name (no matter the transaction_style setting. because we do not know more at the time the traces_sampler is called.)
        requests that end in a middleware (like 404, CORS): the functions name or the raw URL (depending on transaction_style setting)
    FastAPI
        normal request: transaction name is function name or route (depending on transaction_style setting)
        traces_sampler: always receives the raw URL as the transaction name (no matter the transaction_style setting. because we do not know more at the time the traces_sampler is called.)
        requests that end in a middleware (like 404, CORS): the functions name or the raw URL (depending on transaction_style setting)
    There used to be "generic ASGI request" transactions being created at the server startup (when a "lifespan" ASGI message was received.) Those transactions are not created anymore. (we can think of creating propper "Server was started/stopped" transactions in the future)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants