Skip to content

Commit 1ea0970

Browse files
committed
Update requests implementation
1 parent 836c2c7 commit 1ea0970

File tree

3 files changed

+13
-5
lines changed

3 files changed

+13
-5
lines changed

instrumentation/opentelemetry-instrumentation-requests/src/opentelemetry/instrumentation/requests/__init__.py

+10-2
Original file line numberDiff line numberDiff line change
@@ -245,8 +245,16 @@ def _uninstrument_from(instr_root, restore_as_bound_func=False):
245245

246246

247247
def get_default_span_name(method):
248-
"""Default implementation for name_callback, returns HTTP {method_name}."""
249-
return f"HTTP {method.strip()}"
248+
"""
249+
Default implementation for name_callback, returns HTTP {method_name}.
250+
https://opentelemetry.io/docs/reference/specification/trace/semantic_conventions/http/#name
251+
252+
Args:
253+
method: string representing HTTP method
254+
Returns:
255+
span name
256+
"""
257+
return method.strip()
250258

251259

252260
class RequestsInstrumentor(BaseInstrumentor):

instrumentation/opentelemetry-instrumentation-requests/tests/test_requests_integration.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ def test_basic(self):
116116
span = self.assert_span()
117117

118118
self.assertIs(span.kind, trace.SpanKind.CLIENT)
119-
self.assertEqual(span.name, "HTTP GET")
119+
self.assertEqual(span.name, "GET")
120120

121121
self.assertEqual(
122122
span.attributes,
@@ -191,7 +191,7 @@ def name_callback(method, url):
191191
self.assertEqual(result.text, "Hello!")
192192
span = self.assert_span()
193193

194-
self.assertEqual(span.name, "HTTP GET")
194+
self.assertEqual(span.name, "GET")
195195

196196
def test_not_foundbasic(self):
197197
url_404 = "http://httpbin.org/status/404"

instrumentation/opentelemetry-instrumentation-requests/tests/test_requests_ip_support.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ def assert_success_span(self, response: requests.Response):
7171

7272
span = self.assert_span()
7373
self.assertIs(trace.SpanKind.CLIENT, span.kind)
74-
self.assertEqual("HTTP GET", span.name)
74+
self.assertEqual("GET", span.name)
7575

7676
attributes = {
7777
"http.status_code": 200,

0 commit comments

Comments
 (0)