Cloud Observability 101: Distributed Tracing and Logging with CloudWatch and AWS X-Ray
Explore cloud observability fundamentals and learn how Amazon CloudWatch, AWS X-Ray, and OpenTelemetry work together to monitor distributed applications, analyze logs, trace requests, identify performance bottlenecks, and improve system reliability.
Cloud Observability 101: Distributed Tracing and Logging with CloudWatch and AWS X-Ray
Learn how to understand application behavior across distributed systems using logs, traces, and metrics—and how Amazon CloudWatch and AWS X-Ray help identify performance bottlenecks, troubleshoot failures, and improve reliability.
Introduction
Modern applications rarely operate as a single, self-contained program. A typical cloud application may consist of multiple microservices, APIs, databases, message queues, and external integrations, often distributed across different environments.
This architecture offers flexibility and scalability, but it also introduces a major challenge: when something goes wrong, how do you determine where the problem actually happened?
Imagine a user accessing an online shopping application. The frontend sends a request to an API, which communicates with an authentication service, retrieves product information from a database, and eventually requests payment processing from another service.
If the request takes five seconds instead of the expected few hundred milliseconds, identifying the cause may not be straightforward. The delay could originate from the API, a database query, network communication, or an external dependency.
Traditional monitoring alone may not provide enough context to understand the complete request lifecycle.
This is where cloud observability becomes essential.
By combining logs, metrics, and distributed traces, development and operations teams can gain a clearer understanding of how applications behave internally. AWS provides services such as Amazon CloudWatch and AWS X-Ray to help collect, analyze, and visualize this information.
In this article, we will explore the fundamentals of observability, understand the differences between logging and distributed tracing, and see how these capabilities work together in AWS environments.
1. The Three Pillars of Observability
Observability is commonly organized around three types of telemetry: metrics, logs, and traces.
Each provides a different perspective on application behavior. They become especially powerful when analyzed together.
Metrics: What is happening?
Metrics are numerical measurements collected over time. They help teams understand the overall health and performance of an application.
Common examples include:
- CPU and memory utilization.
- Request count and throughput.
- Average response time.
- Error rates.
- Database connection counts.
For example, if an application suddenly starts responding slowly, a dashboard showing increased CPU utilization may indicate that a resource bottleneck is developing.
Metrics are particularly useful for identifying trends, detecting anomalies, and configuring alerts.
Logs: What happened?
Logs are records of events generated by applications, operating systems, and infrastructure components.
They provide contextual information about individual operations and errors.
For example:
2026-11-10 10:32:14 INFO Request received: GET /products/1232026-11-10 10:32:14 INFO Database connection established2026-11-10 10:32:15 ERROR Database query timed out2026-11-10 10:32:15 INFO Response returned: HTTP 500This sequence helps developers understand what happened during a particular operation.
Unlike metrics, which summarize behavior numerically, logs can preserve detailed event information, making them useful for debugging and investigating unexpected behavior.
Traces: Where did the request go?
Distributed traces follow a request as it travels through different services and components.
Instead of examining each service independently, developers can reconstruct the request's journey and understand how much time each operation consumed.
For example, an online shopping request might follow this path:
- API Gateway receives the request.
- An authentication service validates the user.
- A product service retrieves product information.
- A database executes a query.
- The API returns the response.
A distributed trace connects these operations, helping identify which component introduced latency or returned an error.
How the three signals complement each other
Signal | Main question | Typical use |
|---|---|---|
Metrics | What is happening? | Detecting performance degradation |
Logs | What happened? | Investigating errors and events |
Traces | Where did it happen? | Identifying bottlenecks across services |
Consider a practical situation: users report that a checkout operation is taking too long.
- Metrics reveal that the application's response time increased.
- Traces show that the payment service is responsible for most of the delay.
- Logs reveal that the payment service is repeatedly timing out while communicating with an external provider.
Together, these signals transform an unclear performance issue into an investigation with a much more specific direction.
2. Understanding Distributed Tracing
Distributed tracing is particularly important in microservice architectures, where a single user action can trigger multiple internal requests.
To understand how it works, we need to introduce two fundamental concepts: traces and spans.
What is a trace?
A trace represents the complete journey of a request through an application.
Each trace receives a unique identifier that allows its related operations to be connected, even when they occur across different services.
For example, imagine a customer placing an order:
Customer Request | v API Gateway | v Order Service | +----------------+ | | v vInventory Service Payment Service | | v v Database Payment Provider | | +--------+-------+ | v Final ResponseThe trace provides a way to examine this complete request flow instead of investigating each component independently.
What is a span?
A span represents an individual operation within a trace.
It contains information such as:
- Operation name.
- Start and end timestamps.
- Duration.
- Parent-child relationships.
- Attributes describing the operation.
- Status information, including errors.
For example, a trace might contain the following spans:
Operation | Duration |
|---|---|
API Gateway | 450 ms |
Order Service | 380 ms |
Inventory Service | 80 ms |
Payment Service | 250 ms |
Database Query | 35 ms |
These numbers are illustrative. In a real trace, spans may overlap, run in parallel, or include additional nested operations.
The important idea is that spans help developers understand where time is being spent.
If a request takes 450 milliseconds and the payment service accounts for most of its processing time, the investigation can focus on that dependency instead of examining the entire application.
Context propagation: Connecting the services
Distributed tracing depends on context propagation.
When one service sends a request to another, it must transmit tracing information so that the receiving service can associate its operation with the original request.
OpenTelemetry supports standard propagation formats such as W3C Trace Context, while AWS X-Ray also supports its own trace header format.
Without proper context propagation, individual services may generate separate traces instead of contributing to one connected request journey.
This is particularly important when applications communicate through HTTP APIs, messaging systems, or other distributed mechanisms.
3. Amazon CloudWatch: Centralizing Application Telemetry
Amazon CloudWatch is an AWS monitoring and observability service that helps collect, visualize, and analyze operational data from cloud resources and applications.
It provides several capabilities that support observability workflows.
CloudWatch Metrics
CloudWatch Metrics collects numerical measurements from AWS services and applications.
For example, an application running on Amazon EC2 can be monitored through metrics such as CPU utilization and network activity.
Developers can also publish custom application metrics, such as:
- Number of successful orders.
- Failed payment attempts.
- Requests processed per minute.
- Average processing duration.
These measurements can be displayed in dashboards and used to create alarms.
CloudWatch Logs
CloudWatch Logs centralizes log data generated by applications and infrastructure.
Logs are organized into log groups and log streams, making it easier to manage and investigate information from different services.
For example, an ECS application can send container logs to CloudWatch Logs, allowing developers to investigate application errors without connecting directly to individual compute environments.
CloudWatch Logs Insights provides a query interface for searching and analyzing log data.
A simplified example:
fields @timestamp, @message| filter @message like /ERROR/| sort @timestamp desc| limit 20This query retrieves recent log events containing the word
ERROR .Logs Insights supports more advanced queries, including aggregations and statistical analysis, which can help identify recurring errors or unusual application behavior.
CloudWatch Dashboards and Alarms
Dashboards combine metrics and other monitoring information into visual representations.
Instead of navigating through multiple services, developers can create a centralized view of application health.
Alarms can evaluate metric thresholds and initiate notifications or configured actions when conditions are met.
For example, a team might create an alarm when an application's error rate exceeds an acceptable threshold.
This makes CloudWatch useful not only for investigating problems but also for detecting them before they significantly affect users.
4. AWS X-Ray: Visualizing Distributed Requests
AWS X-Ray is designed to help developers analyze requests as they travel through distributed applications.
It collects trace information and provides visual representations of service interactions, allowing teams to investigate latency, errors, and dependencies.
Service maps
One of X-Ray's most useful capabilities is the service map.
A service map presents the relationships between application components based on collected tracing information.
For example, an application might contain:
- An API Gateway endpoint.
- An AWS Lambda function.
- An Amazon DynamoDB table.
- An external payment service.
The service map helps developers understand how these components interact and identify where problems may be occurring.
Trace analysis
Developers can inspect individual traces to understand the operations associated with a request.
A trace can reveal:
- Which services processed the request.
- How long individual operations took.
- Which dependencies introduced latency.
- Where errors occurred.
- How requests propagated between components.
This is particularly valuable when an application has many dependencies and a problem cannot be reproduced easily.
Sampling: Controlling trace collection
Collecting detailed traces for every request can introduce additional processing and storage costs.
Sampling helps control the amount of trace data collected.
Instead of recording every request, a sampling strategy determines which requests should generate detailed traces.
This reduces telemetry volume while still providing useful information about application behavior.
However, sampling must be configured carefully. If the sampling rate is too low, rare failures or unusual performance problems may not appear in the collected traces.
For applications requiring detailed investigation of specific operations, teams can use appropriate sampling strategies and additional instrumentation.
AWS X-Ray also integrates with CloudWatch capabilities such as Application Signals, allowing teams to correlate application health information with distributed traces.
5. Bringing CloudWatch and X-Ray Together
CloudWatch and X-Ray are most valuable when used together rather than as completely separate monitoring solutions.
CloudWatch provides centralized access to metrics, logs, and application health information, while X-Ray provides detailed visibility into distributed request execution.
Their integration makes it possible to move from detecting a problem to understanding its underlying cause.
A practical example: Troubleshooting a slow application
Imagine a containerized e-commerce application running on Amazon ECS with AWS Fargate.
The architecture includes:
- An Application Load Balancer receiving user requests.
- An ECS service running the application.
- A product service communicating with a database.
- A payment service integrating with an external provider.
- CloudWatch collecting logs and metrics.
- AWS X-Ray receiving distributed trace data.
Now imagine users begin reporting slow checkout operations.
A possible investigation would look like this:
Step 1 — Detect the problem with CloudWatch.
A CloudWatch dashboard shows an increase in application response time and error rates.
Step 2 — Investigate the request with X-Ray.
The trace reveals that most of the request's duration is associated with the payment service.
Step 3 — Examine the application logs.
CloudWatch Logs Insights reveals repeated timeout messages from the payment integration.
Step 4 — Identify the root cause.
The team determines that communication with the external payment provider is introducing excessive latency.
Step 5 — Implement and validate a solution.
Developers investigate connection timeouts, retry behavior, and dependency availability. After implementing a fix, they use metrics, logs, and traces to verify whether application performance has improved.
This workflow demonstrates why observability is more than collecting data: it is about connecting different sources of information to make troubleshooting more effective.
CloudWatch Application Signals
Application Signals provides application performance monitoring capabilities, helping teams understand service health and dependencies through standardized service-level indicators.
It can simplify the process of monitoring distributed applications by presenting information such as:
- Request rate.
- Error rate.
- Latency.
- Service dependencies.
- Service-level objectives (SLOs).
It also integrates with X-Ray tracing and CloudWatch telemetry, providing a more unified application monitoring experience.
For teams building microservices, this can reduce the effort required to assemble an observability solution from individual monitoring components.
6. OpenTelemetry: The Recommended Direction for New Instrumentation
When learning about AWS X-Ray, it is important to understand how application instrumentation is evolving.
OpenTelemetry (OTel) is an open-source, vendor-neutral framework for generating, collecting, and exporting telemetry data.
It supports the three main observability signals:
- Metrics.
- Logs.
- Traces.
Instead of requiring developers to depend entirely on a specific monitoring vendor's instrumentation libraries, OpenTelemetry provides standardized APIs, SDKs, and collection mechanisms.
AWS supports OpenTelemetry through the AWS Distro for OpenTelemetry (ADOT), CloudWatch integrations, and X-Ray.
How does OpenTelemetry fit into AWS?
A simplified architecture looks like this:
Application | vOpenTelemetry SDK | vOpenTelemetry Collector | +----------------------+ | | v vCloudWatch AWS X-RayMetrics and Logs Distributed TracesThe OpenTelemetry SDK instruments the application and generates telemetry.
The collector receives, processes, and exports this information to supported observability destinations.
This architecture is particularly useful when an application runs across multiple environments, such as Amazon EC2, ECS, EKS, and on-premises infrastructure.
An important AWS X-Ray update
Important for new projects
AWS has been transitioning its tracing ecosystem toward OpenTelemetry.
As of November 2026:
- AWS X-Ray SDKs and the X-Ray Daemon entered maintenance mode on February 25, 2026.
- Maintenance mode means AWS limits updates to security-related fixes rather than continuing regular feature development.
- AWS has announced that support for these SDKs and the Daemon will end on February 25, 2027.
For new instrumentation, AWS recommends OpenTelemetry-based solutions. Existing applications using the X-Ray SDK should evaluate migration to OpenTelemetry rather than building new dependencies on legacy instrumentation.
This does not mean that AWS X-Ray tracing itself is disappearing. OpenTelemetry-generated traces can still be exported to and analyzed through AWS X-Ray.
The distinction is between the instrumentation technology used to generate telemetry and the AWS service used to analyze it.
For developers starting new cloud projects, learning OpenTelemetry alongside CloudWatch and X-Ray is therefore a particularly valuable investment.
7. Best Practices for Cloud Observability
Implementing observability requires more than enabling monitoring services. The quality of collected telemetry directly influences how useful the information will be during an investigation.
Consider the following recommendations.
Use structured logging.
Prefer structured formats such as JSON instead of inconsistent plain-text messages.
This makes it easier to filter, search, and analyze logs using CloudWatch Logs Insights.
Correlate logs and traces.
Include trace identifiers in application logs whenever possible.
This helps developers move from a trace to the corresponding log events without manually searching through unrelated information.
CloudWatch Application Signals supports trace-to-log correlation through instrumentation that adds trace context to application logs.
Avoid logging sensitive information.
Never expose passwords, access tokens, secret keys, or unnecessary personal information in logs or trace attributes.
Telemetry can contain operational and business-sensitive data, so access permissions and retention policies should be configured carefully.
Use meaningful trace attributes.
Add useful context to spans, such as service names, operation types, and relevant application identifiers.
Avoid using high-cardinality attributes unnecessarily, especially when they contain unique values that significantly increase telemetry volume.
Configure sampling intentionally.
Choose sampling strategies according to application traffic, troubleshooting requirements, and budget.
For critical operations, consider whether additional tracing coverage is necessary.
Establish monitoring thresholds.
Use metrics and alarms to detect abnormal application behavior.
A dashboard is more useful when it helps teams identify meaningful changes rather than simply displaying large amounts of data.
Monitor observability costs.
Logs, metrics, and traces consume resources and may generate charges based on ingestion, storage, retention, and analysis.
Set appropriate log retention periods, avoid collecting unnecessary telemetry, and review sampling configurations regularly.
8. Getting Started: A Practical Learning Path
For developers who want to apply these concepts in AWS, a gradual approach is often more effective than trying to implement every observability capability simultaneously.
A suggested learning path is:
- Start with CloudWatch Metrics: Monitor basic infrastructure and application performance.
- Explore CloudWatch Logs: Configure an application to send logs to CloudWatch Logs and practice querying them with Logs Insights.
- Learn OpenTelemetry fundamentals: Understand instrumentation, spans, context propagation, and collectors.
- Send traces to AWS: Configure an OpenTelemetry-based application to export traces to AWS X-Ray.
- Explore service maps and Application Signals: Analyze service dependencies, latency, and application health.
- Build dashboards and alarms: Create a centralized monitoring view and configure alerts for relevant performance conditions.
AWS provides an official quickstart that demonstrates how to send metrics, logs, and traces to CloudWatch using OpenTelemetry. It is a useful practical starting point for experimenting with all three observability signals.
Conclusion
Cloud observability is a fundamental capability for operating modern distributed applications.
Metrics help identify abnormal behavior, logs provide detailed information about application events, and distributed traces reveal how requests move through different services.
Amazon CloudWatch and AWS X-Ray provide complementary capabilities that help developers collect, analyze, and correlate this information.
However, observability is not just about knowing whether an application is running. It is about understanding how it behaves, identifying why problems occur, and gathering enough information to make informed improvements.
As AWS continues expanding its OpenTelemetry integrations, developers should become familiar with standardized instrumentation and telemetry collection alongside CloudWatch and X-Ray.
Ultimately, a well-designed observability strategy helps transform troubleshooting from a process of guessing into a structured investigation supported by evidence.
References and Further Reading
Enjoyed reading this content? Let the author know!
Your likes, comments, shares, and saves help creators reach more builders.
Loading recommendations
Loading article