Basic Features
Sampling
3 min
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 with python sdk, you can configure sampling when initializing the client from abvdev import abv, get client import os \# method 1 set environment variable os environ\["abv sample rate"] = "0 5" # as string in env var abv = get client() \# method 2 initialize with constructor parameter then get client abv(sample rate=0 5) # 50% of traces will be sampled abv = get client() when using the @observe() decorator from abvdev import observe, abv, get client \# initialize the client with sampling abv(sample rate=0 3) # 30% of traces will be sampled @observe() def process data() \# only 30% of calls to this function will generate traces \# the decision is made at the trace level (first span) pass 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 instrumentation ts import { nodesdk } from "@opentelemetry/sdk node"; import { abvspanprocessor } from "@abvdev/otel"; import { traceidratiobasedsampler } from "@opentelemetry/sdk trace base"; const sdk = new nodesdk({ // sample 20% of all traces sampler new traceidratiobasedsampler(0 2), spanprocessors \[new abvspanprocessor()], }); see typescript sdk overview docid\ j4sdnlmdmnfmk99ootgn7 for more details