File tree Expand file tree Collapse file tree 3 files changed +27
-9
lines changed Expand file tree Collapse file tree 3 files changed +27
-9
lines changed Original file line number Diff line number Diff line change 11"""
2- The flask trace middleware will track request timings and templates. It
2+ The Flask trace middleware will track request timings and templates. It
33requires the `Blinker <https://pythonhosted.org/blinker/>`_ library, which
44Flask uses for signalling.
55
6- To install the middleware, do the following::
6+ To install the middleware, add::
7+
8+ from ddtrace import tracer
9+ from ddtrace.contrib.flask import TraceMiddleware
10+
11+ and create a `TraceMiddleware` object::
12+
13+ traced_app = TraceMiddleware(app, tracer, service="my-flask-app")
14+
15+ Here is the end result, in a sample app::
716
817 from flask import Flask
918 import blinker as _
1019
1120 from ddtrace import tracer
1221 from ddtrace.contrib.flask import TraceMiddleware
1322
14- app = Flask(... )
23+ app = Flask(__name__ )
1524
1625 traced_app = TraceMiddleware(app, tracer, service="my-flask-app")
1726
Original file line number Diff line number Diff line change 22The flask cache tracer will track any access to a cache backend.
33You can use this tracer together with the Flask tracer middleware.
44
5- To install the tracer, do the following::
5+ To install the tracer, ``from ddtrace`` needs to be added::
6+
7+ from ddtrace import tracer
8+ from ddtrace.contrib.flask_cache import get_traced_cache
9+
10+ and the tracer needs to be initialized::
11+
12+ Cache = get_traced_cache(tracer, service='my-flask-cache-app')
13+
14+ Here is the end result, in a sample app::
615
716 from flask import Flask
817
Original file line number Diff line number Diff line change @@ -18,9 +18,11 @@ Install with :code:`pip` but point to Datadog's package repo::
1818
1919 $ pip install ddtrace --find-links=https://s3.amazonaws.com/pypi.datadoghq.com/trace/index.html
2020
21- If you are using a supported integration, proceed to the :ref: `relevant instructions <integrations >` next.
21+ Quick Start (Auto Instrumentation)
22+ -----------
23+ If you are using a supported integration, proceed to the :ref: `relevant instructions<integrations> ` for the integrations you are interested in.
2224
23- Quick Start
25+ Quick Start (Manual Instrumentation)
2426-----------
2527
2628Adding tracing to your code is very simple. As an example, let's imagine we are adding
@@ -33,10 +35,8 @@ tracing from scratch to a small web app::
3335 @route("/home")
3436 def home(request):
3537
36- with tracer.trace('web.request') as span:
38+ with tracer.trace('web.request', service=service, resource='home' ) as span:
3739 # set some span metadata
38- span.service = service
39- span.resource = "home"
4040 span.set_tag('web.user', request.username)
4141
4242 # trace a database request
You can’t perform that action at this time.
0 commit comments