@parca/profile 0.16.448 → 0.16.450
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.
- package/CHANGELOG.md +8 -0
- package/dist/MetricsGraphStrips/AreaGraph/index.d.ts +1 -1
- package/dist/MetricsGraphStrips/AreaGraph/index.d.ts.map +1 -1
- package/dist/MetricsGraphStrips/MetricsGraphStrips.stories.d.ts +2 -1
- package/dist/MetricsGraphStrips/MetricsGraphStrips.stories.d.ts.map +1 -1
- package/dist/MetricsGraphStrips/MetricsGraphStrips.stories.js +8 -1
- package/dist/MetricsGraphStrips/index.d.ts +2 -1
- package/dist/MetricsGraphStrips/index.d.ts.map +1 -1
- package/dist/MetricsGraphStrips/index.js +13 -3
- package/dist/ProfileIcicleGraph/IcicleGraphArrow/index.js +1 -1
- package/dist/ProfileSelector/MetricsGraphSection.d.ts +26 -0
- package/dist/ProfileSelector/MetricsGraphSection.d.ts.map +1 -0
- package/dist/ProfileSelector/MetricsGraphSection.js +80 -0
- package/dist/ProfileSelector/QueryControls.d.ts +41 -0
- package/dist/ProfileSelector/QueryControls.d.ts.map +1 -0
- package/dist/ProfileSelector/QueryControls.js +54 -0
- package/dist/ProfileSelector/index.d.ts +10 -4
- package/dist/ProfileSelector/index.d.ts.map +1 -1
- package/dist/ProfileSelector/index.js +7 -111
- package/dist/TimelineGuide/index.d.ts +11 -0
- package/dist/TimelineGuide/index.d.ts.map +1 -0
- package/dist/{MetricsGraphStrips/TimelineGuide → TimelineGuide}/index.js +3 -13
- package/dist/styles.css +1 -1
- package/dist/utils.d.ts +1 -0
- package/dist/utils.d.ts.map +1 -1
- package/package.json +2 -2
- package/src/MetricsGraphStrips/AreaGraph/index.tsx +2 -2
- package/src/MetricsGraphStrips/MetricsGraphStrips.stories.tsx +11 -2
- package/src/MetricsGraphStrips/index.tsx +16 -4
- package/src/ProfileIcicleGraph/IcicleGraphArrow/index.tsx +1 -1
- package/src/ProfileSelector/MetricsGraphSection.tsx +172 -0
- package/src/ProfileSelector/QueryControls.tsx +233 -0
- package/src/ProfileSelector/index.tsx +70 -282
- package/src/{MetricsGraphStrips/TimelineGuide → TimelineGuide}/index.tsx +7 -17
- package/src/utils.ts +2 -0
- package/dist/MetricsGraphStrips/TimelineGuide/index.d.ts +0 -10
- package/dist/MetricsGraphStrips/TimelineGuide/index.d.ts.map +0 -1
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,14 @@
|
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
4
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
5
|
|
|
6
|
+
## [0.16.450](https://github.com/parca-dev/parca/compare/@parca/profile@0.16.449...@parca/profile@0.16.450) (2024-11-28)
|
|
7
|
+
|
|
8
|
+
**Note:** Version bump only for package @parca/profile
|
|
9
|
+
|
|
10
|
+
## [0.16.449](https://github.com/parca-dev/parca/compare/@parca/profile@0.16.444...@parca/profile@0.16.449) (2024-11-26)
|
|
11
|
+
|
|
12
|
+
**Note:** Version bump only for package @parca/profile
|
|
13
|
+
|
|
6
14
|
## [0.16.448](https://github.com/parca-dev/parca/compare/@parca/profile@0.16.447...@parca/profile@0.16.448) (2024-11-21)
|
|
7
15
|
|
|
8
16
|
**Note:** Version bump only for package @parca/profile
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/MetricsGraphStrips/AreaGraph/index.tsx"],"names":[],"mappings":"AAmBA,MAAM,WAAW,SAAS;IACxB,SAAS,EAAE,MAAM,CAAC;IAClB,KAAK,EAAE,MAAM,CAAC;CACf;AAED,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/MetricsGraphStrips/AreaGraph/index.tsx"],"names":[],"mappings":"AAmBA,OAAO,EAAC,SAAS,EAAC,MAAM,aAAa,CAAC;AAEtC,MAAM,WAAW,SAAS;IACxB,SAAS,EAAE,MAAM,CAAC;IAClB,KAAK,EAAE,MAAM,CAAC;CACf;AAED,UAAU,KAAK;IACb,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;IACf,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,IAAI,EAAE,SAAS,EAAE,CAAC;IAClB,eAAe,CAAC,EAAE,SAAS,GAAG,SAAS,CAAC;IACxC,kBAAkB,EAAE,CAAC,SAAS,EAAE,SAAS,GAAG,SAAS,KAAK,IAAI,CAAC;CAChE;AA8JD,eAAO,MAAM,SAAS,0HAWnB,KAAK,KAAG,GAAG,CAAC,OAkHd,CAAC"}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { Meta } from '@storybook/react';
|
|
2
|
-
import {
|
|
2
|
+
import { NumberDuo } from '../utils';
|
|
3
|
+
import { DataPoint } from './AreaGraph';
|
|
3
4
|
declare const meta: Meta;
|
|
4
5
|
export default meta;
|
|
5
6
|
export declare const ThreeCPUStrips: {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MetricsGraphStrips.stories.d.ts","sourceRoot":"","sources":["../../src/MetricsGraphStrips/MetricsGraphStrips.stories.tsx"],"names":[],"mappings":"AAgBA,OAAO,EAAC,IAAI,EAAC,MAAM,kBAAkB,CAAC;AAEtC,OAAO,EAAC,SAAS,
|
|
1
|
+
{"version":3,"file":"MetricsGraphStrips.stories.d.ts","sourceRoot":"","sources":["../../src/MetricsGraphStrips/MetricsGraphStrips.stories.tsx"],"names":[],"mappings":"AAgBA,OAAO,EAAC,IAAI,EAAC,MAAM,kBAAkB,CAAC;AAEtC,OAAO,EAAC,SAAS,EAAC,MAAM,UAAU,CAAC;AACnC,OAAO,EAAC,SAAS,EAAC,MAAM,aAAa,CAAC;AAqBtC,QAAA,MAAM,IAAI,EAAE,IAGX,CAAC;AACF,eAAe,IAAI,CAAC;AAEpB,eAAO,MAAM,cAAc;;;;;;;;oCAKK,MAAM,UAAU,SAAS,KAAG,IAAI;;mBAI7B,GAAG,KAAG,GAAG,CAAC,OAAO;CAUnD,CAAC"}
|
|
@@ -14,12 +14,19 @@ import { jsx as _jsx } from "react/jsx-runtime";
|
|
|
14
14
|
// eslint-disable-next-line import/named
|
|
15
15
|
import { useArgs } from '@storybook/preview-api';
|
|
16
16
|
import { MetricsGraphStrips } from './index';
|
|
17
|
+
function seededRandom(seed) {
|
|
18
|
+
return () => {
|
|
19
|
+
seed = (seed * 16807) % 2147483647;
|
|
20
|
+
return (seed - 1) / 2147483646;
|
|
21
|
+
};
|
|
22
|
+
}
|
|
17
23
|
const mockData = [[], [], []];
|
|
24
|
+
const random = seededRandom(42);
|
|
18
25
|
for (let i = 0; i < 200; i++) {
|
|
19
26
|
for (let j = 0; j < mockData.length; j++) {
|
|
20
27
|
mockData[j].push({
|
|
21
28
|
timestamp: 1731326092000 + i * 100,
|
|
22
|
-
value: Math.floor(
|
|
29
|
+
value: Math.floor(random() * 100),
|
|
23
30
|
});
|
|
24
31
|
}
|
|
25
32
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/MetricsGraphStrips/index.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/MetricsGraphStrips/index.tsx"],"names":[],"mappings":"AAmBA,OAAO,EAAC,SAAS,EAAC,MAAM,UAAU,CAAC;AACnC,OAAO,EAAY,SAAS,EAAC,MAAM,aAAa,CAAC;AAEjD,UAAU,KAAK;IACb,IAAI,EAAE,MAAM,EAAE,CAAC;IACf,IAAI,EAAE,SAAS,EAAE,EAAE,CAAC;IACpB,gBAAgB,CAAC,EAAE;QACjB,KAAK,EAAE,MAAM,CAAC;QACd,MAAM,EAAE,SAAS,CAAC;KACnB,CAAC;IACF,kBAAkB,EAAE,CAAC,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,SAAS,GAAG,SAAS,KAAK,IAAI,CAAC;CAC5E;AAMD,eAAO,MAAM,kBAAkB,0DAK5B,KAAK,KAAG,GAAG,CAAC,OA+Dd,CAAC"}
|
|
@@ -11,11 +11,11 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
|
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 { useState } from 'react';
|
|
14
|
+
import { useMemo, useState } from 'react';
|
|
15
15
|
import { Icon } from '@iconify/react';
|
|
16
16
|
import * as d3 from 'd3';
|
|
17
|
+
import { TimelineGuide } from '../TimelineGuide';
|
|
17
18
|
import { AreaGraph } from './AreaGraph';
|
|
18
|
-
import { TimelineGuide } from './TimelineGuide';
|
|
19
19
|
const getTimelineGuideHeight = (cpus, collapsedIndices) => {
|
|
20
20
|
return 56 * (cpus.length - collapsedIndices.length) + 20 * collapsedIndices.length + 24;
|
|
21
21
|
};
|
|
@@ -23,7 +23,17 @@ export const MetricsGraphStrips = ({ cpus, data, selectedTimeline, onSelectedTim
|
|
|
23
23
|
const [collapsedIndices, setCollapsedIndices] = useState([]);
|
|
24
24
|
// @ts-expect-error
|
|
25
25
|
const color = d3.scaleOrdinal(d3.schemeObservable10);
|
|
26
|
-
|
|
26
|
+
const bounds = useMemo(() => {
|
|
27
|
+
const bounds = [Infinity, -Infinity];
|
|
28
|
+
data.forEach(cpuData => {
|
|
29
|
+
cpuData.forEach(dataPoint => {
|
|
30
|
+
bounds[0] = Math.min(bounds[0], dataPoint.timestamp);
|
|
31
|
+
bounds[1] = Math.max(bounds[1], dataPoint.timestamp);
|
|
32
|
+
});
|
|
33
|
+
});
|
|
34
|
+
return [0, bounds[1] - bounds[0]];
|
|
35
|
+
}, [data]);
|
|
36
|
+
return (_jsxs("div", { className: "flex flex-col gap-1 relative", children: [_jsx(TimelineGuide, { bounds: bounds, width: 1468, height: getTimelineGuideHeight(cpus, collapsedIndices), margin: 1 }), cpus.map((cpu, i) => {
|
|
27
37
|
const isCollapsed = collapsedIndices.includes(i);
|
|
28
38
|
return (_jsxs("div", { className: "relative min-h-5", children: [_jsxs("div", { className: "text-xs absolute top-0 left-0 flex gap-[2px] items-center bg-white/50 px-1 rounded-sm cursor-pointer z-30", onClick: () => {
|
|
29
39
|
const newCollapsedIndices = [...collapsedIndices];
|
|
@@ -192,6 +192,6 @@ export const IcicleGraphArrow = memo(function IcicleGraphArrow({ arrow, total, f
|
|
|
192
192
|
path,
|
|
193
193
|
highlightSimilarStacksSetName,
|
|
194
194
|
]);
|
|
195
|
-
return (_jsx(_Fragment, { children: _jsxs("div", { onMouseLeave: () => dispatch(setHoveringNode(undefined)), children: [_jsx(ContextMenu, { menuId: MENU_ID, table: table, row: hoveringRow ?? 0, level: hoveringLevel ?? 0, total: total, totalUnfiltered: total + filtered, profileType: profileType, compareAbsolute: compareAbsolute, trackVisibility: trackVisibility, curPath: curPath, setCurPath: setCurPath, hideMenu: hideAll, hideBinary: hideBinary, unit: arrow.unit }), dockedMetainfo ? (_jsx(DockedGraphTooltip, { table: table, row: hoveringRow, level: hoveringLevel ?? 0, total: total, totalUnfiltered: total + filtered, profileType: profileType, unit: arrow.unit, compareAbsolute: compareAbsolute })) : (!isContextMenuOpen && (_jsx(GraphTooltipArrow, { contextElement: svg.current, isContextMenuOpen: isContextMenuOpen, children: _jsx(GraphTooltipArrowContent, { table: table, row: hoveringRow, level: hoveringLevel ?? 0, isFixed: false, total: total, totalUnfiltered: total + filtered, profileType: profileType, unit: arrow.unit, compareAbsolute: compareAbsolute }) }))), root] }) }));
|
|
195
|
+
return (_jsx(_Fragment, { children: _jsxs("div", { className: "relative z-[9]", onMouseLeave: () => dispatch(setHoveringNode(undefined)), children: [_jsx(ContextMenu, { menuId: MENU_ID, table: table, row: hoveringRow ?? 0, level: hoveringLevel ?? 0, total: total, totalUnfiltered: total + filtered, profileType: profileType, compareAbsolute: compareAbsolute, trackVisibility: trackVisibility, curPath: curPath, setCurPath: setCurPath, hideMenu: hideAll, hideBinary: hideBinary, unit: arrow.unit }), dockedMetainfo ? (_jsx(DockedGraphTooltip, { table: table, row: hoveringRow, level: hoveringLevel ?? 0, total: total, totalUnfiltered: total + filtered, profileType: profileType, unit: arrow.unit, compareAbsolute: compareAbsolute })) : (!isContextMenuOpen && (_jsx(GraphTooltipArrow, { contextElement: svg.current, isContextMenuOpen: isContextMenuOpen, children: _jsx(GraphTooltipArrowContent, { table: table, row: hoveringRow, level: hoveringLevel ?? 0, isFixed: false, total: total, totalUnfiltered: total + filtered, profileType: profileType, unit: arrow.unit, compareAbsolute: compareAbsolute }) }))), root] }) }));
|
|
196
196
|
});
|
|
197
197
|
export default IcicleGraphArrow;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { QueryServiceClient } from '@parca/client';
|
|
2
|
+
import { DateTimeRange } from '@parca/components';
|
|
3
|
+
import { Query } from '@parca/parser';
|
|
4
|
+
import { ProfileSelection } from '..';
|
|
5
|
+
import { QuerySelection } from './index';
|
|
6
|
+
interface MetricsGraphSectionProps {
|
|
7
|
+
showMetricsGraph: boolean;
|
|
8
|
+
setDisplayHideMetricsGraphButton: (show: boolean) => void;
|
|
9
|
+
heightStyle: string;
|
|
10
|
+
querySelection: QuerySelection;
|
|
11
|
+
profileSelection: ProfileSelection | null;
|
|
12
|
+
comparing: boolean;
|
|
13
|
+
sumBy: string[] | null;
|
|
14
|
+
defaultSumByLoading: boolean;
|
|
15
|
+
queryClient: QueryServiceClient;
|
|
16
|
+
queryExpressionString: string;
|
|
17
|
+
setTimeRangeSelection: (range: DateTimeRange) => void;
|
|
18
|
+
selectQuery: (query: QuerySelection) => void;
|
|
19
|
+
selectProfile: (source: ProfileSelection) => void;
|
|
20
|
+
query: Query;
|
|
21
|
+
setNewQueryExpression: (queryExpression: string) => void;
|
|
22
|
+
setQueryExpression: (updateTs?: boolean) => void;
|
|
23
|
+
}
|
|
24
|
+
export declare function MetricsGraphSection({ showMetricsGraph, setDisplayHideMetricsGraphButton, heightStyle, querySelection, profileSelection, comparing, sumBy, defaultSumByLoading, queryClient, queryExpressionString, setTimeRangeSelection, selectQuery, selectProfile, query, setNewQueryExpression, }: MetricsGraphSectionProps): JSX.Element;
|
|
25
|
+
export {};
|
|
26
|
+
//# sourceMappingURL=MetricsGraphSection.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"MetricsGraphSection.d.ts","sourceRoot":"","sources":["../../src/ProfileSelector/MetricsGraphSection.tsx"],"names":[],"mappings":"AAeA,OAAO,EAAQ,kBAAkB,EAAC,MAAM,eAAe,CAAC;AACxD,OAAO,EAAC,aAAa,EAAC,MAAM,mBAAmB,CAAC;AAChD,OAAO,EAAC,KAAK,EAAC,MAAM,eAAe,CAAC;AAEpC,OAAO,EAAyB,gBAAgB,EAAC,MAAM,IAAI,CAAC;AAE5D,OAAO,EAAC,cAAc,EAAC,MAAM,SAAS,CAAC;AAEvC,UAAU,wBAAwB;IAChC,gBAAgB,EAAE,OAAO,CAAC;IAC1B,gCAAgC,EAAE,CAAC,IAAI,EAAE,OAAO,KAAK,IAAI,CAAC;IAC1D,WAAW,EAAE,MAAM,CAAC;IACpB,cAAc,EAAE,cAAc,CAAC;IAC/B,gBAAgB,EAAE,gBAAgB,GAAG,IAAI,CAAC;IAC1C,SAAS,EAAE,OAAO,CAAC;IACnB,KAAK,EAAE,MAAM,EAAE,GAAG,IAAI,CAAC;IACvB,mBAAmB,EAAE,OAAO,CAAC;IAC7B,WAAW,EAAE,kBAAkB,CAAC;IAChC,qBAAqB,EAAE,MAAM,CAAC;IAC9B,qBAAqB,EAAE,CAAC,KAAK,EAAE,aAAa,KAAK,IAAI,CAAC;IACtD,WAAW,EAAE,CAAC,KAAK,EAAE,cAAc,KAAK,IAAI,CAAC;IAC7C,aAAa,EAAE,CAAC,MAAM,EAAE,gBAAgB,KAAK,IAAI,CAAC;IAClD,KAAK,EAAE,KAAK,CAAC;IACb,qBAAqB,EAAE,CAAC,eAAe,EAAE,MAAM,KAAK,IAAI,CAAC;IACzD,kBAAkB,EAAE,CAAC,QAAQ,CAAC,EAAE,OAAO,KAAK,IAAI,CAAC;CAClD;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,aAAa,EACb,KAAK,EACL,qBAAqB,GACtB,EAAE,wBAAwB,GAAG,GAAG,CAAC,OAAO,CAiHxC"}
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
import { jsxs as _jsxs, jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
// Copyright 2022 The Parca Authors
|
|
3
|
+
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
4
|
+
// you may not use this file except in compliance with the License.
|
|
5
|
+
// You may obtain a copy of the License at
|
|
6
|
+
//
|
|
7
|
+
// http://www.apache.org/licenses/LICENSE-2.0
|
|
8
|
+
//
|
|
9
|
+
// Unless required by applicable law or agreed to in writing, software
|
|
10
|
+
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
11
|
+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
12
|
+
// See the License for the specific language governing permissions and
|
|
13
|
+
// limitations under the License.
|
|
14
|
+
import cx from 'classnames';
|
|
15
|
+
import { Query } from '@parca/parser';
|
|
16
|
+
import { MergedProfileSelection } from '..';
|
|
17
|
+
import ProfileMetricsGraph, { ProfileMetricsEmptyState } from '../ProfileMetricsGraph';
|
|
18
|
+
export function MetricsGraphSection({ showMetricsGraph, setDisplayHideMetricsGraphButton, heightStyle, querySelection, profileSelection, comparing, sumBy, defaultSumByLoading, queryClient, queryExpressionString, setTimeRangeSelection, selectQuery, selectProfile, query, setNewQueryExpression, }) {
|
|
19
|
+
const handleTimeRangeChange = (range) => {
|
|
20
|
+
const from = range.getFromMs();
|
|
21
|
+
const to = range.getToMs();
|
|
22
|
+
let mergedProfileParams = {};
|
|
23
|
+
if (query.profileType().delta) {
|
|
24
|
+
mergedProfileParams = { mergeFrom: from, mergeTo: to };
|
|
25
|
+
}
|
|
26
|
+
setTimeRangeSelection(range);
|
|
27
|
+
selectQuery({
|
|
28
|
+
expression: queryExpressionString,
|
|
29
|
+
from,
|
|
30
|
+
to,
|
|
31
|
+
timeSelection: range.getRangeKey(),
|
|
32
|
+
...mergedProfileParams,
|
|
33
|
+
});
|
|
34
|
+
};
|
|
35
|
+
const addLabelMatcher = (labels) => {
|
|
36
|
+
// When a user clicks on a label on the metrics graph tooltip,
|
|
37
|
+
// replace single `\` in the `value` string with doubles `\\` if available.
|
|
38
|
+
const replaceBackslash = (value) => {
|
|
39
|
+
return value.includes('\\') ? value.replaceAll('\\', '\\\\') : value;
|
|
40
|
+
};
|
|
41
|
+
let newQuery;
|
|
42
|
+
let hasChanged;
|
|
43
|
+
if (Array.isArray(labels)) {
|
|
44
|
+
const newLabels = labels.map(({ key, value }) => {
|
|
45
|
+
const newValue = replaceBackslash(value);
|
|
46
|
+
return { key, value: newValue };
|
|
47
|
+
});
|
|
48
|
+
const [query, changed] = Query.parse(queryExpressionString).setMultipleMatchers(newLabels);
|
|
49
|
+
hasChanged = changed;
|
|
50
|
+
newQuery = query;
|
|
51
|
+
}
|
|
52
|
+
else {
|
|
53
|
+
const { key, value } = labels;
|
|
54
|
+
const newValue = replaceBackslash(value);
|
|
55
|
+
const [query, changed] = Query.parse(queryExpressionString).setMatcher(key, newValue);
|
|
56
|
+
hasChanged = changed;
|
|
57
|
+
newQuery = query;
|
|
58
|
+
}
|
|
59
|
+
if (hasChanged) {
|
|
60
|
+
// TODO: Change this to store the query object
|
|
61
|
+
setNewQueryExpression(newQuery.toString());
|
|
62
|
+
}
|
|
63
|
+
};
|
|
64
|
+
const handlePointClick = (timestamp, labels, queryExpression, duration) => {
|
|
65
|
+
let query = Query.parse(queryExpression);
|
|
66
|
+
labels.forEach(l => {
|
|
67
|
+
const [newQuery, updated] = query.setMatcher(l.name, l.value);
|
|
68
|
+
if (updated) {
|
|
69
|
+
query = newQuery;
|
|
70
|
+
}
|
|
71
|
+
});
|
|
72
|
+
const durationInMilliseconds = duration / 1000000; // duration is in nanoseconds
|
|
73
|
+
const mergeFrom = timestamp;
|
|
74
|
+
const mergeTo = query.profileType().delta ? mergeFrom + durationInMilliseconds : mergeFrom;
|
|
75
|
+
selectProfile(new MergedProfileSelection(mergeFrom, mergeTo, query));
|
|
76
|
+
};
|
|
77
|
+
return (_jsxs("div", { className: cx('relative', { 'py-4': !showMetricsGraph }), children: [_jsxs("button", { onClick: () => setDisplayHideMetricsGraphButton(!showMetricsGraph), className: cx('hidden z-10 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', showMetricsGraph && 'absolute right-0 bottom-3 !flex', !showMetricsGraph && 'relative !flex ml-auto'), children: [showMetricsGraph ? 'Hide' : 'Show', " Metrics Graph"] }), showMetricsGraph && (_jsx("div", { style: { height: heightStyle }, children: querySelection.expression !== '' &&
|
|
78
|
+
querySelection.from !== undefined &&
|
|
79
|
+
querySelection.to !== undefined ? (_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." }) }))) }))] }));
|
|
80
|
+
}
|
|
@@ -0,0 +1,41 @@
|
|
|
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
|
+
setUserSumBySelection: (sumBy: string[]) => void;
|
|
36
|
+
sumByRef: React.RefObject<SelectInstance>;
|
|
37
|
+
profileType: ProfileType;
|
|
38
|
+
}
|
|
39
|
+
export declare function QueryControls({ showProfileTypeSelector, profileTypesData, profileTypesLoading, selectedProfileName, setProfileName, viewComponent, setQueryBrowserMode, advancedModeForQueryBrowser, setAdvancedModeForQueryBrowser, setMatchersString, setQueryExpression, query, queryBrowserRef, timeRangeSelection, setTimeRangeSelection, searchDisabled, queryClient, labels, sumBySelection, setUserSumBySelection, sumByRef, profileType, showSumBySelector, profileTypesError, }: QueryControlsProps): JSX.Element;
|
|
40
|
+
export {};
|
|
41
|
+
//# sourceMappingURL=QueryControls.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"QueryControls.d.ts","sourceRoot":"","sources":["../../src/ProfileSelector/QueryControls.tsx"],"names":[],"mappings":"AAcA,OAAO,EAAC,QAAQ,EAAC,MAAM,0BAA0B,CAAC;AAClD,OAAe,EAAC,KAAK,cAAc,EAAC,MAAM,cAAc,CAAC;AAEzD,OAAO,EAAC,oBAAoB,EAAE,kBAAkB,EAAC,MAAM,eAAe,CAAC;AACvE,OAAO,EAAsB,aAAa,EAAsB,MAAM,mBAAmB,CAAC;AAC1F,OAAO,EAAC,WAAW,EAAE,KAAK,EAAC,MAAM,eAAe,CAAC;AAYjD,UAAU,kBAAkB;IAC1B,uBAAuB,EAAE,OAAO,CAAC;IACjC,iBAAiB,EAAE,OAAO,CAAC;IAC3B,0BAA0B,EAAE,OAAO,CAAC;IACpC,gBAAgB,CAAC,EAAE,oBAAoB,CAAC;IACxC,mBAAmB,EAAE,OAAO,CAAC;IAC7B,mBAAmB,EAAE,MAAM,CAAC;IAC5B,cAAc,EAAE,CAAC,IAAI,EAAE,MAAM,GAAG,SAAS,KAAK,IAAI,CAAC;IACnD,iBAAiB,CAAC,EAAE,QAAQ,CAAC;IAC7B,aAAa,CAAC,EAAE;QACd,2BAA2B,CAAC,EAAE,OAAO,CAAC;QACtC,0BAA0B,CAAC,EAAE,OAAO,CAAC;QACrC,UAAU,CAAC,EAAE,MAAM,EAAE,CAAC;QACtB,mBAAmB,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;KACvC,CAAC;IACF,gBAAgB,EAAE,MAAM,CAAC;IACzB,mBAAmB,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,CAAC;IAC5C,2BAA2B,EAAE,OAAO,CAAC;IACrC,8BAA8B,EAAE,CAAC,IAAI,EAAE,OAAO,KAAK,IAAI,CAAC;IACxD,iBAAiB,EAAE,CAAC,QAAQ,EAAE,MAAM,KAAK,IAAI,CAAC;IAC9C,kBAAkB,EAAE,CAAC,QAAQ,CAAC,EAAE,OAAO,KAAK,IAAI,CAAC;IACjD,KAAK,EAAE,KAAK,CAAC;IACb,eAAe,EAAE,KAAK,CAAC,SAAS,CAAC,cAAc,CAAC,CAAC;IACjD,kBAAkB,EAAE,aAAa,CAAC;IAClC,qBAAqB,EAAE,CAAC,KAAK,EAAE,aAAa,KAAK,IAAI,CAAC;IACtD,cAAc,EAAE,OAAO,CAAC;IACxB,WAAW,EAAE,kBAAkB,CAAC;IAChC,MAAM,EAAE,MAAM,EAAE,CAAC;IACjB,cAAc,EAAE,MAAM,EAAE,CAAC;IACzB,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;CAC1B;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,QAAQ,EACR,WAAW,EACX,iBAAiB,EACjB,iBAAiB,GAClB,EAAE,kBAAkB,GAAG,GAAG,CAAC,OAAO,CA8IlC"}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
|
+
// Copyright 2022 The Parca Authors
|
|
3
|
+
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
4
|
+
// you may not use this file except in compliance with the License.
|
|
5
|
+
// You may obtain a copy of the License at
|
|
6
|
+
//
|
|
7
|
+
// http://www.apache.org/licenses/LICENSE-2.0
|
|
8
|
+
//
|
|
9
|
+
// Unless required by applicable law or agreed to in writing, software
|
|
10
|
+
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
11
|
+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
12
|
+
// See the License for the specific language governing permissions and
|
|
13
|
+
// limitations under the License.
|
|
14
|
+
import { Switch } from '@headlessui/react';
|
|
15
|
+
import Select from 'react-select';
|
|
16
|
+
import { Button, ButtonGroup, DateTimeRangePicker } from '@parca/components';
|
|
17
|
+
import MatchersInput from '../MatchersInput';
|
|
18
|
+
import ProfileTypeSelector from '../ProfileTypeSelector';
|
|
19
|
+
import SimpleMatchers from '../SimpleMatchers';
|
|
20
|
+
import ViewMatchers from '../ViewMatchers';
|
|
21
|
+
export function QueryControls({ showProfileTypeSelector, profileTypesData, profileTypesLoading, selectedProfileName, setProfileName, viewComponent, setQueryBrowserMode, advancedModeForQueryBrowser, setAdvancedModeForQueryBrowser, setMatchersString, setQueryExpression, query, queryBrowserRef, timeRangeSelection, setTimeRangeSelection, searchDisabled, queryClient, labels, sumBySelection, setUserSumBySelection, sumByRef, profileType, showSumBySelector, profileTypesError, }) {
|
|
22
|
+
return (_jsxs("div", { className: "flex w-full flex-wrap items-end gap-2", children: [showProfileTypeSelector && (_jsxs("div", { children: [_jsx("label", { className: "text-xs", 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", ref: queryBrowserRef, children: [_jsx("div", { className: "flex items-center justify-between", children: _jsxs("div", { className: "flex items-center gap-3", children: [_jsx("label", { className: "text-xs", children: "Query" }), viewComponent?.disableExplorativeQuerying !== true && (_jsxs(_Fragment, { children: [_jsxs(Switch, { checked: advancedModeForQueryBrowser, onChange: () => {
|
|
23
|
+
setAdvancedModeForQueryBrowser(!advancedModeForQueryBrowser);
|
|
24
|
+
setQueryBrowserMode(advancedModeForQueryBrowser ? 'simple' : 'advanced');
|
|
25
|
+
}, 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`, 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", children: "Advanced Mode" })] }))] }) }), viewComponent?.disableExplorativeQuerying === true &&
|
|
26
|
+
viewComponent?.labelnames !== undefined &&
|
|
27
|
+
viewComponent?.labelnames.length >= 1 ? (_jsx(ViewMatchers, { labelNames: viewComponent.labelnames, setMatchersString: setMatchersString, profileType: selectedProfileName, runQuery: setQueryExpression, currentQuery: query, queryClient: queryClient })) : advancedModeForQueryBrowser ? (_jsx(MatchersInput, { setMatchersString: setMatchersString, runQuery: setQueryExpression, currentQuery: query, profileType: selectedProfileName, queryClient: queryClient })) : (_jsx(SimpleMatchers, { setMatchersString: setMatchersString, runQuery: setQueryExpression, currentQuery: query, profileType: selectedProfileName, queryBrowserRef: queryBrowserRef, queryClient: queryClient }))] }), showSumBySelector && (_jsxs("div", { children: [_jsx("div", { className: "mb-0.5 mt-1.5 flex items-center justify-between", children: _jsx("label", { className: "text-xs", children: "Sum by" }) }), _jsx(Select, { id: "h-sum-by-selector", defaultValue: [], isMulti: true, 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 => {
|
|
28
|
+
setUserSumBySelection(newValue.map(option => option.value));
|
|
29
|
+
}, placeholder: "Labels...", styles: {
|
|
30
|
+
indicatorSeparator: () => ({ display: 'none' }),
|
|
31
|
+
menu: provided => ({ ...provided, width: 'max-content' }),
|
|
32
|
+
}, isDisabled: !profileType.delta,
|
|
33
|
+
// @ts-expect-error
|
|
34
|
+
ref: sumByRef, onKeyDown: e => {
|
|
35
|
+
const currentRef = sumByRef.current;
|
|
36
|
+
if (currentRef == null) {
|
|
37
|
+
return;
|
|
38
|
+
}
|
|
39
|
+
const inputRef = currentRef.inputRef;
|
|
40
|
+
if (inputRef == null) {
|
|
41
|
+
return;
|
|
42
|
+
}
|
|
43
|
+
if (e.key === 'Enter' &&
|
|
44
|
+
inputRef.value === '' &&
|
|
45
|
+
currentRef.state.focusedOptionId === null // menu is not open
|
|
46
|
+
) {
|
|
47
|
+
setQueryExpression(true);
|
|
48
|
+
currentRef.blur();
|
|
49
|
+
}
|
|
50
|
+
} })] })), _jsx(DateTimeRangePicker, { onRangeSelection: setTimeRangeSelection, range: timeRangeSelection }), _jsx(ButtonGroup, { children: _jsx(Button, { disabled: searchDisabled, onClick: (e) => {
|
|
51
|
+
e.preventDefault();
|
|
52
|
+
setQueryExpression(true);
|
|
53
|
+
}, id: "h-matcher-search-button", children: "Search" }) })] }));
|
|
54
|
+
}
|
|
@@ -12,7 +12,14 @@ export interface QuerySelection {
|
|
|
12
12
|
mergeFrom?: number;
|
|
13
13
|
mergeTo?: number;
|
|
14
14
|
}
|
|
15
|
-
interface
|
|
15
|
+
interface ProfileSelectorFeatures {
|
|
16
|
+
showMetricsGraph: boolean;
|
|
17
|
+
showSumBySelector?: boolean;
|
|
18
|
+
showProfileTypeSelector?: boolean;
|
|
19
|
+
disableExplorativeQuerying?: boolean;
|
|
20
|
+
disableProfileTypesDropdown?: boolean;
|
|
21
|
+
}
|
|
22
|
+
interface ProfileSelectorProps extends ProfileSelectorFeatures {
|
|
16
23
|
queryClient: QueryServiceClient;
|
|
17
24
|
querySelection: QuerySelection;
|
|
18
25
|
selectProfile: (source: ProfileSelection) => void;
|
|
@@ -22,9 +29,8 @@ interface ProfileSelectorProps {
|
|
|
22
29
|
profileSelection: ProfileSelection | null;
|
|
23
30
|
comparing: boolean;
|
|
24
31
|
navigateTo: NavigateFunction;
|
|
25
|
-
suffix?: string;
|
|
26
|
-
showMetricsGraph: boolean;
|
|
27
32
|
setDisplayHideMetricsGraphButton: Dispatch<SetStateAction<boolean>>;
|
|
33
|
+
suffix?: string;
|
|
28
34
|
}
|
|
29
35
|
export interface IProfileTypesResult {
|
|
30
36
|
loading: boolean;
|
|
@@ -32,6 +38,6 @@ export interface IProfileTypesResult {
|
|
|
32
38
|
error?: RpcError;
|
|
33
39
|
}
|
|
34
40
|
export declare const useProfileTypes: (client: QueryServiceClient) => IProfileTypesResult;
|
|
35
|
-
declare const ProfileSelector: ({ queryClient, querySelection, selectProfile, selectQuery, closeProfile, enforcedProfileName, profileSelection, comparing, navigateTo, showMetricsGraph, setDisplayHideMetricsGraphButton, }: ProfileSelectorProps) => JSX.Element;
|
|
41
|
+
declare const ProfileSelector: ({ queryClient, querySelection, selectProfile, selectQuery, closeProfile, enforcedProfileName, profileSelection, comparing, navigateTo, showMetricsGraph, showSumBySelector, showProfileTypeSelector, disableExplorativeQuerying, setDisplayHideMetricsGraphButton, }: ProfileSelectorProps) => JSX.Element;
|
|
36
42
|
export default ProfileSelector;
|
|
37
43
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/ProfileSelector/index.tsx"],"names":[],"mappings":"AAaA,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/ProfileSelector/index.tsx"],"names":[],"mappings":"AAaA,OAAO,EAAC,QAAQ,EAAE,cAAc,EAAuC,MAAM,OAAO,CAAC;AAErF,OAAO,EAAC,QAAQ,EAAC,MAAM,0BAA0B,CAAC;AAElD,OAAO,EAAC,oBAAoB,EAAE,kBAAkB,EAAC,MAAM,eAAe,CAAC;AAUvE,OAAO,EAAC,KAAK,gBAAgB,EAAC,MAAM,kBAAkB,CAAC;AAEvD,OAAO,EAAC,gBAAgB,EAAC,MAAM,IAAI,CAAC;AAQpC,MAAM,WAAW,cAAc;IAC7B,UAAU,EAAE,MAAM,CAAC;IACnB,IAAI,EAAE,MAAM,CAAC;IACb,EAAE,EAAE,MAAM,CAAC;IACX,aAAa,EAAE,MAAM,CAAC;IACtB,KAAK,CAAC,EAAE,MAAM,EAAE,CAAC;IACjB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB;AAED,UAAU,uBAAuB;IAC/B,gBAAgB,EAAE,OAAO,CAAC;IAC1B,iBAAiB,CAAC,EAAE,OAAO,CAAC;IAC5B,uBAAuB,CAAC,EAAE,OAAO,CAAC;IAClC,0BAA0B,CAAC,EAAE,OAAO,CAAC;IACrC,2BAA2B,CAAC,EAAE,OAAO,CAAC;CACvC;AAED,UAAU,oBAAqB,SAAQ,uBAAuB;IAC5D,WAAW,EAAE,kBAAkB,CAAC;IAChC,cAAc,EAAE,cAAc,CAAC;IAC/B,aAAa,EAAE,CAAC,MAAM,EAAE,gBAAgB,KAAK,IAAI,CAAC;IAClD,WAAW,EAAE,CAAC,KAAK,EAAE,cAAc,KAAK,IAAI,CAAC;IAC7C,YAAY,EAAE,MAAM,IAAI,CAAC;IACzB,mBAAmB,EAAE,MAAM,CAAC;IAC5B,gBAAgB,EAAE,gBAAgB,GAAG,IAAI,CAAC;IAC1C,SAAS,EAAE,OAAO,CAAC;IACnB,UAAU,EAAE,gBAAgB,CAAC;IAC7B,gCAAgC,EAAE,QAAQ,CAAC,cAAc,CAAC,OAAO,CAAC,CAAC,CAAC;IACpE,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;AAED,MAAM,WAAW,mBAAmB;IAClC,OAAO,EAAE,OAAO,CAAC;IACjB,IAAI,CAAC,EAAE,oBAAoB,CAAC;IAC5B,KAAK,CAAC,EAAE,QAAQ,CAAC;CAClB;AAED,eAAO,MAAM,eAAe,WAAY,kBAAkB,KAAG,mBAkB5D,CAAC;AAEF,QAAA,MAAM,eAAe,yQAelB,oBAAoB,KAAG,GAAG,CAAC,OAyM7B,CAAC;AAEF,eAAe,eAAe,CAAC"}
|
|
@@ -12,20 +12,14 @@ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-run
|
|
|
12
12
|
// See the License for the specific language governing permissions and
|
|
13
13
|
// limitations under the License.
|
|
14
14
|
import { useEffect, useMemo, useRef, useState } from 'react';
|
|
15
|
-
import {
|
|
16
|
-
import cx from 'classnames';
|
|
17
|
-
import Select from 'react-select';
|
|
18
|
-
import { Button, ButtonGroup, DateTimeRange, DateTimeRangePicker, IconButton, useGrpcMetadata, useParcaContext, useURLState, } from '@parca/components';
|
|
15
|
+
import { DateTimeRange, IconButton, useGrpcMetadata, useParcaContext, useURLState, } from '@parca/components';
|
|
19
16
|
import { CloseIcon } from '@parca/icons';
|
|
20
17
|
import { Query } from '@parca/parser';
|
|
21
|
-
import {
|
|
22
|
-
import MatchersInput, { useLabelNames } from '../MatchersInput/index';
|
|
18
|
+
import { useLabelNames } from '../MatchersInput/index';
|
|
23
19
|
import { useMetricsGraphDimensions } from '../MetricsGraph/useMetricsGraphDimensions';
|
|
24
|
-
import ProfileMetricsGraph, { ProfileMetricsEmptyState } from '../ProfileMetricsGraph';
|
|
25
|
-
import ProfileTypeSelector from '../ProfileTypeSelector/index';
|
|
26
|
-
import SimpleMatchers from '../SimpleMatchers';
|
|
27
|
-
import ViewMatchers from '../ViewMatchers';
|
|
28
20
|
import { useDefaultSumBy, useSumBySelection } from '../useSumBy';
|
|
21
|
+
import { MetricsGraphSection } from './MetricsGraphSection';
|
|
22
|
+
import { QueryControls } from './QueryControls';
|
|
29
23
|
import { useAutoQuerySelector } from './useAutoQuerySelector';
|
|
30
24
|
export const useProfileTypes = (client) => {
|
|
31
25
|
const [result, setResult] = useState(undefined);
|
|
@@ -44,11 +38,10 @@ export const useProfileTypes = (client) => {
|
|
|
44
38
|
}, [client, metadata, loading]);
|
|
45
39
|
return { loading, data: result, error };
|
|
46
40
|
};
|
|
47
|
-
const ProfileSelector = ({ queryClient, querySelection, selectProfile, selectQuery, closeProfile, enforcedProfileName, profileSelection, comparing, navigateTo, showMetricsGraph, setDisplayHideMetricsGraphButton, }) => {
|
|
41
|
+
const ProfileSelector = ({ queryClient, querySelection, selectProfile, selectQuery, closeProfile, enforcedProfileName, profileSelection, comparing, navigateTo, showMetricsGraph = true, showSumBySelector = true, showProfileTypeSelector = true, disableExplorativeQuerying = false, setDisplayHideMetricsGraphButton, }) => {
|
|
48
42
|
const { loading: profileTypesLoading, data: profileTypesData, error, } = useProfileTypes(queryClient);
|
|
49
43
|
const { heightStyle } = useMetricsGraphDimensions(comparing);
|
|
50
44
|
const { viewComponent } = useParcaContext();
|
|
51
|
-
const sumByRef = useRef(null);
|
|
52
45
|
const [queryBrowserMode, setQueryBrowserMode] = useURLState('query_browser_mode');
|
|
53
46
|
const [timeRangeSelection, setTimeRangeSelection] = useState(DateTimeRange.fromRangeKey(querySelection.timeSelection, querySelection.from, querySelection.to));
|
|
54
47
|
const [queryExpressionString, setQueryExpressionString] = useState(querySelection.expression);
|
|
@@ -113,35 +106,6 @@ const ProfileSelector = ({ queryClient, querySelection, selectProfile, selectQue
|
|
|
113
106
|
const setQueryExpression = (updateTs = false) => {
|
|
114
107
|
setNewQueryExpression(query.toString(), updateTs);
|
|
115
108
|
};
|
|
116
|
-
const addLabelMatcher = (labels) => {
|
|
117
|
-
// When a user clicks on a label on the metrics graph tooltip,
|
|
118
|
-
// replace single `\` in the `value` string with doubles `\\` if available.
|
|
119
|
-
const replaceBackslash = (value) => {
|
|
120
|
-
return value.includes('\\') ? value.replaceAll('\\', '\\\\') : value;
|
|
121
|
-
};
|
|
122
|
-
let newQuery;
|
|
123
|
-
let hasChanged;
|
|
124
|
-
if (Array.isArray(labels)) {
|
|
125
|
-
const newLabels = labels.map(({ key, value }) => {
|
|
126
|
-
const newValue = replaceBackslash(value);
|
|
127
|
-
return { key, value: newValue };
|
|
128
|
-
});
|
|
129
|
-
const [query, changed] = Query.parse(queryExpressionString).setMultipleMatchers(newLabels);
|
|
130
|
-
hasChanged = changed;
|
|
131
|
-
newQuery = query;
|
|
132
|
-
}
|
|
133
|
-
else {
|
|
134
|
-
const { key, value } = labels;
|
|
135
|
-
const newValue = replaceBackslash(value);
|
|
136
|
-
const [query, changed] = Query.parse(queryExpressionString).setMatcher(key, newValue);
|
|
137
|
-
hasChanged = changed;
|
|
138
|
-
newQuery = query;
|
|
139
|
-
}
|
|
140
|
-
if (hasChanged) {
|
|
141
|
-
// TODO: Change this to store the query object
|
|
142
|
-
setNewQueryExpression(newQuery.toString());
|
|
143
|
-
}
|
|
144
|
-
};
|
|
145
109
|
const setMatchersString = (matchers) => {
|
|
146
110
|
const newExpressionString = `${selectedProfileName}{${matchers}}`;
|
|
147
111
|
setQueryExpressionString(newExpressionString);
|
|
@@ -174,75 +138,7 @@ const ProfileSelector = ({ queryClient, querySelection, selectProfile, selectQue
|
|
|
174
138
|
queryExpressionString === '' ||
|
|
175
139
|
queryExpressionString === '{}';
|
|
176
140
|
const queryBrowserRef = useRef(null);
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
setQueryBrowserMode(advancedModeForQueryBrowser ? 'simple' : 'advanced');
|
|
180
|
-
}, className: `${advancedModeForQueryBrowser
|
|
181
|
-
? 'bg-indigo-600'
|
|
182
|
-
: 'bg-gray-400 dark:bg-gray-800'}
|
|
183
|
-
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`, children: [_jsx("span", { className: "sr-only", children: "Use setting" }), _jsx("span", { "aria-hidden": "true", className: `${advancedModeForQueryBrowser ? 'translate-x-6' : 'translate-x-0'}
|
|
184
|
-
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", children: "Advanced Mode" })] }))] }), (query.matchers.length > 0 || query.inputMatcherString.length > 0) &&
|
|
185
|
-
viewComponent !== undefined && _jsx("div", { children: viewComponent?.createViewComponent })] }), viewComponent?.disableExplorativeQuerying === true &&
|
|
186
|
-
viewComponent?.labelnames !== undefined &&
|
|
187
|
-
viewComponent?.labelnames.length >= 1 ? (_jsx(_Fragment, { children: _jsx(ViewMatchers, { labelNames: viewComponent.labelnames, setMatchersString: setMatchersString, profileType: selectedProfileName, runQuery: setQueryExpression, currentQuery: query, queryClient: queryClient }) })) : (_jsx(_Fragment, { children: advancedModeForQueryBrowser ? (_jsx(MatchersInput, { queryClient: queryClient, setMatchersString: setMatchersString, runQuery: setQueryExpression, currentQuery: query, profileType: selectedProfileName })) : (_jsx(SimpleMatchers, { queryClient: queryClient, setMatchersString: setMatchersString, runQuery: setQueryExpression, currentQuery: query, profileType: selectedProfileName, queryBrowserRef: queryBrowserRef })) }))] }), _jsxs("div", { children: [_jsx("div", { className: "mb-0.5 mt-1.5 flex items-center justify-between", children: _jsx("label", { className: "text-xs", children: "Sum by" }) }), _jsx(Select, { id: "h-sum-by-selector", defaultValue: [], isMulti: true, 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: selectedOptions => {
|
|
188
|
-
setUserSumBySelection(selectedOptions.map(option => option.value));
|
|
189
|
-
}, placeholder: "Labels...", styles: {
|
|
190
|
-
indicatorSeparator: () => ({ display: 'none' }),
|
|
191
|
-
menu: provided => ({ ...provided, width: 'max-content' }),
|
|
192
|
-
}, isDisabled: !profileType.delta, ref: sumByRef, onKeyDown: e => {
|
|
193
|
-
const currentRef = sumByRef.current;
|
|
194
|
-
if (currentRef == null) {
|
|
195
|
-
return;
|
|
196
|
-
}
|
|
197
|
-
const inputRef = currentRef.inputRef;
|
|
198
|
-
if (inputRef == null) {
|
|
199
|
-
return;
|
|
200
|
-
}
|
|
201
|
-
if (e.key === 'Enter' &&
|
|
202
|
-
inputRef.value === '' &&
|
|
203
|
-
currentRef.state.focusedOptionId === null // menu is not open
|
|
204
|
-
) {
|
|
205
|
-
setQueryExpression(true);
|
|
206
|
-
currentRef.blur();
|
|
207
|
-
}
|
|
208
|
-
} })] }), _jsx(DateTimeRangePicker, { onRangeSelection: setTimeRangeSelection, range: timeRangeSelection }), _jsx(ButtonGroup, { children: _jsx(Button, { disabled: searchDisabled, onClick: (e) => {
|
|
209
|
-
e.preventDefault();
|
|
210
|
-
setQueryExpression(true);
|
|
211
|
-
}, id: "h-matcher-search-button", children: "Search" }) })] }), _jsx("div", { children: comparing && _jsx(IconButton, { onClick: () => closeProfile(), icon: _jsx(CloseIcon, {}) }) })] }), _jsxs("div", { className: cx('relative', {
|
|
212
|
-
'py-4': !showMetricsGraph,
|
|
213
|
-
}), children: [_jsxs("button", { onClick: () => setDisplayHideMetricsGraphButton(!showMetricsGraph), className: cx('hidden z-10 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', showMetricsGraph && 'absolute right-0 bottom-3 !flex', !showMetricsGraph && 'relative !flex ml-auto'), children: [showMetricsGraph ? 'Hide' : 'Show', " Metrics Graph"] }), showMetricsGraph ? (_jsx("div", { style: { height: heightStyle }, children: querySelection.expression !== undefined &&
|
|
214
|
-
querySelection.expression.length > 0 &&
|
|
215
|
-
querySelection.from !== undefined &&
|
|
216
|
-
querySelection.to !== undefined ? (_jsx("div", { children: _jsx(ProfileMetricsGraph, { queryClient: queryClient, queryExpression: querySelection.expression, from: querySelection.from, to: querySelection.to, profile: profileSelection, comparing: comparing, sumBy: querySelection.sumBy ?? defaultSumBy ?? [], sumByLoading: defaultSumByLoading, setTimeRange: (range) => {
|
|
217
|
-
const from = range.getFromMs();
|
|
218
|
-
const to = range.getToMs();
|
|
219
|
-
let mergedProfileParams = {};
|
|
220
|
-
if (query.profileType().delta) {
|
|
221
|
-
mergedProfileParams = { mergeFrom: from, mergeTo: to };
|
|
222
|
-
}
|
|
223
|
-
setTimeRangeSelection(range);
|
|
224
|
-
selectQuery({
|
|
225
|
-
expression: queryExpressionString,
|
|
226
|
-
from,
|
|
227
|
-
to,
|
|
228
|
-
timeSelection: range.getRangeKey(),
|
|
229
|
-
...mergedProfileParams,
|
|
230
|
-
});
|
|
231
|
-
}, addLabelMatcher: addLabelMatcher, onPointClick: (timestamp, labels, queryExpression, duration) => {
|
|
232
|
-
// TODO: Pass the query object via click rather than queryExpression
|
|
233
|
-
let query = Query.parse(queryExpression);
|
|
234
|
-
labels.forEach(l => {
|
|
235
|
-
const [newQuery, updated] = query.setMatcher(l.name, l.value);
|
|
236
|
-
if (updated) {
|
|
237
|
-
query = newQuery;
|
|
238
|
-
}
|
|
239
|
-
});
|
|
240
|
-
const durationInMilliseconds = duration / 1000000; // duration is in nanoseconds
|
|
241
|
-
const mergeFrom = timestamp;
|
|
242
|
-
const mergeTo = query.profileType().delta
|
|
243
|
-
? mergeFrom + durationInMilliseconds
|
|
244
|
-
: mergeFrom;
|
|
245
|
-
selectProfile(new MergedProfileSelection(mergeFrom, mergeTo, query));
|
|
246
|
-
} }) })) : (_jsx(_Fragment, { children: profileSelection == null ? (_jsx("div", { className: "p-2", children: _jsx(ProfileMetricsEmptyState, { message: `Please select a profile type and click "Search" to begin.` }) })) : null })) })) : null] })] }));
|
|
141
|
+
const sumByRef = useRef(null);
|
|
142
|
+
return (_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: setTimeRangeSelection, searchDisabled: searchDisabled, queryBrowserMode: queryBrowserMode, setQueryBrowserMode: setQueryBrowserMode, advancedModeForQueryBrowser: advancedModeForQueryBrowser, setAdvancedModeForQueryBrowser: setAdvancedModeForQueryBrowser, queryClient: queryClient, sumByRef: sumByRef, labels: labels, sumBySelection: sumBySelection ?? [], setUserSumBySelection: setUserSumBySelection, profileType: profileType, profileTypesError: error }), comparing && (_jsx("div", { children: _jsx(IconButton, { onClick: () => closeProfile(), icon: _jsx(CloseIcon, {}) }) }))] }), _jsx(MetricsGraphSection, { showMetricsGraph: showMetricsGraph, setDisplayHideMetricsGraphButton: setDisplayHideMetricsGraphButton, heightStyle: heightStyle, querySelection: querySelection, profileSelection: profileSelection, comparing: comparing, sumBy: querySelection.sumBy ?? defaultSumBy ?? [], defaultSumByLoading: defaultSumByLoading, queryClient: queryClient, queryExpressionString: queryExpressionString, setTimeRangeSelection: setTimeRangeSelection, selectQuery: selectQuery, selectProfile: selectProfile, query: query, setQueryExpression: setQueryExpression, setNewQueryExpression: setNewQueryExpression })] }));
|
|
247
143
|
};
|
|
248
144
|
export default ProfileSelector;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { NumberDuo } from '../utils';
|
|
2
|
+
interface Props {
|
|
3
|
+
width: number;
|
|
4
|
+
height: number;
|
|
5
|
+
margin: number;
|
|
6
|
+
bounds: NumberDuo;
|
|
7
|
+
ticks?: number;
|
|
8
|
+
}
|
|
9
|
+
export declare const TimelineGuide: ({ bounds, width, height, margin, ticks }: Props) => JSX.Element;
|
|
10
|
+
export {};
|
|
11
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/TimelineGuide/index.tsx"],"names":[],"mappings":"AAiBA,OAAO,EAAC,SAAS,EAAC,MAAM,UAAU,CAAC;AAEnC,UAAU,KAAK;IACb,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,SAAS,CAAC;IAClB,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAaD,eAAO,MAAM,aAAa,6CAA4C,KAAK,KAAG,GAAG,CAAC,OA8DjF,CAAC"}
|
|
@@ -11,7 +11,7 @@ import { jsxs as _jsxs, jsx as _jsx } from "react/jsx-runtime";
|
|
|
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
|
|
14
|
+
import { Fragment } from 'react';
|
|
15
15
|
import * as d3 from 'd3';
|
|
16
16
|
const alignBeforeAxisCorrection = (val) => {
|
|
17
17
|
if (val < 10000) {
|
|
@@ -22,19 +22,9 @@ const alignBeforeAxisCorrection = (val) => {
|
|
|
22
22
|
}
|
|
23
23
|
return 0;
|
|
24
24
|
};
|
|
25
|
-
export const TimelineGuide = ({
|
|
26
|
-
const bounds = useMemo(() => {
|
|
27
|
-
const bounds = [Infinity, -Infinity];
|
|
28
|
-
data.forEach(cpuData => {
|
|
29
|
-
cpuData.forEach(dataPoint => {
|
|
30
|
-
bounds[0] = Math.min(bounds[0], dataPoint.timestamp);
|
|
31
|
-
bounds[1] = Math.max(bounds[1], dataPoint.timestamp);
|
|
32
|
-
});
|
|
33
|
-
});
|
|
34
|
-
return [0, bounds[1] - bounds[0]];
|
|
35
|
-
}, [data]);
|
|
25
|
+
export const TimelineGuide = ({ bounds, width, height, margin, ticks }) => {
|
|
36
26
|
const xScale = d3.scaleLinear().domain(bounds).range([0, width]);
|
|
37
|
-
return (_jsx("div", { className: "relative h-4", children: _jsx("div", { className: "absolute", style: { width, height }, children: _jsx("svg", { style: { width: '100%', height: '100%' }, children: _jsxs("g", { className: "x axis", fill: "none", fontSize: "10", textAnchor: "middle", transform: `translate(0,${height - margin})`, children: [xScale.ticks().map((d, i) => (_jsxs(Fragment, { children: [_jsx("g", { className: "tick",
|
|
27
|
+
return (_jsx("div", { className: "relative h-4", children: _jsx("div", { className: "absolute", style: { width, height }, children: _jsx("svg", { style: { width: '100%', height: '100%' }, className: "z-[5]", children: _jsxs("g", { className: "x axis", fill: "none", fontSize: "10", textAnchor: "middle", transform: `translate(0,${height - margin})`, children: [xScale.ticks(ticks).map((d, i) => (_jsxs(Fragment, { children: [_jsx("g", { className: "tick",
|
|
38
28
|
/* eslint-disable-next-line @typescript-eslint/restrict-template-expressions */
|
|
39
29
|
transform: `translate(${xScale(d) + alignBeforeAxisCorrection(d)}, ${-height})`, children: _jsxs("text", { fill: "currentColor", dy: ".71em", y: 9, children: [d, " ms"] }) }, `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: width, y1: -height + 1, y2: -height + 1 }), _jsx("line", { className: "stroke-gray-300 dark:stroke-gray-500", x1: 0, x2: width, y1: -height + 20, y2: -height + 20 })] }) }) }) }));
|
|
40
30
|
};
|