Instrument OpenAI Assistants
Recipe — instrument OpenAI / Assistants. Pointer to the SDK samples.
Canonical samples:
samples/integrations/openai_traced.py— manual trace upload around an OpenAI completionsamples/integrations/openai_instrumented.py— zero-code auto-instrumentation viainstrument_openai(),@trace,span()
pip install --extra-index-url https://sdk.layerlens.ai/package 'layerlens[openai]'The OpenAI provider adapter emits one event per chat or embedding call: model.invoke (with parameters, token counts, latency, response_id, system_fingerprint, full messages); cost.record (USD computed from pricing table); tool.call (one per tool when present); policy.violation (on SDK error). Streaming responses emit a single consolidated model.invoke on completion.
Capture configs: CaptureConfig.minimal(), .standard(), or .full(). Circuit breaker opens after 10 consecutive sink failures (60s cooldown, silent drop while open).
See also
Last updated
Was this helpful?