Skip to content

ddtrace Sampling


Warning

This example uses ddtrace version 0.114.0 (latest) for testing

Prerequisites

java -javaagent:D:/ddtrace/dd-java-agent-0.114.0.jar \
-Ddd.service.name=ddtrace-server \
-Ddd.agent.port=9529 \
-jar springboot-ddtrace-server.jar

Installation and Deployment

1 Sampler Configuration in ddtrace.conf

  ## Sampler config uses to set global sampling strategy.
  ## sampling_rate used to set global sampling rate.
  [inputs.ddtrace.sampler]
    sampling_rate = 0.1

2 Test Script

for ((i=1;i<=100;i++)); 
do
    curl http://localhost:8080/counter
done

3 Enable Sampling

  1. Enable Sampling on the Collector Side

The range of sampling_rate is (0,1). If the value is outside this range, the trace is discarded.

If full sampling is required, do not configure [inputs.ddtrace.sampler].

  1. Enable Sampling on the Application Side

Enable sampling on the application side by using -Ddd.trace.sample.rate, with the range (0,1).

This is a tagged sampling, meaning the trace is fully collected while a sampling tag is applied.

  1. Sampling Priority

Both sampling methods have the same effect. If both are configured, the collector-side sampling does not take effect. That is:

Summary

-Ddd.trace.sample.rate > sampling_rate

Reference Documentation

<Demo Source Code>

<ddtrace Startup Options>

Feedback

Is this page helpful?