Trace sampling modes (for agent versions earlier than 3.2.8)
Application Real-Time Monitoring Service (ARMS) provides multiple trace sampling modes so that you can capture the trace data you need at a lower cost.
In most distributed systems, recording every trace is impractical because many traces contain repetitive, low-priority information. Sampling reduces observability costs and filters out noise.
Trace sampling prioritizes capturing the most relevant traces. ARMS provides the following sampling modes:
Fixed-rate sampling
Fixed-rate sampling records a specific percentage of traces based on the TraceId. For example, a rate of 10% means that one out of every 10 traces is recorded. A sampling decision applies to the entire trace: either all spans are kept, or the entire trace is discarded. This ensures that no partial traces are stored.
To configure fixed-rate sampling, follow these steps:
-
Log on to the ARMS console. In the left-side navigation pane, choose .
At the top of the Application List page, select the destination region, and then click the target application.
NoteThe icons in the Language column have the following meanings:
: A Java application connected to Application Monitoring.
: A Go application monitored by Application Monitoring.
: A Python application monitored by Application Monitoring.-: An application integrated with Managed Service for OpenTelemetry.
- In the left-side navigation pane, click Application Settings. On the page that appears, click the Custom Configuration tab.
In the Sampling Rate Settings section, set the sampling rate. Set Sampling rate mode to fixed-rate sampling and enter the percentage value in the Sampling Rate Settings field. For example, enter 10 for a 10% sampling rate.
NoteThe changes take effect immediately without restarting your application. The default value is 10 for Java and Go applications, and 100 for Python applications. Increasing the sampling rate consumes additional system resources. We recommend keeping the default value.
Adaptive sampling
To further reduce costs and improve the trace query experience, ARMS offers adaptive sampling. Unlike fixed-rate sampling, adaptive sampling uses multiple hit policies to dynamically decide whether to sample a trace, balancing the limited coverage of low sampling rates against the high cost of high sampling rates. Adaptive sampling is recommended for scenarios with high or highly variable traffic.
Adaptive sampling includes three main hit strategies: full sampling for specific interfaces, sampling for top N requests, and minimum sampling for all interfaces.
Full sampling for specific interfaces: You can specify interfaces by name, prefix, or suffix for 100% sampling. All requests to these interfaces trigger full trace sampling. Because this significantly increases the amount of data collected, enable it only for critical interfaces or when temporarily needed.
Sampling for top N requests: This strategy uses a variant of the LFU (Least Frequently Used) algorithm. Within a given time frame, it samples only a limited number of requests per interface, ensuring that data collection volume does not grow linearly with traffic.
Minimum sampling for all interfaces: This strategy ensures that at least one trace is sampled per interface within a given time frame, capturing representative data even for low-traffic interfaces.
Currently, ARMS only allows you to customize settings for full sampling of specific interfaces. Fine-grained tuning for top N request sampling and minimum sampling is not yet supported.
To configure adaptive sampling, follow these steps:
-
Log on to the ARMS console. In the left-side navigation pane, choose .
At the top of the Application List page, select the destination region, and then click the target application.
NoteThe icons in the Language column have the following meanings:
: A Java application connected to Application Monitoring.
: A Go application monitored by Application Monitoring.
: A Python application monitored by Application Monitoring.-: An application integrated with Managed Service for OpenTelemetry.
- In the left-side navigation pane, click Application Settings. On the page that appears, click the Custom Configuration tab.
In the Sampling Rate Settings section, set the sampling rate. Set Sampling rate mode to adaptive sampling. You can then specify the interfaces, prefixes, and suffixes for full sampling.
NoteThe changes take effect immediately without restarting your application. Adaptive sampling is supported only by agent versions 2.8.3 and later.
Basic Edition sampling
Basic Edition sampling is available only to users who have activated Basic Edition billing. It includes one free default sampling policy and multiple customizable sampling policies.
Default sampling (free): By default, ARMS collects one trace per minute for each agent across all interfaces in your account, free of charge.
Custom sampling policies: You can configure custom sampling policies based on your requirements. Each policy can sample traces at a fixed rate or a traffic quota and can be applied to all or specific interfaces.
To configure a custom sampling policy, follow these steps:
-
Log on to the ARMS console. In the left-side navigation pane, choose .
At the top of the Application List page, select the destination region, and then click the target application.
NoteThe icons in the Language column have the following meanings:
: A Java application connected to Application Monitoring.
: A Go application monitored by Application Monitoring.
: A Python application monitored by Application Monitoring.-: An application integrated with Managed Service for OpenTelemetry.
- In the left-side navigation pane, click Application Settings. On the page that appears, click the Custom Configuration tab.
In the Sampling Rate Settings section, click Add Client Sampling Policy, configure the following parameters, and then click Save.
Parameter
Description
Policy Name
A custom name for the sampling policy.
Sampling Type and Samples
Fixed-rate Sampling: Samples traces based on a fixed proportion. If you select this option, set the Samples to a fixed percentage, such as 10%.
Traffic Limit: If you select this option, set the Samples to the number of traces each agent collects within the specified time window. For example, a setting of 5 traces per agent per 1 second means that each agent collects up to 5 traces every second.
Applicable interface
Specify the scope to which the sampling policy applies. You can select per span or select Specify a span and enter the interface name.
NoteCurrently, each sampling policy supports only one interface name. To sample traces for multiple interfaces, you must configure multiple sampling policies.
Custom sampling policy examples:
For the
/elastic/updateinterface, sample 20 traces per minute.For all interfaces, sample traces at a 20% rate.
Sampling for failed or slow requests
This strategy samples the spans of a request that meets any of the following criteria:
The request fails. A request is considered failed in two scenarios:
For HTTP interfaces, the status code is not in the 2xx or 3xx range.
An exception is caught through LocalRootSpan instrumentation, which typically occurs when a business exception is thrown to the framework.
The request latency exceeds the P99 latency of previous requests to the same interface. Note that the P99 value is calculated using bucket aggregation and may have a slight deviation.
An internal method within the request throws an exception. This feature is supported in agent versions 4.1.x and later.
This sampling policy does not guarantee complete end-to-end traces. When triggered, it saves only the spans of a single request within a specific application.
Additional information
To prevent trace collection from affecting business operations in high-traffic scenarios, ARMS limits the maximum number of traces an agent can collect per second. The default limit is 100. This safeguard applies to both fixed-rate and adaptive sampling. You can change this limit by modifying the Throttling Threshold parameter on the Custom Configuration tab.
A value higher than the default consumes additional system resources. We recommend keeping the default value.
Related documentation
After collecting traces, you can analyze the stored data in real time by combining filter conditions and aggregation dimensions. For more information, see Trace Explorer.