Skip to content

Commit

Permalink
feat: Tolerate exceptions among experimental resource detectors
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
cruisehall authored Dec 29, 2024
1 parent 415c94f commit 2dbd4f4
Showing 1 changed file with 14 additions and 10 deletions.
24 changes: 14 additions & 10 deletions opentelemetry-sdk/src/opentelemetry/sdk/resources/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down

0 comments on commit 2dbd4f4

Please sign in to comment.