Skip to content

Commit

Permalink
Update instrumentation/opentelemetry-instrumentation-tornado/tests/te…
Browse files Browse the repository at this point in the history
…st_instrumentation.py

Co-authored-by: (Eliseo) Nathaniel Ruiz Nowell <enruizno@uwaterloo.ca>
  • Loading branch information
owais and NathanielRN committed Oct 2, 2020
1 parent 1f4fd30 commit 5c0bc91
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -165,9 +165,11 @@ def process_request(self, req, resp):
if not span:
return

attributes = extract_attributes_from_object(req, self._traced_request_attrs)
attributes = extract_attributes_from_object(
req, self._traced_request_attrs
)
for key, value in attributes.items():
span.set_attribute(key, str(value))
span.set_attribute(key, value)

def process_resource(self, req, resp, resource, params):
span = req.env.get(_ENVIRON_SPAN_KEY)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

## Unreleased

- Added support for `OTEL_PYTHON_TORNADO_TRACED_REQUEST_ATTRS` ([#1178](https://github.com/open-telemetry/opentelemetry-python/pull/1178))

## Version 0.13b0

Released 2020-09-17
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ For example,

::

export OTEL_PYTHON_TONADO_TRACED_REQUEST_ATTRS='uri,query'
export OTEL_PYTHON_TORNADO_TRACED_REQUEST_ATTRS='uri,query'

will extract path_info and content_type attributes from every traced request and add them as span attributes.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -362,10 +362,10 @@ def test_traced_attrs(self):
self.fetch("/ping?q=abc&b=123")
spans = self.sorted_spans(self.memory_exporter.get_finished_spans())
self.assertEqual(len(spans), 2)
server = spans[0]
self.assertEqual(server.kind, SpanKind.SERVER)
server_span = spans[0]
self.assertEqual(server_span.kind, SpanKind.SERVER)
self.assert_span_has_attributes(
server, {"uri": "/ping?q=abc&b=123", "query": "q=abc&b=123"}
server_span, {"uri": "/ping?q=abc&b=123", "query": "q=abc&b=123"}
)
self.memory_exporter.clear()

Expand Down

0 comments on commit 5c0bc91

Please sign in to comment.