Packages

Unofficial Elixir SDK for the OpenRouter API: chat, anthropic messages, embeddings, speech, transcription, OAuth PKCE, and a versioned model/provider catalog. Not affiliated with or endorsed by the OpenRouter team. Maintained by the San Francisco Voice Company.

Current section

Files

Jump to
openrouter_sdk lib openrouter_sdk telemetry.ex
Raw

lib/openrouter_sdk/telemetry.ex

defmodule OpenrouterSdk.Telemetry do
@moduledoc """
thin wrapper around `:telemetry.span/3`.
emits `[:openrouter_sdk, event, :start | :stop | :exception]` so
consumers can hook in their own tracing / metrics without us having
to know about it.
"""
@doc "run `fun` inside a telemetry span keyed by `event` (a list of atoms)"
@spec span([atom()], map(), (-> {result, map()})) :: result when result: var
def span(event, metadata, fun)
when is_list(event) and is_map(metadata) and is_function(fun, 0) do
:telemetry.span([:openrouter_sdk | event], metadata, fun)
end
end