@@ -200,15 +200,15 @@ func TestOnRemoteConfigUpdate(t *testing.T) {
200200 })
201201 })
202202
203- t .Run ("DD_TRACE_SAMPLING_RULES=0.1 and RC rule rate=1.0 and revert" , func (t * testing.T ) {
203+ t .Run ("DD_TRACE_SAMPLING_RULES=0.0 and RC rule rate=1.0 and revert" , func (t * testing.T ) {
204204 telemetryClient := new (telemetrytest.RecordClient )
205205 defer telemetry .MockClient (telemetryClient )()
206206
207207 t .Setenv ("DD_TRACE_SAMPLING_RULES" , `[{
208208 "service": "my-service",
209209 "name": "web.request",
210210 "resource": "*",
211- "sample_rate": 0.1
211+ "sample_rate": 0.0
212212 }]` )
213213 tracer , _ , _ , stop , err := startTestTracer (t , WithService ("my-service" ), WithEnv ("my-env" ))
214214 defer stop ()
@@ -218,10 +218,11 @@ func TestOnRemoteConfigUpdate(t *testing.T) {
218218 s := tracer .StartSpan ("web.request" )
219219 s .Finish ()
220220 rate , _ := getMetric (s , keyRulesSamplerAppliedRate )
221- require .Equal (t , 0.1 , rate )
222- if p , ok := s .context .trace .samplingPriority (); ok && p > 0 {
223- require .Equal (t , samplerToDM (samplernames .RuleRate ), s .context .trace .propagatingTags [keyDecisionMaker ])
224- }
221+ require .Equal (t , 0.0 , rate )
222+ p , ok := s .context .trace .samplingPriority ()
223+ require .True (t , ok )
224+ require .Equal (t , p , - 1 )
225+ require .Empty (t , s .context .trace .propagatingTags [keyDecisionMaker ])
225226
226227 input := remoteconfig.ProductUpdate {
227228 "path" : []byte (`{"lib_config": {"tracing_sampling_rate": 0.5,
@@ -232,14 +233,14 @@ func TestOnRemoteConfigUpdate(t *testing.T) {
232233 "provenance": "customer",
233234 "sample_rate": 1.0
234235 },
235- {
236- "service": "my-service",
237- "name": "web.request",
238- "resource": "*",
239- "provenance": "dynamic",
240- "sample_rate": 0.3
241- }]},
242- "service_target": {"service": "my-service", "env": "my-env"}}` ),
236+ {
237+ "service": "my-service",
238+ "name": "web.request",
239+ "resource": "*",
240+ "provenance": "dynamic",
241+ "sample_rate": 1.0
242+ }]},
243+ "service_target": {"service": "my-service", "env": "my-env"}}` ),
243244 }
244245 applyStatus := tracer .onRemoteConfigUpdate (input )
245246 require .Equal (t , state .ApplyStateAcknowledged , applyStatus ["path" ].State )
@@ -254,14 +255,15 @@ func TestOnRemoteConfigUpdate(t *testing.T) {
254255 s .resource = "not_abc"
255256 s .Finish ()
256257 rate , _ = getMetric (s , keyRulesSamplerAppliedRate )
257- require .Equal (t , 0.3 , rate )
258- if p , ok := s .context .trace .samplingPriority (); ok && p > 0 {
259- require .Equal (
260- t ,
261- samplerToDM (samplernames .RemoteDynamicRule ),
262- s .context .trace .propagatingTags [keyDecisionMaker ],
263- )
264- }
258+ require .Equal (t , 1.0 , rate )
259+ p , ok = s .context .trace .samplingPriority ()
260+ require .True (t , ok )
261+ require .Equal (t , p , 2 )
262+ require .Equal (
263+ t ,
264+ samplerToDM (samplernames .RemoteDynamicRule ),
265+ s .context .trace .propagatingTags [keyDecisionMaker ],
266+ )
265267
266268 // Reset restores local rules
267269 input = remoteconfig.ProductUpdate {"path" : nil }
@@ -271,21 +273,22 @@ func TestOnRemoteConfigUpdate(t *testing.T) {
271273 s .resource = "not_abc"
272274 s .Finish ()
273275 rate , _ = getMetric (s , keyRulesSamplerAppliedRate )
274- require .Equal (t , 0.1 , rate )
275- if p , ok := s .context .trace .samplingPriority (); ok && p > 0 {
276- require .Equal (t , samplerToDM (samplernames .RuleRate ), s .context .trace .propagatingTags [keyDecisionMaker ])
277- }
276+ require .Equal (t , 0.0 , rate )
277+ p , ok = s .context .trace .samplingPriority ()
278+ require .True (t , ok )
279+ require .Equal (t , p , - 1 )
280+ require .Empty (t , s .context .trace .propagatingTags [keyDecisionMaker ])
278281
279282 assertCalled (t , telemetryClient , []telemetry.Configuration {
280283 {Name : "trace_sample_rate" , Value : 0.5 , Origin : telemetry .OriginRemoteConfig },
281284 {Name : "trace_sample_rules" ,
282- Value : `[{"service":"my-service","name":"web.request","resource":"abc","sample_rate":1,"provenance":"customer"} {"service":"my-service","name":"web.request","resource":"*","sample_rate":0.3 ,"provenance":"dynamic"}]` , Origin : telemetry .OriginRemoteConfig },
285+ Value : `[{"service":"my-service","name":"web.request","resource":"abc","sample_rate":1,"provenance":"customer"} {"service":"my-service","name":"web.request","resource":"*","sample_rate":1 ,"provenance":"dynamic"}]` , Origin : telemetry .OriginRemoteConfig },
283286 })
284287 assertCalled (t , telemetryClient , []telemetry.Configuration {
285288 {Name : "trace_sample_rate" , Value : nil , Origin : telemetry .OriginDefault },
286289 {
287290 Name : "trace_sample_rules" ,
288- Value : `[{"service":"my-service","name":"web.request","resource":"*","sample_rate":0.1 }]` ,
291+ Value : `[{"service":"my-service","name":"web.request","resource":"*","sample_rate":0}]` ,
289292 Origin : telemetry .OriginDefault ,
290293 },
291294 })
0 commit comments