opentelemetry-sdk: inline the method `_clean_attribute_value` (#5275)
* opentelemetry-sdk: inline the method `_clean_attribute_value` This removes an if statement to check if the value is None and embeds the method inline to remove the need for that check. This removes a second check for None in the loop through the Sequence type. Ran the following: ``` pytest opentelemetry-sdk/benchmarks/trace/test_benchmark_trace.py::test_set_attribute_types \ --benchmark-min-rounds=10 --benchmark-columns=mean,median,ops ``` And got these results for the different types: | type | Before (ms) | After (ms) | Δ | |-----------|------------|-----------|------| | bool | 204.1 | 197.3 | -3% | | str | 211.9 | 203.9 | -4% | | int | 221.3 | 213.5 | -4% | | bytes | 226.5 | 216.8 | -4% | | float | 227.3 | 222.1 | -2% | | seq_bool | 488.3 | 453.7 | -7% | | seq_bytes | 513.7 | 471.7 | -8% | | seq_float | 539.6 | 508.4 | -6% | | seq_str | 594.3 | 537.0 | -10% | | seq_int | 636.0 | 576.3 | -9% | Signed-off-by: Alex Boten <223565+codeboten@users.noreply.github.com> * changelog Signed-off-by: Alex Boten <223565+codeboten@users.noreply.github.com> * inlining the function causes lint to trigger, adding ignore Signed-off-by: Alex Boten <223565+codeboten@users.noreply.github.com> * none is a valid type in sequence Signed-off-by: Alex Boten <223565+codeboten@users.noreply.github.com> * fix Signed-off-by: Alex Boten <223565+codeboten@users.noreply.github.com> * dont miss truncation on bytes Signed-off-by: Alex Boten <223565+codeboten@users.noreply.github.com> * precommit Signed-off-by: Alex Boten <223565+codeboten@users.noreply.github.com> --------- Signed-off-by: Alex Boten <223565+codeboten@users.noreply.github.com>
A
Alex Boten committed
39ff55d3093ec7f218dad2709645824ace971e2d
Parent: 60b6749
Committed by GitHub <noreply@github.com>
on 6/9/2026, 5:13:17 PM