Skip to content

Commit

Permalink
Merge branch 'main' into rd-support-confluent-kafka-261
Browse files Browse the repository at this point in the history
  • Loading branch information
emdneto authored Dec 17, 2024
2 parents 9fd318a + cc62d1f commit d9b6cd4
Show file tree
Hide file tree
Showing 23 changed files with 792 additions and 679 deletions.
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,14 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

- `opentelemetry-instrumentation-confluent-kafka` Add support for confluent-kafka <=2.7.0
([#3100](https://github.com/open-telemetry/opentelemetry-python-contrib/pull/3100))
- Add support to database stability opt-in in `_semconv` utilities and add tests
([#3111](https://github.com/open-telemetry/opentelemetry-python-contrib/pull/3111))

### Fixed

- `opentelemetry-instrumentation-httpx` Fix `RequestInfo`/`ResponseInfo` type hints
([#3105](https://github.com/open-telemetry/opentelemetry-python-contrib/pull/3105))


## Version 1.29.0/0.50b0 (2024-12-11)

Expand Down
1 change: 0 additions & 1 deletion dev-requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ pytest==7.4.4
pytest-cov==4.1.0
readme-renderer==42.0
bleach==4.1.0 # transient dependency for readme-renderer
protobuf~=3.13
markupsafe>=2.0.1
codespell==2.1.0
requests==2.32.3
Expand Down
2 changes: 2 additions & 0 deletions docs/nitpick-exceptions.ini
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ py-class=
httpx.SyncByteStream
httpx.AsyncByteStream
httpx.Response
httpx.URL
httpx.Headers
aiohttp.web_request.Request
yarl.URL
cimpl.Producer
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
openai~=1.54.4
openai~=1.57.3

opentelemetry-sdk~=1.28.2
opentelemetry-exporter-otlp-proto-grpc~=1.28.2
opentelemetry-sdk~=1.29.0
opentelemetry-exporter-otlp-proto-grpc~=1.29.0
opentelemetry-instrumentation-openai-v2~=2.0b0
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
openai~=1.54.4
openai~=1.57.3

opentelemetry-sdk~=1.28.2
opentelemetry-exporter-otlp-proto-grpc~=1.28.2
opentelemetry-distro~=0.49b2
opentelemetry-sdk~=1.29.0
opentelemetry-exporter-otlp-proto-grpc~=1.29.0
opentelemetry-distro~=0.50b0
opentelemetry-instrumentation-openai-v2~=2.0b0
Original file line number Diff line number Diff line change
Expand Up @@ -92,13 +92,13 @@ def response_hook(span: Span, params: typing.Union[
from opentelemetry import trace
from opentelemetry.instrumentation._semconv import (
_get_schema_url,
_HTTPStabilityMode,
_OpenTelemetrySemanticConventionStability,
_OpenTelemetryStabilitySignalType,
_report_new,
_set_http_method,
_set_http_url,
_set_status,
_StabilityMode,
)
from opentelemetry.instrumentation.aiohttp_client.package import _instruments
from opentelemetry.instrumentation.aiohttp_client.version import __version__
Expand Down Expand Up @@ -142,7 +142,7 @@ def _set_http_status_code_attribute(
span,
status_code,
metric_attributes=None,
sem_conv_opt_in_mode=_HTTPStabilityMode.DEFAULT,
sem_conv_opt_in_mode=_StabilityMode.DEFAULT,
):
status_code_str = str(status_code)
try:
Expand All @@ -169,7 +169,7 @@ def create_trace_config(
request_hook: _RequestHookT = None,
response_hook: _ResponseHookT = None,
tracer_provider: TracerProvider = None,
sem_conv_opt_in_mode: _HTTPStabilityMode = _HTTPStabilityMode.DEFAULT,
sem_conv_opt_in_mode: _StabilityMode = _StabilityMode.DEFAULT,
) -> aiohttp.TraceConfig:
"""Create an aiohttp-compatible trace configuration.
Expand Down Expand Up @@ -326,7 +326,7 @@ def _instrument(
trace_configs: typing.Optional[
typing.Sequence[aiohttp.TraceConfig]
] = None,
sem_conv_opt_in_mode: _HTTPStabilityMode = _HTTPStabilityMode.DEFAULT,
sem_conv_opt_in_mode: _StabilityMode = _StabilityMode.DEFAULT,
):
"""Enables tracing of all ClientSessions
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@
from opentelemetry.instrumentation import aiohttp_client
from opentelemetry.instrumentation._semconv import (
OTEL_SEMCONV_STABILITY_OPT_IN,
_HTTPStabilityMode,
_OpenTelemetrySemanticConventionStability,
_StabilityMode,
)
from opentelemetry.instrumentation.aiohttp_client import (
AioHttpClientInstrumentor,
Expand Down Expand Up @@ -150,7 +150,7 @@ def test_status_codes_new_semconv(self):
path = "test-path?query=param#foobar"
host, port = self._http_request(
trace_config=aiohttp_client.create_trace_config(
sem_conv_opt_in_mode=_HTTPStabilityMode.HTTP
sem_conv_opt_in_mode=_StabilityMode.HTTP
),
url=f"/{path}",
status_code=status_code,
Expand All @@ -173,7 +173,7 @@ def test_status_codes_both_semconv(self):
path = "test-path?query=param#foobar"
host, port = self._http_request(
trace_config=aiohttp_client.create_trace_config(
sem_conv_opt_in_mode=_HTTPStabilityMode.HTTP_DUP
sem_conv_opt_in_mode=_StabilityMode.HTTP_DUP
),
url=f"/{path}",
status_code=status_code,
Expand Down Expand Up @@ -213,7 +213,7 @@ def test_schema_url_new_semconv(self):
with self.subTest(status_code=200):
self._http_request(
trace_config=aiohttp_client.create_trace_config(
sem_conv_opt_in_mode=_HTTPStabilityMode.HTTP
sem_conv_opt_in_mode=_StabilityMode.HTTP
),
url="/test-path?query=param#foobar",
status_code=200,
Expand All @@ -230,7 +230,7 @@ def test_schema_url_both_semconv(self):
with self.subTest(status_code=200):
self._http_request(
trace_config=aiohttp_client.create_trace_config(
sem_conv_opt_in_mode=_HTTPStabilityMode.HTTP_DUP
sem_conv_opt_in_mode=_StabilityMode.HTTP_DUP
),
url="/test-path?query=param#foobar",
status_code=200,
Expand Down Expand Up @@ -398,7 +398,7 @@ async def request_handler(request):

host, port = self._http_request(
trace_config=aiohttp_client.create_trace_config(
sem_conv_opt_in_mode=_HTTPStabilityMode.HTTP
sem_conv_opt_in_mode=_StabilityMode.HTTP
),
url="/test",
request_handler=request_handler,
Expand Down Expand Up @@ -426,7 +426,7 @@ async def request_handler(request):

host, port = self._http_request(
trace_config=aiohttp_client.create_trace_config(
sem_conv_opt_in_mode=_HTTPStabilityMode.HTTP_DUP
sem_conv_opt_in_mode=_StabilityMode.HTTP_DUP
),
url="/test",
request_handler=request_handler,
Expand Down Expand Up @@ -546,7 +546,7 @@ async def do_request(url):
def test_nonstandard_http_method_new_semconv(self):
trace_configs = [
aiohttp_client.create_trace_config(
sem_conv_opt_in_mode=_HTTPStabilityMode.HTTP
sem_conv_opt_in_mode=_StabilityMode.HTTP
)
]
app = HttpServerMock("nonstandard_method")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,6 @@ def client_response_hook(span: Span, scope: dict[str, Any], message: dict[str, A
_filter_semconv_active_request_count_attr,
_filter_semconv_duration_attrs,
_get_schema_url,
_HTTPStabilityMode,
_OpenTelemetrySemanticConventionStability,
_OpenTelemetryStabilitySignalType,
_report_new,
Expand All @@ -225,6 +224,7 @@ def client_response_hook(span: Span, scope: dict[str, Any], message: dict[str, A
_set_http_url,
_set_http_user_agent,
_set_status,
_StabilityMode,
)
from opentelemetry.instrumentation.asgi.types import (
ClientRequestHook,
Expand Down Expand Up @@ -324,7 +324,7 @@ def set(self, carrier: dict, key: str, value: str) -> None: # pylint: disable=n

# pylint: disable=too-many-branches
def collect_request_attributes(
scope, sem_conv_opt_in_mode=_HTTPStabilityMode.DEFAULT
scope, sem_conv_opt_in_mode=_StabilityMode.DEFAULT
):
"""Collects HTTP request attributes from the ASGI scope and returns a
dictionary to be used as span creation attributes."""
Expand Down Expand Up @@ -356,7 +356,7 @@ def collect_request_attributes(
_set_http_url(
result,
remove_url_credentials(http_url),
_HTTPStabilityMode.DEFAULT,
_StabilityMode.DEFAULT,
)
http_method = scope.get("method", "")
if http_method:
Expand Down Expand Up @@ -439,7 +439,7 @@ def set_status_code(
span,
status_code,
metric_attributes=None,
sem_conv_opt_in_mode=_HTTPStabilityMode.DEFAULT,
sem_conv_opt_in_mode=_StabilityMode.DEFAULT,
):
"""Adds HTTP response attributes to span using the status_code argument."""
status_code_str = str(status_code)
Expand Down Expand Up @@ -755,12 +755,12 @@ async def __call__(
)
duration_s = default_timer() - start
duration_attrs_old = _parse_duration_attrs(
attributes, _HTTPStabilityMode.DEFAULT
attributes, _StabilityMode.DEFAULT
)
if target:
duration_attrs_old[SpanAttributes.HTTP_TARGET] = target
duration_attrs_new = _parse_duration_attrs(
attributes, _HTTPStabilityMode.HTTP
attributes, _StabilityMode.HTTP
)
if self.duration_histogram_old:
self.duration_histogram_old.record(
Expand Down Expand Up @@ -960,7 +960,7 @@ async def otel_send(message: dict[str, Any]):


def _parse_duration_attrs(
req_attrs, sem_conv_opt_in_mode=_HTTPStabilityMode.DEFAULT
req_attrs, sem_conv_opt_in_mode=_StabilityMode.DEFAULT
):
return _filter_semconv_duration_attrs(
req_attrs,
Expand All @@ -971,7 +971,7 @@ def _parse_duration_attrs(


def _parse_active_request_count_attrs(
req_attrs, sem_conv_opt_in_mode=_HTTPStabilityMode.DEFAULT
req_attrs, sem_conv_opt_in_mode=_StabilityMode.DEFAULT
):
return _filter_semconv_active_request_count_attr(
req_attrs,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,12 @@
from opentelemetry import trace as trace_api
from opentelemetry.instrumentation._semconv import (
OTEL_SEMCONV_STABILITY_OPT_IN,
_HTTPStabilityMode,
_OpenTelemetrySemanticConventionStability,
_server_active_requests_count_attrs_new,
_server_active_requests_count_attrs_old,
_server_duration_attrs_new,
_server_duration_attrs_old,
_StabilityMode,
)
from opentelemetry.instrumentation.propagators import (
TraceResponsePropagator,
Expand Down Expand Up @@ -1652,7 +1652,7 @@ def test_request_attributes_new_semconv(self):

attrs = otel_asgi.collect_request_attributes(
self.scope,
_HTTPStabilityMode.HTTP,
_StabilityMode.HTTP,
)

self.assertDictEqual(
Expand All @@ -1677,7 +1677,7 @@ def test_request_attributes_both_semconv(self):

attrs = otel_asgi.collect_request_attributes(
self.scope,
_HTTPStabilityMode.HTTP_DUP,
_StabilityMode.HTTP_DUP,
)

self.assertDictEqual(
Expand Down Expand Up @@ -1715,7 +1715,7 @@ def test_query_string_new_semconv(self):
self.scope["query_string"] = b"foo=bar"
attrs = otel_asgi.collect_request_attributes(
self.scope,
_HTTPStabilityMode.HTTP,
_StabilityMode.HTTP,
)
self.assertEqual(attrs[URL_SCHEME], "http")
self.assertEqual(attrs[CLIENT_ADDRESS], "127.0.0.1")
Expand All @@ -1726,7 +1726,7 @@ def test_query_string_both_semconv(self):
self.scope["query_string"] = b"foo=bar"
attrs = otel_asgi.collect_request_attributes(
self.scope,
_HTTPStabilityMode.HTTP_DUP,
_StabilityMode.HTTP_DUP,
)
self.assertEqual(
attrs[SpanAttributes.HTTP_URL], "http://127.0.0.1/?foo=bar"
Expand Down Expand Up @@ -1762,7 +1762,7 @@ def test_response_attributes_new_semconv(self):
self.span,
404,
None,
_HTTPStabilityMode.HTTP,
_StabilityMode.HTTP,
)
expected = (mock.call(HTTP_RESPONSE_STATUS_CODE, 404),)
self.assertEqual(self.span.set_attribute.call_count, 1)
Expand All @@ -1774,7 +1774,7 @@ def test_response_attributes_both_semconv(self):
self.span,
404,
None,
_HTTPStabilityMode.HTTP_DUP,
_StabilityMode.HTTP_DUP,
)
expected = (mock.call(SpanAttributes.HTTP_STATUS_CODE, 404),)
expected2 = (mock.call(HTTP_RESPONSE_STATUS_CODE, 404),)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,13 @@
from opentelemetry.instrumentation._semconv import (
_filter_semconv_active_request_count_attr,
_filter_semconv_duration_attrs,
_HTTPStabilityMode,
_report_new,
_report_old,
_server_active_requests_count_attrs_new,
_server_active_requests_count_attrs_old,
_server_duration_attrs_new,
_server_duration_attrs_old,
_StabilityMode,
)
from opentelemetry.instrumentation.propagators import (
get_global_response_propagator,
Expand Down Expand Up @@ -158,7 +158,7 @@ class _DjangoMiddleware(MiddlewareMixin):
_duration_histogram_old = None
_duration_histogram_new = None
_active_request_counter = None
_sem_conv_opt_in_mode = _HTTPStabilityMode.DEFAULT
_sem_conv_opt_in_mode = _StabilityMode.DEFAULT

_otel_request_hook: Callable[[Span, HttpRequest], None] = None
_otel_response_hook: Callable[[Span, HttpRequest, HttpResponse], None] = (
Expand Down Expand Up @@ -430,7 +430,7 @@ def process_response(self, request, response):
duration_s = default_timer() - request_start_time
if self._duration_histogram_old:
duration_attrs_old = _parse_duration_attrs(
duration_attrs, _HTTPStabilityMode.DEFAULT
duration_attrs, _StabilityMode.DEFAULT
)
# http.target to be included in old semantic conventions
target = duration_attrs.get(SpanAttributes.HTTP_TARGET)
Expand All @@ -441,7 +441,7 @@ def process_response(self, request, response):
)
if self._duration_histogram_new:
duration_attrs_new = _parse_duration_attrs(
duration_attrs, _HTTPStabilityMode.HTTP
duration_attrs, _StabilityMode.HTTP
)
self._duration_histogram_new.record(
max(duration_s, 0), duration_attrs_new
Expand All @@ -455,7 +455,7 @@ def process_response(self, request, response):


def _parse_duration_attrs(
req_attrs, sem_conv_opt_in_mode=_HTTPStabilityMode.DEFAULT
req_attrs, sem_conv_opt_in_mode=_StabilityMode.DEFAULT
):
return _filter_semconv_duration_attrs(
req_attrs,
Expand All @@ -466,7 +466,7 @@ def _parse_duration_attrs(


def _parse_active_request_count_attrs(
req_attrs, sem_conv_opt_in_mode=_HTTPStabilityMode.DEFAULT
req_attrs, sem_conv_opt_in_mode=_StabilityMode.DEFAULT
):
return _filter_semconv_active_request_count_attr(
req_attrs,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -186,9 +186,9 @@ def client_response_hook(span: Span, scope: dict[str, Any], message: dict[str, A

from opentelemetry.instrumentation._semconv import (
_get_schema_url,
_HTTPStabilityMode,
_OpenTelemetrySemanticConventionStability,
_OpenTelemetryStabilitySignalType,
_StabilityMode,
)
from opentelemetry.instrumentation.asgi import OpenTelemetryMiddleware
from opentelemetry.instrumentation.asgi.types import (
Expand Down Expand Up @@ -362,7 +362,7 @@ class _InstrumentedFastAPI(fastapi.FastAPI):
_client_request_hook: ClientRequestHook = None
_client_response_hook: ClientResponseHook = None
_instrumented_fastapi_apps = set()
_sem_conv_opt_in_mode = _HTTPStabilityMode.DEFAULT
_sem_conv_opt_in_mode = _StabilityMode.DEFAULT

def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
Expand Down
Loading

0 comments on commit d9b6cd4

Please sign in to comment.