agentleFS
roedyrustamroedyrustam/vibes-plug/.cursor/skills/data-telemetry-expert/SKILL.md

data-telemetry-expert

Skill129 starsChanged 12 days agoMITView on GitHub

Observability, OpenTelemetry, metrics, and analytics (PostHog, Mixpanel) / Observabilitas, OpenTelemetry, metrik, dan analitik data.

  • Reads credentials

The file

We split this skill into the rules it gives an agent

6 rules. About 0 are common, 0 are distinctive, and 6 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.

  • 6

    Very specific

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

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

    Never attach unbounded high-cardinality identifiers (user_id, email, request_id, session_id) as Prometheus/OTel Metric attributes (which …

    line 195
  2. Very specific:

    Zero High-Cardinality Metric Labels: Never pass userId, tenantId, email, orderId, or raw URL paths with dynamic IDs (/users/123) as …

    line 240
  3. Very specific:

    Always Close Active Spans in finally: Every manually started span (tracer.startActiveSpan) must call span.end() inside a finally block …

    line 241
  4. Very specific:

    Batch OTLP Exports in Production: Use BatchSpanProcessor and batched JSONEachRow ClickHouse inserts instead of synchronous per-request …

    line 242
  5. Very specific:

    Mandatory Blue-Ocean Pairing: Always compose data-telemetry-expert with sbom-supply-chain-security-expert, self-healing-cloud-orchestrator, …

    line 246
  6. Very specific:

    Pre-Disk Gate: Run vibes verify-gate and vibes skill auto-diff --json to inject <350-token slices and eliminate placeholder slop.

    line 248

≈ “Common” is an estimate: at least 1 in 5 of the 408,460 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

Data & Telemetry Expert (OpenTelemetry 1.x / ClickHouse Edition)

English | Bahasa Indonesia


<a name="english"></a>

English

Orchestration & Integration

  • Upstream Orchestrators: Works under brainstorming and zero-to-prod-orchestrator (Phase 7 - Monitoring & Production Telemetry) to define system observability architectures.
  • Downstream Cooperating Skills:
    • logging-error-tracking-expert — Correlate OpenTelemetry traces with structured Pino logs and Sentry alerts.
    • llm-observability-expert — Extend trace contexts with GenAI token costs, prompt latencies, and evaluations.
    • error-resilience-expert — Feed real-time telemetry metrics into circuit breaker thresholds and automated failovers.
    • feature-flag-analytics-expert & geospatial-maps-expert — Correlate PostHog feature flag experiments, funnel analytics, and geospatial PostGIS/Mapbox user distribution telemetry.
    • session-memory-manager — Persist telemetry pipeline configurations and observability checkpoints.
  • Cross-Domain Synergy & Subagent Swarm Integration: olap-columnar-analytics-expert, proactive-background-watcher

Description

Expert guide for production observability, product analytics, and data pipelines. Covers OpenTelemetry 1.x (stable, vendor-neutral traces/metrics/logs), PostHog (open-source product analytics), ClickHouse (OLAP analytics database), Grafana stack, and AI agent observability patterns.

Trigger Conditions

  • Adding distributed tracing to a microservice or Next.js application.
  • Setting up structured logging and metrics collection.
  • Implementing product analytics (funnel analysis, feature flags, session replay).
  • Building a high-performance analytics pipeline with ClickHouse.
  • Monitoring AI agent runs, LLM token costs, and response quality.

OpenTelemetry 1.x — Vendor-Neutral Observability

OpenTelemetry (OTel) is the CNCF standard for generating traces, metrics, and logs from any application.

Three Pillars of OTel

SignalWhat It CapturesExample
TracesRequest flow across servicesGET /api/users → DB query → cache
MetricsNumeric measurements over timehttp_requests_total, db_query_duration
LogsStructured event records{"level":"error","msg":"DB timeout"}

Next.js 16 + OTel Instrumentation

// instrumentation.ts (Next.js built-in OTel support)
export async function register() {
  if (process.env.NEXT_RUNTIME === 'nodejs') {
    const { NodeSDK } = await import('@opentelemetry/sdk-node');
    const { OTLPTraceExporter } = await import('@opentelemetry/exporter-trace-otlp-http');
    const { OTLPMetricExporter } = await import('@opentelemetry/exporter-metrics-otlp-http');
    const { PeriodicExportingMetricReader } = await import('@opentelemetry/sdk-metrics');
    const { Resource } = await import('@opentelemetry/resources');
    const { SEMRESATTRS_SERVICE_NAME } = await import('@opentelemetry/semantic-conventions');

    const sdk = new NodeSDK({
      resource: new Resource({
        [SEMRESATTRS_SERVICE_NAME]: 'my-saas-app',
      }),
      traceExporter: new OTLPTraceExporter({
        url: process.env.OTEL_EXPORTER_OTLP_ENDPOINT,
      }),
      metricReader: new PeriodicExportingMetricReader({
        exporter: new OTLPMetricExporter(),
        exportIntervalMillis: 30_000,
      }),
    });

    sdk.start();
  }
}

Custom Spans for Business Logic

import { trace, SpanStatusCode } from '@opentelemetry/api';

const tracer = trace.getTracer('my-service', '1.0.0');

async function processOrder(orderId: string) {
  return tracer.startActiveSpan('processOrder', async (span) => {
    span.setAttribute('order.id', orderId);
    span.setAttribute('order.source', 'api');
    
    try {
      const order = await db.order.findUnique({ where: { id: orderId } });
      span.setAttribute('order.amount', order.amount);
      
      const result = await chargeCustomer(order);
      span.setStatus({ code: SpanStatusCode.OK });
      return result;
    } catch (error) {
      span.recordException(error as Error);
      span.setStatus({ code: SpanStatusCode.ERROR, message: String(error) });
      throw error;
    } finally {
      span.end();
    }
  });
}

ClickHouse — High-Performance Analytics Database

ClickHouse is the 2026 standard for analytical workloads — ingests billions of events and queries them in milliseconds:

-- Create an events table optimized for time-series analytics
CREATE TABLE events (
    event_id     UUID DEFAULT generateUUIDv4(),
    workspace_id String,
    user_id      String,
    event_name   LowCardinality(String),
    properties   JSON,
    timestamp    DateTime64(3, 'UTC'),
    date         Date DEFAULT toDate(timestamp)
)
ENGINE = MergeTree()
PARTITION BY toYYYYMM(date)
ORDER BY (workspace_id, event_name, timestamp)
TTL date + INTERVAL 1 YEAR;

-- Query: Funnel analysis — users who signed up then upgraded
SELECT
    countIf(event_name = 'signup') AS signups,
    countIf(event_name = 'plan_upgraded') AS upgrades,
    round(countIf(event_name = 'plan_upgraded') / countIf(event_name = 'signup') * 100, 2) AS conversion_rate
FROM events
WHERE workspace_id = 'ws_abc'
  AND timestamp >= now() - INTERVAL 30 DAY;
// Node.js ClickHouse client
import { createClient } from '@clickhouse/client';

const client = createClient({ url: process.env.CLICKHOUSE_URL });

await client.insert({
  table: 'events',
  values: [{
    workspace_id: 'ws_abc',
    user_id: 'user_123',
    event_name: 'page_view',
    properties: { path: '/dashboard', referrer: 'google.com' },
    timestamp: new Date().toISOString(),
  }],
  format: 'JSONEachRow',
});

PostHog — Open-Source Product Analytics

// Next.js + PostHog (client-side)
import posthog from 'posthog-js';

posthog.init(process.env.NEXT_PUBLIC_POSTHOG_KEY!, {
  api_host: process.env.NEXT_PUBLIC_POSTHOG_HOST ?? 'https://app.posthog.com',
  capture_pageview: false, // Manual with App Router
});

// Track custom events
posthog.capture('feature_used', {
  feature: 'ai_assistant',
  plan: user.plan,
  workspace_id: workspace.id,
});

// Feature flags
if (posthog.isFeatureEnabled('new-dashboard')) {
  return <NewDashboard />;
}

AI Agent Observability

Track LLM costs, latency, and quality for production AI applications:

// Custom OTel attributes for LLM calls
span.setAttribute('llm.model', 'claude-4-sonnet');
span.setAttribute('llm.input_tokens', response.usage.input_tokens);
span.setAttribute('llm.output_tokens', response.usage.output_tokens);
span.setAttribute('llm.cost_usd', calculateCost(response.usage));
span.setAttribute('llm.latency_ms', Date.now() - startTime);
span.setAttribute('llm.cached', response.usage.cache_read_input_tokens > 0);

Backend tracing tools for LLM: LangSmith (LangChain/LangGraph), OpenAI Tracing (Agents SDK), Langfuse (open-source, any LLM).

W3C traceparent Context Propagation & Metric Cardinality Guard (TypeScript)

Never attach unbounded high-cardinality identifiers (user_id, email, request_id, session_id) as Prometheus/OTel Metric attributes (which causes time-series memory explosion). Keep high-cardinality IDs on Trace Spans and Logs, and enforce an explicit allowlist on metric labels:

// src/lib/telemetry/cardinality-guard.ts
import { context, propagation, trace, type Span } from '@opentelemetry/api';

const ALLOWED_METRIC_DIMENSION_KEYS = new Set([
  'http.method',
  'http.route',
  'http.status_code',
  'service.tier',
  'region',
  'llm.model',
  'payment.provider',
]);

export function sanitizeMetricAttributes(
  rawAttrs: Record<string, string | number | boolean>
): Record<string, string | number | boolean> {
  const safeAttrs: Record<string, string | number | boolean> = {};
  for (const [key, value] of Object.entries(rawAttrs)) {
    if (!ALLOWED_METRIC_DIMENSION_KEYS.has(key)) {
      continue;
    }
    const strVal = String(value);
    safeAttrs[key] = strVal.length > 64 ? strVal.slice(0, 64) : value;
  }
  return safeAttrs;
}

export function injectW3CTraceHeaders(baseHeaders: Record<string, string> = {}): Record<string, string> {
  const carrier: Record<string, string> = { ...baseHeaders };
  propagation.inject(context.active(), carrier);
  return carrier;
}

export function getActiveTraceCorrelation(): { traceId: string; spanId: string } | null {
  const activeSpan: Span | undefined = trace.getActiveSpan();
  if (!activeSpan) return null;
  const spanCtx = activeSpan.spanContext();
  return { traceId: spanCtx.traceId, spanId: spanCtx.spanId };
}

Hard Guardrails (Declarative Invariants)

  • Zero High-Cardinality Metric Labels: Never pass userId, tenantId, email, orderId, or raw URL paths with dynamic IDs (/users/123) as OpenTelemetry Metric attributes; use parameterized route templates (/users/:id) and place entity IDs on Trace Spans instead.
  • Always Close Active Spans in finally: Every manually started span (tracer.startActiveSpan) must call span.end() inside a finally block and record exceptions via span.recordException(err) + SpanStatusCode.ERROR.
  • Batch OTLP Exports in Production: Use BatchSpanProcessor and batched JSONEachRow ClickHouse inserts instead of synchronous per-request telemetry HTTP calls on the hot path.
  • W3C traceparent Propagation: Propagate W3C TraceContext headers (propagation.inject) across outbound fetch() and async queue payloads so distributed traces remain unbroken.

Blue-Ocean Synergy & Anti-Commodity Protocol

  • Mandatory Blue-Ocean Pairing: Always compose data-telemetry-expert with sbom-supply-chain-security-expert, self-healing-cloud-orchestrator, zero-trust-secret-vault, adaptive-model-cascade so commodity boilerplate is elevated into verified, self-healing production architecture.
  • Anti-Commodity Mandate: Go beyond basic Docker/CI YAML: mandate rootless distroless builds, CycloneDX SBOM attestation, zero-trust secret rotation, and self-healing telemetry loops.
  • Pre-Disk Gate: Run vibes verify-gate and vibes skill auto-diff --json to inject <350-token slices and eliminate placeholder slop.

Sovereign Execution, Token Efficiency & Invariants

DimensionSovereign Mandate & Deterministic Contract
Frontier Model CascadeHigh Fast / Medium / High (Gemini 4 Carbon, Gemini 4 Neon, Gemini 4 Hydrogen, Gemini 4 Argon, Claude Sonnet 5.5 High, Grok 4.7 High Fast)
Availability FallbackGemini 4 (Carbon/Hydrogen/Neon/Argon/Pro) -> Gemini 3.8 Flash; Claude Opus 5.5 -> Claude Opus 4.6 (Zero unhandled missing-model errors)
KV-Cache & Token ProtocolPin static instructions & schemas at prompt prefix (kv-cache-prefix-optimizer); pass surgical CONTEXT_MAP.md slices (<250 tokens/call) during Swarm Fan-Out
SaaT CLI & MCP DispatchCLI: vibes skill exec data-telemetry-expert <audit|eval|verify|generate|blueprint> / MCP: vibes_skill_dispatch, vibes_ast_query, vibes_compile_cache, vibes_optimize_budget, vibes_verify_gate
NFR & Anti-Slop InvariantsP99 API Gateway Latency < 85ms, OpenAPI 3.1 / TypeSpec strict schema parity, RFC 9457 Problem Details error contracts, Idempotency-Key enforcement; 100% complete zero-placeholder output verified via node scripts/check-anti-slop.js --strict


<a name="bahasa-indonesia"></a>

Bahasa Indonesia

Integrasi Orkestrasi

  • Orkestrator Hulu: Beroperasi di bawah arahan brainstorming dan zero-to-prod-orchestrator (Fase 7 - Pemantauan & Telemetri Produksi) untuk merancang arsitektur observabilitas sistem.
  • Skill Hilir & Kerja Sama:
    • logging-error-tracking-expert — Mengorelasikan trace OpenTelemetry dengan log terstruktur Pino dan alert Sentry.
    • llm-observability-expert — Memperluas konteks trace dengan metrik GenAI, latensi prompt, dan evaluasi.
    • error-resilience-expert — Menyalurkan metrik telemetri ke threshold circuit breaker dan failover otomatis.
    • session-memory-manager — Menyimpan konfigurasi pipeline telemetri dan checkpoint observabilitas.
  • Sinergi Lintas Domain & Integrasi Swarm Subagent: olap-columnar-analytics-expert, feature-flag-analytics-expert, proactive-background-watcher

Deskripsi

Panduan ahli untuk observabilitas produksi, analitik produk, dan pipeline data. Mencakup OpenTelemetry 1.x (standar traces, metrics, logs netral vendor), PostHog (analitik produk open-source), ClickHouse (database analitik OLAP berkecepatan tinggi), Grafana stack, dan pola pemantauan agen AI.

Kondisi Pemicu

  • Menambahkan distributed tracing ke microservice atau aplikasi Next.js.
  • Menyiapkan structured logging dan pengumpulan metrik performa.
  • Mengimplementasikan analitik produk (funnel, feature flag, session replay).
  • Membangun pipeline analitik berkecepatan tinggi menggunakan ClickHouse.

Tiga Pilar OpenTelemetry (Traces, Metrics, Logs)

SinyalDefinisiContoh Kasus
TracesAlur request di berbagai microserviceGET /api/pesanan → query DB → redis cache
MetricsPengukuran numerik sepanjang waktuhttp_requests_total, durasi query DB
LogsCatatan kejadian terstruktur{"level":"error","pesan":"Koneksi DB timeout"}

Implementasi Pola Kunci (TypeScript)

1. Instrumentasi OpenTelemetry di Next.js 16

// instrumentation.ts
export async function register() {
  if (process.env.NEXT_RUNTIME === 'nodejs') {
    const { NodeSDK } = await import('@opentelemetry/sdk-node');
    const { OTLPTraceExporter } = await import('@opentelemetry/exporter-trace-otlp-http');
    const { OTLPMetricExporter } = await import('@opentelemetry/exporter-metrics-otlp-http');
    const { PeriodicExportingMetricReader } = await import('@opentelemetry/sdk-metrics');
    const { Resource } = await import('@opentelemetry/resources');
    const { SEMRESATTRS_SERVICE_NAME } = await import('@opentelemetry/semantic-conventions');

    const sdk = new NodeSDK({
      resource: new Resource({
        [SEMRESATTRS_SERVICE_NAME]: 'saas-produksi-app',
      }),
      traceExporter: new OTLPTraceExporter({
        url: process.env.OTEL_EXPORTER_OTLP_ENDPOINT,
      }),
      metricReader: new PeriodicExportingMetricReader({
        exporter: new OTLPMetricExporter(),
        exportIntervalMillis: 30_000,
      }),
    });

    sdk.start();
  }
}

2. Klien ClickHouse untuk Ingestion Event Skala Masif

import { createClient } from '@clickhouse/client';

const clickhouse = createClient({ url: process.env.CLICKHOUSE_URL });

export async function rekamEventTelemetri(namaEvent: string, dataProperti: Record<string, unknown>) {
  await clickhouse.insert({
    table: 'events',
    values: [{
      event_name: namaEvent,
      properties: dataProperti,
      timestamp: new Date().toISOString(),
    }],
    format: 'JSONEachRow',
  });
}

3. Pelacakan Event PostHog di Sisi Klien

import posthog from 'posthog-js';

posthog.init(process.env.NEXT_PUBLIC_POSTHOG_KEY!, {
  api_host: process.env.NEXT_PUBLIC_POSTHOG_HOST ?? 'https://app.posthog.com',
  capture_pageview: false,
});

export function lacakAktivitasPengguna(namaFitur: string) {
  posthog.capture('fitur_digunakan', { fitur: namaFitur, timestamp: new Date().toISOString() });
}

Sinergi Blue-Ocean & Protokol Anti-Komoditas

  • Pasangan Wajib Blue-Ocean: Selalu komposisikan data-telemetry-expert bersama sbom-supply-chain-security-expert, self-healing-cloud-orchestrator, zero-trust-secret-vault, adaptive-model-cascade agar boilerplate standar naik kelas menjadi arsitektur produksi terverifikasi dan self-healing.
  • Mandat Anti-Komoditas: Lampaui YAML Docker/CI standar: wajibkan build distroless non-root, atestasi CycloneDX SBOM, rotasi secret zero-trust, dan loop telemetri self-healing.
  • Gerbang Pra-Disk: Jalankan vibes verify-gate dan vibes skill auto-diff --json untuk menyuntikkan slice <350 token serta mencegah placeholder slop.

Matriks Eksekusi Berdaulat, Efisiensi Token & Invarian

DimensiMandat Berdaulat & Kontrak Deterministik
Kaskade Model FrontierHigh Fast / Medium / High (Gemini 4 Carbon, Gemini 4 Neon, Gemini 4 Hydrogen, Gemini 4 Argon, Claude Sonnet 5.5 High, Grok 4.7 High Fast)
Invarian Fallback KetersediaanGemini 4 (Carbon/Hydrogen/Neon/Argon/Pro) -> Gemini 3.8 Flash; Claude Opus 5.5 -> Claude Opus 4.6 (Bebas gagal saat model belum tersedia/kuota penuh)
Protokol Hemat Token & KV-CacheKunci instruksi & skema statis di prefix awal (kv-cache-prefix-optimizer); kirim potongan CONTEXT_MAP.md (<250 token/panggilan) saat Fan-Out
Eksekusi SaaT CLI & MCPCLI: vibes skill exec data-telemetry-expert <audit|eval|verify|generate|blueprint> / MCP: vibes_skill_dispatch, vibes_ast_query, vibes_compile_cache, vibes_optimize_budget, vibes_verify_gate
Invarian NFR & Anti-SlopLatensi P99 API < 85ms, paritas skema ketat OpenAPI 3.1 / TypeSpec, kontrak error RFC 9457 Problem Details, penegakan Idempotency-Key; kode 100% tuntas tanpa placeholder diverifikasi melalui node scripts/check-anti-slop.js --strict

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.