Skip to content

Commit 9cd9de7

Browse files
authored
Fix errors introduced in regression (#1913)
1 parent 6007e0c commit 9cd9de7

File tree

4 files changed

+9
-6
lines changed

4 files changed

+9
-6
lines changed

.github/component_owners.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ components:
33
docs/instrumentation:
44
- nemoshlag
55

6+
67
instrumentation/opentelemetry-instrumentation-aio-pika:
78
- ofek1weiss
89

CHANGELOG.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
99

1010
### Fixed
1111

12-
- `opentelemetry-instrumentation-asgi` Fix UnboundLocalError local variable 'start' referenced before assignment
12+
- `opentelemetry-instrumentation-asgi` Fix UnboundLocalError local variable 'start' referenced before assignment
1313
([#1889](https://github.com/open-telemetry/opentelemetry-python-contrib/pull/1889))
14+
- Fixed union typing error not compatible with Python 3.7 introduced in `opentelemetry-util-http`, fix tests introduced by patch related to sanitize method for wsgi
15+
([#1913](https://github.com/open-telemetry/opentelemetry-python-contrib/pull/1913))
1416

1517
## Version 1.19.0/0.40b0 (2023-07-13)
1618
- `opentelemetry-instrumentation-asgi` Add `http.server.request.size` metric

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -289,7 +289,7 @@ def test_nonstandard_http_method(self):
289289
self.environ["REQUEST_METHOD"]= "NONSTANDARD"
290290
app = otel_wsgi.OpenTelemetryMiddleware(simple_wsgi)
291291
response = app(self.environ, self.start_response)
292-
self.validate_response(response, span_name="HTTP UNKNOWN", http_method="UNKNOWN")
292+
self.validate_response(response, span_name="UNKNOWN /", http_method="UNKNOWN")
293293

294294
@mock.patch.dict(
295295
"os.environ",
@@ -301,7 +301,7 @@ def test_nonstandard_http_method_allowed(self):
301301
self.environ["REQUEST_METHOD"]= "NONSTANDARD"
302302
app = otel_wsgi.OpenTelemetryMiddleware(simple_wsgi)
303303
response = app(self.environ, self.start_response)
304-
self.validate_response(response, span_name="HTTP NONSTANDARD", http_method="NONSTANDARD")
304+
self.validate_response(response, span_name="NONSTANDARD /", http_method="NONSTANDARD")
305305

306306
def test_default_span_name_missing_path_info(self):
307307
"""Test that default span_names with missing path info."""

util/opentelemetry-util-http/src/opentelemetry/util/http/__init__.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
from re import IGNORECASE as RE_IGNORECASE
1717
from re import compile as re_compile
1818
from re import search
19-
from typing import Iterable, List
19+
from typing import Iterable, List, Optional
2020
from urllib.parse import urlparse, urlunparse
2121

2222
from opentelemetry.semconv.trace import SpanAttributes
@@ -190,15 +190,15 @@ def normalise_response_header_name(header: str) -> str:
190190
key = header.lower().replace("-", "_")
191191
return f"http.response.header.{key}"
192192

193-
def sanitize_method(method: str | None) -> str | None:
193+
def sanitize_method(method: Optional[str]) -> Optional[str]:
194194
if method is None:
195195
return None
196196
method = method.upper()
197197
if (environ.get(OTEL_PYTHON_INSTRUMENTATION_HTTP_CAPTURE_ALL_METHODS) or
198198
# Based on https://www.rfc-editor.org/rfc/rfc7231#section-4.1 and https://www.rfc-editor.org/rfc/rfc5789#section-2.
199199
method in ["GET", "HEAD", "POST", "PUT", "DELETE", "CONNECT", "OPTIONS", "TRACE", "PATCH"]):
200200
return method
201-
return "NONSTANDARD"
201+
return "UNKNOWN"
202202

203203
def get_custom_headers(env_var: str) -> List[str]:
204204
custom_headers = environ.get(env_var, [])

0 commit comments

Comments
 (0)