Skip to content

Commit 6343545

Browse files
authored
[profiling] Take care of @UpdateForV9 (elastic#123977) (elastic#124070)
* [profiling] Take care of @UpdateForV9 * Fix GetStackTracesResponseTests
1 parent b3e5cff commit 6343545

File tree

7 files changed

+15
-18
lines changed

7 files changed

+15
-18
lines changed

x-pack/plugin/profiling/src/main/java/org/elasticsearch/xpack/profiling/action/CO2Calculator.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
package org.elasticsearch.xpack.profiling.action;
99

10-
import org.elasticsearch.core.UpdateForV9;
10+
import org.elasticsearch.core.UpdateForV10;
1111

1212
import java.util.Map;
1313

@@ -54,7 +54,8 @@ public double getAnnualCO2Tons(String hostID, long samples) {
5454
return getKiloWattsPerCore(host) * getCO2TonsPerKWH(host) * annualCoreHours * getDatacenterPUE(host);
5555
}
5656

57-
@UpdateForV9(owner = UpdateForV9.Owner.PROFILING) // only allow OTEL semantic conventions
57+
@UpdateForV10(owner = UpdateForV10.Owner.PROFILING) // only allow OTEL semantic conventions
58+
// still required for data that has been migrated from 8.x to 9.x
5859
private double getKiloWattsPerCore(HostMetadata host) {
5960
return switch (host.hostArchitecture) {
6061
// For the OTEL donation of the profiling agent, we switch to OTEL semantic conventions,

x-pack/plugin/profiling/src/main/java/org/elasticsearch/xpack/profiling/action/GetFlamegraphResponse.java

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
import org.elasticsearch.common.io.stream.StreamOutput;
1414
import org.elasticsearch.common.xcontent.ChunkedToXContentHelper;
1515
import org.elasticsearch.common.xcontent.ChunkedToXContentObject;
16-
import org.elasticsearch.core.UpdateForV9;
16+
import org.elasticsearch.core.UpdateForV10;
1717
import org.elasticsearch.xcontent.ToXContent;
1818

1919
import java.io.IOException;
@@ -25,9 +25,7 @@ public class GetFlamegraphResponse extends ActionResponse implements ChunkedToXC
2525
private final int size;
2626
private final double samplingRate;
2727
private final long selfCPU;
28-
@UpdateForV9(owner = UpdateForV9.Owner.PROFILING) // remove this field - it is unused in Kibana
2928
private final long totalCPU;
30-
@UpdateForV9(owner = UpdateForV9.Owner.PROFILING) // remove this field - it is unused in Kibana
3129
private final long totalSamples;
3230
private final List<Map<String, Integer>> edges;
3331
private final List<String> fileIds;
@@ -173,7 +171,7 @@ public long getTotalSamples() {
173171
return totalSamples;
174172
}
175173

176-
@UpdateForV9(owner = UpdateForV9.Owner.PROFILING) // change casing from Camel Case to Snake Case (requires updates in Kibana as well)
174+
@UpdateForV10(owner = UpdateForV10.Owner.PROFILING) // change casing from Camel Case to Snake Case (requires updates in Kibana as well)
177175
@Override
178176
public Iterator<? extends ToXContent> toXContentChunked(ToXContent.Params params) {
179177
/*

x-pack/plugin/profiling/src/main/java/org/elasticsearch/xpack/profiling/action/GetStackTracesResponse.java

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313
import org.elasticsearch.common.xcontent.ChunkedToXContentHelper;
1414
import org.elasticsearch.common.xcontent.ChunkedToXContentObject;
1515
import org.elasticsearch.core.Nullable;
16-
import org.elasticsearch.core.UpdateForV9;
1716
import org.elasticsearch.xcontent.ToXContent;
1817

1918
import java.util.Collections;
@@ -29,10 +28,8 @@ public class GetStackTracesResponse extends ActionResponse implements ChunkedToX
2928
private final Map<String, StackFrame> stackFrames;
3029
@Nullable
3130
private final Map<String, String> executables;
32-
@UpdateForV9(owner = UpdateForV9.Owner.PROFILING) // remove this field - it is unused in Kibana
3331
@Nullable
3432
private final Map<String, TraceEvent> stackTraceEvents;
35-
@UpdateForV9(owner = UpdateForV9.Owner.PROFILING) // remove this field - it is unused in Kibana
3633
private final int totalFrames;
3734
private final double samplingRate;
3835
private final long totalSamples;
@@ -101,7 +98,6 @@ public Iterator<? extends ToXContent> toXContentChunked(ToXContent.Params params
10198
stackTraceEvents,
10299
(n, v) -> ChunkedToXContentHelper.object(n, v, entry -> (b, p) -> b.field(entry.getKey(), entry.getValue().count))
103100
),
104-
Iterators.single((b, p) -> b.field("total_frames", totalFrames)),
105101
Iterators.single((b, p) -> b.field("sampling_rate", samplingRate)),
106102
// the following fields are intentionally not written to the XContent representation (only needed on the transport layer):
107103
//

x-pack/plugin/profiling/src/main/java/org/elasticsearch/xpack/profiling/action/HostMetadata.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
package org.elasticsearch.xpack.profiling.action;
99

10-
import org.elasticsearch.core.UpdateForV9;
10+
import org.elasticsearch.core.UpdateForV10;
1111
import org.elasticsearch.xcontent.ToXContentObject;
1212
import org.elasticsearch.xcontent.XContentBuilder;
1313

@@ -31,8 +31,9 @@ final class HostMetadata implements ToXContentObject {
3131
this.profilingNumCores = profilingNumCores != null ? profilingNumCores : DEFAULT_PROFILING_NUM_CORES;
3232
}
3333

34-
@UpdateForV9(owner = UpdateForV9.Owner.PROFILING)
34+
@UpdateForV10(owner = UpdateForV10.Owner.PROFILING)
3535
// remove fallback to the "profiling.host.machine" field and remove it from the component template "profiling-hosts".
36+
// still required for data that has been migrated from 8.x to 9.x
3637
public static HostMetadata fromSource(Map<String, Object> source) {
3738
if (source != null) {
3839
String hostID = (String) source.get("host.id");

x-pack/plugin/profiling/src/main/java/org/elasticsearch/xpack/profiling/action/InstanceType.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
package org.elasticsearch.xpack.profiling.action;
99

10-
import org.elasticsearch.core.UpdateForV9;
10+
import org.elasticsearch.core.UpdateForV10;
1111
import org.elasticsearch.xcontent.ToXContentObject;
1212
import org.elasticsearch.xcontent.XContentBuilder;
1313

@@ -74,7 +74,8 @@ public static InstanceType fromHostSource(Map<String, Object> source) {
7474
return new InstanceType(provider, region, null);
7575
}
7676

77-
@UpdateForV9(owner = UpdateForV9.Owner.PROFILING) // remove this method
77+
@UpdateForV10(owner = UpdateForV10.Owner.PROFILING) // remove this method
78+
// still required for data that has been migrated from 8.x to 9.x
7879
private static InstanceType fromObsoleteHostSource(Map<String, Object> source) {
7980
// Check and handle AWS.
8081
String region = (String) source.get("ec2.placement.region");

x-pack/plugin/profiling/src/main/java/org/elasticsearch/xpack/profiling/action/SubGroup.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
package org.elasticsearch.xpack.profiling.action;
99

10-
import org.elasticsearch.core.UpdateForV9;
10+
import org.elasticsearch.core.UpdateForV10;
1111
import org.elasticsearch.xcontent.ToXContentFragment;
1212
import org.elasticsearch.xcontent.XContentBuilder;
1313

@@ -19,7 +19,7 @@
1919
public class SubGroup implements ToXContentFragment {
2020
private final String name;
2121
private Long count;
22-
@UpdateForV9(owner = UpdateForV9.Owner.PROFILING) // remove legacy XContent rendering
22+
@UpdateForV10(owner = UpdateForV10.Owner.PROFILING) // remove legacy XContent rendering
2323
private final Map<String, SubGroup> subgroups;
2424

2525
public static SubGroup root(String name) {

x-pack/plugin/profiling/src/test/java/org/elasticsearch/xpack/profiling/action/GetStackTracesResponseTests.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,8 +56,8 @@ private GetStackTracesResponse createTestInstance() {
5656

5757
public void testChunking() {
5858
AbstractChunkedSerializingTestCase.assertChunkCount(createTestInstance(), instance -> {
59-
// start, end, total_frames, samplingrate
60-
int chunks = 4;
59+
// start, end, samplingrate
60+
int chunks = 3;
6161
chunks += size(instance.getExecutables());
6262
chunks += size(instance.getStackFrames());
6363
chunks += size(instance.getStackTraces());

0 commit comments

Comments
 (0)