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 comprehensive API tracing and distributed instrumentation using OpenTelemetry-compatible standards. It allows developers to monitor request latency, track performance metrics like p50/p95, and debug complex API issues by correlating spans across services while maintaining strict security best practices for data logging.
Use Cases
- Performance Bottleneck Identification: Pinpoint specific services or endpoints causing high latency in multi-tier architectures using distributed tracing and span correlation.
- API Reliability Monitoring: Track real-time error rates and HTTP status codes to quickly identify and resolve production regressions or service outages.
- SLA Compliance & Benchmarking: Measure p50 and p95 response times against defined thresholds to ensure the application meets performance requirements and user expectations.
- Secure Observability Implementation: Generate OTel-compliant interceptors that log essential metadata like request duration and path while automatically excluding sensitive PII and authentication tokens.
| 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