opentelemetry-specification
opentelemetry-specification copied to clipboard
No clear API defined for resource detector libraries
What are you trying to achieve?
We have specified the way to load resource attributes from the environment via resource detector packages.
The Resource SDK spec says:
Resource detector packages MUST provide a method that returns a resource. This can then be associated with TracerProvider or MeterProvider instances as described above.
But it never defined exactly what the method is called. This may end up in a situation where each library exposes a method with a different name which then creates problems if such packages are to be loaded/invoked automatically (e.g., by an agent). This would make implementing something like #2948 impossible.
What did you expect to see?
Clear specification of what a resource detector package must provide, giving which method it must have, similar to what we do for Samplers for example.
Since many languages have resource detectors implemented already, a few pointers how it looks like right now:
As I expected, already inconsistent behavior =/
For Go it is Detector.Detect: https://pkg.go.dev/go.opentelemetry.io/otel/sdk/resource#Detector
For C++ and Envoy it's also Detect.
So I think we should add this method to the specification. It seems it's the most common denominator.
A PR to clarify this would be welcome!
For java its ResourceProvider. Detectors that implement this interface are able to contribute to the resource generated by opentelemetry-sdk-extension-autoconfigure, which is java's tool for automatically configuring the SDK based on environment.