@@ -304,28 +304,34 @@ def test_sampler_with_env_non_existent_entry_point(self):
304
304
self .verify_default_sampler (tracer_provider )
305
305
306
306
@mock .patch ("opentelemetry.sdk.trace.util.iter_entry_points" )
307
- @mock .patch .dict ("os.environ" , { OTEL_TRACES_SAMPLER : "custom_sampler_factory" })
308
- def test_custom_sampler_with_env (
309
- self , mock_iter_entry_points
310
- ):
307
+ @mock .patch .dict (
308
+ "os.environ" , { OTEL_TRACES_SAMPLER : "custom_sampler_factory" }
309
+ )
310
+ def test_custom_sampler_with_env ( self , mock_iter_entry_points ):
311
311
# mock_iter_entry_points.return_value = [
312
312
# ("custom_sampler_factory", CustomSamplerFactory.get_custom_sampler)
313
313
# ]
314
- mock_iter_entry_points .return_value = [
315
- IterEntryPoint ("custom_sampler_factory" , CustomSamplerFactory .get_custom_sampler )
314
+ mock_iter_entry_points .return_value = [
315
+ IterEntryPoint (
316
+ "custom_sampler_factory" ,
317
+ CustomSamplerFactory .get_custom_sampler ,
318
+ )
316
319
]
317
320
# pylint: disable=protected-access
318
321
reload (trace )
319
322
tracer_provider = trace .TracerProvider ()
320
323
self .assertIsInstance (tracer_provider .sampler , CustomSampler )
321
324
322
325
@mock .patch ("opentelemetry.sdk.trace.util.iter_entry_points" )
323
- @mock .patch .dict ("os.environ" , { OTEL_TRACES_SAMPLER : "custom_sampler_factory" })
324
- def test_custom_sampler_with_env_bad_factory (
325
- self , mock_iter_entry_points
326
- ):
326
+ @mock .patch .dict (
327
+ "os.environ" , { OTEL_TRACES_SAMPLER : "custom_sampler_factory" }
328
+ )
329
+ def test_custom_sampler_with_env_bad_factory ( self , mock_iter_entry_points ):
327
330
mock_iter_entry_points .return_value = [
328
- IterEntryPoint ("custom_sampler_factory" , CustomSamplerFactory .empty_get_custom_sampler )
331
+ IterEntryPoint (
332
+ "custom_sampler_factory" ,
333
+ CustomSamplerFactory .empty_get_custom_sampler ,
334
+ )
329
335
]
330
336
# pylint: disable=protected-access
331
337
reload (trace )
@@ -340,11 +346,12 @@ def test_custom_sampler_with_env_bad_factory(
340
346
OTEL_TRACES_SAMPLER_ARG : "0.5" ,
341
347
},
342
348
)
343
- def test_custom_sampler_with_env_unused_arg (
344
- self , mock_iter_entry_points
345
- ):
349
+ def test_custom_sampler_with_env_unused_arg (self , mock_iter_entry_points ):
346
350
mock_iter_entry_points .return_value = [
347
- IterEntryPoint ("custom_sampler_factory" , CustomSamplerFactory .get_custom_sampler )
351
+ IterEntryPoint (
352
+ "custom_sampler_factory" ,
353
+ CustomSamplerFactory .get_custom_sampler ,
354
+ )
348
355
]
349
356
# pylint: disable=protected-access
350
357
reload (trace )
@@ -359,11 +366,12 @@ def test_custom_sampler_with_env_unused_arg(
359
366
OTEL_TRACES_SAMPLER_ARG : "0.5" ,
360
367
},
361
368
)
362
- def test_custom_ratio_sampler_with_env (
363
- self , mock_iter_entry_points
364
- ):
369
+ def test_custom_ratio_sampler_with_env (self , mock_iter_entry_points ):
365
370
mock_iter_entry_points .return_value = [
366
- IterEntryPoint ("custom_ratio_sampler_factory" , CustomSamplerFactory .get_custom_ratio_sampler )
371
+ IterEntryPoint (
372
+ "custom_ratio_sampler_factory" ,
373
+ CustomSamplerFactory .get_custom_ratio_sampler ,
374
+ )
367
375
]
368
376
# pylint: disable=protected-access
369
377
reload (trace )
@@ -383,7 +391,10 @@ def test_custom_ratio_sampler_with_env_bad_arg(
383
391
self , mock_iter_entry_points
384
392
):
385
393
mock_iter_entry_points .return_value = [
386
- IterEntryPoint ("custom_ratio_sampler_factory" , CustomSamplerFactory .get_custom_ratio_sampler )
394
+ IterEntryPoint (
395
+ "custom_ratio_sampler_factory" ,
396
+ CustomSamplerFactory .get_custom_ratio_sampler ,
397
+ )
387
398
]
388
399
# pylint: disable=protected-access
389
400
reload (trace )
@@ -401,7 +412,10 @@ def test_custom_ratio_sampler_with_env_no_arg(
401
412
self , mock_iter_entry_points
402
413
):
403
414
mock_iter_entry_points .return_value = [
404
- IterEntryPoint ("custom_ratio_sampler_factory" , CustomSamplerFactory .get_custom_ratio_sampler )
415
+ IterEntryPoint (
416
+ "custom_ratio_sampler_factory" ,
417
+ CustomSamplerFactory .get_custom_ratio_sampler ,
418
+ )
405
419
]
406
420
# pylint: disable=protected-access
407
421
reload (trace )
@@ -420,9 +434,18 @@ def test_custom_ratio_sampler_with_env_multiple_entry_points(
420
434
self , mock_iter_entry_points
421
435
):
422
436
mock_iter_entry_points .return_value = [
423
- IterEntryPoint ("custom_ratio_sampler_factory" , CustomSamplerFactory .get_custom_ratio_sampler ),
424
- IterEntryPoint ("custom_sampler_factory" , CustomSamplerFactory .get_custom_sampler ),
425
- IterEntryPoint ("custom_z_sampler_factory" , CustomSamplerFactory .empty_get_custom_sampler )
437
+ IterEntryPoint (
438
+ "custom_ratio_sampler_factory" ,
439
+ CustomSamplerFactory .get_custom_ratio_sampler ,
440
+ ),
441
+ IterEntryPoint (
442
+ "custom_sampler_factory" ,
443
+ CustomSamplerFactory .get_custom_sampler ,
444
+ ),
445
+ IterEntryPoint (
446
+ "custom_z_sampler_factory" ,
447
+ CustomSamplerFactory .empty_get_custom_sampler ,
448
+ ),
426
449
]
427
450
# pylint: disable=protected-access
428
451
reload (trace )
0 commit comments