Skip to content

Use extended attributes everywhere #4587

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

lmolkova
Copy link
Contributor

This is a prototype of open-telemetry/opentelemetry-specification#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

@@ -180,7 +195,7 @@ class Counter(Synchronous):
def add(
self,
amount: Union[int, float],
attributes: Optional[Attributes] = None,
attributes: Optional[_MetricAttributes] = None,
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TODO: we can use Attributes and let users use complex attributes on metrics without any restrictions. We can also introduce an alias for a limited attribute set.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant