Implementing Observability Patterns

1. Distributed Tracing Pattern

ConceptDetail
TraceEnd-to-end request across services
SpanSingle unit of work; has trace ID, span ID, parent ID
Context PropagationW3C Trace Context (traceparent header)
StandardsOpenTelemetry (OTel) — SDKs in all languages
BackendsJaeger, Tempo, Zipkin, Honeycomb, Datadog

Example: OTel Java Auto-Instrumentation

java -javaagent:opentelemetry-javaagent.jar \
     -Dotel.service.name=order-service \
     -Dotel.exporter.otlp.endpoint=http://otel-collector:4317 \
     -jar app.jar

2. Correlation ID Pattern

AspectDetail
DefinitionSingle ID stamped at edge; propagated through all services
HeaderX-Correlation-ID or traceparent trace ID
UsageLogged on every line; included in error responses
BenefitTie all logs/traces/events for a single business transaction

3. Log Aggregation Pattern

ComponentTools
CollectionFluent Bit, Vector, Filebeat, OTel Collector
TransportKafka, OTLP, syslog
StorageLoki, Elasticsearch, OpenSearch, ClickHouse
Query / UIGrafana, Kibana, Datadog, Splunk
FormatStructured JSON; include trace_id, service, level

4. Application Metrics Pattern

TypeUse
CounterMonotonic count (requests, errors)
GaugeSnapshot value (queue depth, memory)
HistogramDistribution (request latency)
SummaryPre-computed quantiles
REDRate, Errors, Duration — for services
USEUtilization, Saturation, Errors — for resources
ToolsPrometheus, OTel, Micrometer, Datadog

5. Health Check API Pattern

EndpointPurpose
/health/liveProcess alive (binary)
/health/readyReady for traffic (deps check)
/health/startupBoot complete
/healthAggregate (for humans)

Example: Health Response

{
  "status": "UP",
  "checks": {
    "db": { "status": "UP", "latencyMs": 12 },
    "kafka": { "status": "UP" },
    "redis": { "status": "DEGRADED", "message": "high latency" }
  }
}

6. Exception Tracking Pattern

CapabilityDetail
Auto-CaptureUnhandled exceptions reported with stack + context
GroupingSame fingerprint deduplicated
Release Tracking"Introduced in v2.3.0"
ToolsSentry, Rollbar, Bugsnag, Datadog Error Tracking

7. Audit Logging Pattern

FieldDetail
whoAuthenticated principal
whatAction performed
whenTimestamp (UTC, ISO 8601)
whereSource IP, service
targetResource ID
resultSUCCESS / DENIED / FAILED
StorageAppend-only, retention per compliance (often years)

8. Distributed Context Propagation Pattern

StandardDetail
W3C Trace Contexttraceparent, tracestate headers
W3C BaggageArbitrary key-value pairs (tenant, user, feature flag)
B3 HeadersLegacy Zipkin format
OTel ContextAPI for cross-cutting context

9. Service Dependency Mapping Pattern

SourceOutput
Trace DataAuto-derived service graph
Service MeshKiali, Linkerd dashboard
Static AnalysisCode scan for HTTP/gRPC clients
UseImpact analysis, blast radius, capacity planning

10. Span Context Pattern

FieldDetail
trace_id128-bit; same across whole trace
span_id64-bit; unique per span
parent_span_idReference to caller span
trace_flagsSampled bit, debug bit
attributesKey-value tags (http.status, db.statement)
eventsTimestamped log lines within span