@@ -233,6 +233,20 @@ func TestValidateConfig(t *testing.T) {
233
233
},
234
234
error : `"request" context requires a 'condition'` ,
235
235
},
236
+ {
237
+ name : "request context with condition" ,
238
+ config : & Config {
239
+ Table : []RoutingTableItem {
240
+ {
241
+ Context : "request" ,
242
+ Condition : `request["attr"] == "acme"` ,
243
+ Pipelines : []pipeline.ID {
244
+ pipeline .NewIDWithName (pipeline .SignalTraces , "otlp" ),
245
+ },
246
+ },
247
+ },
248
+ },
249
+ },
236
250
{
237
251
name : "request context with invalid condition" ,
238
252
config : & Config {
@@ -248,6 +262,118 @@ func TestValidateConfig(t *testing.T) {
248
262
},
249
263
error : `condition must have format 'request["<name>"] <comparator> <value>'` ,
250
264
},
265
+ {
266
+ name : "span context with statement" ,
267
+ config : & Config {
268
+ Table : []RoutingTableItem {
269
+ {
270
+ Context : "span" ,
271
+ Statement : `route() where attributes["attr"] == "acme"` ,
272
+ Pipelines : []pipeline.ID {
273
+ pipeline .NewIDWithName (pipeline .SignalTraces , "otlp" ),
274
+ },
275
+ },
276
+ },
277
+ },
278
+ },
279
+ {
280
+ name : "span context with condition" ,
281
+ config : & Config {
282
+ Table : []RoutingTableItem {
283
+ {
284
+ Context : "span" ,
285
+ Condition : `attributes["attr"] == "acme"` ,
286
+ Pipelines : []pipeline.ID {
287
+ pipeline .NewIDWithName (pipeline .SignalTraces , "otlp" ),
288
+ },
289
+ },
290
+ },
291
+ },
292
+ },
293
+ {
294
+ name : "metric context with statement" ,
295
+ config : & Config {
296
+ Table : []RoutingTableItem {
297
+ {
298
+ Context : "metric" ,
299
+ Statement : `route() where instrumentation_scope.attributes["attr"] == "acme"` ,
300
+ Pipelines : []pipeline.ID {
301
+ pipeline .NewIDWithName (pipeline .SignalTraces , "otlp" ),
302
+ },
303
+ },
304
+ },
305
+ },
306
+ },
307
+ {
308
+ name : "metric context with condition" ,
309
+ config : & Config {
310
+ Table : []RoutingTableItem {
311
+ {
312
+ Context : "metric" ,
313
+ Condition : `instrumentation_scope.attributes["attr"] == "acme"` ,
314
+ Pipelines : []pipeline.ID {
315
+ pipeline .NewIDWithName (pipeline .SignalTraces , "otlp" ),
316
+ },
317
+ },
318
+ },
319
+ },
320
+ },
321
+ {
322
+ name : "datapoint context with statement" ,
323
+ config : & Config {
324
+ Table : []RoutingTableItem {
325
+ {
326
+ Context : "datapoint" ,
327
+ Statement : `route() where attributes["attr"] == "acme"` ,
328
+ Pipelines : []pipeline.ID {
329
+ pipeline .NewIDWithName (pipeline .SignalTraces , "otlp" ),
330
+ },
331
+ },
332
+ },
333
+ },
334
+ },
335
+ {
336
+ name : "datapoint context with condition" ,
337
+ config : & Config {
338
+ Table : []RoutingTableItem {
339
+ {
340
+ Context : "datapoint" ,
341
+ Condition : `attributes["attr"] == "acme"` ,
342
+ Pipelines : []pipeline.ID {
343
+ pipeline .NewIDWithName (pipeline .SignalTraces , "otlp" ),
344
+ },
345
+ },
346
+ },
347
+ },
348
+ },
349
+ {
350
+ name : "log context with statement" ,
351
+ config : & Config {
352
+ Table : []RoutingTableItem {
353
+ {
354
+ Context : "log" ,
355
+ Statement : `route() where attributes["attr"] == "acme"` ,
356
+ Pipelines : []pipeline.ID {
357
+ pipeline .NewIDWithName (pipeline .SignalTraces , "otlp" ),
358
+ },
359
+ },
360
+ },
361
+ },
362
+ },
363
+ {
364
+ name : "log context with condition" ,
365
+ config : & Config {
366
+ Table : []RoutingTableItem {
367
+ {
368
+ Context : "log" ,
369
+ Condition : `attributes["attr"] == "acme"` ,
370
+ Pipelines : []pipeline.ID {
371
+ pipeline .NewIDWithName (pipeline .SignalTraces , "otlp" ),
372
+ },
373
+ },
374
+ },
375
+ },
376
+ },
251
377
}
252
378
253
379
for _ , tt := range tests {
0 commit comments