Skip to content

Commit fed0071

Browse files
committed
Fix compile errors after merging
1 parent 97d47b8 commit fed0071

File tree

3 files changed

+30
-28
lines changed

3 files changed

+30
-28
lines changed

x-pack/plugin/otel-data/src/main/java/org/elasticsearch/xpack/oteldata/otlp/datapoint/DataPointGroupingContext.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -277,7 +277,7 @@ public String getMetricNamesHash(BufferedMurmur3Hasher hasher) {
277277
return metricNamesHash;
278278
}
279279

280-
boolean addDataPoint(Set<String> ignoredDataPointMessages, DataPoint dataPoint) {
280+
public boolean addDataPoint(Set<String> ignoredDataPointMessages, DataPoint dataPoint) {
281281
metricNamesHash = null; // reset the hash when adding a new data point
282282
if (metricNames.add(dataPoint.getMetricName()) == false) {
283283
ignoredDataPointMessages.add(

x-pack/plugin/otel-data/src/test/java/org/elasticsearch/xpack/oteldata/otlp/datapoint/DataPointGroupingContextTests.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -77,8 +77,8 @@ public void testGroupingDifferentGroupUnit() throws Exception {
7777
public void testGroupingDuplicateNameSameTimeSeries() throws Exception {
7878
ExportMetricsServiceRequest metricsRequest = createMetricsRequest(
7979
List.of(
80-
createGaugeMetric("system.cpu.usage", "{percent}", List.of(createDoubleDataPoint(nowUnixNanos, List.of()))),
81-
createGaugeMetric("system.cpu.usage", "{percent}", List.of(createLongDataPoint(nowUnixNanos, List.of())))
80+
createGaugeMetric("system.cpu.usage", "{percent}", List.of(createDoubleDataPoint(nowUnixNanos))),
81+
createGaugeMetric("system.cpu.usage", "{percent}", List.of(createLongDataPoint(nowUnixNanos)))
8282
)
8383
);
8484
context.groupDataPoints(metricsRequest);
@@ -94,8 +94,8 @@ public void testGroupingDuplicateNameSameTimeSeries() throws Exception {
9494
public void testGroupingDuplicateNameDifferentTimeSeries() throws Exception {
9595
ExportMetricsServiceRequest metricsRequest = createMetricsRequest(
9696
List.of(
97-
createGaugeMetric("system.cpu.usage", "", List.of(createDoubleDataPoint(nowUnixNanos, List.of()))),
98-
createGaugeMetric("system.cpu.usage", "{percent}", List.of(createLongDataPoint(nowUnixNanos, List.of())))
97+
createGaugeMetric("system.cpu.usage", "", List.of(createDoubleDataPoint(nowUnixNanos))),
98+
createGaugeMetric("system.cpu.usage", "{percent}", List.of(createLongDataPoint(nowUnixNanos)))
9999
)
100100
);
101101
context.groupDataPoints(metricsRequest);

x-pack/plugin/otel-data/src/test/java/org/elasticsearch/xpack/oteldata/otlp/docbuilder/MetricDocumentBuilderTests.java

Lines changed: 25 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010
import io.opentelemetry.proto.common.v1.InstrumentationScope;
1111
import io.opentelemetry.proto.common.v1.KeyValue;
1212
import io.opentelemetry.proto.metrics.v1.AggregationTemporality;
13-
import io.opentelemetry.proto.metrics.v1.NumberDataPoint;
1413
import io.opentelemetry.proto.resource.v1.Resource;
1514

1615
import com.google.protobuf.ByteString;
@@ -30,6 +29,7 @@
3029
import java.util.ArrayList;
3130
import java.util.HashMap;
3231
import java.util.List;
32+
import java.util.Set;
3333
import java.util.concurrent.TimeUnit;
3434

3535
import static org.elasticsearch.xpack.oteldata.otlp.OtlpUtils.createDoubleDataPoint;
@@ -66,11 +66,24 @@ public void testBuildMetricDocument() throws IOException {
6666

6767
List<KeyValue> dataPointAttributes = List.of(keyValue("operation", "test"), (keyValue("environment", "production")));
6868

69-
List<DataPoint> dataPoints = List.of(
69+
DataPointGroupingContext.DataPointGroup dataPointGroup = new DataPointGroupingContext.DataPointGroup(
70+
resource,
71+
resourceSchemaUrl,
72+
scope,
73+
scopeSchemaUrl,
74+
dataPointAttributes,
75+
"{test}",
76+
"metrics-generic.otel-default"
77+
);
78+
dataPointGroup.addDataPoint(
79+
Set.of(),
7080
new DataPoint.Number(
7181
createDoubleDataPoint(timestamp, startTimestamp, dataPointAttributes),
7282
createGaugeMetric("system.cpu.usage", "", List.of())
73-
),
83+
)
84+
);
85+
dataPointGroup.addDataPoint(
86+
Set.of(),
7487
new DataPoint.Number(
7588
createLongDataPoint(timestamp, startTimestamp, dataPointAttributes),
7689
createSumMetric(
@@ -82,16 +95,6 @@ public void testBuildMetricDocument() throws IOException {
8295
)
8396
)
8497
);
85-
DataPointGroupingContext.DataPointGroup dataPointGroup = new DataPointGroupingContext.DataPointGroup(
86-
resource,
87-
resourceSchemaUrl,
88-
scope,
89-
scopeSchemaUrl,
90-
dataPointAttributes,
91-
"{test}",
92-
dataPoints,
93-
"metrics-generic.otel-default"
94-
);
9598

9699
XContentBuilder builder = XContentFactory.contentBuilder(XContentType.JSON);
97100
HashMap<String, String> dynamicTemplates = documentBuilder.buildMetricDocument(builder, dataPointGroup);
@@ -129,20 +132,19 @@ public void testAttributeTypes() throws IOException {
129132
Resource resource = Resource.newBuilder().addAllAttributes(resourceAttributes).build();
130133
InstrumentationScope scope = InstrumentationScope.newBuilder().build();
131134

132-
List<DataPoint> dataPoints = List.of(
133-
new DataPoint.Number(createDoubleDataPoint(timestamp), createGaugeMetric("test.metric", "", List.of()))
134-
);
135-
136135
DataPointGroupingContext.DataPointGroup dataPointGroup = new DataPointGroupingContext.DataPointGroup(
137136
resource,
138137
null,
139138
scope,
140139
null,
141140
List.of(),
142141
"",
143-
dataPoints,
144142
"metrics-generic.otel-default"
145143
);
144+
dataPointGroup.addDataPoint(
145+
Set.of(),
146+
new DataPoint.Number(createDoubleDataPoint(timestamp), createGaugeMetric("test.metric", "", List.of()))
147+
);
146148

147149
XContentBuilder builder = XContentFactory.contentBuilder(XContentType.JSON);
148150
documentBuilder.buildMetricDocument(builder, dataPointGroup);
@@ -162,21 +164,21 @@ public void testEmptyFields() throws IOException {
162164
Resource resource = Resource.newBuilder().build();
163165
InstrumentationScope scope = InstrumentationScope.newBuilder().build();
164166

165-
NumberDataPoint dataPoint = createDoubleDataPoint(timestamp);
166-
var metric = createGaugeMetric("test.metric", "", List.of(dataPoint));
167-
List<DataPoint> dataPoints = List.of(new DataPoint.Number(dataPoint, metric));
168-
169167
DataPointGroupingContext.DataPointGroup dataPointGroup = new DataPointGroupingContext.DataPointGroup(
170168
resource,
171169
null,
172170
scope,
173171
null,
174172
List.of(),
175173
"",
176-
dataPoints,
177174
"metrics-generic.otel-default"
178175
);
179176

177+
dataPointGroup.addDataPoint(
178+
Set.of(),
179+
new DataPoint.Number(createDoubleDataPoint(timestamp), createGaugeMetric("test.metric", "", List.of()))
180+
);
181+
180182
XContentBuilder builder = XContentFactory.contentBuilder(XContentType.JSON);
181183
documentBuilder.buildMetricDocument(builder, dataPointGroup);
182184

0 commit comments

Comments
 (0)