一键导入
otel-fastapi-style
FastAPI OpenTelemetry style: native FastAPIInstrumentor, centralized observability init, Python decorators, OTLP logs, and LLM cost metrics.
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
菜单
FastAPI OpenTelemetry style: native FastAPIInstrumentor, centralized observability init, Python decorators, OTLP logs, and LLM cost metrics.
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
基于 SOC 职业分类
| name | otel-fastapi-style |
| description | FastAPI OpenTelemetry style: native FastAPIInstrumentor, centralized observability init, Python decorators, OTLP logs, and LLM cost metrics. |
Use native FastAPI instrumentation. Do not replace request handling with manual middleware just to create spans.
from fastapi import FastAPI
from opentelemetry.instrumentation.fastapi import FastAPIInstrumentor
def init_observability(app: FastAPI) -> bool:
...
FastAPIInstrumentor.instrument_app(app)
return True
Keep FastAPIInstrumentor.instrument_app(app) with the rest of the
observability setup so the bootstrap is easy to reason about. If the generated
token is not claimed yet because signup is still in progress, it is still okay
to initialize providers; ingest may reject exports until the browser flow
finishes.
Initialize before serving user traffic.
app = FastAPI(title="Mugline API")
init_observability(app)
Use module-scope OTel objects and decorators for helpers that auto-instrumented HTTP spans cannot see.
tracer = trace.get_tracer("mugline.api")
meter = metrics.get_meter("mugline.api")
@tracer.start_as_current_span("mug.recommend")
async def recommend_mug(*, tenant_id: str, preference: str) -> dict[str, str]:
span = trace.get_current_span()
span.set_attribute("tenant.id", tenant_id)
...
For OTLP-forwarded stdlib logs, configure all of these:
LoggerProviderset_logger_provider(logger_provider)OTLPLogExporterLoggingHandlerLoggingInstrumentor().instrument(...)LLM routes need token coverage:
llm.tokens.inputllm.tokens.outputTag explicit token counters with tenant, provider, model, use case, call site, and outcome only when provider instrumentation cannot capture token usage. Do not add app-side LLM cost metrics or pricing tables; Superlog estimates cost centrally from provider/model/token data.
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.