Skip to content
guidePhase: OperateOperationsGuide 10 of 16

Roles: devops sre

Guide: Monitoring, Tracing & Logging ​

Decision: How to instrument services and store/query the three pillars — metrics, logs, traces — on AWS.

Related: operations-observability.md · dashboards-reporting.md · incident-management.md


The three pillars ​

PillarAnswersTypical use
MetricsHow much? How fast? How many errors?Dashboards, alerts, SLOs
LogsWhat happened in this request?Debug, audit, security
TracesWhere did time go across services?Latency, dependency failures

Golden rule: Correlate with shared trace_id / request_id across all three.


Instrumentation approach ​

ApproachProsCons
OpenTelemetry (OTel) SDKVendor-neutral; future-proofSDK config in each service
AWS Distro for OpenTelemetry (ADOT)AWS-supported collectorCollector ops
X-Ray SDK directSimple on AWSLock-in; merging with OTel anyway
Auto-instrumentation agentsLow dev effortMagic; harder to debug overhead

Recommended: OTel SDK → ADOT collector → export to CloudWatch + X-Ray (and/or vendor).


Metrics ​

BackendProsCons
CloudWatch MetricsNative; alarms integratedCardinality limits; cost at high card
Amazon Managed Prometheus (AMP)PromQL; Grafana nativeOperate remote write
Datadog / DynatraceRich APM metricsCost
StatsD / custom pushLegacy appsLess standard today

What to emit (RED + USE) ​

PatternMetrics
RED (services)Rate, Errors, Duration
USE (resources)Utilization, Saturation, Errors
Business KPIsOrders/min, signups — for reporting

Pitfall: AI-generated code omits custom metrics → template/middleware in your service scaffold.


Logging ​

BackendProsCons
CloudWatch LogsNative; subscription filtersQuery UX vs OpenSearch
OpenSearch (logs)Full-text + MLCluster cost
S3 + AthenaCheap long-term archiveNot real-time
Datadog LogsUnified with APMCost

Structured logging (required) ​

json
{
  "timestamp": "ISO8601",
  "level": "info",
  "service": "orders-api",
  "trace_id": "...",
  "message": "order created",
  "order_id": "uuid",
  "duration_ms": 42
}
PracticeWhy
JSON linesParseable; AI log analysis works
No PII in messageData governance
Consistent field namesCross-service queries

Pitfall: console.log(customer) in AI-generated handlers → Macie/DLP won't save you if logs already shipped.


Tracing ​

BackendProsCons
AWS X-RayIntegrated with API Gateway, Lambda, ECSUI limited vs vendors
OTel → X-Ray + vendorBest of bothDual export cost
Jaeger (self-hosted)Open sourceOperate Jaeger
Datadog APM / HoneycombExcellent trace UXCost

Propagation ​

  • W3C traceparent header on all HTTP/gRPC
  • Message attributes on SQS/SNS/EventBridge
  • Pitfall: Broken context across async boundaries AI code creates → document pattern in ADR

Real user monitoring (RUM) ​

ToolProsCons
CloudWatch RUMAWS-nativeWeb-focused
Datadog RUM / SentrySession replay, frontend errorsPrivacy review for replay
Web Vitals onlyLightweightLess backend correlation

Links frontend slowness to backend traces when trace_id passed from browser (careful with PII).


Synthetic monitoring ​

ToolProsCons
CloudWatch SyntheticsCanaries in AWSScript maintenance
Pingdom / ChecklyExternal perspectiveOutside AWS account
Playwright in CIPre-releaseNot continuous prod

See also observability-monitoring-qa.md for QA-oriented synthetics.


Cost & cardinality pitfalls ​

PitfallMitigation
High-cardinality labels (user_id on every metric)Allowlist labels; aggregate
Verbose debug logs in prodLevel per env; dynamic debug with trace flag
100% trace sampling alwaysTail-based or adaptive sampling
Duplicate telemetry (X-Ray + full vendor double pay)Single OTel pipeline, fan-out consciously

OTel in services → ADOT sidecar/collector → CloudWatch Logs + Metrics + X-Ray → structured JSON logs with trace_id → RED metrics on all T1 APIs → RUM on customer UI → Synthetics on checkout/login paths.


Reference template only — no production code. Adapt in your own project.