PlaidEx.Telemetry.OpenTelemetry (plaid_ex v1.0.0)

Copy Markdown View Source

OpenTelemetry span wrappers for distributed tracing.

Automatically propagates trace context across async operations (webhook dispatch, sync workers) using OpenTelemetry's context API.

Setup

# Add to deps:
{:opentelemetry, "~> 1.4"},
{:opentelemetry_exporter, "~> 1.7"},

# In config.exs:
config :opentelemetry,
  resource: [service: [name: "my-plaid-app"]],
  span_processor: :batch,
  traces_exporter: :otlp

Summary

Functions

Creates a span for a Plaid API call.

Captures a Plaid error as an OpenTelemetry span event. No-op without opentelemetry_api.

Wraps a function in an OpenTelemetry span. No-op if opentelemetry_api is not in deps.

Functions

api_span(product, endpoint, config, fun)

@spec api_span(String.t(), String.t(), PlaidEx.Config.t(), (-> result)) :: result
when result: term()

Creates a span for a Plaid API call.

record_error(error)

@spec record_error(PlaidEx.Error.t()) :: :ok

Captures a Plaid error as an OpenTelemetry span event. No-op without opentelemetry_api.

with_span(name, attributes \\ %{}, fun)

@spec with_span(String.t(), map(), (-> result)) :: result when result: term()

Wraps a function in an OpenTelemetry span. No-op if opentelemetry_api is not in deps.