superloglabs/skills

otel-fastapi-style

FastAPI OpenTelemetry style: native FastAPIInstrumentor, centralized observability init, Python decorators, OTLP logs, and LLM cost metrics.

First seen May 8, 2026

Installation

$ npx skills add superloglabs/skills --skill otel-fastapi-style

Similar popular skills

Related neighbors and high-traction skills in the same topics — useful to compare before installing.

Also in this package

Other skills from superloglabs/skills · top by installs.

npx skills add superloglabs/skills

Browse all from superloglabs/skills

More details

Agent compatibility

Declared targets from SKILL.md / docs. Unmarked agents are not listed — the skill may still install via the CLI.

Claude Code Not declared
Cursor Not declared
Codex Not declared
GitHub Copilot Not declared
Windsurf Not declared
Gemini CLI Not declared
Cline Not declared
OpenCode Not declared

Repository health

Stars 13
License LICENSE
Default branch main
Open issues 0
Status Active

Package contents

Files included with this skill beyond the listing page.

  • skill md SKILL.md 2,006 B
  • docs SUMMARY.md 1,942 B

History

  1. First seen on skills.sh
  2. First recorded snapshot · 372 installs

SKILL.md

OTel FastAPI Style

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.

Entrypoint

Initialize before serving user traffic.

app = FastAPI(title="Mugline API")
init_observability(app)

Bounded Work

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)
    ...

Logs

For OTLP-forwarded stdlib logs, configure all of these:

  • LoggerProvider
  • setloggerprovider(logger_provider)
  • OTLPLogExporter
  • LoggingHandler
  • LoggingInstrumentor().instrument(...)

LLM Calls

LLM routes need token coverage:

  • llm.tokens.input
  • llm.tokens.output

Tag 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.