-
Notifications
You must be signed in to change notification settings - Fork 47
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
Best way to trace from inside other classes and static methods #14
Comments
Hi @trondhindenes , that's an amazing suggestion! I am in fact in the middle of getting some of my real life micro-services instrumented with this. And there's ongoing effort for more documentation. So both sides of the question should be covered. Feel free to leave more feedback and contribute your own findings as well. |
I'm just toying with adding this to an existing, medium-sized Flask app that uses Blueprints and ran into the same issue. I need to pass the app instance to My solution was to sub-class class Tracer(FlaskTracer):
def trace_app(self, app, attributes=None):
if attributes is None:
attributes = []
@app.before_request
def start_trace():
self._before_request_fn(attributes)
@app.after_request
def end_trace(response):
self._after_request_fn()
return response That allows me to create the tracer separately from the app, and import the tracer into the file which sets up the app (and any other file), without causing any circular imports. |
Hey @jscn Sounds like we need to support some way of late |
oops |
Yah, an example app with both flask-tracing and "regular" opentracing components would help so much. I'm still not sure what the best way is to wire all this up. |
This may be a bit too generic question, but I'm attempting it anyway:
It would be awesome if the there was examples of a more "real-life" flask app. As a rule we split up the app into multiple classes (one class per route), and also move "helpers" into separate class functions (static or not).
It's not completely clear to me how I would go about maintining a reference to the instantiated
FlaskTracer
object (calledtracer
in the examples).FlaskTracer
by importing it from the app classI guess I'm looking for best-practices in how to deal the
FlaskTracer
throughout my app. Some more advanced examples would be awesome.The text was updated successfully, but these errors were encountered: