opentelemetry-python
opentelemetry-python copied to clipboard
Use extended attributes everywhere
This is a prototype of https://github.com/open-telemetry/opentelemetry-specification/pull/4485:
- extends standard attributes to include AnyValue
- use them on all public APIs type hints except metrics
TODO:
- [ ] Decide if we want MetricAttribute alias
- [ ] Tests for resource/instr scope
- [ ] More tests for hashing
Benchmarks:
Perf is not a priority - we don't really want people to use complex attributes on metrics, to goal here to show that even if they do, the impact is not huge.
Based on the results, the cost of reporting complex attribute is ~1.5-2 times higher than a standard one.
| Name | Min (us) | Max (us) | Mean (us) | StdDev (us) | Median (us) | IQR (us) | Outliers | OPS | Rounds | Iterations |
|---|---|---|---|---|---|---|---|---|---|---|
| test_histogram_record_10[1] | 2.7000 | 215.5000 | 3.1023 | 4.3836 | 3.0000 | 0.1000 | 11;247 | 322,337.2017 | 2392 | 1 |
| test_histogram_record_10[3] | 3.0000 | 222.4000 | 3.4215 | 2.5234 | 3.3000 | 0.1000 | 245;3827 | 292,266.1848 | 31056 | 1 |
| test_histogram_record_10_small_mapping_attrs[1] | 3.7000 | 2908.4000 | 5.3577 | 30.0136 | 4.2000 | 0.5000 | 32;2907 | 186,646.7723 | 16639 | 1 |
| test_histogram_record_10_array_attrs[1] | 3.9000 | 233.7000 | 4.5473 | 3.7219 | 4.3000 | 0.2000 | 400;1218 | 219,911.5654 | 32363 | 1 |
| test_histogram_record_10_json_string_attrs[1] | 4.2000 | 362.5000 | 4.8095 | 5.1960 | 4.5000 | 0.2000 | 159;761 | 207,921.2007 | 17153 | 1 |
| test_histogram_record_10_complex_attrs[1] | 5.7000 | 719.1000 | 6.5912 | 7.0330 | 6.3000 | 0.2000 | 176;1162 | 151,717.5248 | 27625 | 1 |
| test_histogram_record_10_small_mapping_attrs[3] | 5.9000 | 311.1000 | 6.7337 | 4.4705 | 6.4000 | 0.3000 | 191;924 | 148,505.8706 | 22676 | 1 |
| test_histogram_record_10_array_attrs[3] | 6.3000 | 377.6000 | 7.1968 | 5.2675 | 6.8000 | 0.2000 | 383;1542 | 138,950.8709 | 33004 | 1 |
| test_histogram_record_10_json_string_attrs[3] | 7.0000 | 181.4000 | 7.9721 | 4.2540 | 7.6000 | 0.2000 | 329;1026 | 125,437.0785 | 21187 | 1 |
| test_histogram_record_10_complex_attrs[3] | 11.9000 | 407.1000 | 13.5603 | 7.4609 | 12.9000 | 0.4000 | 359;1100 | 73,744.4408 | 23530 | 1 |