Skip to content

Commit 4d90845

Browse files
committed
update changelog && add test
1 parent 9252deb commit 4d90845

File tree

2 files changed

+13
-1
lines changed

2 files changed

+13
-1
lines changed

CHANGELOG.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1919
([#3111](https://github.com/open-telemetry/opentelemetry-python-contrib/pull/3111))
2020
- `opentelemetry-instrumentation-falcon` add support version to v4
2121
([#3086](https://github.com/open-telemetry/opentelemetry-python-contrib/pull/3086))
22-
- `opentelemetry-instrumentation-wsgi` remove is_recording method to record status code in all metrics
22+
- `opentelemetry-instrumentation-wsgi` always record span status code to have it available in metrics
2323
([#3148](https://github.com/open-telemetry/opentelemetry-python-contrib/pull/3148))
2424

2525
### Fixed

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

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -779,6 +779,18 @@ def test_response_attributes(self):
779779
self.span.set_attribute.assert_has_calls(expected, any_order=True)
780780
self.span.set_attribute.assert_has_calls(expected_new, any_order=True)
781781

782+
def test_response_attributes_noop(self):
783+
mock_span = mock.Mock()
784+
mock_span.is_recording.return_value = False
785+
786+
attrs = {}
787+
otel_wsgi.add_response_attributes(mock_span, "404 Not Found", {}, duration_attrs=attrs)
788+
789+
self.assertEqual(mock_span.set_attribute.call_count, 0)
790+
self.assertEqual(mock_span.is_recording.call_count, 2)
791+
self.assertEqual(attrs[SpanAttributes.HTTP_STATUS_CODE], 404)
792+
793+
782794
def test_credential_removal(self):
783795
self.environ["HTTP_HOST"] = "username:password@mock"
784796
self.environ["PATH_INFO"] = "/status/200"

0 commit comments

Comments
 (0)