Skip to content

Commit 370952f

Browse files
authored
Remove http.status_text from span attributes (#406)
1 parent 1ee8924 commit 370952f

File tree

17 files changed

+6
-51
lines changed

17 files changed

+6
-51
lines changed

CHANGELOG.md

+4
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
2222
- `opentelemetry-instrumenation-django` now supports request and response hooks.
2323
([#407](https://github.com/open-telemetry/opentelemetry-python-contrib/pull/407))
2424

25+
### Removed
26+
- Remove `http.status_text` from span attributes
27+
([#406](https://github.com/open-telemetry/opentelemetry-python-contrib/pull/406))
28+
2529
## [0.19b0](https://github.com/open-telemetry/opentelemetry-python-contrib/releases/tag/v0.19b0) - 2021-03-26
2630

2731
- Implement context methods for `_InterceptorChannel`

instrumentation/opentelemetry-instrumentation-aiohttp-client/src/opentelemetry/instrumentation/aiohttp_client/__init__.py

-3
Original file line numberDiff line numberDiff line change
@@ -198,9 +198,6 @@ async def on_request_end(
198198
trace_config_ctx.span.set_attribute(
199199
"http.status_code", params.response.status
200200
)
201-
trace_config_ctx.span.set_attribute(
202-
"http.status_text", params.response.reason
203-
)
204201
_end_trace(trace_config_ctx)
205202

206203
async def on_request_exception(

instrumentation/opentelemetry-instrumentation-aiohttp-client/tests/test_aiohttp_client_integration.py

-4
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,6 @@ def test_status_codes(self):
134134
host, port
135135
),
136136
"http.status_code": int(status_code),
137-
"http.status_text": status_code.phrase,
138137
},
139138
)
140139
]
@@ -191,7 +190,6 @@ def test_span_name_option(self):
191190
host, port, path
192191
),
193192
"http.status_code": int(HTTPStatus.OK),
194-
"http.status_text": HTTPStatus.OK.phrase,
195193
},
196194
)
197195
]
@@ -222,7 +220,6 @@ def strip_query_params(url: yarl.URL) -> str:
222220
host, port
223221
),
224222
"http.status_code": int(HTTPStatus.OK),
225-
"http.status_text": HTTPStatus.OK.phrase,
226223
},
227224
)
228225
]
@@ -361,7 +358,6 @@ def test_instrument(self):
361358
span.attributes["http.url"],
362359
)
363360
self.assertEqual(200, span.attributes["http.status_code"])
364-
self.assertEqual("OK", span.attributes["http.status_text"])
365361

366362
def test_instrument_with_existing_trace_config(self):
367363
trace_config = aiohttp.TraceConfig()

instrumentation/opentelemetry-instrumentation-django/tests/test_middleware.py

-3
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,6 @@ def test_templated_route_get(self):
121121
)
122122
self.assertEqual(span.attributes["http.scheme"], "http")
123123
self.assertEqual(span.attributes["http.status_code"], 200)
124-
self.assertEqual(span.attributes["http.status_text"], "OK")
125124

126125
def test_traced_get(self):
127126
Client().get("/traced/")
@@ -143,7 +142,6 @@ def test_traced_get(self):
143142
self.assertEqual(span.attributes["http.route"], "^traced/")
144143
self.assertEqual(span.attributes["http.scheme"], "http")
145144
self.assertEqual(span.attributes["http.status_code"], 200)
146-
self.assertEqual(span.attributes["http.status_text"], "OK")
147145

148146
def test_not_recording(self):
149147
mock_tracer = Mock()
@@ -178,7 +176,6 @@ def test_traced_post(self):
178176
self.assertEqual(span.attributes["http.route"], "^traced/")
179177
self.assertEqual(span.attributes["http.scheme"], "http")
180178
self.assertEqual(span.attributes["http.status_code"], 200)
181-
self.assertEqual(span.attributes["http.status_text"], "OK")
182179

183180
def test_error(self):
184181
with self.assertRaises(ValueError):

instrumentation/opentelemetry-instrumentation-falcon/tests/test_falcon.py

-2
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,6 @@ def _test_method(self, method):
104104
"net.peer.port": "65133",
105105
"http.flavor": "1.1",
106106
"falcon.resource": "HelloWorldResource",
107-
"http.status_text": "Created",
108107
"http.status_code": 201,
109108
},
110109
)
@@ -129,7 +128,6 @@ def test_404(self):
129128
"net.peer.ip": "127.0.0.1",
130129
"net.peer.port": "65133",
131130
"http.flavor": "1.1",
132-
"http.status_text": "Not Found",
133131
"http.status_code": 404,
134132
},
135133
)

instrumentation/opentelemetry-instrumentation-flask/tests/test_programmatic.py

-3
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,6 @@ def expected_attributes(override_attributes):
3535
"http.host": "localhost",
3636
"http.target": "/",
3737
"http.flavor": "1.1",
38-
"http.status_text": "OK",
3938
"http.status_code": 200,
4039
}
4140
for key, val in override_attributes.items():
@@ -138,7 +137,6 @@ def test_404(self):
138137
{
139138
"http.method": "POST",
140139
"http.target": "/bye",
141-
"http.status_text": "NOT FOUND",
142140
"http.status_code": 404,
143141
}
144142
)
@@ -157,7 +155,6 @@ def test_internal_error(self):
157155
{
158156
"http.target": "/hello/500",
159157
"http.route": "/hello/<int:helloid>",
160-
"http.status_text": "INTERNAL SERVER ERROR",
161158
"http.status_code": 500,
162159
}
163160
)

instrumentation/opentelemetry-instrumentation-pyramid/tests/test_programmatic.py

-3
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,6 @@ def expected_attributes(override_attributes):
3535
"http.host": "localhost",
3636
"http.target": "/",
3737
"http.flavor": "1.1",
38-
"http.status_text": "OK",
3938
"http.status_code": 200,
4039
}
4140
for key, val in override_attributes.items():
@@ -118,7 +117,6 @@ def test_404(self):
118117
{
119118
"http.method": "POST",
120119
"http.target": "/bye",
121-
"http.status_text": "Not Found",
122120
"http.status_code": 404,
123121
}
124122
)
@@ -137,7 +135,6 @@ def test_internal_error(self):
137135
{
138136
"http.target": "/hello/500",
139137
"http.route": "/hello/{helloid}",
140-
"http.status_text": "Internal Server Error",
141138
"http.status_code": 500,
142139
}
143140
)

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

-1
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,6 @@ def _instrumented_requests_call(
150150
if isinstance(result, Response):
151151
if span.is_recording():
152152
span.set_attribute("http.status_code", result.status_code)
153-
span.set_attribute("http.status_text", result.reason)
154153
span.set_status(
155154
Status(http_status_to_status_code(result.status_code))
156155
)

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

-4
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,6 @@ def test_basic(self):
8282
"http.method": "GET",
8383
"http.url": self.URL,
8484
"http.status_code": 200,
85-
"http.status_text": "OK",
8685
},
8786
)
8887

@@ -127,7 +126,6 @@ def test_not_foundbasic(self):
127126
span = self.assert_span()
128127

129128
self.assertEqual(span.attributes.get("http.status_code"), 404)
130-
self.assertEqual(span.attributes.get("http.status_text"), "Not Found")
131129

132130
self.assertIs(
133131
span.status.status_code, trace.StatusCode.ERROR,
@@ -235,7 +233,6 @@ def span_callback(span, result: requests.Response):
235233
"http.method": "GET",
236234
"http.url": self.URL,
237235
"http.status_code": 200,
238-
"http.status_text": "OK",
239236
"http.response.body": "Hello!",
240237
},
241238
)
@@ -304,7 +301,6 @@ def test_requests_exception_with_response(self, *_, **__):
304301
"http.method": "GET",
305302
"http.url": self.URL,
306303
"http.status_code": 500,
307-
"http.status_text": "Internal Server Error",
308304
},
309305
)
310306
self.assertEqual(span.status.status_code, StatusCode.ERROR)

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

-2
Original file line numberDiff line numberDiff line change
@@ -238,8 +238,6 @@ def _finish_span(tracer, handler, error=None):
238238
return
239239

240240
if ctx.span.is_recording():
241-
if reason:
242-
ctx.span.set_attribute("http.status_text", reason)
243241
ctx.span.set_attribute("http.status_code", status_code)
244242
ctx.span.set_status(
245243
Status(

instrumentation/opentelemetry-instrumentation-tornado/tests/test_instrumentation.py

-4
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,6 @@ def _test_http_method_call(self, method):
132132
"http.host": "127.0.0.1:" + str(self.get_http_port()),
133133
"http.target": "/",
134134
"net.peer.ip": "127.0.0.1",
135-
"http.status_text": "Created",
136135
"http.status_code": 201,
137136
},
138137
)
@@ -205,7 +204,6 @@ def _test_async_handler(self, url, handler_name):
205204
"http.host": "127.0.0.1:" + str(self.get_http_port()),
206205
"http.target": url,
207206
"net.peer.ip": "127.0.0.1",
208-
"http.status_text": "Created",
209207
"http.status_code": 201,
210208
},
211209
)
@@ -274,7 +272,6 @@ def test_404(self):
274272
"http.host": "127.0.0.1:" + str(self.get_http_port()),
275273
"http.target": "/missing-url",
276274
"net.peer.ip": "127.0.0.1",
277-
"http.status_text": "Not Found",
278275
"http.status_code": 404,
279276
},
280277
)
@@ -318,7 +315,6 @@ def test_dynamic_handler(self):
318315
"http.host": "127.0.0.1:" + str(self.get_http_port()),
319316
"http.target": "/dyna",
320317
"net.peer.ip": "127.0.0.1",
321-
"http.status_text": "Accepted",
322318
"http.status_code": 202,
323319
},
324320
)

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

-1
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,6 @@ def _instrumented_open_call(
171171

172172
if span.is_recording():
173173
span.set_attribute("http.status_code", code_)
174-
span.set_attribute("http.status_text", result.reason)
175174
span.set_status(Status(http_status_to_status_code(code_)))
176175

177176
ver_ = str(getattr(result, "version", ""))

instrumentation/opentelemetry-instrumentation-urllib/tests/test_urllib_integration.py

-4
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,6 @@ def test_basic(self):
107107
"http.method": "GET",
108108
"http.url": self.URL,
109109
"http.status_code": 200,
110-
"http.status_text": "OK",
111110
},
112111
)
113112

@@ -158,7 +157,6 @@ def test_not_foundbasic(self):
158157
span = self.assert_span()
159158

160159
self.assertEqual(span.attributes.get("http.status_code"), 404)
161-
self.assertEqual(span.attributes.get("http.status_text"), "Not Found")
162160

163161
self.assertIs(
164162
span.status.status_code, trace.StatusCode.ERROR,
@@ -269,7 +267,6 @@ def span_callback(span, result: HTTPResponse):
269267
"http.method": "GET",
270268
"http.url": self.URL,
271269
"http.status_code": 200,
272-
"http.status_text": "OK",
273270
"http.response.body": "Hello!",
274271
},
275272
)
@@ -299,7 +296,6 @@ def test_requests_exception_with_response(self, *_, **__):
299296
"http.method": "GET",
300297
"http.url": "http://httpbin.org/status/500",
301298
"http.status_code": 500,
302-
"http.status_text": "Internal Server Error",
303299
},
304300
)
305301
self.assertEqual(span.status.status_code, StatusCode.ERROR)

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

-1
Original file line numberDiff line numberDiff line change
@@ -203,7 +203,6 @@ def _apply_response(span: Span, response: urllib3.response.HTTPResponse):
203203
return
204204

205205
span.set_attribute("http.status_code", response.status)
206-
span.set_attribute("http.status_text", response.reason)
207206
span.set_status(Status(http_status_to_status_code(response.status)))
208207

209208

instrumentation/opentelemetry-instrumentation-urllib3/tests/test_urllib3_integration.py

-2
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,6 @@ def assert_success_span(
7272
"http.method": "GET",
7373
"http.url": url,
7474
"http.status_code": 200,
75-
"http.status_text": "OK",
7675
}
7776
self.assertEqual(attributes, span.attributes)
7877

@@ -127,7 +126,6 @@ def test_basic_not_found(self):
127126

128127
span = self.assert_span()
129128
self.assertEqual(404, span.attributes.get("http.status_code"))
130-
self.assertEqual("Not Found", span.attributes.get("http.status_text"))
131129
self.assertIs(trace.status.StatusCode.ERROR, span.status.status_code)
132130

133131
def test_basic_http_non_default_port(self):

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

+1-2
Original file line numberDiff line numberDiff line change
@@ -157,8 +157,7 @@ def add_response_attributes(
157157
passed to a PEP3333-conforming start_response callable."""
158158
if not span.is_recording():
159159
return
160-
status_code, status_text = start_response_status.split(" ", 1)
161-
span.set_attribute("http.status_text", status_text)
160+
status_code, _ = start_response_status.split(" ", 1)
162161

163162
try:
164163
status_code = int(status_code)

instrumentation/opentelemetry-instrumentation-wsgi/tests/test_wsgi_middleware.py

+1-12
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,6 @@ def validate_response(
112112
"http.host": "127.0.0.1",
113113
"http.flavor": "1.0",
114114
"http.url": "http://127.0.0.1/",
115-
"http.status_text": "OK",
116115
"http.status_code": 200,
117116
}
118117
if http_method is not None:
@@ -337,20 +336,10 @@ def test_http_user_agent_attribute(self):
337336

338337
def test_response_attributes(self):
339338
otel_wsgi.add_response_attributes(self.span, "404 Not Found", {})
340-
expected = (
341-
mock.call("http.status_code", 404),
342-
mock.call("http.status_text", "Not Found"),
343-
)
339+
expected = (mock.call("http.status_code", 404),)
344340
self.assertEqual(self.span.set_attribute.call_count, len(expected))
345341
self.span.set_attribute.assert_has_calls(expected, any_order=True)
346342

347-
def test_response_attributes_invalid_status_code(self):
348-
otel_wsgi.add_response_attributes(self.span, "Invalid Status Code", {})
349-
self.assertEqual(self.span.set_attribute.call_count, 1)
350-
self.span.set_attribute.assert_called_with(
351-
"http.status_text", "Status Code"
352-
)
353-
354343

355344
if __name__ == "__main__":
356345
unittest.main()

0 commit comments

Comments
 (0)