[FEATURE] add trace heatmap chart plugin - #724
Conversation
c40e966 to
139f2ea
Compare
b33097f to
cad2d04
Compare
e90da96 to
30c30f1
Compare
30c30f1 to
69d4258
Compare
69d4258 to
ec0a324
Compare
|
|
||
| func MustGetWorkspaces(dirPath string) []string { | ||
| excludedWorkspaces := []string{"e2e"} | ||
| excludedWorkspaces := []string{"e2e", "traceheatmapchart"} |
There was a problem hiding this comment.
At the moment this plugin does not include any Go files. Therefore, the pipeline throws an exception. For now, we can exclude the plugin from this part of the pipeline.
There was a problem hiding this comment.
not sure why the plugin should not include go files. At least the sdk related files should exist.
There was a problem hiding this comment.
we don't need these files as they are included in the repo root.
There was a problem hiding this comment.
we don't need these files as they are included in the repo root.
There was a problem hiding this comment.
we don't need these files as they are included in the repo root.
There was a problem hiding this comment.
we don't need these files as they are included in the repo root.
There was a problem hiding this comment.
we don't need these files as they are included in the repo root.
| @@ -0,0 +1,30 @@ | |||
| module github.com/perses/plugins/prometheus | |||
There was a problem hiding this comment.
| module github.com/perses/plugins/prometheus | |
| module github.com/perses/plugins/traceheatmapchart |
| @@ -0,0 +1,17 @@ | |||
| module: "github.com/perses/traceheatmapchart@v0" | |||
There was a problem hiding this comment.
| module: "github.com/perses/traceheatmapchart@v0" | |
| module: "github.com/perses/plugins/traceheatmapchart@v0" |
| @@ -0,0 +1,63 @@ | |||
| { | |||
| "name": "@perses/traceheatmap-chart-plugin", | |||
There was a problem hiding this comment.
| "name": "@perses/traceheatmap-chart-plugin", | |
| "name": "@perses-dev/traceheatmap-chart-plugin", |
| })(), | ||
| }); | ||
|
|
||
| return `<div style=" |
There was a problem hiding this comment.
this HTML is invalid, was this ran to check?
There was a problem hiding this comment.
Surprisingly the HTML works just fine although it has some syntax issue, funny! Let me check.
I also found out this can fall under the XSS attack! Let's see if I can improve it.
| scale: 'hourly', | ||
| getBuckets: (start, end, local) => { | ||
| const generateHourlyLabels = (ts: number) => { | ||
| const formatter = new Intl.DateTimeFormat('en-US', { hour: 'numeric' }); |
There was a problem hiding this comment.
can we avoid to hardcode the en-US locale?
| elementId: generateId(column, row, 'min'), | ||
| value: ((): string | undefined => { | ||
| const indexes = bucketToFlatResultsMap[column]?.[row]; | ||
| if (!indexes) return undefined; |
There was a problem hiding this comment.
since this does not guard against empty arrays, what would be displayed?
There was a problem hiding this comment.
If I understood your point right,
That should be fine to return undefined. When the Tooltip html is being built the undefined values are scaped by the filter
return bucketDetails
.filter((i) => i.value)There was a problem hiding this comment.
What I meant is that indexes can be [] which is thuthy
| // See the License for the specific language governing permissions and | ||
| // limitations under the License. | ||
|
|
||
| export { getPluginModule } from './getPluginModule'; |
There was a problem hiding this comment.
We are missing component exports here.
| "dev": "rsbuild dev", | ||
| "build": "npm run build-mf && concurrently \"npm:build:*\"", | ||
| "build-mf": "rsbuild build", | ||
| "build:cjs": "swc ./src -d dist/lib/cjs --strip-leading-paths --config-file .cjs.swcrc", |
There was a problem hiding this comment.
not sure why are we re defining the cjs.swcrc if there is one at the root that can be re used, like other plugins already do.
| resultsStartTimes: Array<Pick<TraceSearchResult, 'startTimeUnixMs' | 'durationMs'>>, | ||
| local?: string | ||
| ): TraceHeatMapTimeBucket => { | ||
| const startTimeStamp = min(...resultsStartTimes.map((i) => i.startTimeUnixMs)); |
There was a problem hiding this comment.
This could create a stack overflow with many traces, the min and max functions don't take arrays, they are expanded as variadic parameters, but the V8's has limits on how many parameters you can add. It will be better to use a plain loop and calculate the max and min at the same time.
862d55b to
62c94d1
Compare
| const indexes = bucketToFlatResultsMap[column]?.[row]; | ||
| if (!indexes?.length) return undefined; | ||
| return ( | ||
| max(...indexes.filter((idx) => flatResults[idx] !== undefined).map((idx) => flatResults[idx]!.durationMs)) + '' |
There was a problem hiding this comment.
This still doing a sort over a large amount of variadic params
62c94d1 to
2a897cd
Compare
Signed-off-by: Mahmoud Shahrokni <seyedmahmoud.shahrokni@amadeus.com> Signed-off-by: Mahmoud Shahrokni <seyedmahmoud.shahrokni@amadeus.com> Signed-off-by: Mahmoud Shahrokni <seyedmahmoud.shahrokni@amadeus.com> Signed-off-by: Mahmoud Shahrokni <seyedmahmoud.shahrokni@amadeus.com> Signed-off-by: Mahmoud Shahrokni <seyedmahmoud.shahrokni@amadeus.com> Signed-off-by: Mahmoud Shahrokni <seyedmahmoud.shahrokni@amadeus.com> Signed-off-by: Mahmoud Shahrokni <seyedmahmoud.shahrokni@amadeus.com> Signed-off-by: Mahmoud Shahrokni <seyedmahmoud.shahrokni@amadeus.com> Signed-off-by: Mahmoud Shahrokni <seyedmahmoud.shahrokni@amadeus.com> Signed-off-by: Mahmoud Shahrokni <seyedmahmoud.shahrokni@amadeus.com> Signed-off-by: Seyed Mahmoud Shahrokni <39291137+shahrokni@users.noreply.github.com> Signed-off-by: Seyed Mahmoud Shahrokni <39291137+shahrokni@users.noreply.github.com> Signed-off-by: Seyed Mahmoud Shahrokni <39291137+shahrokni@users.noreply.github.com> Signed-off-by: Seyed Mahmoud Shahrokni <39291137+shahrokni@users.noreply.github.com> Signed-off-by: Seyed Mahmoud Shahrokni <39291137+shahrokni@users.noreply.github.com> Signed-off-by: Seyed Mahmoud Shahrokni <39291137+shahrokni@users.noreply.github.com> Signed-off-by: Seyed Mahmoud Shahrokni <39291137+shahrokni@users.noreply.github.com> Signed-off-by: Seyed Mahmoud Shahrokni <39291137+shahrokni@users.noreply.github.com> Signed-off-by: Seyed Mahmoud Shahrokni <39291137+shahrokni@users.noreply.github.com> Signed-off-by: Seyed Mahmoud Shahrokni <39291137+shahrokni@users.noreply.github.com> Signed-off-by: Seyed Mahmoud Shahrokni <39291137+shahrokni@users.noreply.github.com> Signed-off-by: Seyed Mahmoud Shahrokni <39291137+shahrokni@users.noreply.github.com> Signed-off-by: Seyed Mahmoud Shahrokni <39291137+shahrokni@users.noreply.github.com> Signed-off-by: Seyed Mahmoud Shahrokni <39291137+shahrokni@users.noreply.github.com> Signed-off-by: Seyed Mahmoud Shahrokni <39291137+shahrokni@users.noreply.github.com> Signed-off-by: Seyed Mahmoud Shahrokni <39291137+shahrokni@users.noreply.github.com> Signed-off-by: Seyed Mahmoud Shahrokni <39291137+shahrokni@users.noreply.github.com> Signed-off-by: Seyed Mahmoud Shahrokni <39291137+shahrokni@users.noreply.github.com> Signed-off-by: Seyed Mahmoud Shahrokni <39291137+shahrokni@users.noreply.github.com>
2a897cd to
f114a88
Compare


Relates to perses/perses#3942
This is the bare minimum
trace heat map chart. All it needs is traces and the exponential base (default 2) to bucketize the traces according to their time and duration.The x-axis and y-axis represent the time and duration buckets respectively. Both buckets are generated dynamically.
The following picture shows a base 2 bucketing.
It also supports base 10. Choosing a proper base may vary by different cases.
Demo
Same queries and traces, different bases
Next Steps?
Checklist
[<catalog_entry>] <commit message>naming convention using one of thefollowing
catalog_entryvalues:FEATURE,ENHANCEMENT,BUGFIX,BREAKINGCHANGE,DOC,IGNORE.UI Changes