-
Notifications
You must be signed in to change notification settings - Fork 515
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Custom transactions being overwritten by ASGI integration #3663
Comments
right that's a bug, thanks for the report, will fix! |
also as a side note, unless you really need to start a transaction, if there's already a transaction started by sentry's asgi integration, you can simply do the following in your request handler function: sentry_sdk.get_current_scope().set_transaction_name("my_custom_transaction", source=TRANSACTION_SOURCE_CUSTOM) to override the transaction name. |
Ok, thanks a lot! So on that topic, I have a related question. We have an open websocket that receives a lot of messages per second. Every time a message is received, Sentry seems to go through at least parts of the motions of creating a transaction. This seems wasteful, and also has the effect that it will override any manually created transaction set on the same scope, as in my code. I feel like the best would be to stop websocket from being instrumented automatically, but I don't see any configuration exposed for doing that on the ASGI or Starlette integrations, or? |
No, that's currently not configurable sadly. The way to stop some transactions being created would be with a so def traces_sampler(sampling_context):
if sampling_context["asgi_scope"]["type"] == "websocket":
return 0.0
return 1.0
sentry_sdk.init(
# ...
traces_sampler=traces_sampler,
) |
How do you use Sentry?
Sentry Saas (sentry.io)
Version
2.16.0
Steps to Reproduce
I'm working on some custom instrumentation. I have some code that creates a manual transaction, like this:
Sentry is setup like this and uses FastAPI automatic instrumentation.
Expected Result
In Sentry.io I keep seeing a different transaction called
/sessions/{session_id}
which corresponds to a websocket endpoint we have, instead of seeingttr
.Actual Result
I debugged this and tracked it down to this code in
asgi.py
The incoming
ttr
transaction hasevent["transaction_info"]["source"] = "custom"
which meansalready_set = False
as it's not considered a valid source here and thereby the transaction name is overwritten.I would expect that my custom transaction is not modified.
(on a separate note, the docs don't mention that I need to set my transaction on the current scope manually, I first thought it would happen when I call
start_transaction
on the scope)The text was updated successfully, but these errors were encountered: