一键导入
otel-livekit-style
LiveKit Agents OpenTelemetry style: entrypoint/session lifecycle spans, shutdown callbacks, session metrics, and LLM turn token counters.
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
菜单
LiveKit Agents OpenTelemetry style: entrypoint/session lifecycle spans, shutdown callbacks, session metrics, and LLM turn token counters.
用 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 token counters. |
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:
llm.tokens.input, llm.tokens.output)Do not add llm.cost_usd metrics; Superlog estimates cost centrally from
provider/model/token data.
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.
attrs = {
"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",
}
llm_tokens_input.add(input_tokens, attrs)
llm_tokens_output.add(output_tokens, attrs)
Pull production observability context from the Superlog MCP to ground debugging, incident response, and 'how is this behaving in prod right now?' questions. Triggers whenever the user is investigating a bug, regression, or incident; asking about real traffic, error rates, latency, or throughput; validating a deploy; or wants the recent history of a service.
Expo / React Native OpenTelemetry style: bootstrap guards, init ordering, inline public ingest token, mobile-compatible exporters, and product action spans.
Generic OpenTelemetry style fallback for languages without a dedicated otel-*-style skill (Go, Java/Kotlin, Ruby, Rust, .NET/C#, PHP, Elixir, plain Node, etc.). Native SDK APIs, module-scope tracers/meters, bounded spans, error recording, OTLP logs, and resource attributes.
Next.js/Vercel OpenTelemetry style: instrumentation.ts, @vercel/otel bootstrap, native @opentelemetry/api call sites, inline public ingest token, 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.