Analyze trace data in real time

Updated at:

If your application encounters issues such as uneven traffic, instance failures, or slow interfaces, you can use Trace Explorer to quickly locate the faulty code. Trace Explorer also helps you monitor service traffic and canary releases. This topic walks through five common scenarios.

Background information

Application Real-Time Monitoring Service (ARMS) lets you troubleshoot errors for individual requests by using traces, and monitor services with pre-aggregated trace metrics. Trace Explorer goes further by analyzing post-aggregated trace data, identifying issues and enabling custom diagnostics more efficiently than traces or pre-aggregated charts alone.

Trace Explorer lets you combine filter conditions and aggregation dimensions for real-time analysis on stored full trace data. For example, you can view time series charts of slow calls that take more than 3 seconds, the distribution of invalid requests across instances, or traffic changes for VIP customers.

Scenario 1: Uneven traffic distribution

Why does SLB route more traffic to some instances than others? What can I do to fix it?

Server Load Balancer (SLB) may route more traffic to some instances than others for various reasons, such as misconfigured SLB settings, node restart failures caused by registry errors, or load factor errors in distributed hash tables (DHTs). Uneven traffic distribution can lead to service unavailability.

When traffic becomes uneven, services slow down and errors increase. Standard troubleshooting may not pinpoint the root cause quickly enough.

Trace Explorer lets you view trace data grouped by IP address to see how requests are distributed across instances and how traffic distribution changes after an issue occurs. If a large number of requests concentrate on one or a few instances, uneven traffic is likely the cause. You can then troubleshoot based on the traffic distribution changes and roll back in time.

On the Trace Explorer page, group the data by IP address. The results may show that most of the traffic is concentrated on a single instance, such as opentelemetry-demo-frontend-XX.

Scenario 2: Instance failures

How do I troubleshoot an instance failure?

Instance failures such as network interface controller damage, CPU overcommitment, and disk overload can occur at any time. While they rarely cause full service outages, they lead to sporadic request failures or timeouts that degrade user experience and increase support costs. Identifying and resolving instance failures promptly is critical.

Instance failures fall into two categories: host failures and container failures. In Kubernetes environments, these correspond to node failures and pod failures. CPU overcommitment and hardware damage are host failures that affect all containers on the host. Container failures such as disk overload and memory leaks affect only a single container. You can troubleshoot by analyzing host IP addresses and container IP addresses separately.

To check for instance failures, query failed or timed-out requests in Trace Explorer and aggregate results by host IP address or container IP address. If failed requests concentrate on a single instance, you can switch to another instance for quick recovery, or inspect system metrics such as disk usage and CPU steal time. If failed requests are scattered across multiple instances, the issue likely lies in downstream services or program logic rather than a specific instance.

On the Trace Explorer page, filter for error or slow calls and group the statistics by IP address. If abnormal calls are concentrated on a specific instance, an instance failure is highly likely. On the Trace Explorer page, set the filter condition to statusCode IN (2, 3) to filter for error requests, and select IP address as the aggregation dimension. In the quick filter panel on the left, select the Error status. The search results show that 2,857 error calls are concentrated on two hosts (1,430 and 1,425 calls respectively), each with a 100% error rate. This indicates one or more instance failures.

Scenario 3: Slow interfaces

How do I query slow interfaces before I release an application or implement a promotion?

Thorough performance optimization is essential before releasing an application or running a promotion. Start by identifying performance bottlenecks and listing the slow interfaces along with their frequency.

To find slow interfaces, use Trace Explorer to query interfaces whose response time exceeds a specific threshold, and group the results by name.

Then, analyze the root causes of slow interfaces by examining traces, method stacks, and thread pools. Common causes include:

  • The database or microservice connection pool is too small, causing many requests to wait for connections. Increase the maximum number of threads in the connection pool.

  • External and internal requests are sent separately. Merge them to reduce network transmission overhead.

  • A single request returns a large amount of data, causing slow network transmission and deserialization that may trigger full garbage collections (GCs). Replace full queries with paged queries.

  • Synchronous logging is inefficient. Replace it with asynchronous logging.

On the Trace Explorer page, filter for calls that take longer than 5 seconds and group them by interface name to identify patterns. For example, on the Trace Explorer page, enter duration>5000000000 in the filter bar. Set the Group by dimension to Interface name, and use the Duration slider on the left to further narrow the range. The list below displays metrics such as call count, error count, and average duration for each interface.

Scenario 4: Service traffic statistics

How do I analyze the traffic changes and service quality of major customers or stores?

Services often involve multiple dimensions such as category, store, and user. For example, a wrong order or a broken POS machine at a physical retail store could cause a public relations (PR) crisis. Physical stores typically have higher service level agreement (SLA) requirements than online stores, so you may need to closely monitor their traffic changes and service quality.

You can use custom attribute filtering and aggregation in Trace Explorer to analyze business traces at a low cost. For example, tag offline orders in the entry service with {"attributes.channel": "offline"}, and add separate tags for stores, user segments, and product categories. Then, filter traces by attributes.channel = offline and use group by on different business tags to aggregate metrics such as request count, duration, or error rate. This allows you to quickly analyze traffic trends and service quality for each business scenario.

Scenario 5: Canary release monitoring

I want to release 500 instances in 10 batches. How do I identify errors after the first batch?

Canary release is a key method to ensure application stability. If errors appear after you release the first few batches of instances, you must roll back immediately. Without effective canary release monitoring, service failures may go undetected.

For example, if the microservice registry fails, the microservice cannot register on instances that you restart or release. Without canary release monitoring, this error goes unnoticed because the overall traffic and duration of the service remain stable. As more batches fail to register, the service eventually becomes unavailable.

In this scenario, tag different instance versions with an attribute such as {"attributes.version": "v1.0.x"}, and use Trace Explorer to query traces by attributes.version. This lets you compare traffic and service quality across instance versions before and after the release, enabling real-time canary release monitoring.

Limits

Trace Explorer supports custom diagnostics across various scenarios but has the following limitations:

  • The cost of analysis based on detailed trace data is high.

    Accurate analysis requires uploading full trace data to Trace Explorer, which can incur high storage costs. To reduce costs, especially for cross-network storage, deploy edge nodes in user clusters to cache and process data locally. You can also separate hot and cold data on the server: use Trace Explorer for hot data analysis, and analyze only slow and invalid traces for cold data.

  • Post-aggregation analysis is not suitable for alerting because it has high performance overhead and low concurrency.

    Trace Explorer scans full data and generates statistics in real time, which incurs much higher performance overhead than pre-aggregated statistics. This makes it unsuitable for alerting, which requires high concurrency. Instead, customize metrics and run post-aggregation analysis statements on the client to generate trace statistics for alerts and dashboards.

  • Trace Explorer requires you to manually specify attributes.

    Unlike pre-aggregated application monitoring metrics, Trace Explorer requires you to manually specify attributes to differentiate business scenarios and perform targeted analysis.

References

You can configure alerting for one or more interfaces so that alert notifications are sent to the O&M team when exceptions occur. For more information, see Application Monitoring alert rules.