Skip to content

Commit

Permalink
Merge branch 'main' into urllib
Browse files Browse the repository at this point in the history
  • Loading branch information
lzchen authored Jul 30, 2024
2 parents 1924c5a + d563f8d commit 7895e7d
Show file tree
Hide file tree
Showing 7 changed files with 121 additions and 22 deletions.
7 changes: 5 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,14 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## Unreleased

### Fixed
## Fixed

- `opentelemetry-instrumentation-aws-lambda` Avoid exception when a handler is not present.
([#2750](https://github.com/open-telemetry/opentelemetry-python-contrib/pull/2750))
- `opentelemetry-instrumentation-django` Fix regression - `http.target` re-added back to old semconv duration metrics
([#2746](https://github.com/open-telemetry/opentelemetry-python-contrib/pull/2746))
- `opentelemetry-instrumentation-grpc` Fixes the issue with the gRPC instrumentation not working with the 1.63.0 and higher version of gRPC
([#2483](https://github.com/open-telemetry/opentelemetry-python-contrib/pull/2484))

## Version 1.26.0/0.47b0 (2024-07-23)

Expand Down Expand Up @@ -108,7 +112,6 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- `opentelemetry-instrumentation-asgi` Bugfix: Middleware did not set status code attribute on duration metrics for non-recording spans.
([#2627](https://github.com/open-telemetry/opentelemetry-python-contrib/pull/2627))


## Version 1.25.0/0.46b0 (2024-05-31)

### Breaking changes
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -410,7 +410,7 @@ def _instrument(self, **kwargs):
"""Instruments Lambda Handlers on AWS Lambda.
See more:
https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/trace/semantic_conventions/instrumentation/aws-lambda.md#instrumenting-aws-lambda
https://github.com/open-telemetry/semantic-conventions/blob/main/docs/faas/aws-lambda.md
Args:
**kwargs: Optional arguments
Expand All @@ -422,6 +422,14 @@ def _instrument(self, **kwargs):
request.
"""
lambda_handler = os.environ.get(ORIG_HANDLER, os.environ.get(_HANDLER))
if not lambda_handler:
logger.warning(
(
"Could not find the ORIG_HANDLER or _HANDLER in the environment variables. ",
"This instrumentation requires the OpenTelemetry Lambda extension installed.",
)
)
return
# pylint: disable=attribute-defined-outside-init
(
self._wrapped_module_name,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -495,6 +495,20 @@ def test_lambda_handles_handler_exception_with_api_gateway_proxy_event(

exc_env_patch.stop()

def test_lambda_handles_should_do_nothing_when_environment_variables_not_present(
self,
):
exc_env_patch = mock.patch.dict(
"os.environ",
{_HANDLER: ""},
)
exc_env_patch.start()
AwsLambdaInstrumentor().instrument()

spans = self.memory_exporter.get_finished_spans()
self.assertEqual(len(spans), 0)
exc_env_patch.stop()

def test_uninstrument(self):
AwsLambdaInstrumentor().instrument()

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -272,47 +272,95 @@ def unsubscribe(self, *args, **kwargs):
self._channel.unsubscribe(*args, **kwargs)

def unary_unary(
self, method, request_serializer=None, response_deserializer=None
self,
method,
request_serializer=None,
response_deserializer=None,
_registered_method=False,
):
base_callable = self._channel.unary_unary(
method, request_serializer, response_deserializer
)
if _registered_method:
base_callable = self._channel.unary_unary(
method,
request_serializer,
response_deserializer,
_registered_method,
)
else:
base_callable = self._channel.unary_unary(
method, request_serializer, response_deserializer
)
if isinstance(self._interceptor, grpcext.UnaryClientInterceptor):
return _InterceptorUnaryUnaryMultiCallable(
method, base_callable, self._interceptor
)
return base_callable

def unary_stream(
self, method, request_serializer=None, response_deserializer=None
self,
method,
request_serializer=None,
response_deserializer=None,
_registered_method=False,
):
base_callable = self._channel.unary_stream(
method, request_serializer, response_deserializer
)
if _registered_method:
base_callable = self._channel.unary_stream(
method,
request_serializer,
response_deserializer,
_registered_method,
)
else:
base_callable = self._channel.unary_stream(
method, request_serializer, response_deserializer
)
if isinstance(self._interceptor, grpcext.StreamClientInterceptor):
return _InterceptorUnaryStreamMultiCallable(
method, base_callable, self._interceptor
)
return base_callable

def stream_unary(
self, method, request_serializer=None, response_deserializer=None
self,
method,
request_serializer=None,
response_deserializer=None,
_registered_method=False,
):
base_callable = self._channel.stream_unary(
method, request_serializer, response_deserializer
)
if _registered_method:
base_callable = self._channel.stream_unary(
method,
request_serializer,
response_deserializer,
_registered_method,
)
else:
base_callable = self._channel.stream_unary(
method, request_serializer, response_deserializer
)
if isinstance(self._interceptor, grpcext.StreamClientInterceptor):
return _InterceptorStreamUnaryMultiCallable(
method, base_callable, self._interceptor
)
return base_callable

def stream_stream(
self, method, request_serializer=None, response_deserializer=None
self,
method,
request_serializer=None,
response_deserializer=None,
_registered_method=False,
):
base_callable = self._channel.stream_stream(
method, request_serializer, response_deserializer
)
if _registered_method:
base_callable = self._channel.stream_stream(
method,
request_serializer,
response_deserializer,
_registered_method,
)
else:
base_callable = self._channel.stream_stream(
method, request_serializer, response_deserializer
)
if isinstance(self._interceptor, grpcext.StreamClientInterceptor):
return _InterceptorStreamStreamMultiCallable(
method, base_callable, self._interceptor
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
asgiref==3.7.2
attrs==23.2.0
Deprecated==1.2.14
grpcio==1.63.0
importlib-metadata==6.11.0
iniconfig==2.0.0
packaging==23.2
pluggy==1.4.0
protobuf==3.20.3
py==1.11.0
py-cpuinfo==9.0.0
pytest==7.1.3
pytest-asyncio==0.23.5
pytest-benchmark==4.0.0
tomli==2.0.1
typing_extensions==4.9.0
wrapt==1.16.0
zipp==3.17.0
-e opentelemetry-instrumentation
-e instrumentation/opentelemetry-instrumentation-grpc
12 changes: 9 additions & 3 deletions tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -247,8 +247,12 @@ envlist =
lint-instrumentation-wsgi

; opentelemetry-instrumentation-grpc
py3{8,9,10,11,12}-test-instrumentation-grpc
pypy3-test-instrumentation-grpc
; The numbers at the end of the environment names
; below mean these dependencies are being used:
; 0: grpcio==1.62.0
; 1: grpcio==1.63.0
py3{8,9,10,11,12}-test-instrumentation-grpc-{0,1}
pypy3-test-instrumentation-grpc-{0,1}
lint-instrumentation-grpc

; opentelemetry-instrumentation-sqlalchemy
Expand Down Expand Up @@ -446,7 +450,9 @@ commands_pre =
grpc: pip install opentelemetry-semantic-conventions@{env:CORE_REPO}\#egg=opentelemetry-semantic-conventions&subdirectory=opentelemetry-semantic-conventions
grpc: pip install opentelemetry-sdk@{env:CORE_REPO}\#egg=opentelemetry-sdk&subdirectory=opentelemetry-sdk
grpc: pip install opentelemetry-test-utils@{env:CORE_REPO}\#egg=opentelemetry-test-utils&subdirectory=tests/opentelemetry-test-utils
grpc: pip install -r {toxinidir}/instrumentation/opentelemetry-instrumentation-grpc/test-requirements.txt
grpc-0: pip install -r {toxinidir}/instrumentation/opentelemetry-instrumentation-grpc/test-requirements-0.txt
grpc-1: pip install -r {toxinidir}/instrumentation/opentelemetry-instrumentation-grpc/test-requirements-1.txt
lint-instrumentation-grpc: pip install -r {toxinidir}/instrumentation/opentelemetry-instrumentation-grpc/test-requirements-1.txt

wsgi: pip install opentelemetry-api@{env:CORE_REPO}\#egg=opentelemetry-api&subdirectory=opentelemetry-api
wsgi: pip install opentelemetry-semantic-conventions@{env:CORE_REPO}\#egg=opentelemetry-semantic-conventions&subdirectory=opentelemetry-semantic-conventions
Expand Down

0 comments on commit 7895e7d

Please sign in to comment.