23
23
import opentelemetry .ext .http_requests
24
24
from opentelemetry import trace
25
25
from opentelemetry .ext .flask import instrument_app
26
+ from opentelemetry .sdk .trace import TracerProvider
26
27
27
28
28
29
def configure_opentelemetry (flask_app : flask .Flask ):
@@ -33,21 +34,16 @@ def configure_opentelemetry(flask_app: flask.Flask):
33
34
* sets tracer to the SDK's Tracer
34
35
* enables requests integration on the Tracer
35
36
* uses a WSGI middleware to enable configuration
36
-
37
- TODO:
38
-
39
- * processors?
40
- * exporters?
41
37
"""
42
- # Start by configuring all objects required to ensure
43
- # a complete end to end workflow.
38
+ # Start by configuring all objects required to ensure a complete end to end
39
+ # workflow.
40
+ trace .set_tracer_provider (TracerProvider ())
44
41
45
- # Next, we need to configure how the values that are used by
46
- # traces and metrics are propagated (such as what specific headers
47
- # carry this value).
48
- # Integrations are the glue that binds the OpenTelemetry API
49
- # and the frameworks and libraries that are used together, automatically
50
- # creating Spans and propagating context as appropriate.
42
+ # Next, we need to configure how the values that are used by traces and
43
+ # metrics are propagated (such as what specific headers carry this value).
44
+ # Integrations are the glue that binds the OpenTelemetry API and the
45
+ # frameworks and libraries that are used together, automatically creating
46
+ # Spans and propagating context as appropriate.
51
47
opentelemetry .ext .http_requests .enable (trace .get_tracer_provider ())
52
48
instrument_app (flask_app )
53
49
@@ -57,8 +53,7 @@ def configure_opentelemetry(flask_app: flask.Flask):
57
53
58
54
@app .route ("/" )
59
55
def hello ():
60
- # emit a trace that measures how long the
61
- # sleep takes
56
+ # Emit a trace that measures how long the sleep takes
62
57
version = pkg_resources .get_distribution (
63
58
"opentelemetry-example-app"
64
59
).version
0 commit comments