-
Notifications
You must be signed in to change notification settings - Fork 25k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Profiling] Aggregate flamegraph by process name and thread name #119115
base: main
Are you sure you want to change the base?
Changes from 18 commits
4d35b22
a4aea04
adae211
29fa515
ea63b21
823579c
72254fb
1d2b984
535d30d
b651317
398fc60
0a33c7e
8046c83
9cf66c8
cf4d652
e514874
28c990c
4fdd4d8
f3ca80c
fbb669b
659a4fd
f9ef6be
62117b4
57d3ad4
c118150
7cd497c
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -32,7 +32,7 @@ public class GetStackTracesResponse extends ActionResponse implements ChunkedToX | |
private final Map<String, String> executables; | ||
@UpdateForV9(owner = UpdateForV9.Owner.PROFILING) // remove this field - it is unused in Kibana | ||
@Nullable | ||
private final Map<String, TraceEvent> stackTraceEvents; | ||
private final Map<TraceEventID, TraceEvent> stackTraceEvents; | ||
@UpdateForV9(owner = UpdateForV9.Owner.PROFILING) // remove this field - it is unused in Kibana | ||
private final int totalFrames; | ||
private final double samplingRate; | ||
|
@@ -42,7 +42,7 @@ public GetStackTracesResponse( | |
Map<String, StackTrace> stackTraces, | ||
Map<String, StackFrame> stackFrames, | ||
Map<String, String> executables, | ||
Map<String, TraceEvent> stackTraceEvents, | ||
Map<TraceEventID, TraceEvent> stackTraceEvents, | ||
int totalFrames, | ||
double samplingRate, | ||
long totalSamples | ||
|
@@ -73,7 +73,7 @@ public Map<String, String> getExecutables() { | |
return executables; | ||
} | ||
|
||
public Map<String, TraceEvent> getStackTraceEvents() { | ||
public Map<TraceEventID, TraceEvent> getStackTraceEvents() { | ||
return stackTraceEvents; | ||
} | ||
|
||
|
@@ -100,23 +100,24 @@ public Iterator<? extends ToXContent> toXContentChunked(ToXContent.Params params | |
optional( | ||
"stack_trace_events", | ||
stackTraceEvents, | ||
(n, v) -> ChunkedToXContentHelper.map(n, v, entry -> (b, p) -> b.field(entry.getKey(), entry.getValue().count)) | ||
(n, v) -> ChunkedToXContentHelper.wrapWithObject( | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Doesn't this change the structure of the output (backwards-compatibility)? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Do you see any issues with this in Kibana (I didn't find any issue so far). BWC tests seem to run fine as well. |
||
n, | ||
Iterators.map(v.entrySet().iterator(), e -> (b, p) -> b.field(e.getKey().stacktraceID(), e.getValue().count)) | ||
) | ||
), | ||
Iterators.single((b, p) -> b.field("total_frames", totalFrames)), | ||
Iterators.single((b, p) -> b.field("sampling_rate", samplingRate)), | ||
Iterators.single((b, p) -> b.field("total_frames", totalFrames).field("sampling_rate", samplingRate).endObject()) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This looks like an unrelated cleanup / optimization? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes, it is an unrelated change. It has been suggested by Armin Braun in a chat. See comment |
||
// the following fields are intentionally not written to the XContent representation (only needed on the transport layer): | ||
// | ||
// * start | ||
// * end | ||
// * totalSamples | ||
ChunkedToXContentHelper.endObject() | ||
); | ||
} | ||
|
||
private static <T> Iterator<? extends ToXContent> optional( | ||
private static <K, T> Iterator<? extends ToXContent> optional( | ||
String name, | ||
Map<String, T> values, | ||
BiFunction<String, Map<String, T>, Iterator<? extends ToXContent>> supplier | ||
Map<K, T> values, | ||
BiFunction<String, Map<K, T>, Iterator<? extends ToXContent>> supplier | ||
) { | ||
return (values != null) ? supplier.apply(name, values) : Collections.emptyIterator(); | ||
} | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License | ||
* 2.0; you may not use this file except in compliance with the Elastic License | ||
* 2.0. | ||
*/ | ||
|
||
package org.elasticsearch.xpack.profiling.action; | ||
|
||
record TraceEventID(String processName, String threadName, String hostID, String stacktraceID) {} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is this instruction needed here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it is because comment