Skip to content

Commit 5e0cf56

Browse files
authored
[Profiling] Remove fallback code for synthetic source (elastic#97161)
* [Profiling] Remove fallback code for synthetic source * Remove unused import
1 parent f156524 commit 5e0cf56

File tree

2 files changed

+6
-44
lines changed

2 files changed

+6
-44
lines changed

x-pack/plugin/profiler/src/main/java/org/elasticsearch/xpack/profiler/StackFrame.java

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

88
package org.elasticsearch.xpack.profiler;
99

10-
import org.elasticsearch.xcontent.ObjectPath;
1110
import org.elasticsearch.xcontent.ToXContentObject;
1211
import org.elasticsearch.xcontent.XContentBuilder;
1312

@@ -18,10 +17,6 @@
1817
import java.util.Objects;
1918

2019
final class StackFrame implements ToXContentObject {
21-
private static final String[] PATH_FILE_NAME = new String[] { "Stackframe", "file", "name" };
22-
private static final String[] PATH_FUNCTION_NAME = new String[] { "Stackframe", "function", "name" };
23-
private static final String[] PATH_FUNCTION_OFFSET = new String[] { "Stackframe", "function", "offset" };
24-
private static final String[] PATH_LINE_NUMBER = new String[] { "Stackframe", "line", "number" };
2520
List<String> fileName;
2621
List<String> functionName;
2722
List<Integer> functionOffset;
@@ -46,26 +41,12 @@ private static <T> List<T> listOf(Object o) {
4641
}
4742

4843
public static StackFrame fromSource(Map<String, Object> source) {
49-
// stack frames may either be stored with synthetic source or regular one
50-
// which results either in a nested or flat document structure.
51-
52-
if (source.containsKey("Stackframe")) {
53-
// synthetic source
54-
return new StackFrame(
55-
ObjectPath.eval(PATH_FILE_NAME, source),
56-
ObjectPath.eval(PATH_FUNCTION_NAME, source),
57-
ObjectPath.eval(PATH_FUNCTION_OFFSET, source),
58-
ObjectPath.eval(PATH_LINE_NUMBER, source)
59-
);
60-
} else {
61-
// regular source
62-
return new StackFrame(
63-
source.get("Stackframe.file.name"),
64-
source.get("Stackframe.function.name"),
65-
source.get("Stackframe.function.offset"),
66-
source.get("Stackframe.line.number")
67-
);
68-
}
44+
return new StackFrame(
45+
source.get("Stackframe.file.name"),
46+
source.get("Stackframe.function.name"),
47+
source.get("Stackframe.function.offset"),
48+
source.get("Stackframe.line.number")
49+
);
6950
}
7051

7152
@Override

x-pack/plugin/profiler/src/test/java/org/elasticsearch/xpack/profiler/StackFrameTests.java

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -23,25 +23,6 @@
2323
import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertToXContentEquivalent;
2424

2525
public class StackFrameTests extends ESTestCase {
26-
public void testCreateFromSyntheticSource() {
27-
// tag::noformat
28-
StackFrame frame = StackFrame.fromSource(
29-
Map.of("Stackframe", Map.of(
30-
"file", Map.of("name", "Main.java"),
31-
"function", Map.of(
32-
"name", "helloWorld",
33-
"offset", 31733
34-
),
35-
"line", Map.of("number", 22))
36-
)
37-
);
38-
// end::noformat
39-
assertEquals(List.of("Main.java"), frame.fileName);
40-
assertEquals(List.of("helloWorld"), frame.functionName);
41-
assertEquals(List.of(31733), frame.functionOffset);
42-
assertEquals(List.of(22), frame.lineNumber);
43-
}
44-
4526
public void testCreateFromRegularSource() {
4627
// tag::noformat
4728
StackFrame frame = StackFrame.fromSource(

0 commit comments

Comments
 (0)