Skip to content

Commit

Permalink
Fix to run the auto-instrumentation example successfully
Browse files Browse the repository at this point in the history
  • Loading branch information
dmarar committed Nov 29, 2020
1 parent c8580b2 commit 207502b
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 7 deletions.
7 changes: 3 additions & 4 deletions docs/examples/auto-instrumentation/README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,8 @@ Manually instrumented server
def server_request():
with tracer.start_as_current_span(
"server_request",
parent=propagators.extract(
lambda dict_, key: dict_.get(key, []), request.headers
)["current-span"],
context=propagators.extract(DictGetter(), request.headers
),
):
print(request.args.get("param"))
return "served"
Expand Down Expand Up @@ -148,7 +147,7 @@ and run the following command instead:

.. code:: sh
$ opentelemetry-instrument python server_uninstrumented.py
$ opentelemetry-instrument -e console_span python server_uninstrumented.py
In the console where you previously executed ``client.py``, run the following
command again:
Expand Down
5 changes: 2 additions & 3 deletions docs/examples/auto-instrumentation/server_instrumented.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
ConsoleSpanExporter,
SimpleExportSpanProcessor,
)
from opentelemetry.trace.propagation.textmap import DictGetter

app = Flask(__name__)

Expand All @@ -36,9 +37,7 @@
def server_request():
with tracer.start_as_current_span(
"server_request",
parent=propagators.extract(
lambda dict_, key: dict_.get(key, []), request.headers
)["current-span"],
context=propagators.extract(DictGetter(), request.headers),
kind=trace.SpanKind.SERVER,
attributes=collect_request_attributes(request.environ),
):
Expand Down
2 changes: 2 additions & 0 deletions opentelemetry-sdk/setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,8 @@ opentelemetry_tracer_provider =
sdk_tracer_provider = opentelemetry.sdk.trace:TracerProvider
opentelemetry_propagator =
b3 = opentelemetry.sdk.trace.propagation.b3_format:B3Format
opentelemetry_exporter =
console_span = opentelemetry.sdk.trace.export:ConsoleSpanExporter

[options.extras_require]
test =
Original file line number Diff line number Diff line change
Expand Up @@ -373,6 +373,7 @@ def __init__(
out: typing.IO = sys.stdout,
formatter: typing.Callable[[Span], str] = lambda span: span.to_json()
+ os.linesep,
**kwargs
):
self.out = out
self.formatter = formatter
Expand Down

0 comments on commit 207502b

Please sign in to comment.