View Source otel_resource_detector behaviour (opentelemetry v1.5.0)

Resource detectors are responsible for reading in attributes about the runtime environment of a node (such as an environment variable or some metadata endpoint provided by a cloud host) and returning a otel_resource:t() made from those attributes.

This module is meant for users who intend to write their own resource detectors.

This behaviour is a state machine (started by the opentelemetry application) which spawns a process for each detector, collects the results of running each, and merges them in the order they are defined. Once the state machine process is ready, it will reply to get_resource/1 calls with the final otel_resource:t().

Summary

Callbacks

Function that takes the configuration of a resource detector and returns a resource.

Functions

Gets the resource formed by detecting attributes through resource detectors.

Callbacks

-callback get_resource(term()) -> otel_resource:t().
Function that takes the configuration of a resource detector and returns a resource.

Functions

-spec get_resource() -> otel_resource:t().

Equivalent to get_resource(6000).

-spec get_resource(timeout()) -> otel_resource:t().

Gets the resource formed by detecting attributes through resource detectors.

If the call doesn't complete within the given Timeout then an empty resource is returned.