Command Palette

Search for a command to run...

UnylyUnyly
Назад к скиллам

observability-setup

БесплатноБез исполняемых скриптовНе проверен

Set up end-to-end observability for microservices. Use when someone asks to "add tracing", "set up monitoring", "configure OpenTelemetry", "build Grafana…

TerminalSkillsот TerminalSkills★ 221 звезда на GitHub

Об этом скилле

Observability Setup

Overview

This skill helps AI agents implement the three pillars of observability — traces, metrics, and structured logs — across microservice architectures. It uses OpenTelemetry as the instrumentation standard and Grafana's LGTM stack (Loki, Grafana, Tempo, Mimir) as the backend, though patterns apply to any OTel-compatible backend.

Instructions

OpenTelemetry Instrumentation (Node.js)

  1. Install packages:

    npm install @opentelemetry/sdk-node @opentelemetry/auto-instrumentations-node \
      @opentelemetry/exporter-trace-otlp-http @opentelemetry/exporter-metrics-otlp-http
    
  2. Create src/instrumentation.ts — this file must be loaded BEFORE any other imports:

    import { NodeSDK } from '@opentelemetry/sdk-node';
    import { getNodeAutoInstrumentations } from '@opentelemetry/auto-instrumentations-node';
    import { OTLPTraceExporter } from '@opentelemetry/exporter-trace-otlp-http';
    import { OTLPMetricExporter } from '@opentelemetry/exporter-metrics-otlp-http';
    import { PeriodicExportingMetricReader } from '@opentelemetry/sdk-metrics';
    
    // Endpoint and service name come from OTEL_EXPORTER_OTLP_ENDPOINT and OTEL_SERVICE_NAME;
    // the exporters append /v1/traces and /v1/metrics themselves.
    const sdk = new NodeSDK({
      traceExporter: new OTLPTraceExporter(),
      metricReaders: [
        new PeriodicExportingMetricReader({
          exporter: new OTLPMetricExporter(),
          exportIntervalMillis: 15000,
        }),
      ],
      instrumentations: [getNodeAutoInstrumentations()],
    });
    sdk.start();
    process.on('SIGTERM', () => sdk.shutdown().finally(() => process.exit(0)));
    

    (@opentelemetry/sdk-metrics is installed as a dependency of the SDK; add it explicitly if your package manager is strict. @opentelemetry/sdk-node 0.301+ takes metricReaders as an array; the old singular metricReader option is gone. It requires Node.js 22.15 or newer.)

  3. Load it before the app. Plain Node cannot --require a .ts file, so use the compiled file or a TypeScript runner: node --require ./dist/instrumentation.js dist/index.js or npx tsx --import ./src/instrumentation.ts src/index.ts. ESM apps additionally need --experimental-loader=@opentelemetry/instrumentation/hook.mjs. Set OTEL_SEMCONV_STABILITY_OPT_IN=http to get the stable http.server.request.duration metric used in the queries below.

  4. Add custom spans for business-critical operations:

    import { trace, SpanStatusCode } from '@opentelemetry/api';
    const tracer = trace.getTracer('payment-service');
    
    async function processPayment(order) {
      return tracer.startActiveSpan('process-payment', async (span) => {
        span.setAttribute('order.id', order.id);
        span.setAttribute('payment.amount_cents', order.totalCents);
        try {
          const result = await paymentGateway.charge(order);
          span.setAttribute('payment.status', result.status);
          return result;
        } catch (error) {
          span.recordException(error);
          span.setStatus({ code: SpanStatusCode.ERROR, message: error.message });
          throw error;
        } finally {
          span.end();
        }
      });
    }
    

OpenTelemetry Instrumentation (Python)

  1. Install: pip install opentelemetry-distro opentelemetry-exporter-otlp, then opentelemetry-bootstrap -a install to add instrumentation for the libraries you already use.
  2. Run: opentelemetry-instrument --service_name notification-service python app.py (endpoint from OTEL_EXPORTER_OTLP_ENDPOINT; set OTEL_PYTHON_LOGGING_AUTO_INSTRUMENTATION_ENABLED=true to export logs too).
  3. For structured logs with trace context:
    import structlog
    from opentelemetry import trace
    
    def add_trace_context(logger, method_name, event_dict):
        span = trace.get_current_span()
        ctx = span.get_span_context()
        if ctx.is_valid:
            event_dict['trace_id'] = format(ctx.trace_id, '032x')
            event_dict['span_id'] = format(ctx.span_id, '016x')
        return event_dict
    
    structlog.configure(processors=[add_trace_context, structlog.dev.ConsoleRenderer()])
    

Structured Logging with Trace Correlation

Every log line must include trace_id and span_id. Use JSON format:

{"level":"error","msg":"payment failed","trace_id":"abc123...","span_id":"def456...","service":"payment-service","error":"timeout","timestamp":"2026-10-13T10:30:00Z"}

For Node.js, use pino with a custom mixin:

const pino = require('pino');
const { trace } = require('@opentelemetry/api');

const logger = pino({
  mixin() {
    const span = trace.getActiveSpan();
    if (span) {
      const ctx = span.spanContext();
      return { trace_id: ctx.traceId, span_id: ctx.spanId };
    }
    return {};
  }
});

OTel Collector Configuration

receivers:
  otlp:
    protocols:
      grpc: { endpoint: "0.0.0.0:4317" }
      http: { endpoint: "0.0.0.0:4318" }

pro
Полный SKILL.md на GitHub

Установить observability-setup в Claude Code и Claude Desktop

Зарегайся, чтобы установить скилл

Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.

  • Открой команду установки в одну строку
  • Сохраняй скиллы в синхронизируемую библиотеку
  • Уведомления, когда скиллы обновляются
Зарегаться бесплатноУ меня уже есть аккаунт

Разрешённые инструменты

Инструменты, которые скиллу разрешено вызывать.

Без ограничений — скилл может использовать любой инструмент.

Вложенные файлы

_scores.json

FAQ

Что делает скилл observability-setup?

Set up end-to-end observability for microservices. Use when someone asks to "add tracing", "set up monitoring", "configure OpenTelemetry", "build Grafana dashboards", "distributed tracing", "structured logging", "metrics collection", or "debug production issues". Covers OpenTelemetry instrumentation, collector configuration, Grafana LGTM stack deployment, dashboard provisioning, and alert rules.

Как установить скилл observability-setup?

Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.

Скилл observability-setup запускает скрипты?

Нет, скилл состоит только из инструкций (SKILL.md), без исполняемых скриптов.

Похожие скиллы

Сравнить observability-setup с