Skip to content

Commit

Permalink
revert changes in wsgi based webframeworks
Browse files Browse the repository at this point in the history
  • Loading branch information
samuelcolvin committed May 1, 2024
1 parent 2ea4ebd commit 94ad9c1
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 9 deletions.
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
([#2425](https://github.com/open-telemetry/opentelemetry-python-contrib/pull/2425))
- `opentelemetry-instrumentation-flask` Add `http.method` to `span.name`
([#2454](https://github.com/open-telemetry/opentelemetry-python-contrib/pull/2454))
- Record repeated HTTP headers in lists, rather than a comma separate strings
- Record repeated HTTP headers in lists, rather than a comma separate strings for ASGI based web frameworks
([#2361](https://github.com/open-telemetry/opentelemetry-python-contrib/pull/2361))

### Added
Expand Down Expand Up @@ -75,6 +75,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- AwsLambdaInstrumentor sets `cloud.account.id` span attribute
([#2367](https://github.com/open-telemetry/opentelemetry-python-contrib/pull/2367))


## Version 1.23.0/0.44b0 (2024-02-23)

- Drop support for 3.7
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1003,8 +1003,7 @@ def test_repeat_custom_response_header_added_in_server_span(self):
"text/plain; charset=utf-8",
),
"http.response.header.my_custom_header": (
"my-custom-value-1",
"my-custom-header-2",
"my-custom-value-1,my-custom-header-2",
),
}
self.assertEqual(span.kind, trace.SpanKind.SERVER)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -210,9 +210,7 @@ def response_hook(span: Span, environ: WSGIEnvironment, status: str, response_he
import functools
import typing
import wsgiref.util as wsgiref_util
from collections import defaultdict
from timeit import default_timer
from typing import DefaultDict

from opentelemetry import context, trace
from opentelemetry.instrumentation._semconv import (
Expand Down Expand Up @@ -422,10 +420,14 @@ def collect_custom_response_headers_attributes(response_headers):
OTEL_INSTRUMENTATION_HTTP_CAPTURE_HEADERS_SANITIZE_FIELDS
)
)
response_headers_dict: DefaultDict[str, list[str]] = defaultdict(list)
response_headers_dict = {}
if response_headers:
for key, val in response_headers:
response_headers_dict[key.lower()].append(val)
key = key.lower()
if key in response_headers_dict:
response_headers_dict[key] += "," + val
else:
response_headers_dict[key] = val

return sanitize.sanitize_header_values(
response_headers_dict,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1032,8 +1032,7 @@ def test_repeat_custom_response_headers_added_in_server_span(self):
span = self.memory_exporter.get_finished_spans()[0]
expected = {
"http.response.header.my_custom_header": (
"my-custom-value-1",
"my-custom-value-2",
"my-custom-value-1,my-custom-value-2",
),
}
self.assertSpanHasAttributes(span, expected)
Expand Down

0 comments on commit 94ad9c1

Please sign in to comment.