Closed jon-whit closed 4 years ago
If you want to track anything related to the context you'll have to do it starting from the ContextFound
event. Tweens are very early in the lifecycle of a request before any sort of url processing / matching has occurred. For things like tracing Pyramid has quite a lot of hooks that you may be interested in depending on what parts of the system you're trying to track.
I'm closing this issue because it's a question and not a bug report. See https://groups.google.com/forum/#!forum/pylons-discuss for a wider community of people who can answer usage questions.
@mmerickel ok, thanks. I didn't think I filed it as a bug report... But I suppose I can ask questions elsewhere.
No worries! For usage questions we just try to redirect to the mailing list versus features/bugs since github is specific to the maintainers.
Quick note, that context
in terms of what Pyramid calls the context
(and what is available on request
as request.context
) may not be the same as what you consider the "context" related to request tracing.
Instead you should likely inject your own tracing_context
into the request
object itself, and now that will be available anywhere the request
is.
As for integrations for inspiration, there are a couple that I know exist, they are of varying quality but should hopefully provide some guidance on how others have built their integration:
https://github.com/opentracing-contrib/python-pyramid https://github.com/Yelp/pyramid_zipkin (https://engineeringblog.yelp.com/2016/04/distributed-tracing-at-yelp.html) https://github.com/getsentry/sentry-python/blob/master/sentry_sdk/integrations/pyramid.py
I'm trying to write some middleware using a Tween that extracts some trace context (using OpenTelemetry) and propagates the context by injecting the tracing context into the request context.
Here's some example code:
I'm not able to inject the tracing context into the
request.context
because the context does not yet exist. Looking at the Request Processing doc and the Pyramid Request doc it appears that the request.contextSo what's the proper way to do this?