opentelemetry-cpp icon indicating copy to clipboard operation
opentelemetry-cpp copied to clipboard

Hash collision risk of metric data aggregation

Open alangy98 opened this issue 1 year ago • 1 comments

Hello, I have concerns regarding the hash collision issue with the current implementation of metric data aggregation, related to this PR #1993.

https://github.com/open-telemetry/opentelemetry-cpp/blob/c6d394547b012077998b6bd74665145488e85ffe/sdk/include/opentelemetry/sdk/metrics/state/attributes_hashmap.h#L201

The aggregation map uses size_t as the key type, and the hash code of the attribute set is treated as a unique identifier. However, if two different attribute sets happen to generate the same hash code, it could lead to collisions, and I haven’t seen any handling for this scenario in the current logic.

Why not consider using the MetricAttributes instead of its hash code as the key of the unordered_map?

Thanks

alangy98 avatar Sep 12 '24 15:09 alangy98