-
Notifications
You must be signed in to change notification settings - Fork 961
Fix Django autoinstrumentation not producing span in STDOUT output #4822
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
base: main
Are you sure you want to change the base?
Changes from all commits
1b3ca3f
1142c66
0b7c1d8
673d786
71fdb7b
664b59f
ddbacfa
4897c9c
a4b5812
9dd5894
8eeb1ed
16c42d4
a9aa015
ed0b2fb
4d31ca2
d9cbc7a
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -10,14 +10,26 @@ | |||||||||||||||||
| import os | ||||||||||||||||||
| import sys | ||||||||||||||||||
|
|
||||||||||||||||||
| from opentelemetry import trace | ||||||||||||||||||
| from opentelemetry.instrumentation.django import DjangoInstrumentor | ||||||||||||||||||
| from opentelemetry.sdk.trace import TracerProvider | ||||||||||||||||||
| from opentelemetry.sdk.trace.export import ( | ||||||||||||||||||
| BatchSpanProcessor, | ||||||||||||||||||
| ConsoleSpanExporter, | ||||||||||||||||||
| ) | ||||||||||||||||||
|
Comment on lines
+16
to
+19
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The example's whole point is "make a request → see the span in stdout," but
Suggested change
|
||||||||||||||||||
|
|
||||||||||||||||||
|
|
||||||||||||||||||
| def main(): | ||||||||||||||||||
| os.environ.setdefault( | ||||||||||||||||||
| "DJANGO_SETTINGS_MODULE", "instrumentation_example.settings" | ||||||||||||||||||
| ) | ||||||||||||||||||
|
|
||||||||||||||||||
| # Set up tracing with console exporter to see spans in stdout | ||||||||||||||||||
| trace.set_tracer_provider(TracerProvider()) | ||||||||||||||||||
| trace.get_tracer_provider().add_span_processor( | ||||||||||||||||||
| BatchSpanProcessor(ConsoleSpanExporter()) | ||||||||||||||||||
| ) | ||||||||||||||||||
|
Comment on lines
+29
to
+31
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||||||||||
|
|
||||||||||||||||||
| # This call is what makes the Django application be instrumented | ||||||||||||||||||
| DjangoInstrumentor().instrument() | ||||||||||||||||||
|
|
||||||||||||||||||
|
|
||||||||||||||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please could you also update https://github.com/open-telemetry/opentelemetry-python/blob/main/docs/examples/django/README.rst?plain=1#L113-L114 to say that the TracerProvider calls should also be commented out when doing auto-instrumentation.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we make the code handling tracing already setup instead?