PlaidEx.Telemetry.Handler (plaid_ex v1.0.0)

Copy Markdown View Source

Telemetry event handlers and attachment helpers.

PlaidEx emits :telemetry events for every significant operation. Attach handlers to integrate with your metrics backend, logging pipeline, or alerting system.

Attaching all handlers

# In your application.ex start/2:
PlaidEx.Telemetry.Handler.attach_all()

Event reference

HTTP events

  • [:plaid_ex, :http, :start] — request initiated
    • metadata: %{path, attempt, tenant_id, url}
  • [:plaid_ex, :http, :stop] — request completed
    • measurements: %{system_time}
    • metadata: %{path, status, duration_ms, attempt, tenant_id}
  • [:plaid_ex, :http, :error] — request failed (after retries)
    • metadata: %{path, error_code, error_type, status, attempt, tenant_id}
  • [:plaid_ex, :http, :retry] — retry scheduled
    • metadata: %{path, attempt, delay_ms, error_code, tenant_id}

Sync events

  • [:plaid_ex, :sync, :start] — sync cycle started
  • [:plaid_ex, :sync, :page] — page fetched and processed
    • measurements: %{added, modified, removed}
    • metadata: %{tenant_id, has_more, total_pages}
  • [:plaid_ex, :sync, :reauth_required] — item needs reauthentication

Webhook events

  • [:plaid_ex, :webhook, :received] — webhook received and ACK'd
    • metadata: %{webhook_type, webhook_code, item_id, tenant_id}
  • [:plaid_ex, :webhook, :dispatch] — dispatched to handler
    • measurements: %{duration_ms}
  • [:plaid_ex, :webhook, :duplicate] — duplicate discarded
  • [:plaid_ex, :webhook, :invalid_signature] — signature check failed

Circuit breaker events

  • [:plaid_ex, :circuit_breaker, :open] — circuit opened
    • measurements: %{failure_count}
    • metadata: %{environment}
  • [:plaid_ex, :circuit_breaker, :close] — circuit closed (recovered)

Rate limit events

  • [:plaid_ex, :rate_limit, :throttled] — request throttled client-side
    • metadata: %{tenant_id}

Summary

Functions

Attaches the built-in structured logging handler for all PlaidEx events.

Detaches the built-in handler.

Returns all event names emitted by PlaidEx.

Functions

attach_all(opts \\ [])

@spec attach_all(keyword()) :: :ok

Attaches the built-in structured logging handler for all PlaidEx events.

detach()

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

Detaches the built-in handler.

events()

@spec events() :: [[atom(), ...], ...]

Returns all event names emitted by PlaidEx.

handle_event(arg1, measurements, meta, arg4)

@spec handle_event([atom()], map(), map(), map()) :: :ok