Comments (4)
Hi @sentrivana, that makes perfect sense, thanks for your support.
I'll close this as I consider it solved.
from sentry-python.
Hey @lucabergamini, thanks for writing in.
In before_send_transaction
, the first argument (the event
) has the unfiltered URL (not just the path) in event["request"]["url"]
.
In profiles_sampler
you get the sampling context as the sole argument and the path should be in sampling_context["asgi_scope"]["path"]
.
Let me know if that helps.
from sentry-python.
Hi @sentrivana
thanks for the reply. That indeed works, but I've realised something after writing the original question.
before_send_transaction
is called at the very end of the endpoint lifespan. That means that I won't be able to control the sampling and all endpoints call will be traced. This would cause a performance issue In our prod env.
profile_sampler
seems to be called before. However the issue with that is that is called before everything else as far as I know, so even before fastapi url resolution. I've tried adding a middleware to inject context, but I believe that does not work exactly for this reason.
Is there any way to get any info to the profile_sampler or to postpone its evaluation? Currently, I resorted to running the path resolution in the function itself (which works, but it's a bit clunky)
from sentry-python.
@lucabergamini I think what you want is actually a custom traces_sampler -- it allows you to set the sampling decision for a transaction at an earlier point than before_send_transaction
and afaik prevents child spans from being created if not sampled.
That being said, the traces_sampler
callback happens at virtually the same point in time as profiles_sampler
(with the same sampling context as well) so if you're missing information in the profile sampling context, you'll have the same issue with the traces_sampler
. If you need more than the path in the sampling context, you might indeed need to get any additional info from the function itself, as you wrote.
from sentry-python.
Related Issues (20)
- Runtime `TypeError`s due to incorrect conditional handling of `Event` and `Hint` types HOT 1
- grpclib support HOT 3
- Sentry sdk sending noisy logs HOT 6
- Metrics not sent on program exit HOT 3
- Missing Span Instrumentation under Profiling HOT 2
- Transactions started with `continue_trace()` do not inherit sampling HOT 6
- Improve debug message when dropping transaction
- Transactions not working as expected (metrics are not sent) HOT 16
- Add a span around Django rest framework authentication HOT 1
- Unable to configure HOT 2
- Logs grouping not working HOT 1
- Starlette fails with Uvicorn when instrumented with Sentry (2.0.0) HOT 4
- Profiling not working HOT 8
- Sentry error reporting is dropping some local variables in favour of other - and no way to control this HOT 1
- Unpin pytest HOT 1
- Is it possible to use Sentry with QuartTrio HOT 2
- Metric tag values not working as expected HOT 2
- Misleading set metric value type hint
- [Quart] sentry_patched_asgi_app() missing 1 required positional argument: 'send' HOT 6
- Improve Quart Tests
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from sentry-python.