Skip to content

Commit

Permalink
Merge branch 'main' into azur_app_service_resource_detector
Browse files Browse the repository at this point in the history
  • Loading branch information
jeremydvoss authored Aug 16, 2023
2 parents 60c39a5 + 9cd9de7 commit a69f6d3
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 6 deletions.
1 change: 1 addition & 0 deletions .github/component_owners.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ components:
docs/instrumentation:
- nemoshlag


instrumentation/opentelemetry-instrumentation-aio-pika:
- ofek1weiss

Expand Down
4 changes: 3 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

### Fixed

- `opentelemetry-instrumentation-asgi` Fix UnboundLocalError local variable 'start' referenced before assignment
- `opentelemetry-instrumentation-asgi` Fix UnboundLocalError local variable 'start' referenced before assignment
([#1889](https://github.com/open-telemetry/opentelemetry-python-contrib/pull/1889))
- 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
([#1913](https://github.com/open-telemetry/opentelemetry-python-contrib/pull/1913))

### Added

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -289,7 +289,7 @@ def test_nonstandard_http_method(self):
self.environ["REQUEST_METHOD"]= "NONSTANDARD"
app = otel_wsgi.OpenTelemetryMiddleware(simple_wsgi)
response = app(self.environ, self.start_response)
self.validate_response(response, span_name="HTTP UNKNOWN", http_method="UNKNOWN")
self.validate_response(response, span_name="UNKNOWN /", http_method="UNKNOWN")

@mock.patch.dict(
"os.environ",
Expand All @@ -301,7 +301,7 @@ def test_nonstandard_http_method_allowed(self):
self.environ["REQUEST_METHOD"]= "NONSTANDARD"
app = otel_wsgi.OpenTelemetryMiddleware(simple_wsgi)
response = app(self.environ, self.start_response)
self.validate_response(response, span_name="HTTP NONSTANDARD", http_method="NONSTANDARD")
self.validate_response(response, span_name="NONSTANDARD /", http_method="NONSTANDARD")

def test_default_span_name_missing_path_info(self):
"""Test that default span_names with missing path info."""
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
from re import IGNORECASE as RE_IGNORECASE
from re import compile as re_compile
from re import search
from typing import Iterable, List
from typing import Iterable, List, Optional
from urllib.parse import urlparse, urlunparse

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

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

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

0 comments on commit a69f6d3

Please sign in to comment.