You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Add a first-class FlameGraph panel for hierarchical profiling results, suitable for ClickHouse system.trace_log queries and other stack/call-tree datasets.
Adopt Grafana's flat nested-set result contract and use d3-flame-graph as the preferred implementation path, behind a SQL Browser-owned adapter and panel lifecycle wrapper. Do not embed Grafana's React component or replace Chart.js solely for this feature.
Research
Grafana
Grafana has a built-in Flame graph visualization and an independently published @grafana/flamegraph component.
Grafana's data contract is a flat table in depth-first order with these fields:
Field
Meaning
level
Zero-based stack depth
value
Inclusive sample count or duration
self
Exclusive sample count or duration
label
Frame/function name
color
Optional explicit color
This is attractive for SQL results because the browser does not need a nested JSON object. Rows can stream as an ordinary table and be validated deterministically.
Grafana supports:
flame-graph and table views;
zooming into a frame;
text search/highlighting;
tooltips with inclusive and self values;
optional sandwich-style/profile navigation in profiling integrations.
The published Grafana component is not a suitable direct dependency for this project. It pulls in React, Grafana UI/data packages, Emotion, lodash, and other runtime dependencies. SQL Browser is a vanilla, single-file application with no third-party network requests, so importing that package would be disproportionate.
Apache Superset
Apache Superset does not currently register a built-in FlameGraph visualization in its main visualization preset. Its built-in hierarchical alternatives include Tree, Sunburst, Treemap, Graph, and Sankey, mostly through ECharts.
Superset's architecture allows a FlameGraph to be added as a custom visualization plugin, but it is not an out-of-the-box chart type.
SQL Browser therefore owns a pure, tested adapter from the flat result contract into the nested d3-flame-graph hierarchy. The adapter remains independent of the renderer and can support a native implementation later.
The dependency does not remove SQL Browser's responsibility for:
schema and hierarchy validation;
keyboard focus and navigation;
accessible frame labels;
theme integration;
result-size limits;
resize and teardown integration;
safe tooltip content;
bundle-size review.
Do not import the full monolithic d3 package. Use only the dependency graph required by d3-flame-graph and record the resulting production bundle increase.
Implications for SQL Browser
The current application uses Chart.js for ordinary bar/line/area/pie charts and has a closed panel configuration union. Flame graphs are not a natural Chart.js chart type. Implement this as a dedicated panel arm rather than forcing it into the existing chart-family abstraction or replacing Chart.js.
Summary
Add a first-class FlameGraph panel for hierarchical profiling results, suitable for ClickHouse
system.trace_logqueries and other stack/call-tree datasets.Adopt Grafana's flat nested-set result contract and use
d3-flame-graphas the preferred implementation path, behind a SQL Browser-owned adapter and panel lifecycle wrapper. Do not embed Grafana's React component or replace Chart.js solely for this feature.Research
Grafana
Grafana has a built-in Flame graph visualization and an independently published
@grafana/flamegraphcomponent.Grafana's data contract is a flat table in depth-first order with these fields:
levelvalueselflabelcolorThis is attractive for SQL results because the browser does not need a nested JSON object. Rows can stream as an ordinary table and be validated deterministically.
Grafana supports:
Sources:
The published Grafana component is not a suitable direct dependency for this project. It pulls in React, Grafana UI/data packages, Emotion, lodash, and other runtime dependencies. SQL Browser is a vanilla, single-file application with no third-party network requests, so importing that package would be disproportionate.
Apache Superset
Apache Superset does not currently register a built-in FlameGraph visualization in its main visualization preset. Its built-in hierarchical alternatives include Tree, Sunburst, Treemap, Graph, and Sankey, mostly through ECharts.
Superset's architecture allows a FlameGraph to be added as a custom visualization plugin, but it is not an out-of-the-box chart type.
Sources:
d3-flame-graphd3-flame-graphis the preferred renderer to prototype before writing a custom SVG implementation.It is a purpose-built Apache-2.0 FlameGraph component with:
destroy()lifecycle;Source:
Its input is a nested tree rather than Grafana's flat rows:
{ "name": "root", "value": 100, "children": [ { "name": "functionA", "value": 70 } ] }SQL Browser therefore owns a pure, tested adapter from the flat result contract into the nested
d3-flame-graphhierarchy. The adapter remains independent of the renderer and can support a native implementation later.The dependency does not remove SQL Browser's responsibility for:
Do not import the full monolithic
d3package. Use only the dependency graph required byd3-flame-graphand record the resulting production bundle increase.Implications for SQL Browser
The current application uses Chart.js for ordinary bar/line/area/pie charts and has a closed panel configuration union. Flame graphs are not a natural Chart.js chart type. Implement this as a dedicated panel arm rather than forcing it into the existing chart-family abstraction or replacing Chart.js.
Proposed v1 design
Add an explicit panel configuration:
{ "panel": { "cfg": { "type": "flamegraph", "level": "level", "value": "value", "self": "self", "label": "label", "color": "color" } } }colorshould be optional. Role fields should use column names, not indexes, matching the Logs panel's resilience to reordered result schemas.Required result contract
Rows must be in depth-first traversal order.
Required columns:
level: non-negative integer;value: finite non-negative number;self: finite non-negative number;label: string.Optional:
color: CSS-compatible color string.Validation rules:
self <= value;The exact sibling-width accounting should follow Grafana's nested-set transform semantics so Grafana-compatible SQL output renders equivalently.
Flat-row adapter
Implement a pure transform that:
d3-flame-graph;The renderer must consume only the validated adapter output, never raw query rows.
Rendering recommendation
Use
d3-flame-graphfor the v1 renderer, wrapped by the existing panel registry and lifecycle:coloris absent;destroy()and remove all wrapper listeners/observers on repaint or teardown.Add an accessibility wrapper because mouse interaction alone is insufficient:
A native SVG renderer remains the fallback if the prototype fails the bundle, lifecycle, performance, accessibility, or styling gates.
Prototype decision gate
Before completing full integration, create a focused prototype and record:
Proceed with
d3-flame-graphunless one of these is materially unacceptable. Do not replace Chart.js as part of this issue.UX scope
V1 should include:
Out of scope for v1:
system.trace_log;Performance and safety
Define and test a maximum rendered frame count. Suggested initial behavior:
Acceptance criteria
panel.cfg.type = "flamegraph"with name-based roles.d3-flame-graph.d3-flame-graphversion, license, dependency tree, and production bundle-size impact.d3bundle, ECharts, or replacement chart framework is added.Suggested implementation sequence
d3-flame-graphprototype with bundle/performance/lifecycle measurements.