otel-instrumentation · dash0hq — скилл для Claude Code: трассировка
Помогает агенту расставить спаны, метрики и логи OpenTelemetry так, чтобы телеметрия отвечала на вопросы, а не жгла бюджет.
npx skills add dash0hq/agent-skills --skill otel-instrumentation -a claude-codeЧто делает otel-instrumentation
Скилл даёт агенту набор правил по OpenTelemetry: как называть спаны, какие атрибуты ресурсов задавать, как выбирать типы инструментов для метрик, как логировать ошибки и как вычищать персональные данные перед экспортом. Внутри — отдельные файлы под каждый язык: Node.js, Go, Python, Java, Scala, .NET, Ruby, PHP, браузер и Next.js с App Router. Есть разделы про Kubernetes, захват параметров подготовленных запросов и чек-лист проверки телеметрии после деплоя.
Отдельно скилл настаивает на том, чтобы сэмплирование жило в коллекторе, а не в SDK. В каждом SDK он советует явно ставить OTEL_TRACES_SAMPLER=always_on, потому что дефолтный ParentBased(root=AlwaysOn) позволяет вызывающему снаружи доверенной границы выключить трассировку сервиса через заголовок traceparent. Пропорциональные сэмплеры в SDK тоже не приветствуются: решение принимается до того, как известен исход запроса, и отменить его нельзя.
Перед добавлением пакетов инструментирования скилл проверяет, что нужные версии вообще существуют в проекте. Это заметно, когда вы ставите observability на живой сервис и не хотите ловить несовпадение версий уже в рантайме.
Какие задачи решает
- расставить спаны в новом сервисе и не забыть про статусы
- вынести сэмплирование из SDK в коллектор
- выбрать типы инструментов и единицы для метрик
- настроить корреляцию логов с трейсами по trace_id
- вычистить PII из телеметрии до экспорта
Примеры запросов агенту
- Настрой OpenTelemetry для этого Node.js-сервиса: спаны, метрики и логи.
- Проверь, что мы не сэмплируем в SDK, и перенеси политику в коллектор.
- Добавь корреляцию логов с трейсами и убери персональные данные из атрибутов.
Как установить otel-instrumentation
1Через Skills CLI (Vercel)
npx skills add dash0hq/agent-skills --skill otel-instrumentation -a claude-code2Вручную: положить файлы
~/.claude/skills/otel-instrumentation/SKILL.mdПапка скилла целиком; для одного проекта — .claude/skills/otel-instrumentation/
1Через Skills CLI (Vercel)
npx skills add dash0hq/agent-skills --skill otel-instrumentation -a codex2Вручную: положить файлы
.agents/skills/otel-instrumentation/SKILL.mdДля всех проектов — ~/.agents/skills/
1Через Skills CLI (Vercel)
npx skills add dash0hq/agent-skills --skill otel-instrumentation -a cursor2Вручную: положить файлы
.cursor/skills/otel-instrumentation/SKILL.mdCursor читает и .agents/skills/, и .claude/skills/
1GitHub CLI
gh skill install dash0hq/agent-skills otel-instrumentation2Вручную: положить файлы
.github/skills/otel-instrumentation/SKILL.md1Через Skills CLI (Vercel)
npx skills add dash0hq/agent-skills --skill otel-instrumentation -a gemini-cli2Командой платформы
gemini skills install https://github.com/dash0hq/agent-skills --path skills/otel-instrumentationВручную: положить файлы
.devin/skills/otel-instrumentation/SKILL.mdСтарый путь .windsurf/skills/ тоже читается
Через Skills CLI (Vercel)
npx skills add dash0hq/agent-skills --skill otel-instrumentation -a opencodeClaude.ai
Упакуйте папку в zip и загрузите в Settings → Capabilities → Skills
По шагам, с командами для каждой платформы: Как установить скилл в Claude Code: пять способов
Вопросы о otel-instrumentation
Как установить otel-instrumentation в Claude?
Выполните npx skills add dash0hq/agent-skills --skill otel-instrumentation -a claude-code. Скилл окажется в ~/.claude/skills/otel-instrumentation/SKILL.md.
Что делает otel-instrumentation?
Подсказывает агенту, как инструментировать приложение трассами, метриками и логами OpenTelemetry: правила именования, атрибуты ресурсов, работа с чувствительными данными и проверка после деплоя.
Где должно происходить сэмплирование?
Скилл советует держать его в коллекторе, а в SDK явно включать OTEL_TRACES_SAMPLER=always_on. Иначе внешний вызывающий может отключить трассировку сервиса через заголовок traceparent.
Исходный текст
SKILL.md · Apache-2.0
---
name: 'otel-instrumentation'
description: Configures trace spans, defines custom metrics, sets up log exporters, and optimizes sampling strategies for OpenTelemetry instrumentation. Use when instrumenting applications with traces, metrics, or logs. Triggers on requests for observability, telemetry, tracing, metrics collection, logging integration, or OTel setup.
license: Apache-2.0
metadata:
author: dash0
version: '2.0.0'
workflow_type: 'advisory'
supports-traces: "true"
supports-metrics: "true"
supports-logs: "true"
---
# OpenTelemetry Instrumentation Guide
Expert guidance for implementing high-quality, cost-efficient OpenTelemetry telemetry.
## Rules & Quick Reference
| Use Case / Rule | Description |
|-----------------|-------------|
| [telemetry](./rules/telemetry.md) | **Entrypoint** — signal types, correlation, and navigation |
| [resolve-values](./rules/resolve-values.md) | Resolving configuration values from the codebase |
| [verify-dependencies](./rules/verify-dependencies.md) | Verifying instrumentation packages and versions exist before adding them |
| [resources](./rules/resources.md) | Resource attributes — service identity and environment |
| [k8s](./rules/platforms/k8s.md) | Kubernetes deployment — downward API, pod spec |
| [spans](./rules/spans.md) | Spans — naming, kind, status, and hygiene |
| [logs](./rules/logs.md) | Logs — structured logging, severity, trace correlation |
| [metrics](./rules/metrics.md) | Metrics — instrument types, naming, units, cardinality |
| [sensitive-data](./rules/sensitive-data.md) | Sensitive data — PII prevention, sanitization, redaction |
| [capture-database-query-parameters](./rules/capture-database-query-parameters.md) | Prepared-statement parameter capture per language (Java, .NET, Python, Node.js, Go) |
| [validation](./rules/validation.md) | Telemetry validation — post-deployment verification checklist |
| [nodejs](./rules/sdks/nodejs.md) | Node.js instrumentation setup |
| [go](./rules/sdks/go.md) | Go instrumentation setup |
| [python](./rules/sdks/python.md) | Python instrumentation setup |
| [java](./rules/sdks/java.md) | Java instrumentation setup |
| [scala](./rules/sdks/scala.md) | Scala instrumentation setup |
| [dotnet](./rules/sdks/dotnet.md) | .NET instrumentation setup |
| [ruby](./rules/sdks/ruby.md) | Ruby instrumentation setup |
| [php](./rules/sdks/php.md) | PHP instrumentation setup |
| [browser](./rules/sdks/browser.md) | Browser instrumentation setup |
| [nextjs](./rules/sdks/nextjs.md) | Next.js full-stack instrumentation (App Router) |
## Official documentation
- [OpenTelemetry Documentation](https://opentelemetry.io/docs/)
- [Semantic Conventions](https://opentelemetry.io/docs/specs/semconv/)
- [Dash0 Integration Hub](https://www.dash0.com/hub/integrations)
## Getting started
Follow these steps when instrumenting an application from scratch:
1. **Pick your SDK rule** — choose the language-specific rule from the table above (e.g., [nodejs](./rules/sdks/nodejs.md), [python](./rules/sdks/python.md)).
2. **Set up resource attributes** — define service identity and environment per [resources](./rules/resources.md).
3. **Add spans, metrics, and logs** — instrument your code following [spans](./rules/spans.md), [metrics](./rules/metrics.md), and [logs](./rules/logs.md).
4. **Guard sensitive data** — scrub PII before export per [sensitive-data](./rules/sensitive-data.md).
5. **Validate** — confirm telemetry reaches the backend using the checklist in [validation](./rules/validation.md).
The snippet below shows a complete span with attributes and status for Node.js — see [nodejs](./rules/sdks/nodejs.md) for full setup including SDK initialisation, exporter configuration, and auto-instrumentation:
```js
import { trace, SpanStatusCode } from '@opentelemetry/api';
const tracer = trace.getTracer('my-service', '1.0.0');
tracer.startActiveSpan('operation-name', async (span) => {
try {
span.setAttribute('user.id', userId);
span.setAttribute('order.id', orderId);
const result = await processOrder(orderId);
span.setAttribute('order.status', result.status);
span.setStatus({ code: SpanStatusCode.OK });
return result;
} catch (err) {
// Record the exception as a structured log record, not span.recordException — see rules/spans.md
span.setStatus({ code: SpanStatusCode.ERROR, message: `${err.name}: ${err.message}` });
const spanContext = span.spanContext();
logger.error('operation-name.failed', {
'trace_id': spanContext.traceId,
'span_id': spanContext.spanId,
'exception.type': err.name,
'exception.message': err.message,
'exception.stacktrace': err.stack,
});
throw err;
} finally {
span.end();
}
});
```
## Key principles
### Signal density over volume
Every telemetry item should serve one of three purposes:
- **Detect** - Help identify that something is wrong
- **Localize** - Help pinpoint where the problem is
- **Explain** - Help understand why it happened
If it doesn't serve one of these purposes, don't emit it.
### Sample in the pipeline, not the SDK
Set the `AlwaysOn` sampler explicitly in every SDK (`OTEL_TRACES_SAMPLER=always_on`).
This overrides the OpenTelemetry default, `ParentBased(root=AlwaysOn)`, under which callers outside the trust boundary can silently switch off a service's tracing through the `traceparent` header.
Do not configure ratio-based SDK samplers either — they make irreversible decisions before the outcome of a request is known.
Defer all sampling to the [Collector](../otel-collector/rules/sampling.md), where policies can be changed centrally without redeploying applications.
See [SDK sampling](./rules/spans.md#sampling) for the full rationale and the conditions under which `ParentBased` is acceptable.
<!-- eval:skip -->
```
SDK (AlwaysOn, set explicitly) → Collector (sampling) → Backend (retention)
↓ ↓ ↓
All spans Head or tail Storage policies
exported sampling applied
```
© dash0 · Apache-2.0 · dash0hq/agent-skills
Похожие скиллы
Всё по теме «DevOps и инфраструктура» →Сначала — otel-instrumentation от других авторов.