Skip to content

Commit d0caca8

Browse files
authored
Merge branch 'main' into fix/prom-exporter-labels
2 parents 3486124 + a7fe4f8 commit d0caca8

File tree

6 files changed

+34
-13
lines changed

6 files changed

+34
-13
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1010
- prometheus-exporter: fix labels out of place for data points with different
1111
attribute sets
1212
([#4413](https://github.com/open-telemetry/opentelemetry-python/pull/4413))
13+
- Tolerates exceptions when loading resource detectors via `OTEL_EXPERIMENTAL_RESOURCE_DETECTORS`
14+
([#4373](https://github.com/open-telemetry/opentelemetry-python/pull/4373))
1315

1416
## Version 1.30.0/0.51b0 (2025-02-03)
1517

docs/examples/fork-process-model/flask-gunicorn/requirements.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ googleapis-common-protos==1.52.0
44
grpcio==1.56.2
55
gunicorn==22.0.0
66
itsdangerous==2.1.2
7-
Jinja2==3.1.4
7+
Jinja2==3.1.5
88
MarkupSafe==2.1.3
99
opentelemetry-api==1.20.0
1010
opentelemetry-exporter-otlp==1.20.0

docs/examples/fork-process-model/flask-uwsgi/requirements.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ googleapis-common-protos==1.52.0
44
grpcio==1.56.2
55
gunicorn==22.0.0
66
itsdangerous==2.1.2
7-
Jinja2==3.1.4
7+
Jinja2==3.1.5
88
MarkupSafe==2.1.3
99
opentelemetry-api==1.20.0
1010
opentelemetry-exporter-otlp==1.20.0

docs/getting_started/tests/requirements.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ idna==3.7
99
importlib-metadata==6.8.0
1010
iniconfig==2.0.0
1111
itsdangerous==2.1.2
12-
Jinja2==3.1.4
12+
Jinja2==3.1.5
1313
MarkupSafe==2.1.3
1414
packaging==24.0
1515
pluggy==1.3.0

opentelemetry-sdk/src/opentelemetry/sdk/resources/__init__.py

Lines changed: 17 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -203,16 +203,23 @@ def create(
203203

204204
resource_detector: str
205205
for resource_detector in otel_experimental_resource_detectors:
206-
resource_detectors.append(
207-
next(
208-
iter(
209-
entry_points(
210-
group="opentelemetry_resource_detector",
211-
name=resource_detector.strip(),
212-
) # type: ignore
213-
)
214-
).load()()
215-
)
206+
try:
207+
resource_detectors.append(
208+
next(
209+
iter(
210+
entry_points(
211+
group="opentelemetry_resource_detector",
212+
name=resource_detector.strip(),
213+
) # type: ignore
214+
)
215+
).load()()
216+
)
217+
except Exception: # pylint: disable=broad-exception-caught
218+
logger.exception(
219+
"Failed to load resource detector '%s', skipping",
220+
resource_detector,
221+
)
222+
continue
216223
resource = get_aggregated_resources(
217224
resource_detectors, _DEFAULT_RESOURCE
218225
).merge(Resource(attributes, schema_url))

opentelemetry-sdk/tests/resources/test_resources.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -800,3 +800,15 @@ def test_resource_detector_entry_points_host(self):
800800
resource = Resource({}).create()
801801
self.assertIn(HOST_NAME, resource.attributes)
802802
self.assertIn(HOST_ARCH, resource.attributes)
803+
804+
@patch.dict(
805+
environ,
806+
{OTEL_EXPERIMENTAL_RESOURCE_DETECTORS: "doesnotexist,host"},
807+
clear=True,
808+
)
809+
def test_resource_detector_entry_points_tolerate_missing_detector(self):
810+
resource = Resource({}).create()
811+
self.assertEqual(
812+
resource.attributes["telemetry.sdk.language"], "python"
813+
)
814+
self.assertIn(HOST_NAME, resource.attributes)

0 commit comments

Comments
 (0)