micrometer-tracing
Distributed tracing and observability with Micrometer and Spring Boot 3
What this skill does
# Micrometer Tracing - Quick Reference
> **Full Reference**: See [advanced.md](advanced.md) for custom ObservationConvention, baggage propagation, logging integration, metrics, async tracing, and testing patterns.
> **Deep Knowledge**: Use `mcp__documentation__fetch_docs` with technology: `micrometer-tracing` for comprehensive documentation.
## Dependencies
```xml
<!-- Micrometer Tracing Bridge (choose one) -->
<!-- For Brave (Zipkin) -->
<dependency>
<groupId>io.micrometer</groupId>
<artifactId>micrometer-tracing-bridge-brave</artifactId>
</dependency>
<!-- For OpenTelemetry -->
<dependency>
<groupId>io.micrometer</groupId>
<artifactId>micrometer-tracing-bridge-otel</artifactId>
</dependency>
<!-- Reporter (choose one) -->
<dependency>
<groupId>io.zipkin.reporter2</groupId>
<artifactId>zipkin-reporter-brave</artifactId>
</dependency>
```
## Configuration
```yaml
spring:
application:
name: order-service
management:
tracing:
sampling:
probability: 1.0 # Sample 100% in dev, lower in prod
zipkin:
tracing:
endpoint: http://localhost:9411/api/v2/spans
logging:
pattern:
level: "%5p [${spring.application.name:},%X{traceId:-},%X{spanId:-}]"
```
## Core Concepts
```
┌─────────────────────────────────────────────────────────────┐
│ Trace (End-to-End Request) │
│ TraceId: abc123 │
│ │
│ ┌──────────────────┐ │
│ │ Span: API Gateway│ SpanId: 001 (Parent) │
│ └────────┬─────────┘ │
│ │ │
│ ┌────────▼─────────┐ ┌─────────────────┐ │
│ │ Span: Order Svc │ │ Span: User Svc │ │
│ │ SpanId: 002 │ │ SpanId: 003 │ │
│ └──────────────────┘ └─────────────────┘ │
└─────────────────────────────────────────────────────────────┘
```
## Automatic Instrumentation
Spring Boot 3 auto-instruments:
- HTTP Server (Spring MVC, WebFlux)
- HTTP Client (RestTemplate, WebClient, RestClient)
- JDBC, Kafka, RabbitMQ, Redis, MongoDB
- Scheduled Tasks
## Using Observation API
```java
@Service
@RequiredArgsConstructor
public class OrderService {
private final ObservationRegistry observationRegistry;
public Order processOrder(OrderRequest request) {
return Observation.createNotStarted("order.process", observationRegistry)
.lowCardinalityKeyValue("order.type", request.getType())
.highCardinalityKeyValue("order.id", request.getId())
.observe(() -> {
Order order = createOrder(request);
validateOrder(order);
return saveOrder(order);
});
}
}
```
## Using @Observed Annotation
```java
@Configuration
public class ObservationConfig {
@Bean
public ObservedAspect observedAspect(ObservationRegistry registry) {
return new ObservedAspect(registry);
}
}
@Service
public class PaymentService {
@Observed(
name = "payment.process",
contextualName = "process-payment",
lowCardinalityKeyValues = {"payment.method", "credit_card"}
)
public PaymentResult processPayment(PaymentRequest request) {
return paymentGateway.charge(request);
}
}
```
## HTTP Client Tracing
```java
@Configuration
public class RestClientConfig {
@Bean
public RestClient restClient(RestClient.Builder builder) {
return builder
.baseUrl("http://order-service")
.build(); // Auto-instrumented in Spring Boot 3
}
}
```
## Best Practices
| Do | Don't |
|----|-------|
| Use low cardinality for tags | High cardinality in metrics |
| Sample appropriately in prod | 100% sampling in production |
| Propagate context in async | Lose trace context |
| Use meaningful span names | Generic names like "process" |
| Include traceId in logs | Log without correlation |
## Production Configuration
```yaml
management:
tracing:
sampling:
probability: 0.1 # Sample 10% in production
zipkin:
tracing:
endpoint: ${ZIPKIN_URL:http://zipkin:9411}/api/v2/spans
metrics:
tags:
application: ${spring.application.name}
environment: ${ENVIRONMENT:development}
```
## Checklist
- [ ] Sampling rate configured
- [ ] Trace exporter configured (Zipkin/Jaeger/OTLP)
- [ ] Logging includes traceId/spanId
- [ ] Baggage propagation configured
- [ ] Async context propagation working
- [ ] Custom observations for business ops
- [ ] Metrics exported to monitoring
- [ ] Health checks include tracing
- [ ] Error tracking in spans
- [ ] Performance overhead measured
## Reference
- [Micrometer Tracing Docs](https://micrometer.io/docs/tracing)
- [Spring Boot Observability](https://docs.spring.io/spring-boot/reference/actuator/tracing.html)
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.