Otel.SDK.Config.Selector (otel v0.2.0)

Copy Markdown View Source

Atom-name → canonical {module, config} normalization for SDK configuration values.

Three input forms are accepted everywhere a module is selected:

  • shortcut atom (:otlp, :console, :batch, :always_on, ...) — spec-blessed enum names mapped through built-in tables to project modules. The shortcut set is closed; only spec values defined in configuration/sdk-environment-variables.md L122-L131, L243-L265, and L143-L152 are accepted.
  • module atom (e.g. Otel.OTLP.Trace.SpanExporter.HTTP) — direct module reference, normalized to {Module, %{}}.
  • {module, config} tuple — passed through unchanged. Always the canonical form a provider expects at its start_link/1 boundary.

Same normalizers serve both code paths — Mix Config (config :otel, trace: [exporter: :otlp | Module | {Module, %{}}]) and OTEL_* env vars (which can only ever produce a shortcut atom because the spec enums are strings).

Public API

FunctionSpec section
trace_exporter/1sdk-environment-variables.md L243-L254
metrics_exporter/1L244, L258-L265
logs_exporter/1L245
trace_processor/1trace/sdk.md §SpanProcessor (no env var)
logs_processor/1logs/sdk.md §LogRecordProcessor (no env var)
sampler/1L143-L152
propagator/1L122-L131 (OTEL_PROPAGATORS)

Out of scope (future PRs)

  • :zipkin, :prometheus — exporters not implemented in this repo.
  • :logging — spec L254 deprecated, "SHOULD NOT be supported by new implementations".
  • :jaeger_remote / :parentbased_jaeger_remote samplers — depend on a remote sampling protocol not yet implemented.
  • :xray sampler — third-party.

Summary

Functions

Normalizes a logs exporter spec to {module, config} or :none.

Normalizes a log record processor selector to a module reference.

Normalizes a metrics exporter spec to {module, config} or :none.

Normalizes a single-propagator selector to a module reference.

Normalizes a sampler selector to {module, opts} (the shape the built-in Otel.SDK.Trace.Sampler.new/1 consumes).

Normalizes a trace exporter spec to {module, config} or :none.

Normalizes a span processor selector to a module reference. The caller wraps it with the exporter + processor knobs at composition time.

Functions

logs_exporter(module)

@spec logs_exporter(value :: atom() | module() | {module(), map()}) ::
  {module(), map()} | :none

Normalizes a logs exporter spec to {module, config} or :none.

logs_processor(module)

@spec logs_processor(value :: atom() | module()) :: module()

Normalizes a log record processor selector to a module reference.

metrics_exporter(module)

@spec metrics_exporter(value :: atom() | module() | {module(), map()}) ::
  {module(), map()} | :none

Normalizes a metrics exporter spec to {module, config} or :none.

propagator(name)

@spec propagator(value :: atom() | module()) :: module()

Normalizes a single-propagator selector to a module reference.

Spec L122-L131 enumerates eight known values; this SDK implements three: :tracecontext, :baggage, and :none. Other spec-named propagators (:b3, :b3multi, :jaeger, :xray, :ottrace) raise ArgumentError — their behaviours are not bundled in this package.

Custom propagator modules pass through unchanged so users can plug their own implementations of Otel.API.Propagator.TextMap.

sampler(module)

@spec sampler(value :: atom() | {atom() | module(), term()}) :: {module(), term()}

Normalizes a sampler selector to {module, opts} (the shape the built-in Otel.SDK.Trace.Sampler.new/1 consumes).

Accepts spec enum atoms (:always_on, :parentbased_always_on, ...), the parameterized {:traceidratio, ratio} / {:parentbased_traceidratio, ratio} tuples, a custom module, or a {module, opts} tuple passed through unchanged.

trace_exporter(module)

@spec trace_exporter(value :: atom() | module() | {module(), map()}) ::
  {module(), map()} | :none

Normalizes a trace exporter spec to {module, config} or :none.

trace_processor(module)

@spec trace_processor(value :: atom() | module()) :: module()

Normalizes a span processor selector to a module reference. The caller wraps it with the exporter + processor knobs at composition time.