Skip to main content
Sampling can be used to control the volume of traces collected by ABV. Sampling is handled client-side. You can configure the sample rate by setting the ABV_SAMPLE_RATE environment variable or by using the sample_rate/sampleRate constructor parameter. The value has to be between 0 and 1. The default value is 1, meaning that all traces are collected. A value of 0.2 means that only 20% of the traces are collected. The SDK samples on the trace level meaning that if a trace is sampled, all observations and scores within that trace will be sampled as well.

Implementation with Python SDK

Install packages
Add credentials and ABV_SAMPLE_RATE environment variable: Add your ABV credentials to your environment variables. Make sure that you have a .env file in your project root.
.env
load environment variables and initialize client with get_client:
Also with Python SDK, you can configure sampling when initializing the client:
If a trace is not sampled, none of its observations (spans or generations) or associated scores will be sent to ABV, which can significantly reduce data volume for high-traffic applications.

Implementation with JS/TS SDK

Install packages
Add credentials Add your ABV credentials to your environment variables. Make sure that you have a .env file in your project root and a package like dotenv to load the variables.
.env
Createinstrumentation.ts file and use dotenv package to load the variables. Additional parameters are provided to get trace visible in the UI immediately. ABV respects OpenTelemetry’s sampling decisions. You can configure a sampler in your OTEL SDK to control which traces are sent to ABV. This is useful for managing costs and reducing noise in high-volume applications. Here is an example of how to configure a TraceIdRatioBasedSampler to send only 20% of traces:
instrumentation.ts
Import the instrumentation.ts file at the top of your application. See JS/TS SDK docs for more details.