From d43bfd9cc3fa6a9962615b150116811722beca9d Mon Sep 17 00:00:00 2001 From: Diego Hurtado Date: Tue, 23 Jul 2024 12:22:22 -0600 Subject: [PATCH] Add entry point test case --- .../pyproject.toml | 3 +++ .../test_aws_lambda_instrumentation_manual.py | 14 ++++++++++++++ 2 files changed, 17 insertions(+) diff --git a/instrumentation/opentelemetry-instrumentation-aws-lambda/pyproject.toml b/instrumentation/opentelemetry-instrumentation-aws-lambda/pyproject.toml index cbed1edb9e..4b461a4894 100644 --- a/instrumentation/opentelemetry-instrumentation-aws-lambda/pyproject.toml +++ b/instrumentation/opentelemetry-instrumentation-aws-lambda/pyproject.toml @@ -33,6 +33,9 @@ dependencies = [ [project.optional-dependencies] instruments = [] +[project.entry-points.opentelemetry_instrumentor] +aws_lambda= "opentelemetry.instrumentation.aws_lambda:AwsLambdaInstrumentor" + [project.urls] Homepage = "https://github.com/open-telemetry/opentelemetry-python-contrib/tree/main/instrumentation/opentelemetry-instrumentation-aws-lambda" diff --git a/instrumentation/opentelemetry-instrumentation-aws-lambda/tests/test_aws_lambda_instrumentation_manual.py b/instrumentation/opentelemetry-instrumentation-aws-lambda/tests/test_aws_lambda_instrumentation_manual.py index 372642a2ed..ad75a19b20 100644 --- a/instrumentation/opentelemetry-instrumentation-aws-lambda/tests/test_aws_lambda_instrumentation_manual.py +++ b/instrumentation/opentelemetry-instrumentation-aws-lambda/tests/test_aws_lambda_instrumentation_manual.py @@ -11,6 +11,7 @@ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. + import os from dataclasses import dataclass from importlib import import_module, reload @@ -37,6 +38,7 @@ from opentelemetry.trace.propagation.tracecontext import ( TraceContextTextMapPropagator, ) +from opentelemetry.util._importlib_metadata import entry_points from .mocks.api_gateway_http_api_event import ( MOCK_LAMBDA_API_GATEWAY_HTTP_API_EVENT, @@ -516,3 +518,15 @@ def test_no_op_tracer_provider(self): spans = self.memory_exporter.get_finished_spans() assert spans is not None self.assertEqual(len(spans), 0) + + def test_load_entry_point(self): + self.assertIs( + next( + iter( + entry_points( + group="opentelemetry_instrumentor", name="aws_lambda" + ) + ) + ).load(), + AwsLambdaInstrumentor, + )