api-tracing
Instrument API requests with spans and distributed tracing. Use when tracking request latency or debugging API issues.
When & Why to Use This Skill
This Claude skill enables developers to instrument API requests with distributed tracing and spans, facilitating real-time monitoring of request latency and system performance. By leveraging OpenTelemetry (OTel) standards, it helps identify bottlenecks, debug complex API issues, and maintain high-performance standards through p50/p95 metric tracking and standardized logging practices.
Use Cases
- Performance Optimization: Identify slow API endpoints by analyzing p50 and p95 latency metrics to improve overall application responsiveness.
- Distributed Debugging: Trace requests across multiple services to pinpoint the exact source of failures or delays in a microservices architecture.
- Compliance & Security: Implement standardized logging that captures essential metadata while automatically excluding sensitive PII and authentication tokens to ensure data privacy.
- System Health Monitoring: Track error rates and response times against predefined thresholds to proactively detect and resolve service degradation.
| name | api-tracing |
|---|---|
| description | Instrument API requests with spans and distributed tracing. Use when tracking request latency or debugging API issues. |
| priority | 2 |
API Tracing
Measure API requests and correlate with backend traces.
What to Capture (OTel-Compatible)
| Attribute | OTel Name | Purpose |
|---|---|---|
| Method | http.request.method |
GET, POST, etc. |
| Status | http.response.status_code |
Success/failure |
| URL | url.path |
Endpoint (sanitized) |
| Duration | http.request.duration |
Request time (ms) |
Using OTel naming now = easier migration later.
Key Thresholds
| Metric | Good | Acceptable | Poor |
|---|---|---|---|
| p50 | <200ms | <500ms | >500ms |
| p95 | <1s | <2s | >2s |
| Error rate | <0.1% | <1% | >1% |
What NOT to Log
| Don't | Why |
|---|---|
| Request bodies | PII risk |
| Auth headers | Security |
| Full response data | Size limits |
| User tokens | Security |
Do log: Request ID, sanitized path, status code, duration, error type.
Implementation
See templates/api-interceptor.ts for fetch/axios interceptors.
Use Read tool to load template when generating implementation.
Related
skills/error-tracking- API error handlingskills/route-transition-tracking- Data fetch during navigationreferences/otel-web.md- OpenTelemetry naming