opentelemetry
OpenTelemetry - vendor-neutral observability framework for distributed systems. Provides traces, metrics, and logs with standardized instrumentation and exporters. USE WHEN: user mentions "opentelemetry", "otel", "distributed tracing", "observability", asks about "how to trace microservices", "opentelemetry setup", "jaeger integration", "prometheus metrics" DO NOT USE FOR: Application logging only - use logging skills instead, APM vendor-specific - use vendor docs, Simple monitoring - Prometheus/Grafana may be sufficient
What this skill does
# OpenTelemetry - Quick Reference
> **Full Reference**: See [advanced.md](advanced.md) for context propagation, detailed metrics API, Collector configuration, Docker Compose stack, sampling strategies, and semantic conventions.
> **Deep Knowledge**: Use `mcp__documentation__fetch_docs` with technology: `opentelemetry` for comprehensive documentation.
## Concepts
```
┌─────────────────────────────────────────────────────────────┐
│ OpenTelemetry │
├─────────────────┬─────────────────┬─────────────────────────┤
│ Traces │ Metrics │ Logs │
│ (Distributed) │ (Aggregated) │ (Structured) │
├─────────────────┴─────────────────┴─────────────────────────┤
│ OTLP Protocol │
├─────────────────────────────────────────────────────────────┤
│ Collector (optional) │
├─────────────────────────────────────────────────────────────┤
│ Jaeger │ Zipkin │ Prometheus │ Grafana │ DataDog │ etc. │
└─────────────────────────────────────────────────────────────┘
```
## Node.js Setup
```bash
npm install @opentelemetry/sdk-node \
@opentelemetry/auto-instrumentations-node \
@opentelemetry/exporter-trace-otlp-http
```
### Basic Configuration
```typescript
// tracing.ts - Load FIRST 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 { Resource } from '@opentelemetry/resources';
import { SEMRESATTRS_SERVICE_NAME } from '@opentelemetry/semantic-conventions';
const sdk = new NodeSDK({
resource: new Resource({
[SEMRESATTRS_SERVICE_NAME]: 'my-service',
}),
traceExporter: new OTLPTraceExporter({
url: process.env.OTEL_EXPORTER_OTLP_ENDPOINT || 'http://localhost:4318/v1/traces',
}),
instrumentations: [getNodeAutoInstrumentations()],
});
sdk.start();
process.on('SIGTERM', () => {
sdk.shutdown().finally(() => process.exit(0));
});
```
### Application Entry Point
```typescript
// index.ts
import './tracing'; // MUST be first import
import express from 'express';
const app = express();
```
## Manual Traces
```typescript
import { trace, SpanStatusCode } from '@opentelemetry/api';
const tracer = trace.getTracer('my-service', '1.0.0');
async function processOrder(orderId: string) {
return tracer.startActiveSpan('process-order', async (span) => {
try {
span.setAttribute('order.id', orderId);
await processOrderLogic(orderId);
span.setStatus({ code: SpanStatusCode.OK });
} catch (error) {
span.setStatus({ code: SpanStatusCode.ERROR, message: error.message });
span.recordException(error);
throw error;
} finally {
span.end();
}
});
}
```
## Spring Boot Setup
```xml
<dependency>
<groupId>io.micrometer</groupId>
<artifactId>micrometer-tracing-bridge-otel</artifactId>
</dependency>
<dependency>
<groupId>io.opentelemetry</groupId>
<artifactId>opentelemetry-exporter-otlp</artifactId>
</dependency>
```
```yaml
management:
tracing:
sampling:
probability: 1.0
otlp:
tracing:
endpoint: http://localhost:4318/v1/traces
```
## Environment Variables
```bash
OTEL_SERVICE_NAME=my-service
OTEL_EXPORTER_OTLP_ENDPOINT=http://localhost:4318
OTEL_TRACES_SAMPLER=parentbased_traceidratio
OTEL_TRACES_SAMPLER_ARG=0.1 # 10% sampling
```
## When NOT to Use This Skill
- **Simple application logging**: Use logging frameworks instead
- **Monolithic applications**: May be overkill
- **Vendor-specific APM**: DataDog, New Relic have their own SDKs
- **Development/debugging only**: Standard logging may suffice
- **Legacy systems**: Migration effort may be high
## Anti-Patterns
| Anti-Pattern | Why It's Bad | Solution |
|--------------|--------------|----------|
| Creating spans for every function | Massive overhead | Span only meaningful operations |
| 100% sampling in production | Performance impact, cost | Use 1-10% sampling |
| Not propagating context | Breaks distributed traces | Inject/extract at service boundaries |
| Logging PII in span attributes | Security/compliance violation | Filter sensitive data |
| Forgetting to end spans | Memory leak | Always end spans in finally block |
| Synchronous exporters | Blocks application | Use batch processors |
## Quick Troubleshooting
| Issue | Cause | Solution |
|-------|-------|----------|
| Traces not appearing | Exporter not configured | Check OTEL_EXPORTER_OTLP_ENDPOINT |
| High memory usage | Too many spans | Enable sampling |
| Missing context propagation | Not injecting headers | Use propagation API |
| Performance degradation | High sampling rate | Reduce to 1-10% |
| SDK initialization error | Import order wrong | Initialize SDK before other imports |
## Monitoring Metrics
| Metric | Target |
|--------|--------|
| Trace latency (p99) | < 10ms overhead |
| Span drop rate | < 1% |
| Collector memory | < 1GB |
| Export success rate | > 99% |
## Checklist
- [ ] SDK initialized before other imports
- [ ] Resource attributes configured
- [ ] Context propagation implemented
- [ ] Sampling strategy defined
- [ ] Graceful shutdown configured
- [ ] Collector deployed
- [ ] Dashboards created (Grafana)
- [ ] Alerts configured
## Reference
> **Deep Knowledge**: Use `mcp__documentation__fetch_docs` with technology: `opentelemetry` for comprehensive documentation
- [OpenTelemetry Docs](https://opentelemetry.io/docs/)
Related in General
modeling-omnistudio-epc-catalog
IncludedSalesforce Industries CME EPC product-modeling skill for Product2-based catalog creation. Use when creating EPC products, configuring product attributes, building offer bundles with Product Child Items, or reviewing EPC DataPack JSON metadata for product catalog changes. TRIGGER when: user creates or updates Product2 EPC records, AttributeAssignment payloads, AttributeMetadata/AttributeDefaultValues, Offer bundles, or ProductChildItem relationships. DO NOT TRIGGER when: designing OmniScripts/FlexCards/Integration Procedures (use building-omnistudio-omniscript, building-omnistudio-flexcard, or building-omnistudio-integration-procedure), implementing Apex business logic (use generating-apex), or troubleshooting deployment pipelines (use deploying-metadata).
relationship-science-coach
IncludedUse this skill for direct, practical adult relationship coaching: couples conflict, repair, trust, marriage, dating, flirting, attachment patterns, emotional connection, sex, desire differences, eroticism, kink negotiation, affection, love languages, breakups, and long-term passion. Draw on Gottman, EFT and Hold Me Tight, attachment science, modern sex research, Perel, Nagoski, Kerner, Schnarch, Love and Stosny, and flexible love-language tools. Be concrete and low-hedge. Redirect only for imminent danger, abuse, coercive control, minors, non-consent, self-harm, stalking, or medical/legal/psychiatric decisions.
building-sf-integrations
IncludedSalesforce integration architecture and runtime plumbing with 120-point scoring. Use this skill to set up Named Credentials, External Credentials, External Services, REST/SOAP callout patterns, Platform Events, and Change Data Capture. TRIGGER when: user sets up Named Credentials, External Services, REST/SOAP callouts, Platform Events, CDC, or touches .namedCredential-meta.xml files. DO NOT TRIGGER when: Connected App/OAuth config (use configuring-connected-apps), Apex-only logic (use generating-apex), or data import/export (use handling-sf-data).
venue-templates
IncludedAccess comprehensive LaTeX templates, formatting requirements, and submission guidelines for major scientific publication venues (Nature, Science, PLOS, IEEE, ACM), academic conferences (NeurIPS, ICML, CVPR, CHI), research posters, and grant proposals (NSF, NIH, DOE, DARPA). This skill should be used when preparing manuscripts for journal submission, conference papers, research posters, or grant proposals and need venue-specific formatting requirements and templates.
let-fate-decide
IncludedDraws the 12 Houses of the Zodiac Tarot spread to inject entropy into planning when prompts are vague, ambiguous, or casually delegated. Interprets the spread to guide next steps. Use when the user says 'let fate decide', 'YOLO', 'whatever', 'idk', or other nonchalant phrases, makes Yu-Gi-Oh references, or when you are about to arbitrarily pick between multiple reasonable approaches. Prefer over ask-questions-if-underspecified when the user's tone is casual or playful rather than precision-seeking.
net-ops
IncludedCross-platform network troubleshooting (Windows, macOS, Linux) via local or remote shell. Use for: DNS broken, can't resolve hostnames, nslookup/dig works but apps fail, NRPT, WFP, scutil, /etc/resolver, systemd-resolved, /etc/resolv.conf, NetworkManager, VPN DNS leak residue (ProtonVPN/Mullvad/WireGuard/AnyConnect), AV/firewall blocking DNS or DoH, Tailscale DNS interaction, intermittent connectivity, remote diagnostics over SSH.