[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill:01M6CDHS7NBM5W4QG6W7NF3CM2":3,"skill-same:01M6CDHS7NBM5W4QG6W7NF3CM2":122},{"skillNo":4,"name":5,"nameZh":6,"description":7,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":6,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":15,"categories":16,"keywords":22,"publishedAt":54,"linkOnly":55,"markdownContent":56,"markdownBody":57,"frontMatter":58,"refName":31,"commitSha":67,"skillDirectory":68,"forksCount":69,"repositoryHtmlUrl":70,"repositoryHomepageUrl":6,"ownerHtmlUrl":71,"ownerBlogUrl":6,"ownerDescription":6,"updatedAt":72,"install":73,"resources":86},"01M6CDHS7NBM5W4QG6W7NF3CM2","agent-observability",null,"Instrument AI agents with tracing, token metrics, latency, and cost visibility. Use for reliability and debugging.","boisenoise\u002Fskills-collections","boisenoise","https:\u002F\u002Favatars.githubusercontent.com\u002Fu\u002F193180?v=4","01M6CDBDQK6BDN55ZMA6B6PKBM","01M6CDBDVSJ3JPTBYN26FZ7TZK",13,"MIT","https:\u002F\u002Fgithub.com\u002Fboisenoise\u002Fskills-collections\u002Fblob\u002Fmain\u002Fskills\u002Fantigravity-agent-observability\u002FSKILL.md",[17],{"categoryNo":18,"categoryName":19,"taxonomyType":20,"taxonomyTypeDesc":21},"01JBSEEDCAT000000000000023","Skill与智能体开发","SCENARIO","使用场景",[23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53],"observability","agent observability","access","2026","relevant","scripts","critical","token","main","community","cost","agent-skills","only","reliability","devops","use","environment","github","helm","devops-security","templates","kubectl","ci","tracing","https","runners","license","git","debugging","security","ai agents","2026-11-10 10:12:30",false,"---\nname: agent-observability\ndescription: Instrument AI agents with tracing, token metrics, latency, and cost visibility.\n  Use for reliability and debugging.\ncategory: devops\nrisk: critical\nsource: https:\u002F\u002Fgithub.com\u002FBagelHole\u002FDevOps-Security-Agent-Skills\nsource_repo: BagelHole\u002FDevOps-Security-Agent-Skills\nsource_type: community\ndate_added: '2026-09-20'\nlicense: MIT\nlicense_source: https:\u002F\u002Fgithub.com\u002FBagelHole\u002FDevOps-Security-Agent-Skills\u002Fblob\u002Fmain\u002FLICENSE\ncompatibility: Requires the relevant platform CLIs (kubectl, helm, terraform, git,\n  CI runners) and authorized access to the target environment. Docs-only; helper scripts\n  and templates not bundled.\nmetadata:\n  author: devops-skills\n  version: '2.0'\n---\n\n# Agent Observability\n\nMonitor AI agent behavior with logs, traces, metrics, and cost telemetry. This skill covers the full observability stack for LLM-powered applications: from raw Prometheus counters to Grafana dashboards, OpenTelemetry tracing, structured logging, cost tracking, SLO definition, and PII redaction.\n\n---\n\nExamples use custom llm.* attributes, not a claim of current OpenTelemetry semantic-convention compliance. Import shared metric definitions once and use bounded configured label values. Telemetry export is data disclosure: approve destination\u002Fretention and omit prompts, credentials, direct user IDs and raw exception bodies. TLS is required for non-loopback collectors.\n\n## Core Metrics\n\nDefine these metrics at the application layer. All examples use the Prometheus client library naming conventions.\n\n### Latency\n\n```python\nfrom prometheus_client import Histogram\n\n# Total end-to-end latency for a full agent turn (user prompt -> final response)\nAGENT_LATENCY = Histogram(\n    \"agent_request_duration_seconds\",\n    \"End-to-end latency of an agent request\",\n    labelnames=[\"agent_name\", \"model\", \"status\"],\n    buckets=(0.25, 0.5, 1, 2, 5, 10, 30, 60, 120),\n)\n\n# Latency of a single LLM API call (one completion request)\nLLM_CALL_LATENCY = Histogram(\n    \"llm_call_duration_seconds\",\n    \"Latency of an individual LLM API call\",\n    labelnames=[\"model\", \"provider\", \"stream\"],\n    buckets=(0.1, 0.25, 0.5, 1, 2, 5, 10, 30),\n)\n\n# Latency of tool\u002Ffunction calls executed by the agent\nTOOL_CALL_LATENCY = Histogram(\n    \"agent_tool_call_duration_seconds\",\n    \"Latency of a tool call executed by the agent\",\n    labelnames=[\"tool_name\", \"agent_name\", \"status\"],\n    buckets=(0.05, 0.1, 0.25, 0.5, 1, 2, 5, 10),\n)\n```\n\n### Token Usage\n\n```python\nfrom prometheus_client import Counter, Histogram\n\nPROMPT_TOKENS = Counter(\n    \"llm_prompt_tokens_total\",\n    \"Total prompt tokens sent to the model\",\n    labelnames=[\"model\", \"agent_name\"],\n)\n\nCOMPLETION_TOKENS = Counter(\n    \"llm_completion_tokens_total\",\n    \"Total completion tokens received from the model\",\n    labelnames=[\"model\", \"agent_name\"],\n)\n\nCACHED_TOKENS = Counter(\n    \"llm_cached_tokens_total\",\n    \"Prompt tokens served from KV-cache (provider-reported)\",\n    labelnames=[\"model\", \"agent_name\"],\n)\n\nTOKENS_PER_REQUEST = Histogram(\n    \"llm_tokens_per_request\",\n    \"Total tokens (prompt + completion) per request\",\n    labelnames=[\"model\", \"agent_name\"],\n    buckets=(100, 500, 1000, 2000, 4000, 8000, 16000, 32000, 64000, 128000),\n)\n```\n\n### Cost\n\n```python\nfrom prometheus_client import Counter\n\nLLM_COST = Counter(\n    \"llm_cost_dollars_total\",\n    \"Estimated cost in USD for LLM usage\",\n    labelnames=[\"model\", \"agent_name\", \"cost_type\"],  # cost_type: prompt | completion\n)\n```\n\n### Tool Calls\n\n```python\nfrom prometheus_client import Counter\n\nTOOL_CALLS_TOTAL = Counter(\n    \"agent_tool_calls_total\",\n    \"Total tool calls made by agents\",\n    labelnames=[\"tool_name\", \"agent_name\", \"status\"],  # status: success | error | timeout\n)\n```\n\n### Errors and Retries\n\n```python\nfrom prometheus_client import Counter, Gauge\n\nLLM_ERRORS = Counter(\n    \"llm_errors_total\",\n    \"Errors returned by the LLM provider\",\n    labelnames=[\"model\", \"provider\", \"error_type\"],  # error_type: rate_limit | timeout | 5xx | auth\n)\n\nLLM_RETRIES = Counter(\n    \"llm_retries_total\",\n    \"Retried LLM API calls\",\n    labelnames=[\"model\", \"provider\", \"retry_reason\"],\n)\n\nAGENT_ACTIVE_REQUESTS = Gauge(\n    \"agent_active_requests\",\n    \"Number of agent requests currently in flight\",\n    labelnames=[\"agent_name\"],\n)\n```\n\n---\n\n## OpenTelemetry Integration\n\nUse the OpenTelemetry Python SDK to create traces that capture every step of an agent turn: the top-level request, each LLM call, each tool execution, and retrieval operations.\n\n### Setup\n\n```python\n# otel_setup.py\nfrom opentelemetry import trace\nfrom opentelemetry.sdk.trace import TracerProvider\nfrom opentelemetry.sdk.trace.export import BatchSpanProcessor\nfrom opentelemetry.exporter.otlp.proto.grpc.trace_exporter import OTLPSpanExporter\nfrom opentelemetry.sdk.resources import Resource\n\ndef init_tracing(service_name: str, otlp_endpoint: str = \"http:\u002F\u002Flocalhost:4317\"):\n    resource = Resource.create({\n        \"service.name\": service_name,\n        \"service.version\": \"1.0.0\",\n        \"deployment.environment\": \"production\",\n    })\n    provider = TracerProvider(resource=resource)\n    exporter = OTLPSpanExporter(endpoint=otlp_endpoint, insecure=otlp_endpoint.startswith(\"http:\u002F\u002Flocalhost:\"))\n    provider.add_span_processor(BatchSpanProcessor(exporter))\n    trace.set_tracer_provider(provider)\n    return trace.get_tracer(service_name)\n```\n\n### Tracing LLM Calls\n\n```python\n# llm_tracing.py\nimport time\nfrom opentelemetry import trace\nfrom opentelemetry.trace import StatusCode\n\ntracer = trace.get_tracer(\"agent.llm\")\n\ndef traced_llm_call(client, messages, model=\"gpt-4o\", **kwargs):\n    \"\"\"Wrap an LLM completion call with a full OpenTelemetry span.\"\"\"\n    if kwargs.get(\"stream\"):\n        raise ValueError(\"This synchronous wrapper does not consume streams; use a stream-aware adapter\")\n    with tracer.start_as_current_span(\"llm.chat_completion\", record_exception=False, set_status_on_exception=False) as span:\n        span.set_attribute(\"llm.model\", model)\n        span.set_attribute(\"llm.provider\", \"openai\")\n        span.set_attribute(\"llm.message_count\", len(messages))\n        span.set_attribute(\"llm.temperature\", kwargs.get(\"temperature\", 1.0))\n        span.set_attribute(\"llm.max_tokens\", kwargs.get(\"max_tokens\", 0))\n\n        start = time.perf_counter()\n        try:\n            response = client.chat.completions.create(\n                model=model, messages=messages, **kwargs\n            )\n            elapsed = time.perf_counter() - start\n\n            usage = response.usage\n            if usage is None or not response.choices:\n                raise ValueError(\"Usage\u002Fchoices unavailable; record unknown rather than inventing zero\")\n            span.set_attribute(\"llm.prompt_tokens\", usage.prompt_tokens)\n            span.set_attribute(\"llm.completion_tokens\", usage.completion_tokens)\n            span.set_attribute(\"llm.total_tokens\", usage.total_tokens)\n            span.set_attribute(\"llm.duration_seconds\", elapsed)\n            span.set_attribute(\"llm.finish_reason\", response.choices[0].finish_reason)\n            span.set_status(StatusCode.OK)\n\n            # Update Prometheus counters\n            PROMPT_TOKENS.labels(model=model, agent_name=\"default\").inc(usage.prompt_tokens)\n            COMPLETION_TOKENS.labels(model=model, agent_name=\"default\").inc(usage.completion_tokens)\n            LLM_CALL_LATENCY.labels(model=model, provider=\"openai\", stream=\"false\").observe(elapsed)\n\n            return response\n\n        except Exception as exc:\n            elapsed = time.perf_counter() - start\n            span.set_status(StatusCode.ERROR, type(exc).__name__)\n            # Raw exception text may contain prompts, URLs or credentials.\n            LLM_ERRORS.labels(model=model, provider=\"openai\", error_type=\"request_error\").inc()\n            LLM_CALL_LATENCY.labels(model=model, provider=\"openai\", stream=\"false\").observe(elapsed)\n            raise\n```\n\n### Tracing Tool Execution\n\n```python\n# tool_tracing.py\nimport functools\nfrom opentelemetry import trace\nfrom opentelemetry.trace import StatusCode\n\ntracer = trace.get_tracer(\"agent.tools\")\n\ndef traced_tool(tool_name: str):\n    \"\"\"Decorator that wraps a tool function with an OTel span and Prometheus metrics.\"\"\"\n    def decorator(func):\n        import inspect\n        if inspect.iscoroutinefunction(func) or inspect.isgeneratorfunction(func):\n            raise TypeError(\"Use an async\u002Fgenerator-aware adapter that observes actual completion\")\n        @functools.wraps(func)\n        def wrapper(*args, **kwargs):\n            with tracer.start_as_current_span(f\"tool.{tool_name}\", record_exception=False, set_status_on_exception=False) as span:\n                span.set_attribute(\"tool.name\", tool_name)\n                span.set_attribute(\"tool.args_count\", len(args) + len(kwargs))\n\n                import time\n                start = time.perf_counter()\n                try:\n                    result = func(*args, **kwargs)\n                    elapsed = time.perf_counter() - start\n                    span.set_attribute(\"tool.duration_seconds\", elapsed)\n                    span.set_status(StatusCode.OK)\n                    TOOL_CALLS_TOTAL.labels(\n                        tool_name=tool_name, agent_name=\"default\", status=\"success\"\n                    ).inc()\n                    TOOL_CALL_LATENCY.labels(\n                        tool_name=tool_name, agent_name=\"default\", status=\"success\"\n                    ).observe(elapsed)\n                    return result\n                except Exception as exc:\n                    elapsed = time.perf_counter() - start\n                    span.set_status(StatusCode.ERROR, type(exc).__name__)\n                    # Raw exception text may contain prompts, URLs or credentials.\n                    TOOL_CALLS_TOTAL.labels(\n                        tool_name=tool_name, agent_name=\"default\", status=\"error\"\n                    ).inc()\n                    TOOL_CALL_LATENCY.labels(\n                        tool_name=tool_name, agent_name=\"default\", status=\"error\"\n                    ).observe(elapsed)\n                    raise\n        return wrapper\n    return decorator\n\n# Usage\n@traced_tool(\"web_search\")\ndef web_search(query: str) -> str:\n    # ... tool implementation ...\n    pass\n\n@traced_tool(\"sql_query\")\ndef sql_query(statement: str) -> list:\n    # ... tool implementation ...\n    pass\n```\n\n### Propagating Trace Context Across Services\n\n```python\n# context_propagation.py\nfrom opentelemetry import context\nfrom opentelemetry.propagate import inject, extract\nimport httpx\n\ndef call_downstream_service(url: str, payload: dict) -> dict:\n    \"\"\"Propagate the current trace context to a downstream HTTP service.\"\"\"\n    headers = {}\n    inject(headers)  # injects traceparent + tracestate headers\n    # url must come from trusted service configuration, not model\u002Fuser input.\n    # Enforce an approved HTTPS origin\u002Fegress policy before propagating context.\n    response = httpx.post(url, json=payload, headers=headers, timeout=10.0, follow_redirects=False)\n    response.raise_for_status()\n    return response.json()\n\ndef extract_context_from_request(request_headers: dict):\n    \"\"\"Extract trace context from incoming request headers (for the receiving service).\"\"\"\n    ctx = extract(request_headers)\n    token = context.attach(ctx)\n    return token  # call context.detach(token) when done\n```\n\n---\n\n\n## Contents\n\n- [Structured Logging](references\u002Fdetails.md)\n- [Grafana Dashboards](references\u002Fdetails.md)\n- [Cost Tracking](references\u002Fdetails.md)\n- [Langfuse \u002F Helicone Integration](references\u002Fdetails.md)\n- [SLO Definition](references\u002Fdetails.md)\n- [Debugging Workflows](references\u002Fdetails.md)\n- [PII Redaction in Traces](references\u002Fdetails.md)\n- [Best Practices](references\u002Fdetails.md)\n- [Related Skills](references\u002Fdetails.md)\n\n## When to Use\n\nApply this skill whenever you operate:\n\n- **Autonomous AI agents** that make multi-step tool calls (e.g., coding agents, support agents, data-pipeline agents).\n- **LLM-backed APIs** serving chat completions, summarisation, or classification behind a REST or gRPC gateway.\n- **RAG pipelines** where a retriever fetches context from a vector store before prompting a model.\n- **Multi-agent orchestrations** (crew-style or graph-based) where several agents collaborate on a single task.\n- **Batch inference jobs** that process thousands of prompts against a model endpoint.\n\nKey signals that you need this skill:\n\n1. You cannot answer \"what is p95 latency for agent responses this week?\"\n2. You have no per-request cost attribution.\n3. Debugging a bad agent response requires grepping raw application logs.\n4. You have no alerting on token-usage spikes or elevated error rates.\n\n---\n\n## Limitations\n\n- The snippets require actual integration imports and instrumentation; dashboards alone do not populate metrics. Usage, cached-token categories and prices must match the provider response. Budget alerts do not enforce a spending cap.\n\n- Guidance executes against real environments: confirm target, blast radius, and rollback plan before applying anything.\n- Never deploy to production without explicit approval. Docs-only import: upstream scripts and templates not bundled.\n\n### Example\n\n```bash\ngit status && git diff --stat\nkubectl diff -f manifest.yaml\n```\n\n> Adapted from [BagelHole\u002FDevOps-Security-Agent-Skills](https:\u002F\u002Fgithub.com\u002FBagelHole\u002FDevOps-Security-Agent-Skills) (MIT); frontmatter, When to Use\u002FLimitations, and safety boundaries added for upstream compliance. Docs-only import: helper scripts and templates not bundled.\n","# Agent Observability\n\nMonitor AI agent behavior with logs, traces, metrics, and cost telemetry. This skill covers the full observability stack for LLM-powered applications: from raw Prometheus counters to Grafana dashboards, OpenTelemetry tracing, structured logging, cost tracking, SLO definition, and PII redaction.\n\n---\n\nExamples use custom llm.* attributes, not a claim of current OpenTelemetry semantic-convention compliance. Import shared metric definitions once and use bounded configured label values. Telemetry export is data disclosure: approve destination\u002Fretention and omit prompts, credentials, direct user IDs and raw exception bodies. TLS is required for non-loopback collectors.\n\n## Core Metrics\n\nDefine these metrics at the application layer. All examples use the Prometheus client library naming conventions.\n\n### Latency\n\n```python\nfrom prometheus_client import Histogram\n\n# Total end-to-end latency for a full agent turn (user prompt -> final response)\nAGENT_LATENCY = Histogram(\n    \"agent_request_duration_seconds\",\n    \"End-to-end latency of an agent request\",\n    labelnames=[\"agent_name\", \"model\", \"status\"],\n    buckets=(0.25, 0.5, 1, 2, 5, 10, 30, 60, 120),\n)\n\n# Latency of a single LLM API call (one completion request)\nLLM_CALL_LATENCY = Histogram(\n    \"llm_call_duration_seconds\",\n    \"Latency of an individual LLM API call\",\n    labelnames=[\"model\", \"provider\", \"stream\"],\n    buckets=(0.1, 0.25, 0.5, 1, 2, 5, 10, 30),\n)\n\n# Latency of tool\u002Ffunction calls executed by the agent\nTOOL_CALL_LATENCY = Histogram(\n    \"agent_tool_call_duration_seconds\",\n    \"Latency of a tool call executed by the agent\",\n    labelnames=[\"tool_name\", \"agent_name\", \"status\"],\n    buckets=(0.05, 0.1, 0.25, 0.5, 1, 2, 5, 10),\n)\n```\n\n### Token Usage\n\n```python\nfrom prometheus_client import Counter, Histogram\n\nPROMPT_TOKENS = Counter(\n    \"llm_prompt_tokens_total\",\n    \"Total prompt tokens sent to the model\",\n    labelnames=[\"model\", \"agent_name\"],\n)\n\nCOMPLETION_TOKENS = Counter(\n    \"llm_completion_tokens_total\",\n    \"Total completion tokens received from the model\",\n    labelnames=[\"model\", \"agent_name\"],\n)\n\nCACHED_TOKENS = Counter(\n    \"llm_cached_tokens_total\",\n    \"Prompt tokens served from KV-cache (provider-reported)\",\n    labelnames=[\"model\", \"agent_name\"],\n)\n\nTOKENS_PER_REQUEST = Histogram(\n    \"llm_tokens_per_request\",\n    \"Total tokens (prompt + completion) per request\",\n    labelnames=[\"model\", \"agent_name\"],\n    buckets=(100, 500, 1000, 2000, 4000, 8000, 16000, 32000, 64000, 128000),\n)\n```\n\n### Cost\n\n```python\nfrom prometheus_client import Counter\n\nLLM_COST = Counter(\n    \"llm_cost_dollars_total\",\n    \"Estimated cost in USD for LLM usage\",\n    labelnames=[\"model\", \"agent_name\", \"cost_type\"],  # cost_type: prompt | completion\n)\n```\n\n### Tool Calls\n\n```python\nfrom prometheus_client import Counter\n\nTOOL_CALLS_TOTAL = Counter(\n    \"agent_tool_calls_total\",\n    \"Total tool calls made by agents\",\n    labelnames=[\"tool_name\", \"agent_name\", \"status\"],  # status: success | error | timeout\n)\n```\n\n### Errors and Retries\n\n```python\nfrom prometheus_client import Counter, Gauge\n\nLLM_ERRORS = Counter(\n    \"llm_errors_total\",\n    \"Errors returned by the LLM provider\",\n    labelnames=[\"model\", \"provider\", \"error_type\"],  # error_type: rate_limit | timeout | 5xx | auth\n)\n\nLLM_RETRIES = Counter(\n    \"llm_retries_total\",\n    \"Retried LLM API calls\",\n    labelnames=[\"model\", \"provider\", \"retry_reason\"],\n)\n\nAGENT_ACTIVE_REQUESTS = Gauge(\n    \"agent_active_requests\",\n    \"Number of agent requests currently in flight\",\n    labelnames=[\"agent_name\"],\n)\n```\n\n---\n\n## OpenTelemetry Integration\n\nUse the OpenTelemetry Python SDK to create traces that capture every step of an agent turn: the top-level request, each LLM call, each tool execution, and retrieval operations.\n\n### Setup\n\n```python\n# otel_setup.py\nfrom opentelemetry import trace\nfrom opentelemetry.sdk.trace import TracerProvider\nfrom opentelemetry.sdk.trace.export import BatchSpanProcessor\nfrom opentelemetry.exporter.otlp.proto.grpc.trace_exporter import OTLPSpanExporter\nfrom opentelemetry.sdk.resources import Resource\n\ndef init_tracing(service_name: str, otlp_endpoint: str = \"http:\u002F\u002Flocalhost:4317\"):\n    resource = Resource.create({\n        \"service.name\": service_name,\n        \"service.version\": \"1.0.0\",\n        \"deployment.environment\": \"production\",\n    })\n    provider = TracerProvider(resource=resource)\n    exporter = OTLPSpanExporter(endpoint=otlp_endpoint, insecure=otlp_endpoint.startswith(\"http:\u002F\u002Flocalhost:\"))\n    provider.add_span_processor(BatchSpanProcessor(exporter))\n    trace.set_tracer_provider(provider)\n    return trace.get_tracer(service_name)\n```\n\n### Tracing LLM Calls\n\n```python\n# llm_tracing.py\nimport time\nfrom opentelemetry import trace\nfrom opentelemetry.trace import StatusCode\n\ntracer = trace.get_tracer(\"agent.llm\")\n\ndef traced_llm_call(client, messages, model=\"gpt-4o\", **kwargs):\n    \"\"\"Wrap an LLM completion call with a full OpenTelemetry span.\"\"\"\n    if kwargs.get(\"stream\"):\n        raise ValueError(\"This synchronous wrapper does not consume streams; use a stream-aware adapter\")\n    with tracer.start_as_current_span(\"llm.chat_completion\", record_exception=False, set_status_on_exception=False) as span:\n        span.set_attribute(\"llm.model\", model)\n        span.set_attribute(\"llm.provider\", \"openai\")\n        span.set_attribute(\"llm.message_count\", len(messages))\n        span.set_attribute(\"llm.temperature\", kwargs.get(\"temperature\", 1.0))\n        span.set_attribute(\"llm.max_tokens\", kwargs.get(\"max_tokens\", 0))\n\n        start = time.perf_counter()\n        try:\n            response = client.chat.completions.create(\n                model=model, messages=messages, **kwargs\n            )\n            elapsed = time.perf_counter() - start\n\n            usage = response.usage\n            if usage is None or not response.choices:\n                raise ValueError(\"Usage\u002Fchoices unavailable; record unknown rather than inventing zero\")\n            span.set_attribute(\"llm.prompt_tokens\", usage.prompt_tokens)\n            span.set_attribute(\"llm.completion_tokens\", usage.completion_tokens)\n            span.set_attribute(\"llm.total_tokens\", usage.total_tokens)\n            span.set_attribute(\"llm.duration_seconds\", elapsed)\n            span.set_attribute(\"llm.finish_reason\", response.choices[0].finish_reason)\n            span.set_status(StatusCode.OK)\n\n            # Update Prometheus counters\n            PROMPT_TOKENS.labels(model=model, agent_name=\"default\").inc(usage.prompt_tokens)\n            COMPLETION_TOKENS.labels(model=model, agent_name=\"default\").inc(usage.completion_tokens)\n            LLM_CALL_LATENCY.labels(model=model, provider=\"openai\", stream=\"false\").observe(elapsed)\n\n            return response\n\n        except Exception as exc:\n            elapsed = time.perf_counter() - start\n            span.set_status(StatusCode.ERROR, type(exc).__name__)\n            # Raw exception text may contain prompts, URLs or credentials.\n            LLM_ERRORS.labels(model=model, provider=\"openai\", error_type=\"request_error\").inc()\n            LLM_CALL_LATENCY.labels(model=model, provider=\"openai\", stream=\"false\").observe(elapsed)\n            raise\n```\n\n### Tracing Tool Execution\n\n```python\n# tool_tracing.py\nimport functools\nfrom opentelemetry import trace\nfrom opentelemetry.trace import StatusCode\n\ntracer = trace.get_tracer(\"agent.tools\")\n\ndef traced_tool(tool_name: str):\n    \"\"\"Decorator that wraps a tool function with an OTel span and Prometheus metrics.\"\"\"\n    def decorator(func):\n        import inspect\n        if inspect.iscoroutinefunction(func) or inspect.isgeneratorfunction(func):\n            raise TypeError(\"Use an async\u002Fgenerator-aware adapter that observes actual completion\")\n        @functools.wraps(func)\n        def wrapper(*args, **kwargs):\n            with tracer.start_as_current_span(f\"tool.{tool_name}\", record_exception=False, set_status_on_exception=False) as span:\n                span.set_attribute(\"tool.name\", tool_name)\n                span.set_attribute(\"tool.args_count\", len(args) + len(kwargs))\n\n                import time\n                start = time.perf_counter()\n                try:\n                    result = func(*args, **kwargs)\n                    elapsed = time.perf_counter() - start\n                    span.set_attribute(\"tool.duration_seconds\", elapsed)\n                    span.set_status(StatusCode.OK)\n                    TOOL_CALLS_TOTAL.labels(\n                        tool_name=tool_name, agent_name=\"default\", status=\"success\"\n                    ).inc()\n                    TOOL_CALL_LATENCY.labels(\n                        tool_name=tool_name, agent_name=\"default\", status=\"success\"\n                    ).observe(elapsed)\n                    return result\n                except Exception as exc:\n                    elapsed = time.perf_counter() - start\n                    span.set_status(StatusCode.ERROR, type(exc).__name__)\n                    # Raw exception text may contain prompts, URLs or credentials.\n                    TOOL_CALLS_TOTAL.labels(\n                        tool_name=tool_name, agent_name=\"default\", status=\"error\"\n                    ).inc()\n                    TOOL_CALL_LATENCY.labels(\n                        tool_name=tool_name, agent_name=\"default\", status=\"error\"\n                    ).observe(elapsed)\n                    raise\n        return wrapper\n    return decorator\n\n# Usage\n@traced_tool(\"web_search\")\ndef web_search(query: str) -> str:\n    # ... tool implementation ...\n    pass\n\n@traced_tool(\"sql_query\")\ndef sql_query(statement: str) -> list:\n    # ... tool implementation ...\n    pass\n```\n\n### Propagating Trace Context Across Services\n\n```python\n# context_propagation.py\nfrom opentelemetry import context\nfrom opentelemetry.propagate import inject, extract\nimport httpx\n\ndef call_downstream_service(url: str, payload: dict) -> dict:\n    \"\"\"Propagate the current trace context to a downstream HTTP service.\"\"\"\n    headers = {}\n    inject(headers)  # injects traceparent + tracestate headers\n    # url must come from trusted service configuration, not model\u002Fuser input.\n    # Enforce an approved HTTPS origin\u002Fegress policy before propagating context.\n    response = httpx.post(url, json=payload, headers=headers, timeout=10.0, follow_redirects=False)\n    response.raise_for_status()\n    return response.json()\n\ndef extract_context_from_request(request_headers: dict):\n    \"\"\"Extract trace context from incoming request headers (for the receiving service).\"\"\"\n    ctx = extract(request_headers)\n    token = context.attach(ctx)\n    return token  # call context.detach(token) when done\n```\n\n---\n\n\n## Contents\n\n- [Structured Logging](references\u002Fdetails.md)\n- [Grafana Dashboards](references\u002Fdetails.md)\n- [Cost Tracking](references\u002Fdetails.md)\n- [Langfuse \u002F Helicone Integration](references\u002Fdetails.md)\n- [SLO Definition](references\u002Fdetails.md)\n- [Debugging Workflows](references\u002Fdetails.md)\n- [PII Redaction in Traces](references\u002Fdetails.md)\n- [Best Practices](references\u002Fdetails.md)\n- [Related Skills](references\u002Fdetails.md)\n\n## When to Use\n\nApply this skill whenever you operate:\n\n- **Autonomous AI agents** that make multi-step tool calls (e.g., coding agents, support agents, data-pipeline agents).\n- **LLM-backed APIs** serving chat completions, summarisation, or classification behind a REST or gRPC gateway.\n- **RAG pipelines** where a retriever fetches context from a vector store before prompting a model.\n- **Multi-agent orchestrations** (crew-style or graph-based) where several agents collaborate on a single task.\n- **Batch inference jobs** that process thousands of prompts against a model endpoint.\n\nKey signals that you need this skill:\n\n1. You cannot answer \"what is p95 latency for agent responses this week?\"\n2. You have no per-request cost attribution.\n3. Debugging a bad agent response requires grepping raw application logs.\n4. You have no alerting on token-usage spikes or elevated error rates.\n\n---\n\n## Limitations\n\n- The snippets require actual integration imports and instrumentation; dashboards alone do not populate metrics. Usage, cached-token categories and prices must match the provider response. Budget alerts do not enforce a spending cap.\n\n- Guidance executes against real environments: confirm target, blast radius, and rollback plan before applying anything.\n- Never deploy to production without explicit approval. Docs-only import: upstream scripts and templates not bundled.\n\n### Example\n\n```bash\ngit status && git diff --stat\nkubectl diff -f manifest.yaml\n```\n\n> Adapted from [BagelHole\u002FDevOps-Security-Agent-Skills](https:\u002F\u002Fgithub.com\u002FBagelHole\u002FDevOps-Security-Agent-Skills) (MIT); frontmatter, When to Use\u002FLimitations, and safety boundaries added for upstream compliance. Docs-only import: helper scripts and templates not bundled.\n",{"name":5,"risk":29,"source":59,"license":14,"category":37,"metadata":60,"date_added":63,"description":7,"source_repo":64,"source_type":32,"compatibility":65,"license_source":66},"https:\u002F\u002Fgithub.com\u002FBagelHole\u002FDevOps-Security-Agent-Skills",{"author":61,"version":62},"devops-skills","2.0","2026-09-20","BagelHole\u002FDevOps-Security-Agent-Skills","Requires the relevant platform CLIs (kubectl, helm, terraform, git, CI runners) and authorized access to the target environment. Docs-only; helper scripts and templates not bundled.","https:\u002F\u002Fgithub.com\u002FBagelHole\u002FDevOps-Security-Agent-Skills\u002Fblob\u002Fmain\u002FLICENSE","e8c4cb5cbafb600fab08ffdf4b23359c9f608d9d","skills\u002Fantigravity-agent-observability",3,"https:\u002F\u002Fgithub.com\u002Fboisenoise\u002Fskills-collections","https:\u002F\u002Fgithub.com\u002Fboisenoise","2026-11-14 14:18:11",{"source":8,"skillName":5,"commands":74,"prompt":84,"zipAvailable":85},[75,78,81],{"tool":76,"command":77},"npx","npx skills add boisenoise\u002Fskills-collections --skill agent-observability",{"tool":79,"command":80},"bunx","bunx skills add boisenoise\u002Fskills-collections --skill agent-observability",{"tool":82,"command":83},"pnpm","pnpm dlx skills add boisenoise\u002Fskills-collections --skill agent-observability","安装技能，技能地址：https:\u002F\u002Fgithub.com\u002Fboisenoise\u002Fskills-collections\u002Fblob\u002Fmain\u002Fskills\u002Fantigravity-agent-observability\u002FSKILL.md",true,[87,92,98,102,106,110,114,118],{"path":88,"resourceType":88,"resourceTypeDesc":89,"sizeBytes":90,"sourceHtmlUrl":91},"LICENSE","许可证",1140,"https:\u002F\u002Fgithub.com\u002Fjiayaoqijia\u002Fcryptoskill\u002Fblob\u002Fmain\u002Fskills\u002Fdev-tools\u002Fcristallin2006-analysis-session\u002FLICENSE",{"path":93,"resourceType":94,"resourceTypeDesc":95,"sizeBytes":96,"sourceHtmlUrl":97},"references\u002Fcontrolled-requests.md","REFERENCE","参考文档",5988,"https:\u002F\u002Fgithub.com\u002Fjiayaoqijia\u002Fcryptoskill\u002Fblob\u002Fmain\u002Fskills\u002Fdev-tools\u002Fcristallin2006-analysis-session\u002Freferences\u002Fcontrolled-requests.md",{"path":99,"resourceType":94,"resourceTypeDesc":95,"sizeBytes":100,"sourceHtmlUrl":101},"references\u002Fdetails.md",26591,"https:\u002F\u002Fgithub.com\u002Fboisenoise\u002Fskills-collections\u002Fblob\u002Fmain\u002Fskills\u002Fantigravity-agent-observability\u002Freferences\u002Fdetails.md",{"path":103,"resourceType":94,"resourceTypeDesc":95,"sizeBytes":104,"sourceHtmlUrl":105},"references\u002Flegacy-ledger.md",1555,"https:\u002F\u002Fgithub.com\u002Fjiayaoqijia\u002Fcryptoskill\u002Fblob\u002Fmain\u002Fskills\u002Fdev-tools\u002Fcristallin2006-analysis-session\u002Freferences\u002Flegacy-ledger.md",{"path":107,"resourceType":94,"resourceTypeDesc":95,"sizeBytes":108,"sourceHtmlUrl":109},"references\u002Fnative-jobs.md",2666,"https:\u002F\u002Fgithub.com\u002Fjiayaoqijia\u002Fcryptoskill\u002Fblob\u002Fmain\u002Fskills\u002Fdev-tools\u002Fcristallin2006-analysis-session\u002Freferences\u002Fnative-jobs.md",{"path":111,"resourceType":94,"resourceTypeDesc":95,"sizeBytes":112,"sourceHtmlUrl":113},"references\u002Fruntime.md",3448,"https:\u002F\u002Fgithub.com\u002Fjiayaoqijia\u002Fcryptoskill\u002Fblob\u002Fmain\u002Fskills\u002Fdev-tools\u002Fcristallin2006-analysis-session\u002Freferences\u002Fruntime.md",{"path":115,"resourceType":94,"resourceTypeDesc":95,"sizeBytes":116,"sourceHtmlUrl":117},"SOURCE.md",366,"https:\u002F\u002Fgithub.com\u002Fjiayaoqijia\u002Fcryptoskill\u002Fblob\u002Fmain\u002Fskills\u002Fdev-tools\u002Fcristallin2006-analysis-session\u002FSOURCE.md",{"path":119,"resourceType":94,"resourceTypeDesc":95,"sizeBytes":120,"sourceHtmlUrl":121},"TRUST.auto.yaml",2197,"https:\u002F\u002Fgithub.com\u002Fjiayaoqijia\u002Fcryptoskill\u002Fblob\u002Fmain\u002Fskills\u002Fdev-tools\u002Fcristallin2006-analysis-session\u002FTRUST.auto.yaml",[123,132,140,149,157,165],{"skillNo":124,"name":125,"nameZh":6,"description":126,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":6,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":127,"sourceHtmlUrl":128,"categories":129,"keywords":130,"publishedAt":131},"01M7B6HREHB53EHGGVZND7DDXN","scrapely-scrape","Collect web data with ready-made Scrape.ly scrapers: Google Maps places, Amazon products, LinkedIn jobs, reviews, social posts. Use when the user wants structured data from a site.","https:\u002F\u002Fgithub.com\u002Fboisenoise\u002Fskills-collections\u002Fblob\u002Fmain\u002Fskills\u002Fantigravity-scrapely-scrape\u002FLICENSE","https:\u002F\u002Fgithub.com\u002Fboisenoise\u002Fskills-collections\u002Fblob\u002Fmain\u002Fskills\u002Fantigravity-scrapely-scrape\u002FSKILL.md",[],[],"2026-11-15 14:19:17",{"skillNo":133,"name":134,"nameZh":6,"description":135,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":6,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":136,"sourceHtmlUrl":137,"categories":138,"keywords":139,"publishedAt":131},"01M7B6GDNNN4HE662KA6KPF7GW","lumify-odds","Lumify's hosted sports MCP\u002FREST API for sportsbook odds, line-movement history, public betting splits, and player props across MLB, NFL, NBA, NHL, soccer, tennis, NCAAF, NCAAB. Read-only market data.","https:\u002F\u002Fgithub.com\u002Fboisenoise\u002Fskills-collections\u002Fblob\u002Fmain\u002Fskills\u002Fantigravity-lumify-odds\u002FLICENSE","https:\u002F\u002Fgithub.com\u002Fboisenoise\u002Fskills-collections\u002Fblob\u002Fmain\u002Fskills\u002Fantigravity-lumify-odds\u002FSKILL.md",[],[],{"skillNo":141,"name":142,"nameZh":6,"description":143,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":6,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":144,"sourceHtmlUrl":145,"categories":146,"keywords":147,"publishedAt":148},"01M743PZMJW2GEKG5J199GPSK7","sync-lipsync","Lip-sync an existing video of a real person to new audio or a typed script with sync. labs through its hosted MCP server, quoting the cost and waiting for approval first.","https:\u002F\u002Fgithub.com\u002Fboisenoise\u002Fskills-collections\u002Fblob\u002Fmain\u002Fskills\u002Fantigravity-sync-lipsync\u002FLICENSE","https:\u002F\u002Fgithub.com\u002Fboisenoise\u002Fskills-collections\u002Fblob\u002Fmain\u002Fskills\u002Fantigravity-sync-lipsync\u002FSKILL.md",[],[],"2026-11-11 15:11:14",{"skillNo":150,"name":151,"nameZh":6,"description":152,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":6,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":153,"sourceHtmlUrl":154,"categories":155,"keywords":156,"publishedAt":148},"01M743MMN3CKTJVNRSZMB684E5","music-for-robots","Optional music-inspired creative exercise for multimodal agents. Ingests an unquantized acoustic MP3 composition by Michael Luchtan (Music For Robots) into a private temporary directory, analyzing microtiming and texture to inspire creative writing, brainstorming, or technical tasks.","https:\u002F\u002Fgithub.com\u002Fboisenoise\u002Fskills-collections\u002Fblob\u002Fmain\u002Fskills\u002Fantigravity-music-for-robots\u002FLICENSE","https:\u002F\u002Fgithub.com\u002Fboisenoise\u002Fskills-collections\u002Fblob\u002Fmain\u002Fskills\u002Fantigravity-music-for-robots\u002FSKILL.md",[],[],{"skillNo":158,"name":159,"nameZh":6,"description":160,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":6,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":161,"sourceHtmlUrl":162,"categories":163,"keywords":164,"publishedAt":148},"01M743KC2GN5WE11BSTWSSWD8B","imagera-media","Generate or edit images, video clips, voiceovers and music through the hosted Imagera MCP server, quoting the credit cost and getting approval before each paid call.","https:\u002F\u002Fgithub.com\u002Fboisenoise\u002Fskills-collections\u002Fblob\u002Fmain\u002Fskills\u002Fantigravity-imagera-media\u002FLICENSE","https:\u002F\u002Fgithub.com\u002Fboisenoise\u002Fskills-collections\u002Fblob\u002Fmain\u002Fskills\u002Fantigravity-imagera-media\u002FSKILL.md",[],[],{"skillNo":166,"name":167,"nameZh":6,"description":168,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":6,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":169,"sourceHtmlUrl":170,"categories":171,"keywords":172,"publishedAt":148},"01M743HDJNZQA8A4VT68NWGWQJ","deja-history","Search this machine's past AI coding sessions across Claude Code, Codex, Cursor, Gemini CLI and thirty-nine other agents before editing, debugging, or denying something exists.","https:\u002F\u002Fgithub.com\u002Fboisenoise\u002Fskills-collections\u002Fblob\u002Fmain\u002Fskills\u002Fantigravity-deja-history\u002FLICENSE","https:\u002F\u002Fgithub.com\u002Fboisenoise\u002Fskills-collections\u002Fblob\u002Fmain\u002Fskills\u002Fantigravity-deja-history\u002FSKILL.md",[],[]]