Skip to content

Commit f10e4be

Browse files
author
xiancli
committed
Add a more flexible sampling strategy data model
Signed-off-by: Garrett Li <garrett.li.sh@gmail.com>
1 parent bdd5ab5 commit f10e4be

File tree

1 file changed

+41
-3
lines changed

1 file changed

+41
-3
lines changed

proto/api_v2/sampling.proto

Lines changed: 41 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ message PerOperationSamplingStrategies {
7474
// one of the perOperationStrategies.
7575
double defaultLowerBoundTracesPerSecond = 2;
7676

77-
// perOperationStrategies describes sampling strategiesf for individual operations within
77+
// perOperationStrategies describes sampling strategies for individual operations within
7878
// a given service.
7979
repeated OperationSamplingStrategy perOperationStrategies = 3;
8080

@@ -83,6 +83,33 @@ message PerOperationSamplingStrategies {
8383
double defaultUpperBoundTracesPerSecond = 4;
8484
}
8585

86+
// Dimension is a key-value pair that represents a single arbitrary combinations of dimensions.
87+
message Dimension {
88+
string key = 1;
89+
string value = 2;
90+
}
91+
92+
// MultiDimensionalSamplingStrategy is a sampling strategy that takes into account arbitrary
93+
// combinations of dimensions (aka user session). Only probabilistic sampling is currently supported.
94+
message MultiDimensionalSamplingStrategy {
95+
repeated Dimension dimensions = 1;
96+
ProbabilisticSamplingStrategy probabilisticSampling = 2;
97+
}
98+
99+
// PerMultiDimensionalSamplingStrategy is a combination of strategies for different dimensions
100+
// as well as some service-wide defaults. It is particularly useful for services whose
101+
// dimensions receive vastly different traffic, so that any single rate of sampling would
102+
// result in either too much data for some dimensions or almost no data for other dimensions.
103+
message PerMultiDimensionalSamplingStrategy {
104+
// defaultSamplingProbability is the sampling probability for spans that do not match
105+
// any of the perOperationStrategies.
106+
double defaultSamplingProbability = 1;
107+
108+
// perMultiDimensionalStrategies describes sampling strategies for arbitrary combinations
109+
// of dimensions within a given service.
110+
repeated MultiDimensionalSamplingStrategy perMultiDimensionalStrategies = 2;
111+
}
112+
86113
// SamplingStrategyResponse contains an overall sampling strategy for a given service.
87114
// This type should be treated as a union where only one of the strategy field is present.
88115
message SamplingStrategyResponse {
@@ -92,15 +119,17 @@ message SamplingStrategyResponse {
92119
// The recommended approach for consumers is to ignore this field and instead
93120
// checks the other fields being not null (starting with operationSampling).
94121
// For producers, it is recommended to set this field correctly for probabilistic
95-
// and rate-limiting strategies, but if per-operation strategy is returned,
96-
// the enum can be set to 0 (probabilistic).
122+
// and rate-limiting strategies, but if per-operation or per-multi-dimensional
123+
// strategy is returned, the enum can be set to 0 (probabilistic).
97124
SamplingStrategyType strategyType = 1;
98125

99126
ProbabilisticSamplingStrategy probabilisticSampling = 2;
100127

101128
RateLimitingSamplingStrategy rateLimitingSampling = 3;
102129

103130
PerOperationSamplingStrategies operationSampling = 4;
131+
132+
PerMultiDimensionalSamplingStrategy multiDimensionalSampling = 5;
104133
}
105134

106135
// SamplingStrategyParameters defines request parameters for remote sampler.
@@ -117,4 +146,13 @@ service SamplingManager {
117146
body: "*"
118147
};
119148
}
149+
// The OTel Collector Jaeger's Remote Sampling extension can be configured to proxy requests
150+
// to a backend remote sampling server. This means that a server-side streaming API with
151+
// delta updates can significantly reduce network bandwidth usage.
152+
rpc WatchSamplingStrategy(SamplingStrategyParameters) returns (stream SamplingStrategyResponse) {
153+
option (google.api.http) = {
154+
post: "/api/v2/samplingStrategyStream"
155+
body: "*"
156+
};
157+
}
120158
}

0 commit comments

Comments
 (0)