View Source otel_resource (opentelemetry v1.5.0)

A Resource is attributes representing the entity producing telemetry. For example, by default the language (Erlang), name of this library (opentelemetry), and version of this library are included in the Resource.

This module provides the functional interface for working with the resource record.

The opentelemetry library supports resource detectors to detect attributes to include in the Resource. See otel_resource_detector for the behaviour to detect resources, and the otel_resource_app_env and otel_resource_env_var modules for built-in implementations.

See the OpenTelemetry Resource documentation for more information on Resources.

Summary

Types

values allowed in attributes of a resource are limited
A schema URL for the resource.
t/0
The type that represents a resource.
A resource value.

Functions

Returns the attributes of the given Resource.

Creates a new resources from the given map or list of Attributes and with the given SchemaUrl.

Returns true if Key is valid and part of the given resource.

Merges the two given resources.

Returns the schema URL of the resource.

Types

-type key() :: unicode:latin1_binary() | atom().
values allowed in attributes of a resource are limited
-type schema_url() :: uri_string:uri_string().
A schema URL for the resource.
-type t() ::
    #resource{schema_url :: schema_url() | undefined, attributes :: otel_attributes:t()} |
    undefined.
The type that represents a resource.
-type value() :: unicode:latin1_binary() | integer() | float() | boolean().
A resource value.

Functions

-spec attributes(t()) -> otel_attributes:t() | undefined.

Returns the attributes of the given Resource.

This function returns undefined only in case Resource is an invalid argument (not a resource record).
-spec create(#{key() => value()} | [{key(), value()}]) -> t().

Equivalent to create(Attributes, undefined).

-spec create(#{key() => value()} | [{key(), value()}], schema_url() | undefined) -> t().

Creates a new resources from the given map or list of Attributes and with the given SchemaUrl.

This function verifies each key and value, and drops any that don't pass verification.
-spec is_key(key(), t()) -> boolean().
Returns true if Key is valid and part of the given resource.
Link to this function

merge(Resource, CurrentResource)

View Source
-spec merge(t(), t()) -> t().

Merges the two given resources.

In case of collision, the first argument (Resource) takes precedence.
-spec schema_url(t()) -> schema_url() | undefined.
Returns the schema URL of the resource.