Solaris.Telemetry (Solaris v1.0.0)

Copy Markdown View Source

Telemetry integration for the Solaris client.

Emits :telemetry events on every API request and webhook. Compatible with TelemetryMetricsPrometheus, Telemetry.Metrics.ConsoleReporter, etc.

Events

EventMeasurementsMetadata
[:solaris, :request, :start]system_timemethod, path, attempt
[:solaris, :request, :stop]durationmethod, path, attempt, status, success
[:solaris, :request, :exception]durationmethod, path, kind, reason
[:solaris, :webhook, :received]system_timeevent_type, delivery_id
[:solaris, :webhook, :processed]durationevent_type, success
[:solaris, :token, :refreshed]system_timeexpires_in
[:solaris, :rate_limit, :hit]system_time

Attaching the default logger

# In application.ex start/2 or a mix task
Solaris.Telemetry.attach_default_logger(:debug)

Using with Telemetry.Metrics

defmodule MyApp.Metrics do
  def metrics do
    Solaris.Telemetry.metrics()
  end
end

Summary

Functions

Attaches a Logger-based telemetry handler for development/debugging.

Returns a specification to start this module under a supervisor.

Detaches the default logger handler attached by attach_default_logger/1.

Returns a list of Telemetry.Metrics definitions.

Functions

attach_default_logger(level \\ :debug)

@spec attach_default_logger(Logger.level()) :: :ok | {:error, :already_exists}

Attaches a Logger-based telemetry handler for development/debugging.

Logs every request and webhook at the specified level.

Examples

Solaris.Telemetry.attach_default_logger(:debug)

child_spec(init_arg)

Returns a specification to start this module under a supervisor.

See Supervisor.

detach_default_logger()

@spec detach_default_logger() :: :ok | {:error, :not_found}

Detaches the default logger handler attached by attach_default_logger/1.

metrics()

@spec metrics() :: [struct()]

Returns a list of Telemetry.Metrics definitions.

Pass the result to your metrics reporter.