agentleFS
thebharathkumarthebharathkumar/agent-flight-recorder/skills/otel-agent-tracing/SKILL.md

otel-agent-tracing

Skill0 starsChanged 4 months agoMITView on GitHub

Instrument a LangGraph or MCP agent with OpenTelemetry spans and

  • Installs packages

The file

We split this skill into the rules it gives an agent

2 rules. About 0 are common, 0 are distinctive, and 2 are very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈0

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 2

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Very specific:

    Start the local stack: docker compose -f <skill>/assets/docker-compose.yml up -d.

    line 46
  2. Very specific:

    Run the agent once with OTEL_EXPORTER_OTLP_ENDPOINT=http://localhost:4317, then open http://localhost:16686, select the service name, and …

    line 53

≈ “Common” is an estimate: at least 1 in 5 of the 350,495 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

OTel Agent Tracing

Adds OpenTelemetry instrumentation to an agent and stands up a local observability stack (OTel Collector, Jaeger, Grafana) with docker compose. Target: first trace visible in Jaeger within 5 minutes; references/first-trace.md is the walkthrough version of this procedure.

Procedure

  1. Detect the stack. Look for langgraph, fastmcp, or mcp in the project dependencies. This decides step 3.
  2. Install SDK deps in the target project: pip install "opentelemetry-sdk>=1.30,<2" "opentelemetry-exporter-otlp-proto-grpc>=1.30,<2". Copy templates/otel_setup.py into the project and call configure_otel(service_name=...) once at startup. It attaches an OTLP gRPC exporter when OTEL_EXPORTER_OTLP_ENDPOINT (or the otlp_endpoint argument) is set, and an OTLP JSON file exporter when file_export_path (or OTEL_FILE_EXPORT) is set. The file path works with no docker at all and feeds the trace-triage skill directly.
  3. Instrument by stack:
    • LangGraph: copy templates/langgraph_tracing.py and wrap each node with traced_node(graph_name, node_name, agent_id). Nodes become spans named {graph}.{node} carrying gen_ai.operation.name, agent.id, run.id, and turn from state; exceptions set ERROR status and, when the exception has a classification attribute, a failure.classification span attribute.
    • fastmcp (jlowin): native telemetry already emits semconv-shaped spans. Only step 2 is needed.
    • Official mcp SDK server: emit spans named {mcp.method.name} {target} with SpanKind.SERVER and the attributes in references/semconv.md. Prefer SDK-native OTel if the installed version ships it.
    • Warn if the project uses Traceloop's McpInstrumentor or logfire.instrument_mcp(): measured against OTel semconv v1.40.0, neither emits the required mcp.method.name attribute.
  4. Start the local stack: docker compose -f <skill>/assets/docker-compose.yml up -d. Services: otel-collector (4317 grpc, 4318 http), Jaeger UI (16686), Grafana (3000, Jaeger datasource provisioned). The collector also mirrors spans to captures/otlp.json for the trace-triage skill. If docker is unavailable, skip this step and use the file exporter from step 2 instead.
  5. Run the agent once with OTEL_EXPORTER_OTLP_ENDPOINT=http://localhost:4317, then open http://localhost:16686, select the service name, and confirm the trace renders. Show the user what to look for: one root span per run, child spans per node or tool call.
  6. Optional conformance check: references/conformance.md describes the OTel Weaver live-check loop that scores spans against the official semantic conventions.

Files

  • templates/otel_setup.py: SDK boilerplate plus the OTLP JSON file exporter.
  • templates/langgraph_tracing.py: per-node span wrapper.
  • assets/docker-compose.yml, assets/otel-collector-config.yaml, assets/grafana-provisioning/: the local stack.
  • references/first-trace.md: 5 minute walkthrough.
  • references/semconv.md: exact span names, attributes, and the four mcp.*.duration histograms worth emitting.
  • references/conformance.md: Weaver-based semconv self-audit.

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.