Thundra APM
Search…
Deployment Integrations
Powered By GitBook
Sampling in .NET SDK
You can reduce the amount of data that the .NET agent sends to the Thundra web console by enabling sampling. This feature allows you to add built-in sampling rules to the metric, log, and trace plugins or provide a custom sampler and implement sampling logic yourself.
Check out this example project on GitHub showing how to use sampling.
Trace Sampling
Log Sampling
Metric Sampling
The trace plugin provides four built-in samplers, but you can also provide your own custom or composite sampler. Built-in samplers include:
    Count Aware Sampler
    Time Aware Sampler
    Error Aware Sampler
    Duration Aware Sampler
The log plugin provides three built-in samplers, but you can also provide your own custom or composite sampler. Built-in samplers include:
    Count Aware Sampler
    Time Aware Sampler
    Error Aware Sampler
Thundra enables default sampling for the metric plugin that takes into account the time and count. The default sampler for metrics works every 5 minutes or every 100 requests.
The metric plugin provides three built-in samplers, but you can also provide your own custom or composite sampler. Built-in samplers include:
    Count Aware Sampler
    Time Aware Sampler
    Error Aware Sampler

Count Aware Sampler

The Count Aware Sampler enables you to sample data with a count frequency. For example, if the count frequency is 500, data will be sampled with every 500 Lambda invocations.
1
...
2
public Function()
3
{
4
ThundraConfig config = ThundraConfigProvider.GetThundraConfig();
5
config.LogConfig.Sampler = new CountAwareSampler(500);
6
config.TraceConfig.Sampler = new CountAwareSampler(500);
7
config.MetricConfig.Sampler = new CountAwareSampler(500);
8
}
9
...
Copied!

Time Aware Sampler

The Time Aware Sampler enables you to sample data with a time frequency. For example, if the time frequency is 300,000, data will be sampled every 300 seconds within consecutive Lambda invocations.
1
...
2
public Function()
3
{
4
ThundraConfig config = ThundraConfigProvider.GetThundraConfig();
5
config.LogConfig.Sampler = new TimeAwareSampler(300000);
6
config.TraceConfig.Sampler = new TimeAwareSampler(300000);
7
config.MetricConfig.Sampler = new TimeAwareSampler(300000);
8
}
9
...
Copied!

Error Aware Sampler

The Error Aware Sampler enables you to sample data according to erroneous invocations of a Lambda. For example, you would use this sampler if you want to send trace data only if a Lambda execution results with an error.
1
...
2
public Function()
3
{
4
ThundraConfig config = ThundraConfigProvider.GetThundraConfig();
5
config.LogConfig.Sampler = new ErrorAwareSampler();
6
config.TraceConfig.Sampler = new ErrorAwareSampler();
7
config.MetricConfig.Sampler = new ErrorAwareSampler();
8
}
9
...
Copied!

Duration Aware Sampler

The Duration Aware Sampler enables you to sample data according to the duration of a Lambda. For example, you would use this sampler if you want to send trace data only if the duration of a Lambda is longer than 500 milliseconds.
1
...
2
public Function()
3
{
4
ThundraConfig config = ThundraConfigProvider.GetThundraConfig();
5
config.LogConfig.Sampler = new DurationAwareSampler(5000, true);
6
config.TraceConfig.Sampler = new DurationAwareSampler(5000, true);
7
config.MetricConfig.Sampler = new DurationAwareSampler(5000, true);
8
}
9
...
Copied!

Composite Sampler

The Composite Sampler enables you to compose multiple samplers using a specified composition operation (and or or).
An example using TimeAwareSampler and CountAwareSampler with or can be seen below:
1
...
2
public Function()
3
{
4
ThundraConfig config = ThundraConfigProvider.GetThundraConfig();
5
config.LogConfig.Sampler = new CompositeSampler(CompositeSampler.SamplerCompositionOperator.OR,
6
new List<Sampler> {
7
new TimeAwareSampler(300000),
8
new CountAwareSampler(100)
9
}
10
);
11
config.TraceConfig.Sampler = new CompositeSampler(CompositeSampler.SamplerCompositionOperator.OR,
12
new List<Sampler> {
13
new TimeAwareSampler(300000),
14
new CountAwareSampler(100)
15
}
16
);
17
config.MetricConfig.Sampler = new CompositeSampler(CompositeSampler.SamplerCompositionOperator.OR,
18
new List<Sampler> {
19
new TimeAwareSampler(300000),
20
new CountAwareSampler(100)
21
}
22
);
23
}
24
...
Copied!

Last modified 9mo ago