Skip to content
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

Span name updated to follow semantic conventions to reduce cardinality #972

Merged
merged 9 commits into from
Aug 18, 2020
2 changes: 1 addition & 1 deletion docs/getting_started/tests/test_flask.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,6 @@ def test_flask(self):
server.terminate()

output = str(server.stdout.read())
self.assertIn('"name": ""', output)
self.assertIn('"name": "HTTP get"', output)
self.assertIn('"name": "example-request"', output)
self.assertIn('"name": "hello"', output)
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@

- Change package name to opentelemetry-instrumentation-requests
([#961](https://github.com/open-telemetry/opentelemetry-python/pull/961))
- Span name reported updated to follow semantic conventions to reduce
cardinality ([#972](https://github.com/open-telemetry/opentelemetry-python/pull/972))

## 0.7b1

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,11 +80,7 @@ def instrumented_request(self, method, url, *args, **kwargs):

# See
# https://github.com/open-telemetry/opentelemetry-specification/blob/master/specification/trace/semantic_conventions/http.md#http-client
try:
parsed_url = urlparse(url)
span_name = parsed_url.path
except ValueError as exc: # Invalid URL
span_name = "<Unparsable URL: {}>".format(exc)
span_name = "HTTP {}".format(method)

exception = None

Expand All @@ -111,6 +107,7 @@ def instrumented_request(self, method, url, *args, **kwargs):
span.set_status(
Status(_exception_to_canonical_code(exception))
)
span.record_exception(exception)

if result is not None:
span.set_attribute("http.status_code", result.status_code)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ def test_basic(self):
span = span_list[0]

self.assertIs(span.kind, trace.SpanKind.CLIENT)
self.assertEqual(span.name, "/status/200")
self.assertEqual(span.name, "HTTP get")

self.assertEqual(
span.attributes,
Expand Down Expand Up @@ -102,7 +102,7 @@ def test_invalid_url(self):
self.assertEqual(len(span_list), 1)
span = span_list[0]

self.assertTrue(span.name.startswith("<Unparsable URL"))
self.assertEqual(span.name, "HTTP post")
self.assertEqual(
span.attributes,
{"component": "http", "http.method": "POST", "http.url": url},
Expand Down