@@ -190,13 +190,22 @@ func applyPredicates(entry config.GenericMap, rule predicatesRule) bool {
190
190
return false
191
191
}
192
192
}
193
+ if rule .sampling > 0 {
194
+ storeSampling (entry , int (rule .sampling ))
195
+ }
193
196
return true
194
197
}
195
198
196
199
func sample (entry config.GenericMap , rules []* api.SamplingCondition ) bool {
197
200
for _ , r := range rules {
198
201
if isRemoveEntrySatisfied (entry , r .Rules ) {
199
- return rollSampling (r .Value )
202
+ if rollSampling (r .Value ) {
203
+ if r .Value > 0 {
204
+ storeSampling (entry , int (r .Value ))
205
+ }
206
+ return true
207
+ }
208
+ return false
200
209
}
201
210
}
202
211
return true
@@ -206,6 +215,20 @@ func rollSampling(value uint16) bool {
206
215
return value == 0 || (rndgen .Intn (int (value )) == 0 )
207
216
}
208
217
218
+ func storeSampling (entry config.GenericMap , value int ) {
219
+ // TODO: make "Sampling" string configurable, and configured from the operator.
220
+ if current , found := entry ["Sampling" ]; found {
221
+ if cast , err := utils .ConvertToInt (current ); err != nil {
222
+ if cast == 0 {
223
+ cast = 1
224
+ }
225
+ entry ["Sampling" ] = cast * value
226
+ }
227
+ } else {
228
+ entry ["Sampling" ] = value
229
+ }
230
+ }
231
+
209
232
// NewTransformFilter create a new filter transform
210
233
func NewTransformFilter (params config.StageParam ) (Transformer , error ) {
211
234
tlog .Debugf ("entering NewTransformFilter" )
0 commit comments