Skip to content

[exporter/elasticsearch] Use 64 bit hash to reduce metric grouping hash and _metric_names_hash collision#41240

Merged
songy23 merged 5 commits into
open-telemetry:mainfrom
carsonip:xxhash64
Jul 11, 2025
Merged

[exporter/elasticsearch] Use 64 bit hash to reduce metric grouping hash and _metric_names_hash collision#41240
songy23 merged 5 commits into
open-telemetry:mainfrom
carsonip:xxhash64

Conversation

@carsonip

@carsonip carsonip commented Jul 10, 2025

Copy link
Copy Markdown
Contributor

Description

Replace 32 bit hash with 64 bit xxhash to reduce metric grouping hash collisions and _metric_names_hash collisions. The former has a higher risk of data loss.

Link to tracking issue

Fixes #41208

Testing

Documentation

@carsonip carsonip left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

[to reviewer] This leaves us with _metric_names_hash using fnv.New32a. Do we feel comfortable changing it to xxhash as well?

hasher := xxhash.New()

timestampBuf := make([]byte, 8)
binary.LittleEndian.PutUint64(timestampBuf, uint64(dp.Timestamp()))

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

[to reviewer] it is actually possible to make timestamp and starttimestamp a field in the HashKey struct to reduce a dimension of possible hash collision.

@axw axw left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

metric per doc cannot come soon enough 🥹

@carsonip carsonip marked this pull request as ready for review July 11, 2025 08:00
@carsonip carsonip requested a review from a team as a code owner July 11, 2025 08:00
@carsonip carsonip requested a review from dmitryax July 11, 2025 08:00
@carsonip carsonip changed the title [exporter/elasticsearch] Use xxhash to reduce metric grouping hash collision [exporter/elasticsearch] Use 64 bit hash to reduce metric grouping hash and _metric_names_hash collision Jul 11, 2025
@songy23 songy23 merged commit 3015950 into open-telemetry:main Jul 11, 2025
177 checks passed
@github-actions github-actions Bot added this to the next release milestone Jul 11, 2025
Dylan-M pushed a commit to Dylan-M/opentelemetry-collector-contrib that referenced this pull request Aug 5, 2025
…sh and _metric_names_hash collision (open-telemetry#41240)

<!--Ex. Fixing a bug - Describe the bug and how this fixes the issue.
Ex. Adding a feature - Explain what this achieves.-->
#### Description

Replace 32 bit hash with 64 bit xxhash to reduce metric grouping hash
collisions and `_metric_names_hash` collisions. The former has a higher
risk of data loss.

<!-- Issue number (e.g. open-telemetry#1234) or full URL to issue, if applicable. -->
#### Link to tracking issue
Fixes open-telemetry#41208

<!--Describe what testing was performed and which tests were added.-->
#### Testing

<!--Describe the documentation added.-->
#### Documentation

<!--Please delete paragraphs that you did not use before submitting.-->
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[exporter/elasticsearchexporter/integrationtest]: Report for failed tests on main

4 participants