@parca/profile 0.19.44 → 0.19.46

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (53) hide show
  1. package/CHANGELOG.md +8 -0
  2. package/dist/GraphTooltipArrow/Content.d.ts.map +1 -1
  3. package/dist/GraphTooltipArrow/Content.js +1 -1
  4. package/dist/MetricsGraph/MetricsContextMenu/index.d.ts +20 -11
  5. package/dist/MetricsGraph/MetricsContextMenu/index.d.ts.map +1 -1
  6. package/dist/MetricsGraph/MetricsContextMenu/index.js +16 -20
  7. package/dist/MetricsGraph/MetricsTooltip/index.d.ts +2 -8
  8. package/dist/MetricsGraph/MetricsTooltip/index.d.ts.map +1 -1
  9. package/dist/MetricsGraph/MetricsTooltip/index.js +46 -55
  10. package/dist/MetricsGraph/UtilizationMetrics/Throughput.d.ts +2 -5
  11. package/dist/MetricsGraph/UtilizationMetrics/Throughput.d.ts.map +1 -1
  12. package/dist/MetricsGraph/UtilizationMetrics/Throughput.js +126 -205
  13. package/dist/MetricsGraph/UtilizationMetrics/index.d.ts +9 -17
  14. package/dist/MetricsGraph/UtilizationMetrics/index.d.ts.map +1 -1
  15. package/dist/MetricsGraph/UtilizationMetrics/index.js +149 -208
  16. package/dist/MetricsGraph/index.d.ts +19 -26
  17. package/dist/MetricsGraph/index.d.ts.map +1 -1
  18. package/dist/MetricsGraph/index.js +50 -115
  19. package/dist/ProfileFlameGraph/index.d.ts.map +1 -1
  20. package/dist/ProfileFlameGraph/index.js +3 -1
  21. package/dist/ProfileMetricsGraph/index.d.ts +1 -1
  22. package/dist/ProfileMetricsGraph/index.d.ts.map +1 -1
  23. package/dist/ProfileMetricsGraph/index.js +232 -23
  24. package/dist/ProfileSelector/MetricsGraphSection.d.ts +1 -4
  25. package/dist/ProfileSelector/MetricsGraphSection.d.ts.map +1 -1
  26. package/dist/ProfileSelector/MetricsGraphSection.js +8 -4
  27. package/dist/ProfileSelector/index.d.ts +3 -6
  28. package/dist/ProfileSelector/index.d.ts.map +1 -1
  29. package/dist/ProfileSelector/index.js +2 -2
  30. package/dist/ProfileSource.d.ts +9 -6
  31. package/dist/ProfileSource.d.ts.map +1 -1
  32. package/dist/ProfileSource.js +23 -8
  33. package/dist/ProfileView/components/GroupByLabelsDropdown/index.d.ts.map +1 -1
  34. package/dist/ProfileView/components/GroupByLabelsDropdown/index.js +5 -1
  35. package/dist/ProfileView/components/ProfileFilters/index.d.ts.map +1 -1
  36. package/dist/ProfileView/components/ProfileFilters/index.js +6 -5
  37. package/dist/styles.css +1 -1
  38. package/dist/useQuery.js +1 -1
  39. package/package.json +7 -7
  40. package/src/GraphTooltipArrow/Content.tsx +2 -4
  41. package/src/MetricsGraph/MetricsContextMenu/index.tsx +78 -66
  42. package/src/MetricsGraph/MetricsTooltip/index.tsx +53 -210
  43. package/src/MetricsGraph/UtilizationMetrics/Throughput.tsx +242 -434
  44. package/src/MetricsGraph/UtilizationMetrics/index.tsx +312 -448
  45. package/src/MetricsGraph/index.tsx +99 -185
  46. package/src/ProfileFlameGraph/index.tsx +3 -1
  47. package/src/ProfileMetricsGraph/index.tsx +430 -37
  48. package/src/ProfileSelector/MetricsGraphSection.tsx +12 -8
  49. package/src/ProfileSelector/index.tsx +5 -5
  50. package/src/ProfileSource.tsx +34 -17
  51. package/src/ProfileView/components/GroupByLabelsDropdown/index.tsx +15 -3
  52. package/src/ProfileView/components/ProfileFilters/index.tsx +23 -3
  53. package/src/useQuery.tsx +1 -1
@@ -1,4 +1,4 @@
1
- import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
2
  // Copyright 2022 The Parca Authors
3
3
  // Licensed under the Apache License, Version 2.0 (the "License");
4
4
  // you may not use this file except in compliance with the License.
@@ -11,18 +11,84 @@ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-run
11
11
  // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
12
  // See the License for the specific language governing permissions and
13
13
  // limitations under the License.
14
- import { Fragment, useCallback, useId, useMemo, useRef, useState } from 'react';
15
- import * as d3 from 'd3';
16
- import { pointer } from 'd3-selection';
14
+ import { useMemo } from 'react';
15
+ import { Icon } from '@iconify/react';
17
16
  import { AnimatePresence, motion } from 'framer-motion';
18
- import throttle from 'lodash.throttle';
19
- import { useContextMenu } from 'react-contexify';
20
- import { DateTimeRange, MetricsGraphSkeleton, useParcaContext, useURLState } from '@parca/components';
21
- import { formatDate, formatForTimespan, getPrecision, valueFormatter } from '@parca/utilities';
22
- import MetricsContextMenu from '../MetricsContextMenu';
23
- import MetricsTooltip from '../MetricsTooltip';
17
+ import { MetricsGraphSkeleton, TextWithTooltip, useParcaContext, } from '@parca/components';
18
+ import { formatDate, timePattern, valueFormatter } from '@parca/utilities';
19
+ import MetricsGraph from '../index';
24
20
  import { useMetricsGraphDimensions } from '../useMetricsGraphDimensions';
25
- import { getSeriesColor } from '../utils/colorMapping';
21
+ const transformUtilizationLabels = (label) => {
22
+ return label.replace('attributes.', '').replace('attributes_resource.', '');
23
+ };
24
+ const createThroughputContextMenuItems = (addLabelMatcher, transmitData, receiveData) => {
25
+ const allData = [...transmitData, ...receiveData];
26
+ return [
27
+ {
28
+ id: 'focus-on-single-series',
29
+ label: 'Focus only on this series',
30
+ icon: 'ph:star',
31
+ onClick: (closestPoint, _series) => {
32
+ if (closestPoint != null &&
33
+ allData.length > 0 &&
34
+ allData[closestPoint.seriesIndex] != null) {
35
+ const originalSeriesData = allData[closestPoint.seriesIndex];
36
+ if (originalSeriesData.labelset?.labels != null) {
37
+ const labels = originalSeriesData.labelset.labels.filter(label => label.name !== '__name__');
38
+ const labelsToAdd = labels.map(label => ({
39
+ key: label.name,
40
+ value: label.value,
41
+ }));
42
+ addLabelMatcher(labelsToAdd);
43
+ }
44
+ }
45
+ },
46
+ },
47
+ {
48
+ id: 'add-to-query',
49
+ label: 'Add to query',
50
+ icon: 'material-symbols:add',
51
+ createDynamicItems: (closestPoint, _series) => {
52
+ if (closestPoint == null ||
53
+ allData.length === 0 ||
54
+ allData[closestPoint.seriesIndex] == null) {
55
+ return [
56
+ {
57
+ id: 'no-labels-available',
58
+ label: 'No labels available',
59
+ icon: 'ph:warning',
60
+ disabled: () => true,
61
+ onClick: () => { }, // No-op for disabled item
62
+ },
63
+ ];
64
+ }
65
+ const originalSeriesData = allData[closestPoint.seriesIndex];
66
+ if (originalSeriesData.labelset?.labels == null) {
67
+ return [
68
+ {
69
+ id: 'no-labels-available',
70
+ label: 'No labels available',
71
+ icon: 'ph:warning',
72
+ disabled: () => true,
73
+ onClick: () => { }, // No-op for disabled item
74
+ },
75
+ ];
76
+ }
77
+ const labels = originalSeriesData.labelset.labels.filter(label => label.name !== '__name__');
78
+ return labels.map(label => ({
79
+ id: `add-label-${label.name}`,
80
+ label: (_jsx("div", { className: "mr-3 inline-block rounded-lg bg-gray-200 px-2 py-1 text-xs font-bold text-gray-700 dark:bg-gray-700 dark:text-gray-300", children: `${transformUtilizationLabels(label.name)}="${label.value}"` })),
81
+ onClick: () => {
82
+ addLabelMatcher({
83
+ key: label.name,
84
+ value: label.value,
85
+ });
86
+ },
87
+ }));
88
+ },
89
+ },
90
+ ];
91
+ };
26
92
  function transformToSeries(data, isReceive = false) {
27
93
  const series = data.reduce(function (agg, s) {
28
94
  if (s.labelset !== undefined) {
@@ -49,204 +115,59 @@ function transformToSeries(data, isReceive = false) {
49
115
  values: series.values.sort((a, b) => a[0] - b[0]),
50
116
  }));
51
117
  }
52
- const RawAreaChart = ({ transmitData, receiveData, addLabelMatcher, setTimeRange, width, height, margin, humanReadableName, from, to, selectedSeries, onSelectedSeriesChange, }) => {
53
- const { timezone } = useParcaContext();
54
- const graph = useRef(null);
55
- const [dragging, setDragging] = useState(false);
56
- const [hovering, setHovering] = useState(false);
57
- const [relPos, setRelPos] = useState(-1);
58
- const [pos, setPos] = useState([0, 0]);
59
- const [isContextMenuOpen, setIsContextMenuOpen] = useState(false);
60
- const idForContextMenu = useId();
61
- const [_, setSelectedTimeframe] = useURLState('gpu_selected_timeframe');
62
- const parsedSelectedSeries = useMemo(() => {
63
- if (selectedSeries == null || selectedSeries.length === 0) {
64
- return [];
65
- }
66
- return selectedSeries.map(s => ({
67
- key: s.key,
68
- value: s.value,
69
- matcherType: '=',
70
- }));
71
- }, [selectedSeries]);
72
- const lineStroke = '1px';
73
- const lineStrokeHover = '2px';
74
- const lineStrokeSelected = '3px';
75
- const graphWidth = width - margin * 1.5 - margin / 2;
76
- const paddedFrom = from;
77
- const paddedTo = to;
78
- const series = useMemo(() => {
79
- const transmitSeries = transformToSeries(transmitData);
80
- const receiveSeries = transformToSeries(receiveData, true);
81
- return [...transmitSeries, ...receiveSeries];
82
- }, [transmitData, receiveData]);
83
- const extentsY = series.map(function (s) {
84
- return d3.extent(s.values, function (d) {
85
- return d[1];
86
- });
87
- });
88
- const minY = d3.min(extentsY, function (d) {
89
- return d[0];
90
- });
91
- const maxY = d3.max(extentsY, function (d) {
92
- return d[1];
93
- });
94
- // Setup scales with padded time range
95
- const xScale = d3.scaleUtc().domain([paddedFrom, paddedTo]).range([0, graphWidth]);
96
- const yScale = d3
97
- .scaleLinear()
98
- // Ensure domain is symmetric around 0 for balanced visualization
99
- .domain([minY ?? 0, maxY ?? 0])
100
- .range([height - margin, 0])
101
- .nice();
102
- const throttledSetPos = throttle(setPos, 20);
103
- const onMouseMove = (e) => {
104
- if (isContextMenuOpen) {
105
- return;
106
- }
107
- // X/Y coordinate array relative to svg
108
- const rel = pointer(e);
109
- const xCoordinate = rel[0];
110
- const xCoordinateWithoutMargin = xCoordinate - margin;
111
- const yCoordinate = rel[1];
112
- const yCoordinateWithoutMargin = yCoordinate - margin;
113
- throttledSetPos([xCoordinateWithoutMargin, yCoordinateWithoutMargin]);
114
- };
115
- const trackVisibility = (isVisible) => {
116
- setIsContextMenuOpen(isVisible);
117
- };
118
- const MENU_ID = `areachart-context-menu-${idForContextMenu}`;
119
- const { show } = useContextMenu({
120
- id: MENU_ID,
121
- });
122
- const displayMenu = useCallback((e) => {
123
- show({
124
- event: e,
125
- });
126
- }, [show]);
127
- // Create line generator for both transmit and receive
128
- const lineGenerator = d3
129
- .line()
130
- .x(d => xScale(d[0]))
131
- .y(d => yScale(d[1]));
132
- const highlighted = useMemo(() => {
133
- if (series.length === 0) {
134
- return null;
135
- }
136
- // Return the closest point as the highlighted point
137
- const closestPointPerSeries = series.map(function (s) {
138
- const distances = s.values.map(d => {
139
- const x = xScale(d[0]) + margin / 2;
140
- const y = yScale(d[1]) - margin / 3;
141
- return Math.sqrt(Math.pow(pos[0] - x, 2) + Math.pow(pos[1] - y, 2));
142
- });
143
- const pointIndex = d3.minIndex(distances);
144
- const minDistance = distances[pointIndex];
145
- return {
146
- pointIndex,
147
- distance: minDistance,
148
- };
149
- });
150
- const closestSeriesIndex = d3.minIndex(closestPointPerSeries, s => s.distance);
151
- const pointIndex = closestPointPerSeries[closestSeriesIndex].pointIndex;
152
- const point = series[closestSeriesIndex].values[pointIndex];
118
+ function transformNetworkSeriesToSeries(transmitData, receiveData) {
119
+ const transmitSeries = transformToSeries(transmitData);
120
+ const receiveSeries = transformToSeries(receiveData, true);
121
+ const allSeries = [...transmitSeries, ...receiveSeries];
122
+ return allSeries.map(networkSeries => {
123
+ const labels = networkSeries.metric ?? [];
124
+ const sortedLabels = labels
125
+ .filter(label => label.name !== '__name__')
126
+ .sort((a, b) => a.name.localeCompare(b.name));
127
+ const labelString = sortedLabels.map(label => `${label.name}=${label.value}`).join(',');
128
+ const id = (networkSeries.isReceive === true ? 'receive-' : 'transmit-') +
129
+ (labelString !== '' ? labelString : 'default');
153
130
  return {
154
- seriesIndex: closestSeriesIndex,
155
- labels: series[closestSeriesIndex].metric,
156
- timestamp: point[0],
157
- valuePerSecond: point[1],
158
- value: point[2],
159
- duration: point[3],
160
- x: xScale(point[0]),
161
- y: yScale(point[1]),
131
+ id,
132
+ values: networkSeries.values.map(([timestamp, value]) => [
133
+ timestamp,
134
+ value,
135
+ ]),
162
136
  };
163
- }, [pos, series, xScale, yScale, margin]);
164
- const onMouseDown = (e) => {
165
- // only left mouse button
166
- if (e.button !== 0) {
167
- return;
168
- }
169
- // X/Y coordinate array relative to svg
170
- const rel = pointer(e);
171
- const xCoordinate = rel[0];
172
- const xCoordinateWithoutMargin = xCoordinate - margin;
173
- if (xCoordinateWithoutMargin >= 0) {
174
- setRelPos(xCoordinateWithoutMargin);
175
- setDragging(true);
176
- }
177
- e.stopPropagation();
178
- e.preventDefault();
179
- };
180
- const onMouseUp = (e) => {
181
- setDragging(false);
182
- if (relPos === -1) {
183
- // MouseDown happened outside of this element.
184
- return;
185
- }
186
- // This is a normal click. We tolerate tiny movements to still be a
187
- // click as they can occur when clicking based on user feedback.
188
- if (Math.abs(relPos - pos[0]) <= 1) {
189
- setRelPos(-1);
190
- return;
191
- }
192
- let startPos = relPos;
193
- let endPos = pos[0];
194
- if (startPos > endPos) {
195
- startPos = pos[0];
196
- endPos = relPos;
197
- }
198
- const startCorrection = 10;
199
- const endCorrection = 30;
200
- const firstTime = xScale.invert(startPos - startCorrection).valueOf();
201
- const secondTime = xScale.invert(endPos - endCorrection).valueOf();
202
- setTimeRange(DateTimeRange.fromAbsoluteDates(firstTime, secondTime));
203
- setRelPos(-1);
204
- e.stopPropagation();
205
- e.preventDefault();
206
- };
207
- return (_jsxs(_Fragment, { children: [_jsx(MetricsContextMenu, { onAddLabelMatcher: addLabelMatcher, menuId: MENU_ID, highlighted: highlighted, trackVisibility: trackVisibility, utilizationMetrics: true }), highlighted != null && hovering && !dragging && pos[0] !== 0 && pos[1] !== 0 && (_jsx("div", { onMouseMove: onMouseMove, onMouseEnter: () => setHovering(true), onMouseLeave: () => setHovering(false), children: !isContextMenuOpen && (_jsx(MetricsTooltip, { x: pos[0] + margin, y: pos[1] + margin, highlighted: {
208
- ...highlighted,
209
- valuePerSecond: Math.abs(highlighted.valuePerSecond),
210
- }, contextElement: graph.current, sampleType: 'throughput', sampleUnit: 'bytes_per_second', delta: false, utilizationMetrics: true, valuePrefix: highlighted.seriesIndex >= transmitData.length ? 'Receive ' : 'Transmit ' })) })), _jsx("div", { ref: graph, onMouseEnter: () => setHovering(true), onMouseLeave: () => setHovering(false), onContextMenu: displayMenu, children: _jsxs("svg", { width: `${width}px`, height: `${height + margin}px`, onMouseDown: onMouseDown, onMouseUp: onMouseUp, onMouseMove: onMouseMove, children: [_jsx("g", { transform: `translate(${margin}, 0)`, children: dragging && (_jsx("g", { className: "zoom-time-rect", children: _jsx("rect", { className: "bar", x: pos[0] - relPos < 0 ? pos[0] : relPos, y: 0, height: height, width: Math.abs(pos[0] - relPos), fill: 'rgba(0, 0, 0, 0.125)' }) })) }), _jsxs("g", { transform: `translate(${margin * 1.5}, ${margin / 1.5})`, children: [_jsxs("g", { className: "y axis", textAnchor: "end", fontSize: "10", fill: "none", children: [yScale.ticks(6).map((d, i, allTicks) => {
211
- let decimals = 2;
212
- const intervalBetweenTicks = allTicks[1] - allTicks[0];
213
- if (intervalBetweenTicks < 1) {
214
- const precision = getPrecision(intervalBetweenTicks);
215
- decimals = precision;
216
- }
217
- return (_jsxs(Fragment, { children: [_jsxs("g", { className: "tick", transform: `translate(0, ${yScale(d)})`, children: [_jsx("line", { className: "stroke-gray-300 dark:stroke-gray-500", x2: -6 }), _jsxs("text", { fill: "currentColor", x: -9, dy: '0.32em', children: [d < 0 ? '-' : '', valueFormatter(Math.abs(d), 'bytes_per_second', decimals)] })] }, `tick-${i}`), _jsx("g", { children: _jsx("line", { className: "stroke-gray-300 dark:stroke-gray-500", x1: xScale(from), x2: xScale(to), y1: yScale(d), y2: yScale(d) }) }, `grid-${i}`)] }, `${i.toString()}-${d.toString()}`));
218
- }), _jsx("line", { className: "stroke-gray-300 dark:stroke-gray-500", x1: 0, x2: 0, y1: 0, y2: height - margin }), _jsx("line", { className: "stroke-gray-300 dark:stroke-gray-500", x1: xScale(to), x2: xScale(to), y1: 0, y2: height - margin }), _jsx("g", { transform: `translate(${-margin}, ${(height - margin) / 2}) rotate(270)`, children: _jsx("text", { fill: "currentColor", dy: "-0.7em", className: "text-sm capitalize", textAnchor: "middle", children: humanReadableName }) })] }), _jsxs("g", { className: "x axis", fill: "none", fontSize: "10", textAnchor: "middle", transform: `translate(0,${height - margin})`, children: [xScale.ticks(5).map((d, i) => (_jsxs(Fragment, { children: [_jsxs("g", { className: "tick",
219
- /* eslint-disable-next-line @typescript-eslint/restrict-template-expressions */
220
- transform: `translate(${xScale(d)}, 0)`, children: [_jsx("line", { y2: 6, className: "stroke-gray-300 dark:stroke-gray-500" }), _jsx("text", { fill: "currentColor", dy: ".71em", y: 9, children: formatDate(d, formatForTimespan(from, to), timezone) })] }, `tick-${i}`), _jsx("g", { children: _jsx("line", { className: "stroke-gray-300 dark:stroke-gray-500", x1: xScale(d), x2: xScale(d), y1: 0, y2: -height + margin }) }, `grid-${i}`)] }, `${i.toString()}-${d.toString()}`))), _jsx("line", { className: "stroke-gray-300 dark:stroke-gray-500", x1: 0, x2: graphWidth, y1: 0, y2: 0 }), _jsx("g", { transform: `translate(${(width - 2.5 * margin) / 2}, ${margin / 2})`, children: _jsx("text", { fill: "currentColor", dy: ".71em", y: 5, className: "text-sm", children: "Time" }) })] }), _jsxs("g", { className: "areas", children: [_jsx("line", { x1: xScale(from), x2: xScale(to), y1: yScale(0), y2: yScale(0), stroke: "#64748b", strokeDasharray: "4 2", strokeWidth: 1, opacity: 0.7 }), series.map((s, i) => {
221
- let isSelected = false;
222
- if (parsedSelectedSeries != null && parsedSelectedSeries.length > 0) {
223
- isSelected = parsedSelectedSeries.every(m => {
224
- for (let i = 0; i < s.metric.length; i++) {
225
- if (s.metric[i].name === m.key && s.metric[i].value === m.value) {
226
- return true;
227
- }
228
- }
229
- return false;
230
- });
231
- }
232
- return (_jsx("g", { className: "line cursor-pointer", children: _jsx("path", { d: lineGenerator(s.values) ?? '', fill: "none", stroke: getSeriesColor(s.metric), strokeWidth: isSelected
233
- ? lineStrokeSelected
234
- : hovering && highlighted != null && i === highlighted.seriesIndex
235
- ? lineStrokeHover
236
- : lineStroke, strokeOpacity: isSelected ? 1 : 0.8, onClick: () => {
237
- if (highlighted != null && onSelectedSeriesChange != null) {
238
- onSelectedSeriesChange(highlighted.labels.map(l => ({
239
- key: l.name,
240
- value: l.value,
241
- })));
242
- setSelectedTimeframe(undefined);
243
- }
244
- } }) }, i));
245
- })] })] })] }) })] }));
137
+ });
138
+ }
139
+ const RawAreaChart = ({ transmitData, receiveData, transformedData, addLabelMatcher: _addLabelMatcher, setTimeRange, width, height, margin, humanReadableName, from, to, selectedSeries: _selectedSeries, onSeriesClick, contextMenuItems, }) => {
140
+ const { timezone } = useParcaContext();
141
+ // Compute original series data for rich tooltip
142
+ const allOriginalData = useMemo(() => [...transmitData, ...receiveData], [transmitData, receiveData]);
143
+ return (_jsx(MetricsGraph, { data: transformedData, from: from, to: to, setTimeRange: setTimeRange, onSampleClick: closestPoint => {
144
+ if (onSeriesClick != null) {
145
+ onSeriesClick(closestPoint.seriesIndex);
146
+ }
147
+ }, yAxisLabel: humanReadableName, yAxisUnit: "bytes_per_second", width: width, height: height, margin: margin, contextMenuItems: contextMenuItems, renderTooltipContent: (seriesIndex, pointIndex) => {
148
+ if (allOriginalData?.[seriesIndex]?.samples?.[pointIndex] != null) {
149
+ const originalSeriesData = allOriginalData[seriesIndex];
150
+ const originalPoint = allOriginalData[seriesIndex].samples[pointIndex];
151
+ const labels = originalSeriesData.labelset?.labels ?? [];
152
+ const nameLabel = labels.find(e => e.name === '__name__');
153
+ const highlightedNameLabel = nameLabel ?? { name: '', value: '' };
154
+ // Determine if this is receive data (negative values)
155
+ const isReceive = seriesIndex >= transmitData.length;
156
+ const valuePrefix = isReceive ? 'Receive ' : 'Transmit ';
157
+ return (_jsx("div", { className: "flex flex-row", children: _jsxs("div", { className: "ml-2 mr-6", children: [_jsx("span", { className: "font-semibold", children: highlightedNameLabel.value }), _jsx("span", { className: "my-2 block text-gray-700 dark:text-gray-300", children: _jsx("table", { className: "table-auto", children: _jsxs("tbody", { children: [_jsxs("tr", { children: [_jsxs("td", { className: "w-1/4", children: [valuePrefix, "Value"] }), _jsx("td", { className: "w-3/4", children: valueFormatter(Math.abs(originalPoint.value), 'bytes_per_second', 2) })] }), _jsxs("tr", { children: [_jsx("td", { className: "w-1/4", children: "At" }), _jsx("td", { className: "w-3/4", children: formatDate(new Date(originalPoint.timestamp), timePattern(timezone), timezone) })] })] }) }) }), _jsx("span", { className: "my-2 block text-gray-500", children: labels
158
+ .filter(label => label.name !== '__name__')
159
+ .map(label => (_jsx("div", { className: "mr-3 inline-block rounded-lg bg-gray-200 px-2 py-1 text-xs font-bold text-gray-700 dark:bg-gray-700 dark:text-gray-400", children: _jsx(TextWithTooltip, { text: `${transformUtilizationLabels(label.name)}="${label.value}"`, maxTextLength: 37, id: `${seriesIndex.toString()}-${pointIndex.toString()}-tooltip-${label.name}` }) }, `${seriesIndex.toString()}-${pointIndex.toString()}-${label.name}`))) }), _jsxs("div", { className: "flex w-full items-center gap-1 text-xs text-gray-500", children: [_jsx(Icon, { icon: "iconoir:mouse-button-right" }), _jsx("div", { children: "Right click to add labels to query." })] })] }) }));
160
+ }
161
+ return null;
162
+ } }));
246
163
  };
247
- const AreaChart = ({ transmitData, receiveData, addLabelMatcher, setTimeRange, utilizationMetricsLoading, name, humanReadableName, from, to, selectedSeries, onSelectedSeriesChange, }) => {
164
+ const AreaChart = ({ transmitData, receiveData, addLabelMatcher, setTimeRange, utilizationMetricsLoading, name, humanReadableName, from, to, selectedSeries, onSeriesClick, }) => {
248
165
  const { isDarkMode } = useParcaContext();
249
166
  const { width, height, margin, heightStyle } = useMetricsGraphDimensions(false, true);
250
- return (_jsx(AnimatePresence, { children: _jsx(motion.div, { className: "w-full relative", initial: { display: 'none', opacity: 0 }, animate: { display: 'block', opacity: 1 }, transition: { duration: 0.5 }, children: utilizationMetricsLoading === true ? (_jsx(MetricsGraphSkeleton, { heightStyle: heightStyle, isDarkMode: isDarkMode, isMini: true })) : (_jsx(RawAreaChart, { transmitData: transmitData, receiveData: receiveData, addLabelMatcher: addLabelMatcher, setTimeRange: setTimeRange, width: width, height: height, margin: margin, name: name, humanReadableName: humanReadableName, from: from, to: to, selectedSeries: selectedSeries, onSelectedSeriesChange: onSelectedSeriesChange })) }, "area-chart-graph-loaded") }));
167
+ const transformedData = useMemo(() => transformNetworkSeriesToSeries(transmitData, receiveData), [transmitData, receiveData]);
168
+ const contextMenuItems = useMemo(() => {
169
+ return createThroughputContextMenuItems(addLabelMatcher, transmitData, receiveData);
170
+ }, [addLabelMatcher, transmitData, receiveData]);
171
+ return (_jsx(AnimatePresence, { children: _jsx(motion.div, { className: "w-full relative", initial: { display: 'none', opacity: 0 }, animate: { display: 'block', opacity: 1 }, transition: { duration: 0.5 }, children: utilizationMetricsLoading === true ? (_jsx(MetricsGraphSkeleton, { heightStyle: heightStyle, isDarkMode: isDarkMode, isMini: true })) : (_jsx(RawAreaChart, { transmitData: transmitData, receiveData: receiveData, transformedData: transformedData, addLabelMatcher: addLabelMatcher, setTimeRange: setTimeRange, width: width, height: height, margin: margin, name: name, humanReadableName: humanReadableName, from: from, to: to, selectedSeries: selectedSeries, onSeriesClick: onSeriesClick, contextMenuItems: contextMenuItems })) }, "area-chart-graph-loaded") }));
251
172
  };
252
173
  export default AreaChart;
@@ -1,36 +1,28 @@
1
1
  import { DateTimeRange } from '@parca/components';
2
2
  import { type UtilizationMetrics as MetricSeries } from '../../ProfileSelector';
3
3
  interface CommonProps {
4
- data: MetricSeries[];
5
- addLabelMatcher: (labels: {
6
- key: string;
7
- value: string;
8
- } | Array<{
9
- key: string;
10
- value: string;
11
- }>) => void;
12
4
  setTimeRange: (range: DateTimeRange) => void;
13
- name: string;
14
5
  humanReadableName: string;
15
6
  from: number;
16
7
  to: number;
17
- onSelectedSeriesChange?: (series: Array<{
18
- key: string;
19
- value: string;
20
- }>) => void;
8
+ onSeriesClick?: (seriesIndex: number) => void;
21
9
  }
22
10
  type Props = CommonProps & {
23
11
  data: MetricSeries[];
24
- addLabelMatcher: (labels: {
12
+ yAxisUnit: string;
13
+ utilizationMetricsLoading?: boolean;
14
+ addLabelMatcher?: (labels: {
25
15
  key: string;
26
16
  value: string;
27
17
  } | Array<{
28
18
  key: string;
29
19
  value: string;
30
20
  }>) => void;
31
- setTimeRange: (range: DateTimeRange) => void;
32
- utilizationMetricsLoading?: boolean;
21
+ onSelectedSeriesChange?: (series: Array<{
22
+ key: string;
23
+ value: string;
24
+ }>) => void;
33
25
  };
34
- declare const UtilizationMetrics: ({ data, addLabelMatcher, setTimeRange, utilizationMetricsLoading, name, humanReadableName, from, to, onSelectedSeriesChange, }: Props) => JSX.Element;
26
+ declare const UtilizationMetrics: ({ data, setTimeRange, utilizationMetricsLoading, humanReadableName, from, to, yAxisUnit, addLabelMatcher, onSeriesClick, onSelectedSeriesChange: _onSelectedSeriesChange, }: Props) => JSX.Element;
35
27
  export default UtilizationMetrics;
36
28
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/MetricsGraph/UtilizationMetrics/index.tsx"],"names":[],"mappings":"AAqBA,OAAO,EAAC,aAAa,EAAqD,MAAM,mBAAmB,CAAC;AAIpG,OAAO,EAAC,KAAK,kBAAkB,IAAI,YAAY,EAAC,MAAM,uBAAuB,CAAC;AAO9E,UAAU,WAAW;IACnB,IAAI,EAAE,YAAY,EAAE,CAAC;IACrB,eAAe,EAAE,CACf,MAAM,EAAE;QAAC,GAAG,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,MAAM,CAAA;KAAC,GAAG,KAAK,CAAC;QAAC,GAAG,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,MAAM,CAAA;KAAC,CAAC,KACvE,IAAI,CAAC;IACV,YAAY,EAAE,CAAC,KAAK,EAAE,aAAa,KAAK,IAAI,CAAC;IAC7C,IAAI,EAAE,MAAM,C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