Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

No clear API defined for resource detector libraries #4016

Open
joaopgrassi opened this issue Apr 26, 2024 · 6 comments
Open

No clear API defined for resource detector libraries #4016

joaopgrassi opened this issue Apr 26, 2024 · 6 comments
Labels
spec:resource Related to the specification/resource directory triage:accepted:ready Ready to be implemented. Small enough or uncontroversial enough to be implemented without sponsor

Comments

@joaopgrassi
Copy link
Member

joaopgrassi commented Apr 26, 2024

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.

@joaopgrassi joaopgrassi added the spec:resource Related to the specification/resource directory label Apr 26, 2024
@svrnm
Copy link
Member

svrnm commented Apr 26, 2024

Since many languages have resource detectors implemented already, a few pointers how it looks like right now:

  • Go has resource.with<X>, see below
  • Erlang has a resource detector behaviour
  • Java has <X>Resource.get()
  • JS has <X>detector.detect(<config>)
  • ...

@joaopgrassi
Copy link
Member Author

  • Go has resource.with<X>

  • Erlang has a resource detector behaviour

  • Java has <X>Resource.get()

  • JS has <X>detector.detect(<config>)

As I expected, already inconsistent behavior =/

@MrAlias
Copy link
Contributor

MrAlias commented Apr 26, 2024

For Go it is Detector.Detect: https://pkg.go.dev/go.opentelemetry.io/otel/sdk/resource#Detector

@danielgblanco danielgblanco added the triage:deciding:community-feedback Open to community discussion. If the community can provide sufficient reasoning, it may be accepted label Apr 29, 2024
@joaopgrassi
Copy link
Member Author

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.

@austinlparker austinlparker added triage:accepted:ready Ready to be implemented. Small enough or uncontroversial enough to be implemented without sponsor and removed triage:deciding:community-feedback Open to community discussion. If the community can provide sufficient reasoning, it may be accepted labels Jul 23, 2024
@austinlparker
Copy link
Member

A PR to clarify this would be welcome!

@jack-berg
Copy link
Member

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
spec:resource Related to the specification/resource directory triage:accepted:ready Ready to be implemented. Small enough or uncontroversial enough to be implemented without sponsor
Projects
Status: Spec - Accepted
Development

No branches or pull requests

6 participants