OpenTelemetry
Observability
Traces and metrics for BEAM apps (OTLP/HTTP JSON export).
Call configure from boot with an opaque Config. The runtime does not read OTEL_* env vars; bind whatever names you want with Env and pass them in.
Until configure runs, spans and metrics are no-ops. HTTP (Server), outbound Req, and Repo transactions are instrumented automatically once configured.
Types
Config
type Config = ConfigExporter and signal settings.
Examples
OpenTelemetry.defaultConfigValues
defaultConfig
defaultConfig : ConfigDisabled config (no export).
Examples
OpenTelemetry.defaultConfigserviceName
serviceName : String -> Config -> ConfigResource service.name.
Examples
OpenTelemetry.serviceName "my-app" configotlpEndpoint
otlpEndpoint : String -> Config -> ConfigOTLP collector base URL (for example http://127.0.0.1:4318).
Examples
OpenTelemetry.otlpEndpoint "http://127.0.0.1:4318" configtracesEnabled
tracesEnabled : Bool -> Config -> ConfigEnable or disable trace export (default true when an endpoint is set).
Examples
OpenTelemetry.tracesEnabled True configmetricsEnabled
metricsEnabled : Bool -> Config -> ConfigEnable or disable metrics export (default true when an endpoint is set).
Examples
OpenTelemetry.metricsEnabled True configconfigure
configure : Config -> ()Install config and start the SDK once. Call from application boot.
Examples
OpenTelemetry.defaultConfig
|> OpenTelemetry.serviceName "my-app"
|> OpenTelemetry.otlpEndpoint "http://127.0.0.1:4318"
|> OpenTelemetry.configurewithSpan
withSpan : String -> List (String, String) -> (() -> a) -> aRun thunk inside a named span with string attributes.
Examples
OpenTelemetry.withSpan "checkout" [ ("cart_id", id) ] (\() -> charge cart)setAttribute
setAttribute : String -> String -> ()Set an attribute on the current span.
Examples
OpenTelemetry.setAttribute "user.id" userIdaddEvent
addEvent : String -> List (String, String) -> ()Add a timed event on the current span.
Examples
OpenTelemetry.addEvent "cache.miss" [ ("key", key) ]counter
counter : String -> Int -> ()Add n to a counter instrument.
Examples
OpenTelemetry.counter "http.requests" 1histogram
histogram : String -> Float -> ()Record a histogram measurement.
Examples
OpenTelemetry.histogram "http.duration_ms" 12.5traceId
traceId : () -> Maybe StringCurrent trace id when a span is active.
Examples
OpenTelemetry.traceId ()spanId
spanId : () -> Maybe StringCurrent span id when a span is active.
Examples
OpenTelemetry.spanId ()