View Source Erlang/Elixir OpenTelemetry SDK EEF Observability WG
project GitHub Workflow Status

The SDK is an implementation of the OpenTelemetry API and should be included in your final deployable artifact (usually an OTP Release).


The SDK starts up its supervision tree on boot, so initial configuration must be done through the Application or OS environment variables. The following example configurations show configuring the SDK to use the batch span processor which then exports through the OpenTelemetry Protocol over HTTP to http://localhost:4318, encoding the Spans with protobufs.

  [{span_processor, batch},
   {traces_exporter, otlp}]},

  [{otlp_protocol, http_protobuf},
   {otlp_endpoint, "http://localhost:4318"}]}]}
config :opentelemetry, 
  span_processor: :batch,
  traces_exporter: :otlp

config :opentelemetry_exporter,
  otlp_protocol: :http_protobuf,
  otlp_endpoint: "http://localhost:4318"

The following sections detail the available SDK options and how to configure them through either the OS or Application environment.

Automatically Created Tracers

Spans are created by Tracers and each Tracer is associated with a name and version. The name and version can be anything, but the macros provided by the API will always use a Tracer with name/version of the OTP Application the macro is used in. To facilitate this a Tracer is created for each available Application when the SDK boots. It relies on mapping modules to Applications, so if there is a huge number of modules in a Release the time to create all these Tracers can become more than you want to wait on boot.


Disabling the creation of Tracers at start-up means when the macros are used to start Spans the name and version of the Tracer creating those Spans will be undefined, but everything will continue to work as before.


Propagators define how to inject and extract context in requests to or from external services. A propagator that works on key/value pairs of text, like HTTP headers, can be any module that implements the otel_propagator_text_map behaviour. There are 4 built-in propagators that are part of the API:

  • tracecontext: Encodes the Trace context as headers traceparent and tracestate.
  • baggage: Encodes baggage elements as a comma delimited list under header key baggage.
  • b3multi: The propagation format from Zipkin that breaks the context across multiple headers, X-B3-TraceId, X-B3-SpanId and X-B3-Sampled.
  • b3: The propagation format from Zipkin that encodes to a single header b3.
OTEL_PROPAGATORStext_map_propagators[tracecontext,baggage]List of propagators (tracecontext, baggage, b3multi, b3)

Batch Span Processor

Span processors are invoked when a Span is started and when it ends. The default processor is the batch processor (otel_batch_processor) -- also available is the simple processor (otel_simple_processor) which blocks on every finished Span until it is exported.

The batch processor waits bsp_scheduled_delay_ms milliseconds or until the buffer of finished Spans reaches bsp_max_queue_size and then exports the spans together. The export is canceled if it takes longer than bsp_exporting_timeout_ms.


Resource Detectors

Resources capture information about the environment the program is running in. For example, a process producing telemetry that is running in a container on Kubernetes has a Pod name, it is in a namespace and possibly is part of a Deployment which also has a name. All three of these attributes can be included in the Resource.

OTEL_RESOURCE_DETECTORSresource_detectors[otel_resource_env_var, otel_resource_app_env]list of modules

The default detectors read resource attributes from the OS environment variable OTEL_RESOURCE_ATTRIBUTES and Application environment variable resource.

Span Limits

The number of Attributes, Events and Links on a Span are limited, as well as the length of an Attribute's value. When the limit is reached any additional Attributes, Events or Links are dropped and Attribute values larger than the length limit are truncated.

OTEL_SPAN_ATTRIBUTE_VALUE_LENGTH_LIMITattribute_value_length_limitinfinityinteger | infinity

| OTEL_LINK_ATTRIBUTE_COUNT_LIMIT | attribute_per_link_limit | 128 | integer

Read more in the specification about Span limits and Attribute limits.

Span Sweeper

Because of Erlang's "Let It Crash" philosophy it is possible that at some point a Span will never have end_span called. To handle these cases the SDK includes a process that will periodically check the active Span table for Spans that are older than the span_ttl and will drop or end the Span depending on the configured strategy. The failed_attribute_and_end_span strategy will add the attribute finished_by_sweeper with value true to the Span before calling end_span.

The sweeper's configuration is a map under environment key sweeper.

OTEL_SPAN_SWEEPER_INTERVALinterval600000integer | infinity
OTEL_SPAN_SWEEPER_STRATEGYstrategydropdrop | end_span | failed_attribute_and_end_span | fun/1
OTEL_SPAN_SWEEPER_SPAN_TTLspan_ttl1800000integer | infinity
OTEL_SPAN_SWEEPER_STORAGE_SIZEstorage_sizeinfinityinteger | infinity


Read OpenTelemetry project contributing guide for general information about the project.