You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
* Do a linting step.
* Rename FlaskTracer to FlaskTracing.
* Use OT 2.0.
* Do not log failed header extraction.
* Add standard tags. (#21)
* Let the tracer be optional.
* Expose tracer as a property without trailing _.
* Reorganize the tests into tracing an API files.
* Add a start_span_cb callback.
* trace_all_requests defaults to True if an app is specified.
* Properly handle and report errors.
This Flask extension allows for tracing of Flask apps using the OpenTracing API. All
27
-
that it requires is for a FlaskTracing tracer to be initialized using an
30
+
that it requires is for a ``FlaskTracing`` tracer to be initialized using an
28
31
instance of an OpenTracing tracer. You can either trace all requests to your site, or use function decorators to trace certain individual requests.
29
32
30
33
**Note:** `optional_args` in both cases are any number of attributes (as strings) of `flask.Request` that you wish to set as tags on the created span
31
34
32
35
Initialize
33
36
----------
34
37
35
-
`FlaskTracer` wraps the tracer instance that's supported by opentracing. To create a `FlaskTracer` object, you can either pass in a tracer object directly or a callable that returns the tracer object. For example:
38
+
`FlaskTracing` wraps the tracer instance that's supported by opentracing. To create a `FlaskTracing` object, you can either pass in a tracer object directly or a callable that returns the tracer object. For example:
36
39
37
40
.. code-block:: python
38
41
39
42
import opentracing
40
-
from flask_opentracing importFlaskTracer
43
+
from flask_opentracing importFlaskTracing
41
44
42
45
opentracing_tracer =## some OpenTracing tracer implementation
43
-
tracer=FlaskTracer(opentracing_tracer, ...)
46
+
tracing=FlaskTracing(opentracing_tracer, ...)
44
47
45
48
or
46
49
47
50
.. code-block:: python
48
51
49
52
import opentracing
50
-
from flask_opentracing importFlaskTracer
53
+
from flask_opentracing importFlaskTracing
51
54
52
55
definitialize_tracer():
53
56
...
54
57
return opentracing_tracer
55
58
56
-
tracer=FlaskTracer(initialize_tracer, ...)
59
+
tracing=FlaskTracing(initialize_tracer, ...)
57
60
58
61
59
62
Trace All Requests
@@ -62,36 +65,36 @@ Trace All Requests
62
65
.. code-block:: python
63
66
64
67
import opentracing
65
-
from flask_opentracing importFlaskTracer
68
+
from flask_opentracing importFlaskTracing
66
69
67
70
app = Flask(__name__)
68
71
69
72
opentracing_tracer =## some OpenTracing tracer implementation
opentracing_tracer =## some OpenTracing tracer implementation
83
-
tracer=FlaskTracer(opentracing_tracer)
86
+
tracing=FlaskTracing(opentracing_tracer)
84
87
85
88
@app.route('/some_url')
86
-
@tracer.trace(optional_args)
89
+
@tracing.trace(optional_args)
87
90
defsome_view_func():
88
91
...
89
92
return some_view
90
93
91
94
Accessing Spans Manually
92
95
------------------------
93
96
94
-
In order to access the span for a request, we've provided an method `FlaskTracer.get_span(request)` that returns the span for the request, if it is exists and is not finished. This can be used to log important events to the span, set tags, or create child spans to trace non-RPC events. If no request is passed in, the current request will be used.
97
+
In order to access the span for a request, we've provided an method `FlaskTracing.get_span(request)` that returns the span for the request, if it is exists and is not finished. This can be used to log important events to the span, set tags, or create child spans to trace non-RPC events. If no request is passed in, the current request will be used.
95
98
96
99
Tracing an RPC
97
100
--------------
@@ -100,10 +103,10 @@ If you want to make an RPC and continue an existing trace, you can inject the cu
@@ -120,6 +123,18 @@ with integrated OpenTracing tracers.
120
123
121
124
`This tutorial <http://blog.scoutapp.com/articles/2018/01/15/tutorial-tracing-python-flask-requests-with-opentracing>`_ has a step-by-step guide for using `Flask-Opentracing` with `Jaeger <https://github.com/jaegertracing/jaeger>`_.
122
125
126
+
Breaking changes from 0.x
127
+
=========================
128
+
129
+
Starting with the 1.0 version, a few changes have taken place from previous versions:
130
+
131
+
* ``FlaskTracer`` has been renamed to ``FlaskTracing``, although ``FlaskTracing``
132
+
can be used still as a deprecated name.
133
+
* When passing an ``Application`` object at ``FlaskTracing`` creation time,
134
+
``trace_all_requests`` defaults to ``True``.
135
+
* When no ``opentracing.Tracer`` is provided, ``FlaskTracing`` will rely on the
opentracing_tracer =## some OpenTracing tracer implementation
55
-
tracer=FlaskTracer(opentracing_tracer)
55
+
tracing=FlaskTracing(opentracing_tracer)
56
56
57
57
@app.route('/some_url')
58
-
@tracer.trace(optional_args)
58
+
@tracing.trace(optional_args)
59
59
defsome_view_func():
60
60
...
61
61
return some_view
62
62
63
63
Accessing Spans Manually
64
64
~~~~~~~~~~~~~~~~~~~~~~~~
65
65
66
-
In order to access the span for a request, we've provided an method `FlaskTracer.get_span(request)` that returns the span for the request, if it is exists and is not finished. This can be used to log important events to the span, set tags, or create child spans to trace non-RPC events. If no request is passed in, the current request will be used.
66
+
In order to access the span for a request, we've provided an method `FlaskTracing.get_span(request)` that returns the span for the request, if it is exists and is not finished. This can be used to log important events to the span, set tags, or create child spans to trace non-RPC events. If no request is passed in, the current request will be used.
67
67
68
68
Tracing an RPC
69
69
~~~~~~~~~~~~~~
@@ -72,10 +72,10 @@ If you want to make an RPC and continue an existing trace, you can inject the cu
0 commit comments