Skip to content

Commit 207502b

Browse files
committed
Fix to run the auto-instrumentation example successfully
1 parent c8580b2 commit 207502b

File tree

4 files changed

+8
-7
lines changed

4 files changed

+8
-7
lines changed

docs/examples/auto-instrumentation/README.rst

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,9 +37,8 @@ Manually instrumented server
3737
def server_request():
3838
with tracer.start_as_current_span(
3939
"server_request",
40-
parent=propagators.extract(
41-
lambda dict_, key: dict_.get(key, []), request.headers
42-
)["current-span"],
40+
context=propagators.extract(DictGetter(), request.headers
41+
),
4342
):
4443
print(request.args.get("param"))
4544
return "served"
@@ -148,7 +147,7 @@ and run the following command instead:
148147

149148
.. code:: sh
150149
151-
$ opentelemetry-instrument python server_uninstrumented.py
150+
$ opentelemetry-instrument -e console_span python server_uninstrumented.py
152151
153152
In the console where you previously executed ``client.py``, run the following
154153
command again:

docs/examples/auto-instrumentation/server_instrumented.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
ConsoleSpanExporter,
2222
SimpleExportSpanProcessor,
2323
)
24+
from opentelemetry.trace.propagation.textmap import DictGetter
2425

2526
app = Flask(__name__)
2627

@@ -36,9 +37,7 @@
3637
def server_request():
3738
with tracer.start_as_current_span(
3839
"server_request",
39-
parent=propagators.extract(
40-
lambda dict_, key: dict_.get(key, []), request.headers
41-
)["current-span"],
40+
context=propagators.extract(DictGetter(), request.headers),
4241
kind=trace.SpanKind.SERVER,
4342
attributes=collect_request_attributes(request.environ),
4443
):

opentelemetry-sdk/setup.cfg

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,8 @@ opentelemetry_tracer_provider =
5353
sdk_tracer_provider = opentelemetry.sdk.trace:TracerProvider
5454
opentelemetry_propagator =
5555
b3 = opentelemetry.sdk.trace.propagation.b3_format:B3Format
56+
opentelemetry_exporter =
57+
console_span = opentelemetry.sdk.trace.export:ConsoleSpanExporter
5658

5759
[options.extras_require]
5860
test =

opentelemetry-sdk/src/opentelemetry/sdk/trace/export/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -373,6 +373,7 @@ def __init__(
373373
out: typing.IO = sys.stdout,
374374
formatter: typing.Callable[[Span], str] = lambda span: span.to_json()
375375
+ os.linesep,
376+
**kwargs
376377
):
377378
self.out = out
378379
self.formatter = formatter

0 commit comments

Comments
 (0)