open-telemetry / open-telemetry/opentelemetry-python

Resource Detectors produce blank Exception() after 5 seconds

Open
#3,644 4 comments 0 reactions 1 assignee View on GitHub

@jeremydvoss is already working on this.

Since Jan 23, 2024.

bug
Dominant language
Python
Stars
2.6k
Forks
1k
Avg merge
4d 15h
Merged PRs (30d)
19

Description

Describe your environment
Resource Detector only get 5 seconds by default to run. However, instead of ending the process after 5 seconds, a blank "Exception()" is creating resulting in the follow warning:
Exception in detector <opentelemetry.resource.detector.<RESOURCE DETECTOR CLASS> object at 0x000002B955D43D60>, ignoring
Note that the Exception string is blank resulting in 2 whitespaces: Exception__in...
This blank exception is causing confusion among Azure customers. And perhaps more importantly, the process still hangs.

 
Steps to reproduce

  1. Create a resource detector that sleeps for more than 5 seconds (try 10-20):
from opentelemetry.sdk.resources import Resource, ResourceDetector

from time import sleep

class SleepingResourceDetector(ResourceDetector):
    # pylint: disable=no-self-use
    def detect(self) -> "Resource":
        sleep(20)
        attributes = {}
        return Resource(attributes)
  1. Set resource detector entry point in pyproject.toml
[project.entry-points.opentelemetry_resource_detector]
sleeping = "opentelemetry.resource.detector.sleeping:SleepingResourceDetector"
  1. Install package to install entry point
  2. Point sdk to resource detector: export OTEL_EXPERIMENTAL_RESOURCE_DETECTORS=sleeping
  3. Create a Resource: Resource.create() This will eventually call get_aggregated_resources

What is the expected behavior?
The "concurrent future" setup should gracefully exit the process and not print out a confusing blank warning.

What is the actual behavior?
Process hangs and confusing warning message with blank error.

Additional context
Add any other context about the problem here.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.