Skip to content
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

Open
wants to merge 26 commits into
base: main
Choose a base branch
from

Conversation

rockdaboot
Copy link
Contributor

@rockdaboot rockdaboot commented Dec 19, 2024

This PR adds aggregation by process name and by thread name to the Universal Profiling flamegraph view.

The profiling data model has been updated to fit for the new task, so some non-trivial amount of code had to be changed.

TBD: fix and improve tests

This PR works best together with this Kibana PR.

Before

Screenshot_20241219_180743

After

Screenshot_20241219_180530

@rockdaboot rockdaboot added >enhancement :UniversalProfiling/Application Elastic Universal Profiling REST APIs and infrastructure Team:obs-knowledge Meta label for Observability Knowledge team v9.0.0 labels Dec 19, 2024
@rockdaboot rockdaboot self-assigned this Dec 19, 2024
@elasticsearchmachine
Copy link
Collaborator

Pinging @elastic/obs-knowledge-team (Team:obs-knowledge)

@elasticsearchmachine elasticsearchmachine added Team:obs-ux-infra_services Observability Infrastructure & Services User Experience Team external-contributor Pull request authored by a developer outside the Elasticsearch team labels Dec 19, 2024
@elasticsearchmachine
Copy link
Collaborator

Pinging @elastic/obs-ux-infra_services-team (Team:obs-ux-infra_services)

@rockdaboot rockdaboot removed the external-contributor Pull request authored by a developer outside the Elasticsearch team label Dec 19, 2024
@rockdaboot rockdaboot force-pushed the flamegraph-executable-name branch 2 times, most recently from f9ecda3 to df54aca Compare January 2, 2025 17:29
@rockdaboot rockdaboot force-pushed the flamegraph-executable-name branch from df81709 to 52d909b Compare January 4, 2025 12:55
@rockdaboot rockdaboot force-pushed the flamegraph-executable-name branch from 36f1696 to 9cf66c8 Compare January 6, 2025 07:38
@rockdaboot rockdaboot requested a review from christos68k January 6, 2025 07:39
@emma-raffenne emma-raffenne removed the Team:obs-knowledge Meta label for Observability Knowledge team label Jan 6, 2025
Co-authored-by: Jake Landis <[email protected]>
Copy link
Member

@christos68k christos68k left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added some suggestions to avoid confusion if/when someone revisits source code later in time. LGTM otherwise (though I don't really have knowledge of the internals here, so another review from a domain expert would be nice)

@rockdaboot rockdaboot changed the title [Profiling] Aggregate flamegraph by executable name and thread name [Profiling] Aggregate flamegraph by process name and thread name Jan 8, 2025
rockdaboot added a commit to elastic/kibana that referenced this pull request Jan 8, 2025
…, root) (#204977)

## Summary
This PR is a pre-requisite for adding aggregation by process name and by
thread name to the Universal Profiling flamegraph view.

It adds three artificial node types to the flamegraph including color
codes.

As a side-effect, the root node now has its own color code. Previously,
it (accidentally) used the color code of "unknown" type frames.

The PR is backwards compatible, so it doesn't change anything in the UI
when connecting with current Elasticsearch.
As soon as [the PR for
ES](elastic/elasticsearch#119115) is merged, the
new aggregations show up.
crespocarlos pushed a commit to crespocarlos/kibana that referenced this pull request Jan 8, 2025
…, root) (elastic#204977)

## Summary
This PR is a pre-requisite for adding aggregation by process name and by
thread name to the Universal Profiling flamegraph view.

It adds three artificial node types to the flamegraph including color
codes.

As a side-effect, the root node now has its own color code. Previously,
it (accidentally) used the color code of "unknown" type frames.

The PR is backwards compatible, so it doesn't change anything in the UI
when connecting with current Elasticsearch.
As soon as [the PR for
ES](elastic/elasticsearch#119115) is merged, the
new aggregations show up.
@@ -96,5 +96,7 @@ tasks.named("yamlRestCompatTestTransform").configure({ task ->
task.skipTest("esql/180_match_operator/match with non text field", "Match operator can now be used on non-text fields")
task.skipTest("esql/180_match_operator/match with functions", "Error message changed")
task.skipTest("esql/40_unsupported_types/semantic_text declared in mapping", "The semantic text field format changed")
task.replaceValueInMatch("Size", 49, "Test flamegraph from profiling-events")
Copy link
Member

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?

Copy link
Contributor Author

@rockdaboot rockdaboot Jan 13, 2025

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

),
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())
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks like an unrelated cleanup / optimization?

Copy link
Contributor Author

@rockdaboot rockdaboot Jan 10, 2025

Choose a reason for hiding this comment

The 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

@@ -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(
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Doesn't this change the structure of the output (backwards-compatibility)?

Copy link
Contributor Author

@rockdaboot rockdaboot Jan 13, 2025

Choose a reason for hiding this comment

The 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.


// aggregation
Map<String, TraceEvent> stackTraceEvents = new TreeMap<>();
Map<TraceEventID, TraceEvent> stackTraceEvents = new HashMap<>();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changing this might have a performance impact in the K/V lookups. Is there a reason that you've changed this? It is possible to implement Comparable for TraceEventID to keep using TreeMap.

Update: I see that you sort in place below when extracting the ids so that should be fine.

CAWilson94 pushed a commit to CAWilson94/kibana that referenced this pull request Jan 13, 2025
…, root) (elastic#204977)

## Summary
This PR is a pre-requisite for adding aggregation by process name and by
thread name to the Universal Profiling flamegraph view.

It adds three artificial node types to the flamegraph including color
codes.

As a side-effect, the root node now has its own color code. Previously,
it (accidentally) used the color code of "unknown" type frames.

The PR is backwards compatible, so it doesn't change anything in the UI
when connecting with current Elasticsearch.
As soon as [the PR for
ES](elastic/elasticsearch#119115) is merged, the
new aggregations show up.
Copy link
Member

@danielmitterdorfer danielmitterdorfer left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We had an offline conversation about the open questions, which are all resolved now. LGTM

viduni94 pushed a commit to viduni94/kibana that referenced this pull request Jan 23, 2025
…, root) (elastic#204977)

## Summary
This PR is a pre-requisite for adding aggregation by process name and by
thread name to the Universal Profiling flamegraph view.

It adds three artificial node types to the flamegraph including color
codes.

As a side-effect, the root node now has its own color code. Previously,
it (accidentally) used the color code of "unknown" type frames.

The PR is backwards compatible, so it doesn't change anything in the UI
when connecting with current Elasticsearch.
As soon as [the PR for
ES](elastic/elasticsearch#119115) is merged, the
new aggregations show up.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
>enhancement Team:obs-ux-infra_services Observability Infrastructure & Services User Experience Team :UniversalProfiling/Application Elastic Universal Profiling REST APIs and infrastructure v9.0.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants