一键导入
otel-livekit-style
LiveKit Agents OpenTelemetry style: entrypoint/session lifecycle spans, shutdown callbacks, session metrics, and LLM turn cost metrics.
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
菜单
LiveKit Agents OpenTelemetry style: entrypoint/session lifecycle spans, shutdown callbacks, session metrics, and LLM turn cost metrics.
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
基于 SOC 职业分类
| name | otel-livekit-style |
| description | LiveKit Agents OpenTelemetry style: entrypoint/session lifecycle spans, shutdown callbacks, session metrics, and LLM turn cost metrics. |
LiveKit session lifecycle begins in entrypoint(ctx) and cleanup ends in
ctx.add_shutdown_callback(on_shutdown).
It is okay for a voice.session span to end in on_shutdown, because the
operation crosses a framework callback boundary. Make it active while child
work is registered and started.
async def entrypoint(ctx: agents.JobContext) -> None:
await ctx.connect()
started_at = asyncio.get_running_loop().time()
session_span = tracer.start_span(
"voice.session",
attributes={
"tenant.id": tenant_id,
"user.id": user_id,
"voice.room_name": room_name,
},
)
with trace.use_span(session_span, end_on_exit=False):
voice_sessions_started.add(1, {
"tenant.id": tenant_id,
"voice.room_name.present": room_name != "unknown",
})
async def on_shutdown() -> None:
duration_ms = int((asyncio.get_running_loop().time() - started_at) * 1000)
session_span.set_attribute("voice.duration_ms", duration_ms)
voice_session_duration.record(duration_ms, {
"tenant.id": tenant_id,
"voice.disconnect_reason": disconnect_reason,
"outcome": "success",
})
session_span.end()
ctx.add_shutdown_callback(on_shutdown)
await _deliver_initial_greeting(...)
Do not replace this with a short voice.session.end span inside shutdown.
Bounded operations still get their own decorators.
@tracer.start_as_current_span("voice.deliver_initial_greeting")
async def _deliver_initial_greeting(...):
...
Use both:
voice.sessions.started counter at entrypoint startvoice.session.duration_ms histogram in shutdownAdd product metrics for important voice events, e.g.
voice.greetings.delivered.
For a minimal LiveKit fixture, a good smoke path imports the agent and executes one tiny instrumented function or starts a span/log record with a local OTLP endpoint. Checking that tracer/meter objects are non-None is not enough.
Every LLM provider/call site in the voice agent needs:
Name the span for the product operation, not the provider transport call.
For example, prefer llm.voice_response or llm.generate_copy over
llm.anthropic.messages.create.
llm_cost_usd.add(cost, {
"tenant.id": tenant_id,
"llm.provider": "anthropic",
"llm.model": model,
"llm.use_case": "voice.initial_greeting",
"llm.call_site": "_call_mug_copy_llm",
"outcome": "success",
})
FastAPI OpenTelemetry style: native FastAPIInstrumentor, centralized observability init, Python decorators, OTLP logs, and LLM cost metrics.
Next.js/Vercel OpenTelemetry style: instrumentation.ts, @vercel/otel bootstrap, native @opentelemetry/api call sites, env docs, and no raw NodeSDK replacement.
General OpenTelemetry onboarding style for Superlog managed agents: native APIs, signal quality, env vars, LLM metrics, and smoke checks.
Python OpenTelemetry style: module-scope tracers/meters, decorators for bounded work, error spans, logs, and no wrappers.
Supabase Edge Function observability style: tiny provider-neutral OTel-shaped shim, OTLP export config, traces/logs/metrics, and LLM cost metrics.
Onboard a project to Superlog by installing OpenTelemetry traces, logs, and metrics across every app and service in the repo. Triggers on requests like "install Superlog", "set up Superlog", "add Superlog telemetry", "onboard this repo to Superlog", "instrument with OpenTelemetry for Superlog".