Hello, I have concerns regarding the hash collision issue with the current implementation of metric data aggregation, related to this PR #1993.
|
std::unordered_map<size_t, std::pair<MetricAttributes, std::unique_ptr<Aggregation>>> hash_map_; |
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
Hello, I have concerns regarding the hash collision issue with the current implementation of metric data aggregation, related to this PR #1993.
opentelemetry-cpp/sdk/include/opentelemetry/sdk/metrics/state/attributes_hashmap.h
Line 201 in c6d3945
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
MetricAttributesinstead of its hash code as the key of theunordered_map?Thanks