Coffrify. Runtime. Telemetry
(Coffrify v0.9.0)
View Source
Thin wrappers around :telemetry.execute/3.
Events emitted:
[:coffrify, :request, :start]—%{system_time},%{method, url, attempt}[:coffrify, :request, :stop]—%{duration}(native units),%{method, url, status, attempt}[:coffrify, :request, :exception]—%{kind, reason, stacktrace},%{method, url, attempt}[:coffrify, :request, :retry]—%{delay_ms},%{method, url, attempt, reason}[:coffrify, :webhook, :verified]—%{},%{event_type, event_id}[:coffrify, :webhook, :rejected]—%{},%{reason, event_type}
OpenTelemetry
attach_opentelemetry/1 attaches handlers that translate the bundled
events into OpenTelemetry spans and metrics. Requires opentelemetry_api
in your app's deps.
Coffrify.Runtime.Telemetry.attach_opentelemetry()
Summary
Functions
Attach a logger handler that emits OpenTelemetry-friendly metadata.
Requires opentelemetry_api in your dependencies.
Emit [:coffrify, :request, :retry].
Span the work of fun and emit start/stop/exception events.
Emit [:coffrify, :webhook, :rejected].
Emit [:coffrify, :webhook, :verified].
Functions
@spec attach_opentelemetry(keyword()) :: :ok | {:error, :otel_not_loaded}
Attach a logger handler that emits OpenTelemetry-friendly metadata.
Requires opentelemetry_api in your dependencies.
This helper turns every [:coffrify, :request, :*] event into a
OpenTelemetry.Tracer.with_span/3-compatible event using the
Logger.metadata/1 bridge. Wire it once at boot:
Coffrify.Runtime.Telemetry.attach_opentelemetry()Returns :ok on success, {:error, :otel_not_loaded} otherwise.
@spec retry(map()) :: :ok
Emit [:coffrify, :request, :retry].
Span the work of fun and emit start/stop/exception events.
@spec webhook_rejected(map()) :: :ok
Emit [:coffrify, :webhook, :rejected].
@spec webhook_verified(map()) :: :ok
Emit [:coffrify, :webhook, :verified].