-
Notifications
You must be signed in to change notification settings - Fork 8.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add stackframe metadata to TopN stack trace response (#64)
* Refactor grouping metadata by stacktraces * Collate stacktrace events same as flamegraph * Transform raw aggregation result We now use the same TopN histogram bucket format used by prodfiler. * Return no hits when querying stacktrace events * Simplify topN query for stacktrace events * Reduce query time by avoiding unneeded searches * Refactor out query for stacktraces * Refactor out queries for frames and executables * Convert Elastic response to stackframe metadata * Search for frames and executables in parallel * Add default value for contexts * Add types for function parameters * Fix compiler warnings and failing tests
- Loading branch information
1 parent
77a2d20
commit 57f0e8c
Showing
23 changed files
with
570 additions
and
429 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
/* | ||
* 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 and the Server Side Public License, v 1; you may not use this file except | ||
* in compliance with, at your election, the Elastic License 2.0 or the Server | ||
* Side Public License, v 1. | ||
*/ | ||
|
||
import { | ||
AggregationsHistogramAggregate, | ||
AggregationsHistogramBucket, | ||
} from '@elastic/elasticsearch/lib/api/types'; | ||
|
||
import { StackFrameMetadata } from './profiling'; | ||
|
||
type TopNBucket = { | ||
Value: string; | ||
Count: number; | ||
}; | ||
|
||
type TopNBucketsByDate = { | ||
TopN: Record<number, TopNBucket[]>; | ||
}; | ||
|
||
type TopNContainers = TopNBucketsByDate; | ||
type TopNDeployments = TopNBucketsByDate; | ||
type TopNHosts = TopNBucketsByDate; | ||
type TopNThreads = TopNBucketsByDate; | ||
|
||
type TopNTraces = TopNBucketsByDate & { | ||
Metadata: Record<string, StackFrameMetadata[]>; | ||
}; | ||
|
||
type TopN = TopNContainers | TopNDeployments | TopNHosts | TopNThreads | TopNTraces; | ||
|
||
export function createTopNBucketsByDate( | ||
histogram: AggregationsHistogramAggregate | ||
): TopNBucketsByDate { | ||
const topNBucketsByDate: Record<number, TopNBucket[]> = {}; | ||
|
||
const histogramBuckets = (histogram?.buckets as AggregationsHistogramBucket[]) ?? []; | ||
for (let i = 0; i < histogramBuckets.length; i++) { | ||
const key = histogramBuckets[i].key / 1000; | ||
topNBucketsByDate[key] = []; | ||
histogramBuckets[i].group_by.buckets.forEach((item: any) => { | ||
topNBucketsByDate[key].push({ | ||
Value: item.key, | ||
Count: item.count.value, | ||
}); | ||
}); | ||
} | ||
|
||
return { TopN: topNBucketsByDate }; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -95,4 +95,4 @@ export class BitmapTextEllipse extends Pixi.BitmapText { | |
*/ | ||
this.dirty = true | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -30,4 +30,4 @@ export const binarySearchLowerLimit = ( | |
} | ||
|
||
return min; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,4 +8,4 @@ const debounce = (callback: Function, wait: number) => { | |
}; | ||
} | ||
|
||
export default debounce | ||
export default debounce |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -15,4 +15,4 @@ export const toggleSandboxMode = () => { | |
} else { | ||
setSandboxModeTo(ENABLED_KEY) | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.