distributed-tracing
Use when implementing distributed tracing, understanding trace propagation, or debugging cross-service issues. Covers OpenTelemetry, span context, and trace correlation.
What this skill does
# Distributed Tracing
Patterns and practices for implementing distributed tracing across microservices and understanding request flows in distributed systems.
## When to Use This Skill
- Implementing distributed tracing in microservices
- Debugging cross-service request issues
- Understanding trace propagation
- Choosing tracing infrastructure
- Correlating logs, metrics, and traces
## Why Distributed Tracing?
```text
Problem: Request flows through multiple services
How do you debug when something fails?
Without tracing:
User → API → ??? → ??? → Error somewhere
With tracing:
User → API (50ms) → OrderService (20ms) → PaymentService (ERROR: timeout)
└── Full visibility into request flow
```
## Core Concepts
### Traces, Spans, and Context
```text
Trace: End-to-end request journey
├── Span: Single operation within a service
│ ├── SpanID: Unique identifier
│ ├── ParentSpanID: Link to parent span
│ ├── TraceID: Shared across all spans
│ ├── Operation Name: What is being done
│ ├── Start/End Time: Duration
│ ├── Status: Success/Error
│ ├── Attributes: Key-value metadata
│ └── Events: Point-in-time annotations
│
└── Context: Propagated across service boundaries
├── TraceID
├── SpanID
├── Trace Flags
└── Trace State
```
### Trace Visualization
```text
TraceID: abc123
Service A (API Gateway)
├──────────────────────────────────────────────────────┤ 200ms
│
└─► Service B (Order Service)
├───────────────────────────────────┤ 150ms
│
├─► Service C (Inventory)
│ ├───────────────┤ 50ms
│
└─► Service D (Payment)
├───────────────────────┤ 80ms
│
└─► External API
├─────────┤ 60ms
```
## OpenTelemetry
### Overview
```text
OpenTelemetry = Unified observability framework
Components:
┌─────────────────────────────────────────────────────┐
│ Application │
│ ┌─────────────┐ ┌─────────────┐ ┌─────────────┐ │
│ │ SDK │ │ Tracer │ │ Meter │ │
│ │ │ │ Provider │ │ Provider │ │
│ └─────────────┘ └─────────────┘ └─────────────┘ │
└─────────────────────────────────────────────────────┘
│ │ │
└───────────────┼───────────────┘
▼
┌─────────────────────────┐
│ OTLP Exporter │
└─────────────────────────┘
│
▼
┌─────────────────────────┐
│ Collector │
│ (Optional) │
└─────────────────────────┘
│
┌───────────────┼───────────────┐
▼ ▼ ▼
┌─────────┐ ┌─────────┐ ┌─────────┐
│ Jaeger │ │ Zipkin │ │ Tempo │
└─────────┘ └─────────┘ └─────────┘
```
### Trace Context Propagation
```text
HTTP Headers (W3C Trace Context):
traceparent: 00-{trace-id}-{span-id}-{flags}
tracestate: vendor1=value1,vendor2=value2
Example:
traceparent: 00-0af7651916cd43dd8448eb211c80319c-b7ad6b7169203331-01
│ │ │ └─ sampled
│ │ └─ parent span id
│ └─ trace id (128-bit)
└─ version
Propagation across services:
┌─────────────┐ ┌─────────────┐
│ Service A │ ─── HTTP ──────────►│ Service B │
│ │ traceparent: 00-... │ │
│ Create Span │ │ Extract │
│ Inject │ │ Create Span │
└─────────────┘ └─────────────┘
```
### Span Attributes
```text
Semantic conventions (standard attributes):
HTTP:
- http.method: GET, POST, etc.
- http.url: Full URL
- http.status_code: 200, 404, 500
- http.route: /users/{id}
Database:
- db.system: postgresql, mysql
- db.statement: SELECT * FROM...
- db.operation: query, insert
RPC:
- rpc.system: grpc
- rpc.service: OrderService
- rpc.method: CreateOrder
Custom:
- user.id: 12345
- order.total: 99.99
- feature.flag: experiment_v2
```
## Tracing Backends
### Jaeger
```text
Features:
- Open source (CNCF)
- Built-in UI
- Multiple storage backends
- OpenTelemetry native
Architecture:
┌─────────────┐ ┌─────────────┐ ┌─────────────┐
│ Agent │─►│ Collector │─►│ Storage │
│ (optional) │ │ │ │ (Cassandra/ │
└─────────────┘ └─────────────┘ │ Elasticsearch)
│ └─────────────┘
▼
┌─────────────┐
│ Query │
│ Service │
└─────────────┘
│
▼
┌─────────────┐
│ UI │
└─────────────┘
```
### Zipkin
```text
Features:
- Mature, battle-tested
- Simple architecture
- Low resource overhead
- Good ecosystem support
Best for:
- Simpler setups
- Lower resource environments
- Teams familiar with Zipkin
```
### Grafana Tempo
```text
Features:
- Object storage backend (cheap)
- Deep Grafana integration
- Log-based trace discovery
- Exemplars support
Best for:
- Grafana-heavy environments
- Cost-sensitive deployments
- Large-scale traces
```
### Cloud Native Options
| Provider | Service | Integration |
| -------- | ------- | ----------- |
| AWS | X-Ray | Native AWS services |
| GCP | Cloud Trace | Native GCP services |
| Azure | Application Insights | Native Azure services |
| Datadog | APM | Full-stack observability |
## Sampling Strategies
### Why Sample?
```text
High-traffic systems generate millions of spans.
Storing all spans is expensive and often unnecessary.
Sampling: Collect a subset of traces
Goal: Keep enough data to debug issues
while managing costs
```
### Sampling Types
```text
1. Head-based sampling (at trace start):
- Decision made when trace begins
- Consistent across services
- Simple but may miss rare events
2. Tail-based sampling (after trace complete):
- Decision made after seeing full trace
- Can keep interesting traces (errors, slow)
- Requires buffering spans
- More complex infrastructure
3. Priority sampling:
- Assign priority based on attributes
- Keep all errors, sample normal traffic
```
### Sampling Strategies
```text
Rate-based:
- Sample 10% of all traces
- Simple, predictable cost
Priority-based:
- 100% of errors
- 100% of slow requests (>1s)
- 5% of normal requests
Adaptive:
- Adjust rate based on traffic
- Target specific traces/second
- Handle traffic spikes
```
## Correlation Patterns
### Logs-Traces-Metrics
```text
Three Pillars of Observability:
Logs ◄──────────► Traces ◄──────────► Metrics
│ │ │
│ trace_id │ exemplars │
│ span_id │ │
└──────────────────┴───────────────────┘
Correlation:
1. Add trace_id/span_id to log entries
2. Add exemplars (trace links) to metrics
3. Click from metric → trace → logs
```
### Log Correlation
```text
Structured log with trace context:
{
"timestamp": "2024-01-15T10:30:00Z",
"level": "ERROR",
"message": "Payment failed",
"trace_id": "abc123def456",
"span_id": "789xyz",
"service": "payment-service",
"user_id": "12345",
"error": "Card declined"
}
Query in log aggregator:
trace_id:"abc123def456"
→ See all logs for this request
```
### Exemplars (Metrics to Traces)
```text
Metric with exemplar:
http_request_duration{service="api"} = 2.5s
└── exemplar: trace_id=abc123
When latency spikes:
1. See metric spike in dashboard
2. Click on data point
3. Jump directly to slow trace
4. See exactly what caused latency
```
## Instrumentation Patterns
### Automatic Instrumentation
```text
Zero-code instrumentation:
- HTRelated 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.