@parca/profile 0.19.82 → 0.19.83

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 (83) hide show
  1. package/CHANGELOG.md +6 -0
  2. package/dist/MatchersInput/index.d.ts +34 -2
  3. package/dist/MatchersInput/index.d.ts.map +1 -1
  4. package/dist/MatchersInput/index.js +91 -14
  5. package/dist/MetricsGraph/UtilizationMetrics/Throughput.d.ts +29 -0
  6. package/dist/MetricsGraph/UtilizationMetrics/Throughput.d.ts.map +1 -0
  7. package/dist/MetricsGraph/UtilizationMetrics/Throughput.js +175 -0
  8. package/dist/MetricsGraph/UtilizationMetrics/index.d.ts +28 -0
  9. package/dist/MetricsGraph/UtilizationMetrics/index.d.ts.map +1 -0
  10. package/dist/MetricsGraph/UtilizationMetrics/index.js +186 -0
  11. package/dist/MetricsGraph/index.d.ts.map +1 -1
  12. package/dist/MetricsGraph/index.js +1 -13
  13. package/dist/ProfileMetricsGraph/index.d.ts.map +1 -1
  14. package/dist/ProfileMetricsGraph/index.js +29 -6
  15. package/dist/ProfileSelector/MetricsGraphSection.d.ts +9 -2
  16. package/dist/ProfileSelector/MetricsGraphSection.d.ts.map +1 -1
  17. package/dist/ProfileSelector/MetricsGraphSection.js +38 -3
  18. package/dist/ProfileSelector/QueryControls.d.ts +43 -0
  19. package/dist/ProfileSelector/QueryControls.d.ts.map +1 -0
  20. package/dist/{QueryControls/index.js → ProfileSelector/QueryControls.js} +13 -16
  21. package/dist/ProfileSelector/index.d.ts +29 -1
  22. package/dist/ProfileSelector/index.d.ts.map +1 -1
  23. package/dist/ProfileSelector/index.js +9 -12
  24. package/dist/SimpleMatchers/Select.js +1 -1
  25. package/dist/SimpleMatchers/index.d.ts +11 -2
  26. package/dist/SimpleMatchers/index.d.ts.map +1 -1
  27. package/dist/SimpleMatchers/index.js +45 -34
  28. package/dist/ViewMatchers/index.d.ts +9 -0
  29. package/dist/ViewMatchers/index.d.ts.map +1 -1
  30. package/dist/ViewMatchers/index.js +12 -20
  31. package/dist/contexts/MatchersInputLabelsContext.d.ts +29 -0
  32. package/dist/contexts/MatchersInputLabelsContext.d.ts.map +1 -0
  33. package/dist/contexts/MatchersInputLabelsContext.js +79 -0
  34. package/dist/contexts/SimpleMatchersLabelContext.d.ts +25 -0
  35. package/dist/contexts/SimpleMatchersLabelContext.d.ts.map +1 -0
  36. package/dist/contexts/SimpleMatchersLabelContext.js +115 -0
  37. package/dist/contexts/UtilizationLabelsContext.d.ts +15 -0
  38. package/dist/contexts/UtilizationLabelsContext.d.ts.map +1 -0
  39. package/dist/contexts/UtilizationLabelsContext.js +25 -0
  40. package/dist/hooks/useQueryState.d.ts +0 -2
  41. package/dist/hooks/useQueryState.d.ts.map +1 -1
  42. package/dist/hooks/useQueryState.js +0 -18
  43. package/dist/index.d.ts +3 -9
  44. package/dist/index.d.ts.map +1 -1
  45. package/dist/index.js +3 -9
  46. package/dist/styles.css +1 -1
  47. package/dist/useSumBy.js +1 -1
  48. package/package.json +2 -2
  49. package/src/MatchersInput/index.tsx +163 -17
  50. package/src/MetricsGraph/UtilizationMetrics/Throughput.tsx +405 -0
  51. package/src/MetricsGraph/UtilizationMetrics/index.tsx +426 -0
  52. package/src/MetricsGraph/index.tsx +1 -17
  53. package/src/ProfileMetricsGraph/index.tsx +98 -17
  54. package/src/ProfileSelector/MetricsGraphSection.tsx +115 -14
  55. package/src/{QueryControls/index.tsx → ProfileSelector/QueryControls.tsx} +84 -66
  56. package/src/ProfileSelector/index.tsx +109 -106
  57. package/src/SimpleMatchers/Select.tsx +1 -1
  58. package/src/SimpleMatchers/index.tsx +85 -46
  59. package/src/ViewMatchers/index.tsx +30 -22
  60. package/src/contexts/MatchersInputLabelsContext.tsx +141 -0
  61. package/src/contexts/SimpleMatchersLabelContext.tsx +189 -0
  62. package/src/contexts/UtilizationLabelsContext.tsx +45 -0
  63. package/src/hooks/useQueryState.ts +0 -25
  64. package/src/index.tsx +3 -29
  65. package/src/useSumBy.ts +1 -1
  66. package/dist/QueryControls/index.d.ts +0 -42
  67. package/dist/QueryControls/index.d.ts.map +0 -1
  68. package/dist/contexts/LabelsQueryProvider.d.ts +0 -35
  69. package/dist/contexts/LabelsQueryProvider.d.ts.map +0 -1
  70. package/dist/contexts/LabelsQueryProvider.js +0 -70
  71. package/dist/contexts/UnifiedLabelsContext.d.ts +0 -37
  72. package/dist/contexts/UnifiedLabelsContext.d.ts.map +0 -1
  73. package/dist/contexts/UnifiedLabelsContext.js +0 -88
  74. package/dist/contexts/utils.d.ts +0 -10
  75. package/dist/contexts/utils.d.ts.map +0 -1
  76. package/dist/contexts/utils.js +0 -31
  77. package/dist/hooks/useLabels.d.ts +0 -23
  78. package/dist/hooks/useLabels.d.ts.map +0 -1
  79. package/dist/hooks/useLabels.js +0 -75
  80. package/src/contexts/LabelsQueryProvider.tsx +0 -142
  81. package/src/contexts/UnifiedLabelsContext.tsx +0 -155
  82. package/src/contexts/utils.ts +0 -43
  83. package/src/hooks/useLabels.ts +0 -121
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/MetricsGraph/index.tsx"],"names":[],"mappings":"AAaA,OAAO,KAAgE,MAAM,OAAO,CAAC;AAOrF,OAAO,EAAC,aAAa,EAAkB,MAAM,mBAAmB,CAAC;AAMjE,OAA2B,EACzB,eAAe,EACf,wBAAwB,EACxB,kBAAkB,EACnB,MAAM,sBAAsB,CAAC;AAI9B,UAAU,KAAK;IACb,IAAI,EAAE,MAAM,EAAE,CAAC;IACf,IAAI,EAAE,MAAM,CAAC;IACb,EAAE,EAAE,MAAM,CAAC;IACX,aAAa,EAAE,CAAC,YAAY,EAAE,WAAW,KAAK,IAAI,CAAC;IACnD,YAAY,EAAE,CAAC,KAAK,EAAE,aAAa,KAAK,IAAI,CAAC;IAC7C,UAAU,EAAE,MAAM,CAAC;IACnB,SAAS,EAAE,MAAM,CAAC;IAClB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,MAAM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AG,MAAM,GAAG,IAKnD,CAAC;AAKF,eAAO,MAAM,eAAe,GAAI,uJAc7B,KAAK,KAAG,GAAG,CAAC,OAibd,CAAC"}
@@ -90,12 +90,6 @@ export const RawMetricsGraph = ({ data, from, to, onSampleClick, setTimeRange, y
90
90
  return null;
91
91
  }
92
92
  const closestPointPerSeries = series.map(function (s) {
93
- if (s.values.length === 0) {
94
- return {
95
- pointIndex: undefined,
96
- distance: Infinity,
97
- };
98
- }
99
93
  const distances = s.values.map(d => {
100
94
  const x = xScale(d[0]) + margin / 2; // d[0] is timestamp_ms
101
95
  const y = yScale(d[1]) - margin / 3; // d[1] is value
@@ -103,20 +97,14 @@ export const RawMetricsGraph = ({ data, from, to, onSampleClick, setTimeRange, y
103
97
  return Math.sqrt(Math.pow(pos[0] - x, 2) + Math.pow(pos[1] - y, 2));
104
98
  });
105
99
  const pointIndex = d3.minIndex(distances);
106
- const minDistance = pointIndex != null ? distances[pointIndex] : Infinity;
100
+ const minDistance = distances[pointIndex];
107
101
  return {
108
102
  pointIndex,
109
103
  distance: minDistance,
110
104
  };
111
105
  });
112
106
  const closestSeriesIndex = d3.minIndex(closestPointPerSeries, s => s.distance);
113
- if (closestSeriesIndex == null || closestPointPerSeries[closestSeriesIndex] == null) {
114
- return null;
115
- }
116
107
  const pointIndex = closestPointPerSeries[closestSeriesIndex].pointIndex;
117
- if (pointIndex == null) {
118
- return null;
119
- }
120
108
  return {
121
109
  seriesIndex: closestSeriesIndex,
122
110
  pointIndex,
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/ProfileMetricsGraph/index.tsx"],"names":[],"mappings":"AAkBA,OAAO,EACL,KAAK,EAGL,kBAAkB,EACnB,MAAM,eAAe,CAAC;AACvB,OAAO,EACL,aAAa,EAId,MAAM,mBAAmB,CAAC;AAK3B,OAAO,EAAyB,gBAAgB,EAAC,MAAM,IAAI,CAAC;AA6G5D,UAAU,6BAA6B;IACrC,OAAO,EAAE,MAAM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AAI,aAAW,6BAA6B,KAAG,GAAG,CAAC,OAMvF,CAAC;AAEF,UAAU,wBAAwB;IAChC,WAAW,EAAE,kBAAkB,CAAC;IAChC,eAAe,EAAE,MAAM,CAAC;IACxB,OAAO,EAAE,gBAAgB,GAAG,IAAI,CAAC;IACjC,IAAI,EAAE,MAAM,CAAC;IACb,EAAE,EAAE,MAAM,CAAC;IACX,YAAY,EAAE,OAAO,CAAC;IACtB,KAAK,EAAE,MAAM,EAAE,CAAC;IAChB,YAAY,EAAE,CAAC,KAAK,EAAE,aAAa,KAAK,IAAI,CAAC;IAC7C,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,CACZ,SAAS,EAAE,MAAM,EACjB,MAAM,EAAE,KAAK,EAAE,EACf,eAAe,EAAE,MAAM,EACvB,QAAQ,EAAE,MAAM,KACb,IAAI,CAAC;IACV,SAAS,CAAC,EAAE,OAAO,CAAC;CACrB;AAED,QAAA,MAAM,mBAAmB,GAAI,qHAW1B,wBAAwB,KAAG,GAAG,CAAC,OA+ZjC,CAAC;AAEF,eAAe,mBAAmB,CAAC"}
@@ -22,8 +22,14 @@ import { MergedProfileSelection } from '..';
22
22
  import MetricsGraph from '../MetricsGraph';
23
23
  import { useMetricsGraphDimensions } from '../MetricsGraph/useMetricsGraphDimensions';
24
24
  import { useQueryRange } from './hooks/useQueryRange';
25
- const createProfileContextMenuItems = (addLabelMatcher, data // The original MetricsSeriesPb[] data
26
- ) => {
25
+ const transformUtilizationLabels = (label, utilizationMetrics) => {
26
+ if (utilizationMetrics) {
27
+ return label.replace('attributes.', '').replace('attributes_resource.', '');
28
+ }
29
+ return label;
30
+ };
31
+ const createProfileContextMenuItems = (addLabelMatcher, data, // The original MetricsSeriesPb[] data
32
+ utilizationMetrics = false) => {
27
33
  return [
28
34
  {
29
35
  id: 'focus-on-single-series',
@@ -70,7 +76,7 @@ const createProfileContextMenuItems = (addLabelMatcher, data // The original Met
70
76
  }
71
77
  return labels.map((label) => ({
72
78
  id: `add-label-${label.name}`,
73
- 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: `${label.name}="${label.value}"` })),
79
+ 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, utilizationMetrics)}="${label.value}"` })),
74
80
  onClick: () => {
75
81
  addLabelMatcher({
76
82
  key: label.name,
@@ -268,15 +274,32 @@ const ProfileMetricsGraph = ({ queryClient, queryExpression, profile, from, to,
268
274
  const labels = originalSeriesData.labelset?.labels ?? [];
269
275
  const nameLabel = labels.find(e => e.name === '__name__');
270
276
  const highlightedNameLabel = nameLabel ?? { name: '', value: '' };
277
+ // Calculate attributes maps for utilization metrics
278
+ const utilizationMetrics = false; // This is for profile metrics, not utilization
279
+ const attributesMap = labels
280
+ .filter(label => label.name.startsWith('attributes.') &&
281
+ !label.name.startsWith('attributes_resource.'))
282
+ .reduce((acc, label) => {
283
+ const key = label.name.replace('attributes.', '');
284
+ acc[key] = label.value;
285
+ return acc;
286
+ }, {});
287
+ const attributesResourceMap = labels
288
+ .filter(label => label.name.startsWith('attributes_resource.'))
289
+ .reduce((acc, label) => {
290
+ const key = label.name.replace('attributes_resource.', '');
291
+ acc[key] = label.value;
292
+ return acc;
293
+ }, {});
271
294
  const isDeltaType = profile !== null
272
295
  ? profile?.query.profType.delta
273
296
  : false;
274
297
  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: [isDeltaType ? (_jsxs(_Fragment, { children: [_jsxs("tr", { children: [_jsx("td", { className: "w-1/4 pr-3", children: "Per\u00A0Second" }), _jsx("td", { className: "w-3/4", children: valueFormatter(originalPoint.valuePerSecond, sampleUnit === 'nanoseconds' && sampleType === 'cpu'
275
298
  ? 'CPU Cores'
276
299
  : sampleUnit, 5) })] }), _jsxs("tr", { children: [_jsx("td", { className: "w-1/4", children: "Total" }), _jsx("td", { className: "w-3/4", children: valueFormatter(originalPoint.value ?? 0, sampleUnit, 2) })] })] })) : (_jsxs("tr", { children: [_jsx("td", { className: "w-1/4", children: "Value" }), _jsx("td", { className: "w-3/4", children: valueFormatter(originalPoint.valuePerSecond, sampleUnit, 5) })] })), originalPoint.duration != null &&
277
- Number(originalPoint.duration) > 0 && (_jsxs("tr", { children: [_jsx("td", { className: "w-1/4", children: "Duration" }), _jsx("td", { className: "w-3/4", children: valueFormatter(Number(originalPoint.duration.toString()), 'nanoseconds', 2) })] })), _jsxs("tr", { children: [_jsx("td", { className: "w-1/4", children: "At" }), _jsx("td", { className: "w-3/4", children: formatDate(new Date(timestampMs), timePattern(timezone), timezone) })] })] }) }) }), _jsx("span", { className: "my-2 block text-gray-500", children: labels
278
- .filter((label) => label.name !== '__name__')
279
- .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", ...testId(TEST_IDS.TOOLTIP_LABEL), children: _jsx(TextWithTooltip, { text: `${label.name}="${label.value}"`, maxTextLength: 37, id: `tooltip-${label.name}` }) }, 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." })] })] }) }));
300
+ Number(originalPoint.duration) > 0 && (_jsxs("tr", { children: [_jsx("td", { className: "w-1/4", children: "Duration" }), _jsx("td", { className: "w-3/4", children: valueFormatter(Number(originalPoint.duration.toString()), 'nanoseconds', 2) })] })), _jsxs("tr", { children: [_jsx("td", { className: "w-1/4", children: "At" }), _jsx("td", { className: "w-3/4", children: formatDate(new Date(timestampMs), timePattern(timezone), timezone) })] })] }) }) }), _jsx("span", { className: "my-2 block text-gray-500", children: utilizationMetrics ? (_jsxs(_Fragment, { children: [Object.keys(attributesResourceMap).length > 0 && (_jsx("span", { className: "text-sm font-bold text-gray-700 dark:text-white", children: "Resource Attributes" })), _jsx("span", { className: "my-2 block text-gray-500", children: Object.keys(attributesResourceMap).map(name => (_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", ...testId(TEST_IDS.TOOLTIP_LABEL), children: _jsx(TextWithTooltip, { text: `${name.replace('attributes.', '')}="${attributesResourceMap[name]}"`, maxTextLength: 48, id: `tooltip-${name}-${attributesResourceMap[name]}` }) }, name))) }), Object.keys(attributesMap).length > 0 && (_jsx("span", { className: "text-sm font-bold text-gray-700 dark:text-white", children: "Attributes" })), _jsx("span", { className: "my-2 block text-gray-500", children: Object.keys(attributesMap).map(name => (_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", ...testId(TEST_IDS.TOOLTIP_LABEL), children: _jsx(TextWithTooltip, { text: `${name.replace('attributes.', '')}="${attributesMap[name]}"`, maxTextLength: 48, id: `tooltip-${name}-${attributesMap[name]}` }) }, name))) })] })) : (_jsx(_Fragment, { children: labels
301
+ .filter((label) => label.name !== '__name__')
302
+ .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", ...testId(TEST_IDS.TOOLTIP_LABEL), children: _jsx(TextWithTooltip, { text: `${label.name}="${label.value}"`, maxTextLength: 37, id: `tooltip-${label.name}` }) }, 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." })] })] }) }));
280
303
  }
281
304
  }
282
305
  return null;
@@ -2,7 +2,7 @@ import { QueryServiceClient } from '@parca/client';
2
2
  import { DateTimeRange } from '@parca/components';
3
3
  import { Query } from '@parca/parser';
4
4
  import { ProfileSelection } from '..';
5
- import { QuerySelection } from './index';
5
+ import { QuerySelection, type UtilizationMetrics as UtilizationMetricsType } from './index';
6
6
  interface MetricsGraphSectionProps {
7
7
  showMetricsGraph: boolean;
8
8
  setDisplayHideMetricsGraphButton?: (show: boolean) => void;
@@ -20,7 +20,14 @@ interface MetricsGraphSectionProps {
20
20
  query: Query;
21
21
  setNewQueryExpression: (queryExpression: string, commit?: boolean) => void;
22
22
  setQueryExpression: (updateTs?: boolean) => void;
23
+ utilizationMetrics?: Array<{
24
+ name: string;
25
+ humanReadableName: string;
26
+ data: UtilizationMetricsType[];
27
+ }>;
28
+ utilizationMetricsLoading?: boolean;
29
+ onUtilizationSeriesSelect?: (name: string, seriesIndex: number) => void;
23
30
  }
24
- export declare function MetricsGraphSection({ showMetricsGraph, setDisplayHideMetricsGraphButton, heightStyle, querySelection, profileSelection, comparing, sumBy, defaultSumByLoading, queryClient, queryExpressionString, setTimeRangeSelection, selectQuery, setProfileSelection, query, setNewQueryExpression, }: MetricsGraphSectionProps): JSX.Element;
31
+ export declare function MetricsGraphSection({ showMetricsGraph, setDisplayHideMetricsGraphButton, heightStyle, querySelection, profileSelection, comparing, sumBy, defaultSumByLoading, queryClient, queryExpressionString, setTimeRangeSelection, selectQuery, setProfileSelection, query, setNewQueryExpression, utilizationMetrics, utilizationMetricsLoading, onUtilizationSeriesSelect, }: MetricsGraphSectionProps): JSX.Element;
25
32
  export {};
26
33
  //# sourceMappingURL=MetricsGraphSection.d.ts.map
@@ -1 +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AAE,KAAK,EAAE,KAAK,KAAK,IAAI,CAAC;IAChF,KAAK,EAAE,KAAK,CAAC;IACb,qBAAqB,EAAE,CAAC,eAAe,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,OAAO,KAAK,IAAI,CAAC;IAC3E,kBAAkB,EAAE,CAAC,QAAQ,CAAC,EAAE,OAAO,KAAK,IAAI,CAAC;IACjD,kBAAkB,CAAC,EAAE,KAAK,CAAC;QACzB,IAAI,EAAE,MAAM,CAAC;QACb,iBAAiB,EAAE,MAAM,CAAC;QAC1B,IAAI,EAAE,sBAAsB,EAAE,CAAC;KAChC,CAAC,CAAC;IACH,yBAAyB,CAAC,EAAE,OAAO,CAAC;IACpC,yBAAyB,CAAC,EAAE,CAAC,IAAI,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,KAAK,IAAI,CAAC;CACzE;AAED,wBAAgB,mBAAmB,CAAC,EAClC,gBAAgB,EAChB,gCAAgC,EAChC,WAAW,EACX,cAAc,EACd,gBAAgB,EAChB,SAAS,EACT,KAAK,EACL,mBAAmB,EACnB,WAAW,EACX,qBAAqB,EACrB,qBAAqB,EACrB,WAAW,EACX,mBAAmB,EACnB,KAAK,EACL,qBAAqB,EACrB,kBAAkB,EAClB,yBAAyB,EACzB,yBAAyB,GAC1B,EAAE,wBAAwB,GAAG,GAAG,CAAC,OAAO,CAsNxC"}
@@ -1,4 +1,4 @@
1
- import { jsxs as _jsxs, jsx as _jsx, Fragment as _Fragment } from "react/jsx-runtime";
1
+ import { Fragment as _Fragment, 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.
@@ -14,9 +14,11 @@ import { jsxs as _jsxs, jsx as _jsx, Fragment as _Fragment } from "react/jsx-run
14
14
  import cx from 'classnames';
15
15
  import { useURLStateBatch } from '@parca/components';
16
16
  import { Query } from '@parca/parser';
17
+ import UtilizationMetricsGraph from '../MetricsGraph/UtilizationMetrics';
18
+ import AreaChart from '../MetricsGraph/UtilizationMetrics/Throughput';
17
19
  import ProfileMetricsGraph, { ProfileMetricsEmptyState } from '../ProfileMetricsGraph';
18
20
  import { useResetStateOnSeriesChange } from '../ProfileView/hooks/useResetStateOnSeriesChange';
19
- export function MetricsGraphSection({ showMetricsGraph, setDisplayHideMetricsGraphButton, heightStyle, querySelection, profileSelection, comparing, sumBy, defaultSumByLoading, queryClient, queryExpressionString, setTimeRangeSelection, selectQuery, setProfileSelection, query, setNewQueryExpression, }) {
21
+ export function MetricsGraphSection({ showMetricsGraph, setDisplayHideMetricsGraphButton, heightStyle, querySelection, profileSelection, comparing, sumBy, defaultSumByLoading, queryClient, queryExpressionString, setTimeRangeSelection, selectQuery, setProfileSelection, query, setNewQueryExpression, utilizationMetrics, utilizationMetricsLoading, onUtilizationSeriesSelect, }) {
20
22
  const resetStateOnSeriesChange = useResetStateOnSeriesChange();
21
23
  const batchUpdates = useURLStateBatch();
22
24
  const handleTimeRangeChange = (range) => {
@@ -80,7 +82,40 @@ export function MetricsGraphSection({ showMetricsGraph, setDisplayHideMetricsGra
80
82
  setProfileSelection(mergeFrom, mergeTo, query);
81
83
  });
82
84
  };
85
+ const UtilizationGraphToShow = ({ utilizationMetrics, }) => {
86
+ const throughputMetrics = utilizationMetrics.filter(metric => metric.name === 'gpu_pcie_throughput_transmit_bytes' ||
87
+ metric.name === 'gpu_pcie_throughput_receive_bytes');
88
+ const transmitData = throughputMetrics.find(metric => metric.name === 'gpu_pcie_throughput_transmit_bytes')
89
+ ?.data ?? [];
90
+ const receiveData = throughputMetrics.find(metric => metric.name === 'gpu_pcie_throughput_receive_bytes')?.data ??
91
+ [];
92
+ if (utilizationMetrics.length === 0) {
93
+ return _jsx(_Fragment, {});
94
+ }
95
+ return (_jsxs("div", { children: [utilizationMetrics.map(({ name, humanReadableName, data }) => {
96
+ if (name !== 'gpu_pcie_throughput_transmit_bytes' &&
97
+ name !== 'gpu_pcie_throughput_receive_bytes') {
98
+ return (_jsx(UtilizationMetricsGraph, { data: data, setTimeRange: handleTimeRangeChange, utilizationMetricsLoading: utilizationMetricsLoading, humanReadableName: humanReadableName, from: querySelection.from, to: querySelection.to, yAxisUnit: "percentage", addLabelMatcher: addLabelMatcher, onSeriesClick: seriesIndex => {
99
+ // For generic UtilizationMetrics, just pass the series index
100
+ if (onUtilizationSeriesSelect != null) {
101
+ onUtilizationSeriesSelect(name, seriesIndex);
102
+ }
103
+ } }, name));
104
+ }
105
+ return null;
106
+ }), throughputMetrics.length > 0 && (_jsx(AreaChart, { transmitData: transmitData, receiveData: receiveData, addLabelMatcher: addLabelMatcher, setTimeRange: handleTimeRangeChange, name: throughputMetrics[0].name, humanReadableName: throughputMetrics[0].humanReadableName, from: querySelection.from, to: querySelection.to, utilizationMetricsLoading: utilizationMetricsLoading, selectedSeries: undefined, onSeriesClick: (_, seriesIndex) => {
107
+ // For throughput metrics, just pass the series index
108
+ if (onUtilizationSeriesSelect != null) {
109
+ let name = 'gpu_pcie_throughput_transmit_bytes';
110
+ if (seriesIndex > transmitData.length - 1) {
111
+ name = 'gpu_pcie_throughput_receive_bytes';
112
+ seriesIndex -= transmitData.length;
113
+ }
114
+ onUtilizationSeriesSelect(name, seriesIndex);
115
+ }
116
+ } }))] }));
117
+ };
83
118
  return (_jsxs("div", { className: cx('relative', { 'py-4': !showMetricsGraph }), children: [setDisplayHideMetricsGraphButton != null ? (_jsxs("button", { onClick: () => setDisplayHideMetricsGraphButton(!showMetricsGraph), className: cx('hidden px-3 py-1 text-sm font-medium text-gray-700 dark:text-gray-200 bg-gray-100 rounded-md hover:bg-gray-200 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-indigo-500 dark:bg-gray-900 z-[5]', showMetricsGraph && 'absolute right-0 bottom-3 !flex', !showMetricsGraph && 'relative !flex ml-auto'), children: [showMetricsGraph ? 'Hide' : 'Show', " Metrics Graph"] })) : null, showMetricsGraph && (_jsx(_Fragment, { children: _jsx("div", { style: { height: heightStyle }, children: (querySelection.expression !== '' || defaultSumByLoading) &&
84
119
  querySelection.from !== undefined &&
85
- querySelection.to !== undefined ? (_jsx(_Fragment, { children: _jsx(ProfileMetricsGraph, { queryClient: queryClient, queryExpression: querySelection.expression, from: querySelection.from, to: querySelection.to, profile: profileSelection, comparing: comparing, sumBy: querySelection.sumBy ?? sumBy ?? [], sumByLoading: defaultSumByLoading, setTimeRange: handleTimeRangeChange, addLabelMatcher: addLabelMatcher, onPointClick: handlePointClick }) })) : (profileSelection === null && (_jsx("div", { className: "p-2", children: _jsx(ProfileMetricsEmptyState, { message: "Please select a profile type and click 'Search' to begin." }) }))) }) }))] }));
120
+ querySelection.to !== undefined ? (_jsx(_Fragment, { children: utilizationMetrics !== undefined ? (_jsx(UtilizationGraphToShow, { utilizationMetrics: utilizationMetrics })) : (_jsx(_Fragment, { children: _jsx(ProfileMetricsGraph, { queryClient: queryClient, queryExpression: querySelection.expression, from: querySelection.from, to: querySelection.to, profile: profileSelection, comparing: comparing, sumBy: querySelection.sumBy ?? sumBy ?? [], sumByLoading: defaultSumByLoading, setTimeRange: handleTimeRangeChange, addLabelMatcher: addLabelMatcher, onPointClick: handlePointClick }) })) })) : (profileSelection === null && (_jsx("div", { className: "p-2", children: _jsx(ProfileMetricsEmptyState, { message: "Please select a profile type and click 'Search' to begin." }) }))) }) }))] }));
86
121
  }
@@ -0,0 +1,43 @@
1
+ import { RpcError } from '@protobuf-ts/runtime-rpc';
2
+ import { type SelectInstance } from 'react-select';
3
+ import { ProfileTypesResponse, QueryServiceClient } from '@parca/client';
4
+ import { DateTimeRange } from '@parca/components';
5
+ import { ProfileType, Query } from '@parca/parser';
6
+ interface QueryControlsProps {
7
+ showProfileTypeSelector: boolean;
8
+ showSumBySelector: boolean;
9
+ disableExplorativeQuerying: boolean;
10
+ profileTypesData?: ProfileTypesResponse;
11
+ profileTypesLoading: boolean;
12
+ selectedProfileName: string;
13
+ setProfileName: (name: string | undefined) => void;
14
+ profileTypesError?: RpcError;
15
+ viewComponent?: {
16
+ disableProfileTypesDropdown?: boolean;
17
+ disableExplorativeQuerying?: boolean;
18
+ labelnames?: string[];
19
+ createViewComponent?: React.ReactNode;
20
+ };
21
+ queryBrowserMode: string;
22
+ setQueryBrowserMode: (mode: string) => void;
23
+ advancedModeForQueryBrowser: boolean;
24
+ setAdvancedModeForQueryBrowser: (mode: boolean) => void;
25
+ setMatchersString: (matchers: string) => void;
26
+ setQueryExpression: (updateTs?: boolean) => void;
27
+ query: Query;
28
+ queryBrowserRef: React.RefObject<HTMLDivElement>;
29
+ timeRangeSelection: DateTimeRange;
30
+ setTimeRangeSelection: (range: DateTimeRange) => void;
31
+ searchDisabled: boolean;
32
+ queryClient: QueryServiceClient;
33
+ labels: string[];
34
+ sumBySelection: string[];
35
+ sumBySelectionLoading: boolean;
36
+ setUserSumBySelection: (sumBy: string[]) => void;
37
+ sumByRef: React.RefObject<SelectInstance>;
38
+ profileType: ProfileType;
39
+ refreshLabelNames: () => Promise<void>;
40
+ }
41
+ export declare function QueryControls({ showProfileTypeSelector, profileTypesData, profileTypesLoading, selectedProfileName, setProfileName, viewComponent, setQueryBrowserMode, advancedModeForQueryBrowser, setAdvancedModeForQueryBrowser, setMatchersString, setQueryExpression, query, queryBrowserRef, timeRangeSelection, setTimeRangeSelection, searchDisabled, queryClient, labels, sumBySelection, sumBySelectionLoading, setUserSumBySelection, sumByRef, profileType, showSumBySelector, profileTypesError, refreshLabelNames, }: QueryControlsProps): JSX.Element;
42
+ export {};
43
+ //# sourceMappingURL=QueryControls.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"QueryControls.d.ts","sourceRoot":"","sources":["../../src/ProfileSelector/QueryControls.tsx"],"names":[],"mappings":"AAgBA,OAAO,EAAC,QAAQ,EAAC,MAAM,0BAA0B,CAAC;AAClD,OAAO,EAAC,KAAK,cAAc,EAAC,MAAM,cAAc,CAAC;AAEjD,OAAO,EAAC,oBAAoB,EAAE,kBA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B,WAAW,EAAE,kBAAkB,CAAC;IAChC,MAAM,EAAE,MAAM,EAAE,CAAC;IACjB,cAAc,EAAE,MAAM,EAAE,CAAC;IACzB,qBAAqB,EAAE,OAAO,CAAC;IAC/B,qBAAqB,EAAE,CAAC,KAAK,EAAE,MAAM,EAAE,KAAK,IAAI,CAAC;IACjD,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAC,cAAc,CAAC,CAAC;IAC1C,WAAW,EAAE,WAAW,CAAC;IACzB,iBAAiB,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC;CACxC;AAED,wBAAgB,aAAa,CAAC,EAC5B,uBAAuB,EACvB,gBAAgB,EAChB,mBAAmB,EACnB,mBAAmB,EACnB,cAAc,EACd,aAAa,EACb,mBAAmB,EACnB,2BAA2B,EAC3B,8BAA8B,EAC9B,iBAAiB,EACjB,kBAAkB,EAClB,KAAK,EACL,eAAe,EACf,kBAAkB,EAClB,qBAAqB,EACrB,cAAc,EACd,WAAW,EACX,MAAM,EACN,cAAc,EACd,qBAAqB,EACrB,qBAAqB,EACrB,QAAQ,EACR,WAAW,EACX,iBAAiB,EACjB,iBAAiB,EACjB,iBAAiB,GAClB,EAAE,kBAAkB,GAAG,GAAG,CAAC,OAAO,CAmMlC"}
@@ -11,29 +11,25 @@ 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 { useRef, useState } from 'react';
14
+ import { useState } from 'react';
15
15
  import { Switch } from '@headlessui/react';
16
16
  import { Button, DateTimeRangePicker, useParcaContext } from '@parca/components';
17
17
  import { TEST_IDS, testId } from '@parca/test-utils';
18
18
  import MatchersInput from '../MatchersInput';
19
19
  import ProfileTypeSelector from '../ProfileTypeSelector';
20
- import { SelectWithRefresh } from '../SelectWithRefresh';
21
- import SimpleMatchers from '../SimpleMatchers/';
20
+ import SelectWithRefresh from '../SelectWithRefresh';
21
+ import SimpleMatchers from '../SimpleMatchers';
22
22
  import ViewMatchers from '../ViewMatchers';
23
- import { useLabelNames } from '../hooks/useLabels';
24
- export function QueryControls({ profileType, timeRangeSelection, setTimeRangeSelection, setQueryExpression, searchDisabled, showProfileTypeSelector = false, showSumBySelector = false, showAdvancedMode = true, profileTypesData, profileTypesLoading = false, selectedProfileName, setProfileName, profileTypesError, viewComponent, setQueryBrowserMode, advancedModeForQueryBrowser = false, setAdvancedModeForQueryBrowser, queryBrowserRef, labels = [], sumBySelection = [], sumBySelectionLoading = false, setUserSumBySelection, sumByRef, queryClient, }) {
23
+ export function QueryControls({ showProfileTypeSelector, profileTypesData, profileTypesLoading, selectedProfileName, setProfileName, viewComponent, setQueryBrowserMode, advancedModeForQueryBrowser, setAdvancedModeForQueryBrowser, setMatchersString, setQueryExpression, query, queryBrowserRef, timeRangeSelection, setTimeRangeSelection, searchDisabled, queryClient, labels, sumBySelection, sumBySelectionLoading, setUserSumBySelection, sumByRef, profileType, showSumBySelector, profileTypesError, refreshLabelNames, }) {
25
24
  const { timezone } = useParcaContext();
26
- const defaultQueryBrowserRef = useRef(null);
27
- const actualQueryBrowserRef = queryBrowserRef ?? defaultQueryBrowserRef;
28
25
  const [searchExecutedTimestamp, setSearchExecutedTimestamp] = useState(0);
29
- const { refetch: refetchLabelNames } = useLabelNames(queryClient, profileType, timeRangeSelection.getFromMs(), timeRangeSelection.getToMs());
30
- return (_jsxs("div", { className: "flex w-full flex-wrap items-start gap-2", ...testId(TEST_IDS.QUERY_CONTROLS_CONTAINER), children: [showProfileTypeSelector && (_jsxs("div", { children: [_jsx("label", { className: "text-xs", ...testId(TEST_IDS.PROFILE_TYPE_LABEL), children: "Profile type" }), _jsx(ProfileTypeSelector, { profileTypesData: profileTypesData, loading: profileTypesLoading, selectedKey: selectedProfileName, onSelection: setProfileName ?? (() => { }), error: profileTypesError, disabled: viewComponent?.disableProfileTypesDropdown })] })), _jsxs("div", { className: "w-full flex-1 flex flex-col gap-1 mt-auto", ref: actualQueryBrowserRef, ...testId(TEST_IDS.QUERY_BROWSER_CONTAINER), children: [_jsxs("div", { className: "flex items-center justify-between", children: [_jsxs("div", { className: "flex items-center gap-3", children: [_jsx("label", { className: "text-xs", ...testId(TEST_IDS.QUERY_LABEL), children: "Query" }), showAdvancedMode && viewComponent?.disableExplorativeQuerying !== true && (_jsxs(_Fragment, { children: [_jsxs(Switch, { checked: advancedModeForQueryBrowser, onChange: () => {
31
- setAdvancedModeForQueryBrowser?.(!advancedModeForQueryBrowser);
32
- setQueryBrowserMode?.(advancedModeForQueryBrowser ? 'simple' : 'advanced');
26
+ return (_jsxs("div", { className: "flex w-full flex-wrap items-start gap-2", ...testId(TEST_IDS.QUERY_CONTROLS_CONTAINER), children: [showProfileTypeSelector && (_jsxs("div", { children: [_jsx("label", { className: "text-xs", ...testId(TEST_IDS.PROFILE_TYPE_LABEL), children: "Profile type" }), _jsx(ProfileTypeSelector, { profileTypesData: profileTypesData, loading: profileTypesLoading, selectedKey: selectedProfileName, onSelection: setProfileName, error: profileTypesError, disabled: viewComponent?.disableProfileTypesDropdown })] })), _jsxs("div", { className: "w-full flex-1 flex flex-col gap-1 mt-auto", ref: queryBrowserRef, ...testId(TEST_IDS.QUERY_BROWSER_CONTAINER), children: [_jsxs("div", { className: "flex items-center justify-between", children: [_jsxs("div", { className: "flex items-center gap-3", children: [_jsx("label", { className: "text-xs", ...testId(TEST_IDS.QUERY_LABEL), children: "Query" }), viewComponent?.disableExplorativeQuerying !== true && (_jsxs(_Fragment, { children: [_jsxs(Switch, { checked: advancedModeForQueryBrowser, onChange: () => {
27
+ setAdvancedModeForQueryBrowser(!advancedModeForQueryBrowser);
28
+ setQueryBrowserMode(advancedModeForQueryBrowser ? 'simple' : 'advanced');
33
29
  }, className: `${advancedModeForQueryBrowser ? 'bg-indigo-600' : 'bg-gray-400 dark:bg-gray-800'} relative inline-flex h-[20px] w-[44px] shrink-0 cursor-pointer rounded-full border-2 border-transparent transition-colors duration-200 ease-in-out focus:outline-none focus-visible:ring-2 focus-visible:ring-white/75`, ...testId(TEST_IDS.ADVANCED_MODE_SWITCH), children: [_jsx("span", { className: "sr-only", children: "Use setting" }), _jsx("span", { "aria-hidden": "true", className: `${advancedModeForQueryBrowser ? 'translate-x-6' : 'translate-x-0'} pointer-events-none inline-block h-[16px] w-[16px] transform rounded-full bg-white shadow-lg ring-0 transition duration-200 ease-in-out` })] }), _jsx("label", { className: "text-xs", ...testId(TEST_IDS.QUERY_MODE_LABEL), children: "Advanced Mode" })] }))] }), viewComponent?.createViewComponent] }), viewComponent?.disableExplorativeQuerying === true &&
34
30
  viewComponent?.labelnames !== undefined &&
35
- viewComponent?.labelnames.length >= 1 ? (_jsx(ViewMatchers, { labelNames: viewComponent.labelnames })) : showAdvancedMode && advancedModeForQueryBrowser ? (_jsx(MatchersInput, {})) : (_jsx(SimpleMatchers, { queryBrowserRef: actualQueryBrowserRef, searchExecutedTimestamp: searchExecutedTimestamp }))] }), showSumBySelector && (_jsxs("div", { ...testId(TEST_IDS.SUM_BY_CONTAINER), children: [_jsx("div", { className: "mb-0.5 mt-1.5 flex items-center justify-between", children: _jsx("label", { className: "text-xs", ...testId(TEST_IDS.SUM_BY_LABEL), children: "Sum by" }) }), _jsx(SelectWithRefresh, { id: "h-sum-by-selector", "data-testid": testId(TEST_IDS.SUM_BY_SELECT)['data-testid'], defaultValue: [], isMulti: true, isClearable: false, name: "colors", options: labels.map(label => ({ label, value: label })), className: "parca-select-container text-sm w-full max-w-80", classNamePrefix: "parca-select", value: sumBySelection.map(sumBy => ({ label: sumBy, value: sumBy })), onChange: newValue => {
36
- setUserSumBySelection?.(newValue.map(option => option.value));
31
+ viewComponent?.labelnames.length >= 1 ? (_jsx(ViewMatchers, { labelNames: viewComponent.labelnames, setMatchersString: setMatchersString, profileType: selectedProfileName, runQuery: setQueryExpression, currentQuery: query, queryClient: queryClient, start: timeRangeSelection.getFromMs(), end: timeRangeSelection.getToMs() })) : advancedModeForQueryBrowser ? (_jsx(MatchersInput, { setMatchersString: setMatchersString, runQuery: setQueryExpression, currentQuery: query, profileType: selectedProfileName, queryClient: queryClient, start: timeRangeSelection.getFromMs(), end: timeRangeSelection.getToMs() })) : (_jsx(SimpleMatchers, { setMatchersString: setMatchersString, runQuery: setQueryExpression, currentQuery: query, profileType: selectedProfileName, queryBrowserRef: queryBrowserRef, queryClient: queryClient, start: timeRangeSelection.getFromMs(), end: timeRangeSelection.getToMs(), searchExecutedTimestamp: searchExecutedTimestamp }))] }), showSumBySelector && (_jsxs("div", { ...testId(TEST_IDS.SUM_BY_CONTAINER), children: [_jsx("div", { className: "mb-0.5 mt-1.5 flex items-center justify-between", children: _jsx("label", { className: "text-xs", ...testId(TEST_IDS.SUM_BY_LABEL), children: "Sum by" }) }), _jsx(SelectWithRefresh, { id: "h-sum-by-selector", "data-testid": testId(TEST_IDS.SUM_BY_SELECT)['data-testid'], defaultValue: [], isMulti: true, isClearable: false, name: "colors", options: labels.map(label => ({ label, value: label })), className: "parca-select-container text-sm w-full max-w-80", classNamePrefix: "parca-select", value: (sumBySelection ?? []).map(sumBy => ({ label: sumBy, value: sumBy })), onChange: newValue => {
32
+ setUserSumBySelection(newValue.map(option => option.value));
37
33
  }, placeholder: "Labels...", styles: {
38
34
  indicatorSeparator: () => ({ display: 'none' }),
39
35
  menu: provided => ({
@@ -45,10 +41,11 @@ export function QueryControls({ profileType, timeRangeSelection, setTimeRangeSel
45
41
  minWidth: '320px',
46
42
  position: 'absolute',
47
43
  }),
48
- }, isLoading: sumBySelectionLoading, isDisabled: !profileType?.delta,
44
+ // menu: provided => ({...provided, width: 'max-content', zIndex: 50}), // Setting the same zIndex as drop down menus
45
+ }, isLoading: sumBySelectionLoading, isDisabled: !profileType.delta,
49
46
  // @ts-expect-error
50
47
  ref: sumByRef, onKeyDown: e => {
51
- const currentRef = sumByRef?.current;
48
+ const currentRef = sumByRef.current;
52
49
  if (currentRef == null) {
53
50
  return;
54
51
  }
@@ -63,7 +60,7 @@ export function QueryControls({ profileType, timeRangeSelection, setTimeRangeSel
63
60
  setQueryExpression(true);
64
61
  currentRef.blur();
65
62
  }
66
- }, onRefresh: refetchLabelNames, refreshTitle: "Refresh label names", refreshTestId: "sum-by-refresh-button", menuTestId: TEST_IDS.SUM_BY_SELECT_FLYOUT })] })), _jsx(DateTimeRangePicker, { onRangeSelection: setTimeRangeSelection, range: timeRangeSelection, timezone: timezone, ...testId(TEST_IDS.DATE_TIME_RANGE_PICKER) }), _jsxs("div", { children: [_jsx("label", { className: "text-xs", ...testId(TEST_IDS.SEARCH_BUTTON_LABEL), children: "\u00A0" }), _jsx(Button, { disabled: searchDisabled, onClick: (e) => {
63
+ }, onRefresh: refreshLabelNames, refreshTitle: "Refresh label names", refreshTestId: "sum-by-refresh-button", menuTestId: TEST_IDS.SUM_BY_SELECT_FLYOUT })] })), _jsx(DateTimeRangePicker, { onRangeSelection: setTimeRangeSelection, range: timeRangeSelection, timezone: timezone, ...testId(TEST_IDS.DATE_TIME_RANGE_PICKER) }), _jsxs("div", { children: [_jsx("label", { className: "text-xs", ...testId(TEST_IDS.SEARCH_BUTTON_LABEL), children: "\u00A0" }), _jsx(Button, { disabled: searchDisabled, onClick: (e) => {
67
64
  e.preventDefault();
68
65
  setSearchExecutedTimestamp(Date.now());
69
66
  setQueryExpression(true);
@@ -15,8 +15,28 @@ interface ProfileSelectorFeatures {
15
15
  showMetricsGraph: boolean;
16
16
  showSumBySelector?: boolean;
17
17
  showProfileTypeSelector?: boolean;
18
+ disableExplorativeQuerying?: boolean;
18
19
  disableProfileTypesDropdown?: boolean;
19
20
  }
21
+ export interface UtilizationMetrics {
22
+ isSelected: boolean;
23
+ labelset: {
24
+ labels: Array<{
25
+ name: string;
26
+ value: string;
27
+ }>;
28
+ };
29
+ samples: Array<{
30
+ timestamp: number;
31
+ value: number;
32
+ }>;
33
+ }
34
+ export interface UtilizationLabels {
35
+ utilizationLabelNames?: string[];
36
+ utilizationFetchLabelValues?: (key: string) => Promise<string[]>;
37
+ utilizationLabelValues?: string[];
38
+ utilizationLabelNamesLoading?: boolean;
39
+ }
20
40
  interface ProfileSelectorProps extends ProfileSelectorFeatures {
21
41
  queryClient: QueryServiceClient;
22
42
  closeProfile: () => void;
@@ -25,6 +45,14 @@ interface ProfileSelectorProps extends ProfileSelectorFeatures {
25
45
  navigateTo: NavigateFunction;
26
46
  setDisplayHideMetricsGraphButton?: Dispatch<SetStateAction<boolean>>;
27
47
  suffix?: '_a' | '_b';
48
+ utilizationMetrics?: Array<{
49
+ name: string;
50
+ humanReadableName: string;
51
+ data: UtilizationMetrics[];
52
+ }>;
53
+ utilizationMetricsLoading?: boolean;
54
+ utilizationLabels?: UtilizationLabels;
55
+ onUtilizationSeriesSelect?: (name: string, seriesIndex: number) => void;
28
56
  onSearchHook?: () => void;
29
57
  }
30
58
  export interface IProfileTypesResult {
@@ -33,6 +61,6 @@ export interface IProfileTypesResult {
33
61
  error?: RpcError;
34
62
  }
35
63
  export declare const useProfileTypes: (client: QueryServiceClient, start?: number, end?: number) => IProfileTypesResult;
36
- declare const ProfileSelector: ({ queryClient, closeProfile, enforcedProfileName, comparing, navigateTo, showMetricsGraph, showSumBySelector, showProfileTypeSelector, setDisplayHideMetricsGraphButton, suffix, onSearchHook, }: ProfileSelectorProps) => JSX.Element;
64
+ declare const ProfileSelector: ({ queryClient, closeProfile, enforcedProfileName, comparing, navigateTo, showMetricsGraph, showSumBySelector, showProfileTypeSelector, disableExplorativeQuerying, setDisplayHideMetricsGraphButton, suffix, utilizationMetrics, utilizationMetricsLoading, utilizationLabels, onUtilizationSeriesSelect, onSearchHook, }: ProfileSelectorProps) => JSX.Element;
37
65
  export default ProfileSelector;
38
66
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/ProfileSelector/index.tsx"],"names":[],"mappings":"AAaA,OAAO,EAAC,QAAQ,EAAE,cAAc,E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TAiBtB,oBAAoB,KAAG,GAAG,CAAC,OA8N7B,CAAC;AAEF,eAAe,eAAe,CAAC"}
@@ -17,14 +17,13 @@ import { CloseIcon } from '@parca/icons';
17
17
  import { Query } from '@parca/parser';
18
18
  import { TEST_IDS, testId } from '@parca/test-utils';
19
19
  import { millisToProtoTimestamp } from '@parca/utilities';
20
+ import { useLabelNames } from '../MatchersInput/index';
20
21
  import { useMetricsGraphDimensions } from '../MetricsGraph/useMetricsGraphDimensions';
21
- import { QueryControls } from '../QueryControls';
22
- import { LabelsQueryProvider, useLabelsQueryProvider } from '../contexts/LabelsQueryProvider';
23
- import { UnifiedLabelsProvider } from '../contexts/UnifiedLabelsContext';
24
- import { useLabelNames } from '../hooks/useLabels';
22
+ import { UtilizationLabelsProvider } from '../contexts/UtilizationLabelsContext';
25
23
  import { useQueryState } from '../hooks/useQueryState';
26
24
  import useGrpcQuery from '../useGrpcQuery';
27
25
  import { MetricsGraphSection } from './MetricsGraphSection';
26
+ import { QueryControls } from './QueryControls';
28
27
  import { useAutoQuerySelector } from './useAutoQuerySelector';
29
28
  export const useProfileTypes = (client, start, end) => {
30
29
  const metadata = useGrpcMetadata();
@@ -46,8 +45,8 @@ export const useProfileTypes = (client, start, end) => {
46
45
  });
47
46
  return { loading: isLoading, data, error: error };
48
47
  };
49
- const ProfileSelector = ({ queryClient, closeProfile, enforcedProfileName, comparing, navigateTo, showMetricsGraph = true, showSumBySelector = true, showProfileTypeSelector = true, setDisplayHideMetricsGraphButton, suffix, onSearchHook, }) => {
50
- const { heightStyle } = useMetricsGraphDimensions(comparing, false);
48
+ const ProfileSelector = ({ queryClient, closeProfile, enforcedProfileName, comparing, navigateTo, showMetricsGraph = true, showSumBySelector = true, showProfileTypeSelector = true, disableExplorativeQuerying = false, setDisplayHideMetricsGraphButton, suffix, utilizationMetrics, utilizationMetricsLoading, utilizationLabels, onUtilizationSeriesSelect, onSearchHook, }) => {
49
+ const { heightStyle } = useMetricsGraphDimensions(comparing, utilizationMetrics != null);
51
50
  const { viewComponent } = useParcaContext();
52
51
  const [queryBrowserMode, setQueryBrowserMode] = useURLState('query_browser_mode');
53
52
  const batchUpdates = useURLStateBatch();
@@ -68,7 +67,7 @@ const ProfileSelector = ({ queryClient, closeProfile, enforcedProfileName, compa
68
67
  const from = timeRangeSelection.getFromMs();
69
68
  const to = timeRangeSelection.getToMs();
70
69
  const { loading: profileTypesLoading, data: profileTypesData, error, } = useProfileTypes(queryClient, from, to);
71
- const { result } = useLabelNames(queryClient, profileType.toString(), from, to);
70
+ const { result, refetch } = useLabelNames(queryClient, profileType.toString(), from, to);
72
71
  const labels = useMemo(() => {
73
72
  return result.response?.labelNames === undefined ? [] : result.response.labelNames;
74
73
  }, [result]);
@@ -149,10 +148,8 @@ const ProfileSelector = ({ queryClient, closeProfile, enforcedProfileName, compa
149
148
  queryExpressionString === '{}';
150
149
  const queryBrowserRef = useRef(null);
151
150
  const sumByRef = useRef(null);
152
- return (_jsxs(_Fragment, { children: [_jsxs("div", { className: "mb-2 flex", children: [_jsx(LabelsQueryProvider, { setMatchersString: setMatchersString, runQuery: setQueryExpression, currentQuery: query, profileType: selectedProfileName ?? profileType.toString(), queryClient: queryClient, start: timeRangeSelection.getFromMs(), end: timeRangeSelection.getToMs(), suffix: suffix, children: _jsx(LabelsSource, { children: _jsx(QueryControls, { showProfileTypeSelector: showProfileTypeSelector, showSumBySelector: showSumBySelector, profileTypesData: profileTypesData, profileTypesLoading: profileTypesLoading, selectedProfileName: selectedProfileName, setProfileName: setProfileName, setMatchersString: setMatchersString, setQueryExpression: setQueryExpression, query: query, queryBrowserRef: queryBrowserRef, timeRangeSelection: timeRangeSelection, setTimeRangeSelection: handleTimeRangeChange, searchDisabled: searchDisabled, setQueryBrowserMode: setQueryBrowserMode, advancedModeForQueryBrowser: advancedModeForQueryBrowser, setAdvancedModeForQueryBrowser: setAdvancedModeForQueryBrowser, queryClient: queryClient, sumByRef: sumByRef, labels: labels, sumBySelection: draftSelection.sumBy ?? [], sumBySelectionLoading: sumByLoading, setUserSumBySelection: setDraftSumBy, profileType: profileType, profileTypesError: error, viewComponent: viewComponent }) }) }), comparing && (_jsx("div", { children: _jsx(IconButton, { onClick: () => closeProfile(), icon: _jsx(CloseIcon, {}), ...testId(TEST_IDS.COMPARE_CLOSE_BUTTON) }) }))] }), _jsx(MetricsGraphSection, { showMetricsGraph: showMetricsGraph, setDisplayHideMetricsGraphButton: setDisplayHideMetricsGraphButton, heightStyle: heightStyle, querySelection: querySelection, profileSelection: profileSelection, comparing: comparing, sumBy: querySelection.sumBy ?? [], defaultSumByLoading: sumByLoading, queryClient: queryClient, queryExpressionString: queryExpressionString, setTimeRangeSelection: handleTimeRangeChange, selectQuery: commitDraft, setProfileSelection: setProfileSelection, query: query, setQueryExpression: setQueryExpression, setNewQueryExpression: setDraftExpression })] }));
151
+ return (_jsx(UtilizationLabelsProvider, { value: { ...utilizationLabels }, children: _jsxs(_Fragment, { children: [_jsxs("div", { className: "mb-2 flex", children: [_jsx(QueryControls, { showProfileTypeSelector: showProfileTypeSelector, showSumBySelector: showSumBySelector, disableExplorativeQuerying: disableExplorativeQuerying, profileTypesData: profileTypesData, profileTypesLoading: profileTypesLoading, selectedProfileName: selectedProfileName, setProfileName: setProfileName, setMatchersString: setMatchersString, setQueryExpression: setQueryExpression, query: query, queryBrowserRef: queryBrowserRef, timeRangeSelection: timeRangeSelection, setTimeRangeSelection: handleTimeRangeChange, searchDisabled: searchDisabled, queryBrowserMode: queryBrowserMode, setQueryBrowserMode: setQueryBrowserMode, advancedModeForQueryBrowser: advancedModeForQueryBrowser, setAdvancedModeForQueryBrowser: setAdvancedModeForQueryBrowser, queryClient: queryClient, sumByRef: sumByRef, labels: labels, sumBySelection: draftSelection.sumBy ?? [], sumBySelectionLoading: sumByLoading, setUserSumBySelection: setDraftSumBy, profileType: profileType, profileTypesError: error, viewComponent: viewComponent, refreshLabelNames: refetch }), comparing && (_jsx("div", { children: _jsx(IconButton, { onClick: () => closeProfile(), icon: _jsx(CloseIcon, {}), ...testId(TEST_IDS.COMPARE_CLOSE_BUTTON) }) }))] }), _jsx(MetricsGraphSection, { showMetricsGraph: showMetricsGraph, setDisplayHideMetricsGraphButton: setDisplayHideMetricsGraphButton, heightStyle: utilizationMetrics !== undefined && utilizationMetrics?.length > 0
152
+ ? 'auto'
153
+ : heightStyle, querySelection: querySelection, profileSelection: profileSelection, comparing: comparing, sumBy: querySelection.sumBy ?? [], defaultSumByLoading: sumByLoading, queryClient: queryClient, queryExpressionString: queryExpressionString, setTimeRangeSelection: handleTimeRangeChange, selectQuery: commitDraft, setProfileSelection: setProfileSelection, query: query, setQueryExpression: setQueryExpression, setNewQueryExpression: setDraftExpression, utilizationMetrics: utilizationMetrics, utilizationMetricsLoading: utilizationMetricsLoading, onUtilizationSeriesSelect: onUtilizationSeriesSelect })] }) }));
153
154
  };
154
155
  export default ProfileSelector;
155
- const LabelsSource = ({ children }) => {
156
- const { labelNames, labelValues, isLabelNamesLoading, isLabelValuesLoading, refetchLabelValues, refetchLabelNames, currentLabelName, setCurrentLabelName, suffix, } = useLabelsQueryProvider();
157
- return (_jsx(UnifiedLabelsProvider, { labelNames: labelNames, labelValues: labelValues, isLabelNamesLoading: isLabelNamesLoading, isLabelValuesLoading: isLabelValuesLoading, refetchLabelValues: refetchLabelValues, refetchLabelNames: refetchLabelNames, currentLabelName: currentLabelName, setCurrentLabelName: setCurrentLabelName, suffix: suffix, children: children }));
158
- };
@@ -179,7 +179,7 @@ const CustomSelect = ({ items: itemsProp, selectedKey, onSelection, placeholder
179
179
  setIsOpen(false);
180
180
  }, children: "Add" }) }))] })) : (_jsx("input", { ref: searchInputRef, type: "text", className: "w-full px-4 h-[45px] text-sm border-none rounded-none ring-0 outline-none bg-gray-50 dark:bg-gray-800 dark:text-white", placeholder: "Search...", value: searchTerm, onChange: e => setSearchTerm(e.target.value) })) }) })), _jsx("div", { className: "flex-1 min-h-0", children: loading === true ? (_jsx("div", { className: "w-[270px]", children: loader })) : groupedFilteredItems.length === 0 ? (_jsx("div", { className: "px-4 py-3 text-sm text-gray-500 dark:text-gray-400 text-center", ...testId(TEST_IDS.LABEL_VALUE_NO_RESULTS), children: "No values found" })) : (groupedFilteredItems.map(group => (_jsxs(_Fragment, { children: [groupedFilteredItems.length > 1 &&
181
181
  groupedFilteredItems.every(g => g.type !== '') &&
182
- group.type !== '' ? (_jsx("div", { className: "pl-2", children: _jsx(DividerWithLabel, { label: group.type }) })) : null, group.values.map((item, index) => (_jsx(OptionItem, { item: item, index: index, optionRefs: optionRefs, focusedIndex: focusedIndex, selectedKey: selectedKey, handleSelection: handleSelection }, item.key)))] })))) }), refetchValues !== undefined && loading !== true && (_jsx(RefreshButton, { onClick: () => void handleRefetch(), disabled: isRefetching, title: "Refresh results", testId: TEST_IDS.LABEL_VALUE_REFRESH_BUTTON, sticky: true, loading: isRefetching }))] }) }))] }));
182
+ group.type !== '' ? (_jsx("div", { className: "pl-2", children: _jsx(DividerWithLabel, { label: group.type }) })) : null, group.values.map((item, index) => (_jsx(OptionItem, { item: item, index: index, optionRefs: optionRefs, focusedIndex: focusedIndex, selectedKey: selectedKey, handleSelection: handleSelection }, item.key)))] })))) }), refetchValues !== undefined && loading !== true && (_jsx(RefreshButton, { onClick: () => void handleRefetch(), disabled: isRefetching, title: "Refresh label values", testId: TEST_IDS.LABEL_VALUE_REFRESH_BUTTON, sticky: true, loading: isRefetching }))] }) }))] }));
183
183
  };
184
184
  const OptionItem = ({ item, optionRefs, index, focusedIndex, selectedKey, handleSelection, }) => {
185
185
  return (_jsxs("div", { ref: el => {
@@ -1,9 +1,18 @@
1
+ import { QueryServiceClient } from '@parca/client';
2
+ import { Query } from '@parca/parser';
1
3
  import { type SelectItem } from './Select';
2
4
  interface Props {
5
+ queryClient: QueryServiceClient;
6
+ setMatchersString: (arg: string) => void;
7
+ runQuery: () => void;
8
+ currentQuery: Query;
9
+ profileType: string;
3
10
  queryBrowserRef: React.RefObject<HTMLDivElement>;
11
+ start?: number;
12
+ end?: number;
4
13
  searchExecutedTimestamp?: number;
5
14
  }
6
15
  export declare const transformLabelsForSelect: (labelNames: string[]) => SelectItem[];
7
- declare const SimpleMatchers: ({ queryBrowserRef, searchExecutedTimestamp, }: Props) => JSX.Element;
8
- export default SimpleMatchers;
16
+ export default function SimpleMathersWithProvider(props: Props): JSX.Element;
17
+ export {};
9
18
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/SimpleMatchers/index.tsx"],"names":[],"mappings":"AA0BA,OAAe,EAAC,KAAK,UAAU,EAAC,MAAM,UAAU,CAAC;AAEjD,UAAU,KAAK;IACb,eAAe,EAAE,KAAK,CAAC,SAAS,CAAC,cAAc,CAAC,CAAC;IACjD,uBAAuB,CAAC,EAAE,MAAM,CAAC;CAClC;AAUD,eAAO,MAAM,wBAAwB,GAAI,YAAY,MAAM,EAAE,KAAG,UAAU,EAQzE,CAAC;AAiDF,QAAA,MAAM,cAAc,GAAI,+CAIrB,KAAK,KAAG,GAAG,CAAC,OAyZd,CAAC;AAEF,eAAe,cAAc,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/SimpleMatchers/index.tsx"],"names":[],"mappings":"AAmBA,OAAO,EAAC,kBAAkB,EAAC,MAAM,eAAe,CAAC;AAEjD,OAAO,EAAC,KAAK,EAAC,MAAM,eAAe,CAAC;AAMpC,OAAe,EAAC,KAAK,UAAU,EAAC,MAAM,UAAU,CAAC;AAEjD,UAAU,KAAK;IACb,WAAW,EAAE,kBAAkB,CAAC;IAChC,iBAAiB,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,IAAI,CAAC;IACzC,QAAQ,EAAE,MAAM,IAAI,CAAC;IACrB,YAAY,EAAE,KAAK,CAAC;IACpB,WAAW,EAAE,MAAM,CAAC;IACpB,eAAe,EAAE,KAAK,CAAC,SAAS,CAAC,cAAc,CAAC,CAAC;IACjD,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,uBAAuB,CAAC,EAAE,MAAM,CAAC;CAClC;AAoBD,eAAO,MAAM,wBAAwB,GAAI,YAAY,MAAM,EAAE,KAAG,UAAU,EAQzE,CAAC;AAidF,MAAM,CAAC,OAAO,UAAU,yBAAyB,CAAC,KAAK,EAAE,KAAK,GAAG,GAAG,CAAC,OAAO,CAoB3E"}