Fix use of built-in samplers in SDK configuration by matej-g · Pull Request #3176 · open-telemetry/opentelemetry-python

Thanks @matej-g , but the type conversion is also missing here

sampler_arg = os.getenv(OTEL_TRACES_SAMPLER_ARG, "")
sampler = sampler_factory(sampler_arg)

This is an existing bug, let me know if you want to make the change in this PR otherwise I will get it fixed separately and then merge this.

It should be changed to

sampler_factory = _import_sampler_factory(sampler_name)

kwargs = {}
if sampler_name in ("traceidratio", "parentbased_traceidratio"):
    try:
        rate = float(os.getenv(OTEL_TRACES_SAMPLER_ARG))
    except ValueError:
        _logger.warning("Could not convert TRACES_SAMPLER_ARG to float.")
        rate = 1.0
    kwargs["rate"] = rate

sampler = sampler_factory(**kwargs)