From 2dbd4f4775da48da70bd3c48d7ddd26f97341141 Mon Sep 17 00:00:00 2001 From: Cruise Hall <19177287+cruisehall@users.noreply.github.com> Date: Sun, 29 Dec 2024 14:40:03 -0600 Subject: [PATCH] feat: Tolerate exceptions among experimental resource detectors OTEL resource creation will proceed even if one of the resource detector entry points indicated by the `OTEL_EXPERIMENTAL_RESOURCE_DETECTORS` env var fails to load. In fact, subsequent resource detector entry points will continue to be processed as well. --- .../opentelemetry/sdk/resources/__init__.py | 24 +++++++++++-------- 1 file changed, 14 insertions(+), 10 deletions(-) diff --git a/opentelemetry-sdk/src/opentelemetry/sdk/resources/__init__.py b/opentelemetry-sdk/src/opentelemetry/sdk/resources/__init__.py index a52573ac1c..c1d461d9db 100644 --- a/opentelemetry-sdk/src/opentelemetry/sdk/resources/__init__.py +++ b/opentelemetry-sdk/src/opentelemetry/sdk/resources/__init__.py @@ -200,16 +200,20 @@ def create( resource_detector: str for resource_detector in otel_experimental_resource_detectors: - resource_detectors.append( - next( - iter( - entry_points( - group="opentelemetry_resource_detector", - name=resource_detector.strip(), - ) # type: ignore - ) - ).load()() - ) + try: + resource_detectors.append( + next( + iter( + entry_points( + group="opentelemetry_resource_detector", + name=resource_detector.strip(), + ) # type: ignore + ) + ).load()() + ) + except: + # TODO emit warning per failed detector? + continue resource = get_aggregated_resources( resource_detectors, _DEFAULT_RESOURCE ).merge(Resource(attributes, schema_url))