Agent skill

Ag2 Telemetry

by ag2ai in ag2ai/build-with-ag2

Add OpenTelemetry traces to an AG2 beta Agent via TelemetryMiddleware (autogen.beta.middleware.builtin).

Apache-2.0Auto-check passedDevOps & Cloud

Install Ag2 Telemetry

skills CLI
$ npx skills add ag2ai/build-with-ag2 --skill ag2-telemetry -a claude-code

Project install by default; add -g for ~/.claude/skills/.

GitHub CLI
$ gh skill install ag2ai/build-with-ag2 ag2-telemetry --agent claude-code

Project scope by default; add --scope user for a personal install. Needs GitHub CLI 2.90.0 or later (public preview).

Manual copy
$ git clone --depth 1 https://github.com/ag2ai/build-with-ag2.git skills-src && mkdir -p .claude/skills && cp -r skills-src/.agents/skills/ag2-telemetry .claude/skills/ag2-telemetry && rm -rf skills-src

Use ~/.claude/skills/ instead of .claude/skills for a personal install. The folder must contain SKILL.md.

Claude Code skills documentation · loads skills from .claude/skills/

Facts

Skill name
ag2-telemetry
GitHub stars
252
Token cost
~1.9k tokens
SKILL.md length
531 words
Files
1
Skills in repo
16
Repo updated
First seen
Licence
Apache-2.0

At a glance

Add OpenTelemetry traces to an AG2 beta Agent via TelemetryMiddleware (autogen.beta.middleware.builtin).

  • The user wants production-grade traces
  • SKILL.md covers When to use, Installation, 60-second recipe and Span hierarchy, plus 7 more sections
  • Calls pip
  • Latency analysis

What it does

Ag2 Telemetry is an agent skill from ag2ai/build-with-ag2. Add OpenTelemetry traces to an AG2 beta Agent via TelemetryMiddleware (autogen.beta.middleware.builtin). Emits spans for the full turn, each LLM call, each tool execution, and each human-input request, following the OpenTelemetry GenAI semantic conventions. Compatible with any OTLP backend — Jaeger, Grafana Tempo, Datadog, Honeycomb, Langfuse. Use when the user wants production-grade traces, latency analysis, token-usage attribution, or to ship telemetry into an existing observability stack.

Its SKILL.md is about 1.9k tokens, which your agent loads only when the skill is triggered. It is a single SKILL.md file with no bundled scripts.

It sits in DevOps & Cloud, covering Observability, Monitoring and alerting and LLM observability. It works with OpenTelemetry, Langfuse, Datadog and Grafana. The repository describes itself as: Sample code and application showcases to get you going with AG2 (formally AutoGen). The licence is Apache-2.0.

When your agent uses it

  • The user wants production-grade traces
  • Latency analysis
  • Token-usage attribution
  • Ship telemetry into an existing observability stack

Example prompts

  • “/ag2-telemetry”

Requirements

  • Python 3
  • Docker

What it can do on your machine

Read from SKILL.md and the folder at commit 29eeac3. It shows what the files ask for, not the result of running them.

  • Tool permissions

    Pre-approves nothing: there is no allowed-tools line, so your agent's usual permission prompts apply.

    From allowed-tools in the SKILL.md frontmatter.

  • Runs code

    Shell commands in SKILL.md call:

    • pip

    From the folder's file list and the shell code blocks in SKILL.md.

  • Network

    Links to these hosts (documentation or services it may open):

    • opentelemetry.io

    From URLs in SKILL.md, links to its own repository left out.

  • Credentials

    Names no API keys, tokens, secrets or passwords.

    From names ending in _API_KEY, _TOKEN, _SECRET, _KEY or _PASSWORD in SKILL.md.

Context cost

Ag2 Telemetry loads about 1.9k tokens when it runs. Until then it costs about 129 tokens; SKILL.md has 531 words of instructions outside code blocks.

Always · name and description, kept in context so the agent knows when to use it
~129
When it runs · the whole SKILL.md, loaded when a task matches
~1.9k

Estimates: characters ÷ 4, the usual rule of thumb; real counts depend on the model's tokenizer. Scripts and assets cost tokens only if the agent reads them.

Safety

Auto-check passed

The automated check found no risky patterns in SKILL.md.

Automated static check — not a guarantee. Review scripts before installing. It scans the text of SKILL.md for risky patterns (piping downloads into a shell, reading credential files, hidden Unicode, destructive commands); files beside SKILL.md are not scanned.

SKILL.md

The full file from ag2ai/build-with-ag2 at commit 29eeac3, republished under its Apache-2.0 licence (© ag2ai). 531 words, ~1,852 tokens.

Download SKILL.mdSave it as .claude/skills/ag2-telemetry/SKILL.md (or your agent's skills folder).
name
ag2-telemetry
description
Add OpenTelemetry traces to an AG2 beta `Agent` via `TelemetryMiddleware` (`autogen.beta.middleware.builtin`). Emits spans for the full turn, each LLM call, each tool execution, and each human-input request, following the OpenTelemetry GenAI semantic conventions. Compatible with any OTLP backend — Jaeger, Grafana Tempo, Datadog, Honeycomb, Langfuse. Use when the user wants production-grade traces, latency analysis, token-usage attribution, or to ship telemetry into an existing observability stack.
license
Apache-2.0

Telemetry — OpenTelemetry instrumentation

When to use

The user wants to:

  • See per-turn / per-call latency breakdowns
  • Attribute token usage across operations
  • Push traces to Jaeger, Grafana Tempo, Datadog, Honeycomb, Langfuse, etc.
  • Debug a slow agent end-to-end with structured spans rather than print statements

If they just want quick stdout debugging, point them at LoggingMiddleware instead (see ag2-middleware).

Installation

bash
pip install "ag2[openai,tracing]"

60-second recipe

python
from opentelemetry import trace
from opentelemetry.sdk.resources import Resource
from opentelemetry.sdk.trace import TracerProvider
from opentelemetry.sdk.trace.export import SimpleSpanProcessor, ConsoleSpanExporter

from autogen.beta import Agent
from autogen.beta.config import OpenAIConfig
from autogen.beta.middleware.builtin import TelemetryMiddleware

# 1. Configure OpenTelemetry
resource = Resource.create({"service.name": "ag2-beta-quickstart"})
tracer_provider = TracerProvider(resource=resource)
tracer_provider.add_span_processor(SimpleSpanProcessor(ConsoleSpanExporter()))
trace.set_tracer_provider(tracer_provider)

# 2. Wire the middleware
agent = Agent(
    "assistant",
    prompt="You are a helpful assistant.",
    config=OpenAIConfig(model="gpt-4o-mini"),
    middleware=[
        TelemetryMiddleware(
            tracer_provider=tracer_provider,
            agent_name="assistant",
        ),
    ],
)

# 3. Run — spans emit automatically
import asyncio
asyncio.run(agent.ask("What is the capital of France?"))

For production, swap ConsoleSpanExporter for OTLPSpanExporter (or your backend's exporter) and SimpleSpanProcessor for BatchSpanProcessor.

Span hierarchy

Each ask() produces a root span with children:

invoke_agent assistant
  ├── chat gpt-4o-mini              # LLM API call
  ├── execute_tool get_weather      # tool execution
  ├── chat gpt-4o-mini              # LLM call after tool result
  └── await_human_input assistant   # human-in-the-loop

Span types

Every span has an ag2.span.type attribute:

ag2.span.typeOperation nameHook
agentinvoke_agenton_turn — full turn
llmchaton_llm_call — each LLM call
toolexecute_toolon_tool_execution — each tool
human_inputawait_human_inputon_human_input — HITL

Semantic attributes (GenAI semconv)

Spans carry standard OpenTelemetry GenAI attributes:

AttributeSpansDescription
gen_ai.operation.nameAllinvoke_agent / chat / execute_tool / await_human_input
gen_ai.agent.nameagent, human_inputAgent name
gen_ai.provider.nameagent, llmAuto-detected (openai, anthropic, …)
gen_ai.request.modelagent, llme.g. gpt-4o-mini
gen_ai.response.modelllmResolved from response
gen_ai.response.finish_reasonsllme.g. ["stop"], ["tool_calls"]
gen_ai.usage.input_tokensllmPrompt tokens
gen_ai.usage.output_tokensllmCompletion tokens
gen_ai.usage.cache_creation_input_tokensllmPrompt-cache writes (Anthropic)
gen_ai.usage.cache_read_input_tokensllmPrompt-cache reads (Anthropic, OpenAI, Gemini)
gen_ai.tool.nametoolTool function name
gen_ai.tool.call.idtoolTool call ID
gen_ai.tool.typetoolAlways function

Content capture (default ON)

By default, message content, tool args, and results are included on spans. Useful for debugging but can leak sensitive data:

python
TelemetryMiddleware(
    tracer_provider=tracer_provider,
    agent_name="assistant",
    capture_content=False,   # omit messages, tool args, results
)

When enabled, additional attributes appear:

AttributeSpanContent
gen_ai.input.messagesllmJSON request messages
gen_ai.output.messagesllmJSON response messages
gen_ai.tool.call.argumentstoolTool args (JSON)
gen_ai.tool.call.resulttoolTool result
ag2.human_input.prompthuman_inputPrompt shown to human
ag2.human_input.responsehuman_inputHuman's response

For privacy-sensitive backends (or anywhere telemetry leaves your infra), set capture_content=False.

Constructor reference

ParameterTypeDefaultDescription
tracer_providerTracerProvider | NoneGlobal providerOpenTelemetry TracerProvider
capture_contentboolTrueInclude message/tool content in spans
agent_namestr | None"unknown"Agent name for span attributes
provider_namestr | NoneNoneProvider override (auto-detected if unset)
model_namestr | NoneNoneModel override (auto-detected if unset)
Show full SKILL.md (217 more words)Show less

Backend integration

TelemetryMiddleware uses standard OpenTelemetry, so any OTLP-compatible backend works:

  • Jaeger — OTLPSpanExporter(endpoint="http://localhost:4318/v1/traces")
  • Grafana Tempo — same OTLP exporter, point at the Tempo gateway
  • Langfuse, Honeycomb, Datadog — vendor-specific exporters; the agent-side setup is identical

For container-orchestrated stacks, this repo includes a tracing/ directory with Docker-Compose for otel-collector + Grafana Tempo.

Going deeper

  • website/docs/beta/telemetry.mdx — full attribute table, configuration, example.
  • tracing/ — Docker setup for local otel-collector + Tempo + Grafana.
  • For sibling middleware (logging, retry, history limits), see ag2-middleware.

Common pitfalls

  • SimpleSpanProcessor + ConsoleSpanExporter in production — synchronous, blocks every span emit. Use BatchSpanProcessor and a real exporter (OTLP / Jaeger / vendor) outside of dev.
  • Leaking content into telemetry — capture_content=True is the default. For privacy-sensitive prompts (PII, credentials), set capture_content=False and audit what your backend retains.
  • Forgetting trace.set_tracer_provider(...) — without it, tracer_provider you pass to the middleware is fine, but third-party libraries that auto-instrument may use a different provider.
  • Token usage missing — gen_ai.usage.* requires the provider client to surface usage in the response. Streaming providers may emit usage only at the end; if you don't see them, check the provider's response shape.
  • Span hierarchy doesn't show parent-child — your exporter or backend may need the OTLP/HTTP path enabled, not just OTLP/gRPC. Check both.
  • Comparing to V1 tracing docs — the semantic-attribute format is the same; only the agent instrumentation method differs (V1 uses instrument_agent() / instrument_llm_wrapper() / instrument_pattern(); beta uses TelemetryMiddleware).

© ag2ai, Apache-2.0. Rendered from Markdown: HTML in the file is shown as text, images as links, and headings moved down two levels. Raw file

Files

Just SKILL.md in .agents/skills/ag2-telemetry of ag2ai/build-with-ag2.

Open the folder on GitHubat commit 29eeac3

Compare with similar skills

Ag2 Telemetry next to the 5 skills that share the most tags, products or categories with it. Stars are the repository's; “used in” counts other GitHub owners with a copy.

Ag2 Telemetry compared with similar skills
SkillStarsUsed inTokensAuto-checkLicenceRepo updated
Ag2 Telemetry this skillag2ai/build-with-ag2252—~1.9kAutomated safety check: PassApache-2.0
Observability Architecturemajiayu000/litellm-rs117—~1.3kAutomated safety check: PassMIT
Frontmcp Observabilityagentfront/frontmcp146—~4.6kAutomated safety check: PassApache-2.0
Monitoring Observabilityahmedasmar/devops-claude-skills203—~3.9kAutomated safety check: PassNone
App Observabilitygrafana/skills279—~1.8kAutomated safety check: PassApache-2.0
Monitoring Observabilityyonatangross/orchestkit289—~2.2kAutomated safety check: PassMIT

Similar skills

  • Observability Architecture

    majiayu000/litellm-rs

    LiteLLM-RS Observability Architecture. An agent skill from majiayu000/litellm-rs.

    117 GitHub stars~1.3k tokensUpdated today
    DevOps & CloudAuto-check passed
  • Frontmcp Observability

    agentfront/frontmcp

    A skill your agent uses when adding tracing, structured logging, metrics, or monitoring to a FrontMCP server.

    146 GitHub stars~4.6k tokensUpdated yesterday
    DevOps & CloudAuto-check passed
  • Monitoring Observability

    ahmedasmar/devops-claude-skills

    Monitoring and observability strategy, implementation, and troubleshooting.

    203 GitHub stars~3.9k tokensUpdated 6 mo ago
    DevOps & CloudAuto-check passed
  • App Observability

    grafana/skills

    Official

    Get RED metrics + service maps + frontend RUM + AI/LLM monitoring out of Grafana Cloud — Application Observability (tracesspanmetrics from OTel traces, p50/p95/p99 latency, exemplar-to-trace…

    279 GitHub stars~1.8k tokensUpdated 2 days ago
    DevOps & CloudAuto-check passed
  • Monitoring Observability

    yonatangross/orchestkit

    Monitoring and observability patterns for Prometheus metrics, Grafana dashboards, Langfuse v4 LLM tracing (astype, scorecurrentspan, shouldexportspan, LangfuseMedia), and drift detection.

    289 GitHub stars~2.2k tokensUpdated yesterday
    DevOps & CloudAuto-check passed
  • Observability

    TheBeardedBearSAS/claude-craft

    OpenTelemetry, distributed tracing, structured logging, metrics (Prometheus, Grafana, Datadog).

    107 GitHub stars~547 tokensUpdated 24 days ago
    DevOps & CloudAuto-check passed

More from ag2ai/build-with-ag2

All 16 skills in this repo
  • Ag2 Add Custom Tool

    ag2ai/build-with-ag2

    Add a custom Python tool to an AG2 beta Agent using the @tool decorator.

    252 GitHub stars~1.9k tokensUpdated 1 mo ago
    Auto-check passed
  • Ag2 Middleware

    ag2ai/build-with-ag2

    Intercept the AG2 beta agent loop with BaseMiddleware — wrap full turns (onturn), each LLM call (onllmcall), each tool execution (ontoolexecution), or each human-input request (onhumaninput).

    252 GitHub stars~1.9k tokensUpdated 1 mo ago
    Auto-check passed
  • Ag2 Use Builtin Tools

    ag2ai/build-with-ag2

    Wire AG2 beta's shipped tools into an Agent — both provider-native server-side tools (web search, web fetch, code execution, MCP, image generation, memory) and locally-executed common toolkits…

    252 GitHub stars~1.3k tokensUpdated 1 mo ago
    Auto-check passed
  • Ag2 Knowledge And Memory

    ag2ai/build-with-ag2

    Persist agent state across runs, shape what the LLM sees per turn, and cap history to fit a context window.

    252 GitHub stars~2.9k tokensUpdated 1 mo ago
    Auto-check passed
  • Ag2 Observers And Alerts

    ag2ai/build-with-ag2

    Monitor an AG2 beta agent's stream — log events, detect repeated tool calls, track token spend, build trigger-driven observers, route observer alerts to the model, and halt on FATAL conditions.

    252 GitHub stars~2.5k tokensUpdated 1 mo ago
    Auto-check passed
  • Ag2 Quickstart

    ag2ai/build-with-ag2

    Build a minimal AG2 beta Agent end to end — pick a model provider, set a prompt, call agent.ask(), then continue the conversation with reply.ask() (multi-turn).

    252 GitHub stars~1.7k tokensUpdated 1 mo ago
    Auto-check: notes

Categories

Questions about Ag2 Telemetry

What does Ag2 Telemetry do?

Add OpenTelemetry traces to an AG2 beta Agent via TelemetryMiddleware (autogen.beta.middleware.builtin). Ag2 Telemetry is an agent skill from ag2ai/build-with-ag2.builtin).

When should I use Ag2 Telemetry?

Ag2 Telemetry fits situations like: the user wants production-grade traces; latency analysis; token-usage attribution; ship telemetry into an existing observability stack.

How do I install Ag2 Telemetry in Claude Code?

Run `npx skills add ag2ai/build-with-ag2 --skill ag2-telemetry -a claude-code`. Or copy the skill folder (.agents/skills/ag2-telemetry in ag2ai/build-with-ag2) into .claude/skills/ag2-telemetry in your project. Claude Code loads it when a task matches its description.

How do I install Ag2 Telemetry in Codex?

Run `npx skills add ag2ai/build-with-ag2 --skill ag2-telemetry -a codex`. Or copy the skill folder (.agents/skills/ag2-telemetry in ag2ai/build-with-ag2) into .agents/skills/ag2-telemetry in your project. Codex loads it when a task matches its description.

Can I use Ag2 Telemetry in Cursor, Gemini CLI or GitHub Copilot?

Cursor, Gemini CLI, GitHub Copilot and OpenCode also load SKILL.md folders. With the skills CLI, run `npx skills add ag2ai/build-with-ag2 --skill ag2-telemetry -a cursor` (or -a gemini-cli, github-copilot or opencode for the others). To copy it by hand, put the folder in .cursor/skills/ag2-telemetry, .gemini/skills/ag2-telemetry, .github/skills/ag2-telemetry and .opencode/skills/ag2-telemetry in your project.

What does Ag2 Telemetry need to run?

Going by SKILL.md and its folder, Ag2 Telemetry needs the command-line tools its instructions call (pip). Our summary lists: Python 3; Docker.

Does Ag2 Telemetry access the network?

SKILL.md names 1 domain. As links in the text: opentelemetry.io. This is read from the text; nothing was executed.

Is Ag2 Telemetry safe to install?

Our automated static check of SKILL.md found no risky patterns, such as piping downloads into a shell, reading credential files or hidden Unicode. It is not a guarantee. Review the folder before installing.

What licence does Ag2 Telemetry use?

Ag2 Telemetry is published under the Apache-2.0 licence (declared in SKILL.md). It allows redistribution, so the full SKILL.md is shown on this page.

How many tokens does Ag2 Telemetry use?

About 1.9k tokens (SKILL.md is roughly 7.4k characters). Agents keep only the skill's name and description in context until a task matches; then they load SKILL.md in full.

What are the alternatives to Ag2 Telemetry?

Skills that share tags, products or a category with Ag2 Telemetry: Observability Architecture (majiayu000/litellm-rs, 117 stars), Frontmcp Observability (agentfront/frontmcp, 146 stars), Monitoring Observability (ahmedasmar/devops-claude-skills, 203 stars) and App Observability (grafana/skills, 279 stars). The comparison table on this page puts their stars, adoption, token cost, safety result and licence side by side.

Who maintains Ag2 Telemetry?

ag2ai (a GitHub organization) maintains it in ag2ai/build-with-ag2, which has 252 GitHub stars. The repository holds 16 skills in this directory. The repository was last updated on September 6, 2026.

Source: ag2ai/build-with-ag2 on GitHub. Facts on this page come from the repository at the commit we read; the author's words are quoted as theirs.