mirror of
https://github.com/open-telemetry/opentelemetry-python-contrib.git
synced 2025-07-28 20:52:57 +08:00
Remove http.status_text from span attributes (#406)
This commit is contained in:
@ -22,6 +22,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
||||
- `opentelemetry-instrumenation-django` now supports request and response hooks.
|
||||
([#407](https://github.com/open-telemetry/opentelemetry-python-contrib/pull/407))
|
||||
|
||||
### Removed
|
||||
- Remove `http.status_text` from span attributes
|
||||
([#406](https://github.com/open-telemetry/opentelemetry-python-contrib/pull/406))
|
||||
|
||||
## [0.19b0](https://github.com/open-telemetry/opentelemetry-python-contrib/releases/tag/v0.19b0) - 2021-03-26
|
||||
|
||||
- Implement context methods for `_InterceptorChannel`
|
||||
|
@ -198,9 +198,6 @@ def create_trace_config(
|
||||
trace_config_ctx.span.set_attribute(
|
||||
"http.status_code", params.response.status
|
||||
)
|
||||
trace_config_ctx.span.set_attribute(
|
||||
"http.status_text", params.response.reason
|
||||
)
|
||||
_end_trace(trace_config_ctx)
|
||||
|
||||
async def on_request_exception(
|
||||
|
@ -134,7 +134,6 @@ class TestAioHttpIntegration(TestBase):
|
||||
host, port
|
||||
),
|
||||
"http.status_code": int(status_code),
|
||||
"http.status_text": status_code.phrase,
|
||||
},
|
||||
)
|
||||
]
|
||||
@ -191,7 +190,6 @@ class TestAioHttpIntegration(TestBase):
|
||||
host, port, path
|
||||
),
|
||||
"http.status_code": int(HTTPStatus.OK),
|
||||
"http.status_text": HTTPStatus.OK.phrase,
|
||||
},
|
||||
)
|
||||
]
|
||||
@ -222,7 +220,6 @@ class TestAioHttpIntegration(TestBase):
|
||||
host, port
|
||||
),
|
||||
"http.status_code": int(HTTPStatus.OK),
|
||||
"http.status_text": HTTPStatus.OK.phrase,
|
||||
},
|
||||
)
|
||||
]
|
||||
@ -361,7 +358,6 @@ class TestAioHttpClientInstrumentor(TestBase):
|
||||
span.attributes["http.url"],
|
||||
)
|
||||
self.assertEqual(200, span.attributes["http.status_code"])
|
||||
self.assertEqual("OK", span.attributes["http.status_text"])
|
||||
|
||||
def test_instrument_with_existing_trace_config(self):
|
||||
trace_config = aiohttp.TraceConfig()
|
||||
|
@ -121,7 +121,6 @@ class TestMiddleware(TestBase, WsgiTestBase):
|
||||
)
|
||||
self.assertEqual(span.attributes["http.scheme"], "http")
|
||||
self.assertEqual(span.attributes["http.status_code"], 200)
|
||||
self.assertEqual(span.attributes["http.status_text"], "OK")
|
||||
|
||||
def test_traced_get(self):
|
||||
Client().get("/traced/")
|
||||
@ -143,7 +142,6 @@ class TestMiddleware(TestBase, WsgiTestBase):
|
||||
self.assertEqual(span.attributes["http.route"], "^traced/")
|
||||
self.assertEqual(span.attributes["http.scheme"], "http")
|
||||
self.assertEqual(span.attributes["http.status_code"], 200)
|
||||
self.assertEqual(span.attributes["http.status_text"], "OK")
|
||||
|
||||
def test_not_recording(self):
|
||||
mock_tracer = Mock()
|
||||
@ -178,7 +176,6 @@ class TestMiddleware(TestBase, WsgiTestBase):
|
||||
self.assertEqual(span.attributes["http.route"], "^traced/")
|
||||
self.assertEqual(span.attributes["http.scheme"], "http")
|
||||
self.assertEqual(span.attributes["http.status_code"], 200)
|
||||
self.assertEqual(span.attributes["http.status_text"], "OK")
|
||||
|
||||
def test_error(self):
|
||||
with self.assertRaises(ValueError):
|
||||
|
@ -104,7 +104,6 @@ class TestFalconInstrumentation(TestBase):
|
||||
"net.peer.port": "65133",
|
||||
"http.flavor": "1.1",
|
||||
"falcon.resource": "HelloWorldResource",
|
||||
"http.status_text": "Created",
|
||||
"http.status_code": 201,
|
||||
},
|
||||
)
|
||||
@ -129,7 +128,6 @@ class TestFalconInstrumentation(TestBase):
|
||||
"net.peer.ip": "127.0.0.1",
|
||||
"net.peer.port": "65133",
|
||||
"http.flavor": "1.1",
|
||||
"http.status_text": "Not Found",
|
||||
"http.status_code": 404,
|
||||
},
|
||||
)
|
||||
|
@ -35,7 +35,6 @@ def expected_attributes(override_attributes):
|
||||
"http.host": "localhost",
|
||||
"http.target": "/",
|
||||
"http.flavor": "1.1",
|
||||
"http.status_text": "OK",
|
||||
"http.status_code": 200,
|
||||
}
|
||||
for key, val in override_attributes.items():
|
||||
@ -138,7 +137,6 @@ class TestProgrammatic(InstrumentationTest, TestBase, WsgiTestBase):
|
||||
{
|
||||
"http.method": "POST",
|
||||
"http.target": "/bye",
|
||||
"http.status_text": "NOT FOUND",
|
||||
"http.status_code": 404,
|
||||
}
|
||||
)
|
||||
@ -157,7 +155,6 @@ class TestProgrammatic(InstrumentationTest, TestBase, WsgiTestBase):
|
||||
{
|
||||
"http.target": "/hello/500",
|
||||
"http.route": "/hello/<int:helloid>",
|
||||
"http.status_text": "INTERNAL SERVER ERROR",
|
||||
"http.status_code": 500,
|
||||
}
|
||||
)
|
||||
|
@ -35,7 +35,6 @@ def expected_attributes(override_attributes):
|
||||
"http.host": "localhost",
|
||||
"http.target": "/",
|
||||
"http.flavor": "1.1",
|
||||
"http.status_text": "OK",
|
||||
"http.status_code": 200,
|
||||
}
|
||||
for key, val in override_attributes.items():
|
||||
@ -118,7 +117,6 @@ class TestProgrammatic(InstrumentationTest, TestBase, WsgiTestBase):
|
||||
{
|
||||
"http.method": "POST",
|
||||
"http.target": "/bye",
|
||||
"http.status_text": "Not Found",
|
||||
"http.status_code": 404,
|
||||
}
|
||||
)
|
||||
@ -137,7 +135,6 @@ class TestProgrammatic(InstrumentationTest, TestBase, WsgiTestBase):
|
||||
{
|
||||
"http.target": "/hello/500",
|
||||
"http.route": "/hello/{helloid}",
|
||||
"http.status_text": "Internal Server Error",
|
||||
"http.status_code": 500,
|
||||
}
|
||||
)
|
||||
|
@ -150,7 +150,6 @@ def _instrument(tracer_provider=None, span_callback=None, name_callback=None):
|
||||
if isinstance(result, Response):
|
||||
if span.is_recording():
|
||||
span.set_attribute("http.status_code", result.status_code)
|
||||
span.set_attribute("http.status_text", result.reason)
|
||||
span.set_status(
|
||||
Status(http_status_to_status_code(result.status_code))
|
||||
)
|
||||
|
@ -82,7 +82,6 @@ class RequestsIntegrationTestBase(abc.ABC):
|
||||
"http.method": "GET",
|
||||
"http.url": self.URL,
|
||||
"http.status_code": 200,
|
||||
"http.status_text": "OK",
|
||||
},
|
||||
)
|
||||
|
||||
@ -127,7 +126,6 @@ class RequestsIntegrationTestBase(abc.ABC):
|
||||
span = self.assert_span()
|
||||
|
||||
self.assertEqual(span.attributes.get("http.status_code"), 404)
|
||||
self.assertEqual(span.attributes.get("http.status_text"), "Not Found")
|
||||
|
||||
self.assertIs(
|
||||
span.status.status_code, trace.StatusCode.ERROR,
|
||||
@ -235,7 +233,6 @@ class RequestsIntegrationTestBase(abc.ABC):
|
||||
"http.method": "GET",
|
||||
"http.url": self.URL,
|
||||
"http.status_code": 200,
|
||||
"http.status_text": "OK",
|
||||
"http.response.body": "Hello!",
|
||||
},
|
||||
)
|
||||
@ -304,7 +301,6 @@ class RequestsIntegrationTestBase(abc.ABC):
|
||||
"http.method": "GET",
|
||||
"http.url": self.URL,
|
||||
"http.status_code": 500,
|
||||
"http.status_text": "Internal Server Error",
|
||||
},
|
||||
)
|
||||
self.assertEqual(span.status.status_code, StatusCode.ERROR)
|
||||
|
@ -238,8 +238,6 @@ def _finish_span(tracer, handler, error=None):
|
||||
return
|
||||
|
||||
if ctx.span.is_recording():
|
||||
if reason:
|
||||
ctx.span.set_attribute("http.status_text", reason)
|
||||
ctx.span.set_attribute("http.status_code", status_code)
|
||||
ctx.span.set_status(
|
||||
Status(
|
||||
|
@ -132,7 +132,6 @@ class TestTornadoInstrumentation(TornadoTest):
|
||||
"http.host": "127.0.0.1:" + str(self.get_http_port()),
|
||||
"http.target": "/",
|
||||
"net.peer.ip": "127.0.0.1",
|
||||
"http.status_text": "Created",
|
||||
"http.status_code": 201,
|
||||
},
|
||||
)
|
||||
@ -205,7 +204,6 @@ class TestTornadoInstrumentation(TornadoTest):
|
||||
"http.host": "127.0.0.1:" + str(self.get_http_port()),
|
||||
"http.target": url,
|
||||
"net.peer.ip": "127.0.0.1",
|
||||
"http.status_text": "Created",
|
||||
"http.status_code": 201,
|
||||
},
|
||||
)
|
||||
@ -274,7 +272,6 @@ class TestTornadoInstrumentation(TornadoTest):
|
||||
"http.host": "127.0.0.1:" + str(self.get_http_port()),
|
||||
"http.target": "/missing-url",
|
||||
"net.peer.ip": "127.0.0.1",
|
||||
"http.status_text": "Not Found",
|
||||
"http.status_code": 404,
|
||||
},
|
||||
)
|
||||
@ -318,7 +315,6 @@ class TestTornadoInstrumentation(TornadoTest):
|
||||
"http.host": "127.0.0.1:" + str(self.get_http_port()),
|
||||
"http.target": "/dyna",
|
||||
"net.peer.ip": "127.0.0.1",
|
||||
"http.status_text": "Accepted",
|
||||
"http.status_code": 202,
|
||||
},
|
||||
)
|
||||
|
@ -171,7 +171,6 @@ def _instrument(tracer_provider=None, span_callback=None, name_callback=None):
|
||||
|
||||
if span.is_recording():
|
||||
span.set_attribute("http.status_code", code_)
|
||||
span.set_attribute("http.status_text", result.reason)
|
||||
span.set_status(Status(http_status_to_status_code(code_)))
|
||||
|
||||
ver_ = str(getattr(result, "version", ""))
|
||||
|
@ -107,7 +107,6 @@ class RequestsIntegrationTestBase(abc.ABC):
|
||||
"http.method": "GET",
|
||||
"http.url": self.URL,
|
||||
"http.status_code": 200,
|
||||
"http.status_text": "OK",
|
||||
},
|
||||
)
|
||||
|
||||
@ -158,7 +157,6 @@ class RequestsIntegrationTestBase(abc.ABC):
|
||||
span = self.assert_span()
|
||||
|
||||
self.assertEqual(span.attributes.get("http.status_code"), 404)
|
||||
self.assertEqual(span.attributes.get("http.status_text"), "Not Found")
|
||||
|
||||
self.assertIs(
|
||||
span.status.status_code, trace.StatusCode.ERROR,
|
||||
@ -269,7 +267,6 @@ class RequestsIntegrationTestBase(abc.ABC):
|
||||
"http.method": "GET",
|
||||
"http.url": self.URL,
|
||||
"http.status_code": 200,
|
||||
"http.status_text": "OK",
|
||||
"http.response.body": "Hello!",
|
||||
},
|
||||
)
|
||||
@ -299,7 +296,6 @@ class RequestsIntegrationTestBase(abc.ABC):
|
||||
"http.method": "GET",
|
||||
"http.url": "http://httpbin.org/status/500",
|
||||
"http.status_code": 500,
|
||||
"http.status_text": "Internal Server Error",
|
||||
},
|
||||
)
|
||||
self.assertEqual(span.status.status_code, StatusCode.ERROR)
|
||||
|
@ -203,7 +203,6 @@ def _apply_response(span: Span, response: urllib3.response.HTTPResponse):
|
||||
return
|
||||
|
||||
span.set_attribute("http.status_code", response.status)
|
||||
span.set_attribute("http.status_text", response.reason)
|
||||
span.set_status(Status(http_status_to_status_code(response.status)))
|
||||
|
||||
|
||||
|
@ -72,7 +72,6 @@ class TestURLLib3Instrumentor(TestBase):
|
||||
"http.method": "GET",
|
||||
"http.url": url,
|
||||
"http.status_code": 200,
|
||||
"http.status_text": "OK",
|
||||
}
|
||||
self.assertEqual(attributes, span.attributes)
|
||||
|
||||
@ -127,7 +126,6 @@ class TestURLLib3Instrumentor(TestBase):
|
||||
|
||||
span = self.assert_span()
|
||||
self.assertEqual(404, span.attributes.get("http.status_code"))
|
||||
self.assertEqual("Not Found", span.attributes.get("http.status_text"))
|
||||
self.assertIs(trace.status.StatusCode.ERROR, span.status.status_code)
|
||||
|
||||
def test_basic_http_non_default_port(self):
|
||||
|
@ -157,8 +157,7 @@ def add_response_attributes(
|
||||
passed to a PEP3333-conforming start_response callable."""
|
||||
if not span.is_recording():
|
||||
return
|
||||
status_code, status_text = start_response_status.split(" ", 1)
|
||||
span.set_attribute("http.status_text", status_text)
|
||||
status_code, _ = start_response_status.split(" ", 1)
|
||||
|
||||
try:
|
||||
status_code = int(status_code)
|
||||
|
@ -112,7 +112,6 @@ class TestWsgiApplication(WsgiTestBase):
|
||||
"http.host": "127.0.0.1",
|
||||
"http.flavor": "1.0",
|
||||
"http.url": "http://127.0.0.1/",
|
||||
"http.status_text": "OK",
|
||||
"http.status_code": 200,
|
||||
}
|
||||
if http_method is not None:
|
||||
@ -337,20 +336,10 @@ class TestWsgiAttributes(unittest.TestCase):
|
||||
|
||||
def test_response_attributes(self):
|
||||
otel_wsgi.add_response_attributes(self.span, "404 Not Found", {})
|
||||
expected = (
|
||||
mock.call("http.status_code", 404),
|
||||
mock.call("http.status_text", "Not Found"),
|
||||
)
|
||||
expected = (mock.call("http.status_code", 404),)
|
||||
self.assertEqual(self.span.set_attribute.call_count, len(expected))
|
||||
self.span.set_attribute.assert_has_calls(expected, any_order=True)
|
||||
|
||||
def test_response_attributes_invalid_status_code(self):
|
||||
otel_wsgi.add_response_attributes(self.span, "Invalid Status Code", {})
|
||||
self.assertEqual(self.span.set_attribute.call_count, 1)
|
||||
self.span.set_attribute.assert_called_with(
|
||||
"http.status_text", "Status Code"
|
||||
)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
||||
|
Reference in New Issue
Block a user