Accrue.Telemetry.OTel (accrue v0.2.0)

Copy Markdown View Source

Optional OpenTelemetry bridge for Accrue telemetry spans.

The module is always available, but calls into OpenTelemetry only when OpenTelemetry.Tracer is loaded. Without the optional dependency, span/3 executes the passed function unchanged and emits no compiler warnings.

Summary

Functions

Returns the allowlisted, PII-free OpenTelemetry attributes for metadata.

Wraps fun in an OpenTelemetry span when the optional dependency is loaded.

Converts an Accrue telemetry event name to the dotted OTel span name.

Types

event_name()

@type event_name() :: [atom()]

Functions

sanitize_attributes(metadata)

@spec sanitize_attributes(map()) :: map()

Returns the allowlisted, PII-free OpenTelemetry attributes for metadata.

span(event, metadata \\ %{}, fun)

@spec span(event_name(), map(), (-> result)) :: result when result: var

Wraps fun in an OpenTelemetry span when the optional dependency is loaded.

span_name(event)

@spec span_name(event_name()) :: String.t()

Converts an Accrue telemetry event name to the dotted OTel span name.