Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ public boolean equals(Object other) {

@Override
public int hashCode() {
return (int) (h1 ^ h2);
return Long.hashCode(h1 ^ h2);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -265,9 +265,9 @@ public long getStartTimestampUnixNano() {
return dataPoints.getFirst().getStartTimestampUnixNano();
}

public String getMetricNamesHash() {
public String getMetricNamesHash(BufferedMurmur3Hasher hasher) {
if (metricNamesHash == null) {
BufferedMurmur3Hasher hasher = new BufferedMurmur3Hasher(0);
hasher.reset();
for (int i = 0; i < dataPoints.size(); i++) {
hasher.addString(dataPoints.get(i).getMetricName());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
import com.google.protobuf.ByteString;

import org.elasticsearch.common.Strings;
import org.elasticsearch.common.hash.BufferedMurmur3Hasher;
import org.elasticsearch.xcontent.XContentBuilder;
import org.elasticsearch.xpack.oteldata.otlp.datapoint.DataPoint;
import org.elasticsearch.xpack.oteldata.otlp.datapoint.DataPointGroupingContext;
Expand All @@ -32,6 +33,7 @@
public class MetricDocumentBuilder {

private final BufferedByteStringAccessor byteStringAccessor;
private final BufferedMurmur3Hasher hasher = new BufferedMurmur3Hasher(0);

public MetricDocumentBuilder(BufferedByteStringAccessor byteStringAccessor) {
this.byteStringAccessor = byteStringAccessor;
Expand All @@ -49,7 +51,7 @@ public HashMap<String, String> buildMetricDocument(XContentBuilder builder, Data
buildResource(dataPointGroup.resource(), dataPointGroup.resourceSchemaUrl(), builder);
buildScope(builder, dataPointGroup.scopeSchemaUrl(), dataPointGroup.scope());
buildDataPointAttributes(builder, dataPointGroup.dataPointAttributes(), dataPointGroup.unit());
builder.field("_metric_names_hash", dataPointGroup.getMetricNamesHash());
builder.field("_metric_names_hash", dataPointGroup.getMetricNamesHash(hasher));

builder.startObject("metrics");
for (int i = 0, dataPointsSize = dataPoints.size(); i < dataPointsSize; i++) {
Expand Down