@parca/profile 0.19.80 → 0.19.82
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/MatchersInput/index.d.ts +2 -34
- package/dist/MatchersInput/index.d.ts.map +1 -1
- package/dist/MatchersInput/index.js +14 -91
- package/dist/MetricsGraph/index.d.ts.map +1 -1
- package/dist/MetricsGraph/index.js +13 -1
- package/dist/ProfileMetricsGraph/index.d.ts.map +1 -1
- package/dist/ProfileMetricsGraph/index.js +24 -33
- package/dist/ProfileSelector/MetricsGraphSection.d.ts +2 -9
- package/dist/ProfileSelector/MetricsGraphSection.d.ts.map +1 -1
- package/dist/ProfileSelector/MetricsGraphSection.js +3 -38
- package/dist/ProfileSelector/index.d.ts +1 -29
- package/dist/ProfileSelector/index.d.ts.map +1 -1
- package/dist/ProfileSelector/index.js +12 -9
- package/dist/ProfileView/components/ProfileFilters/filterPresets.d.ts.map +1 -1
- package/dist/ProfileView/components/ProfileFilters/filterPresets.js +15 -3
- package/dist/QueryControls/index.d.ts +42 -0
- package/dist/QueryControls/index.d.ts.map +1 -0
- package/dist/{ProfileSelector/QueryControls.js → QueryControls/index.js} +16 -13
- package/dist/SimpleMatchers/Select.js +1 -1
- package/dist/SimpleMatchers/index.d.ts +2 -11
- package/dist/SimpleMatchers/index.d.ts.map +1 -1
- package/dist/SimpleMatchers/index.js +34 -45
- package/dist/ViewMatchers/index.d.ts +0 -9
- package/dist/ViewMatchers/index.d.ts.map +1 -1
- package/dist/ViewMatchers/index.js +20 -12
- package/dist/contexts/LabelsQueryProvider.d.ts +35 -0
- package/dist/contexts/LabelsQueryProvider.d.ts.map +1 -0
- package/dist/contexts/LabelsQueryProvider.js +70 -0
- package/dist/contexts/UnifiedLabelsContext.d.ts +37 -0
- package/dist/contexts/UnifiedLabelsContext.d.ts.map +1 -0
- package/dist/contexts/UnifiedLabelsContext.js +88 -0
- package/dist/contexts/utils.d.ts +10 -0
- package/dist/contexts/utils.d.ts.map +1 -0
- package/dist/contexts/utils.js +31 -0
- package/dist/hooks/useLabels.d.ts +23 -0
- package/dist/hooks/useLabels.d.ts.map +1 -0
- package/dist/hooks/useLabels.js +75 -0
- package/dist/hooks/useQueryState.d.ts +2 -0
- package/dist/hooks/useQueryState.d.ts.map +1 -1
- package/dist/hooks/useQueryState.js +18 -0
- package/dist/index.d.ts +9 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +9 -3
- package/dist/styles.css +1 -1
- package/dist/useSumBy.js +1 -1
- package/package.json +2 -2
- package/src/MatchersInput/index.tsx +17 -163
- package/src/MetricsGraph/index.tsx +17 -1
- package/src/ProfileMetricsGraph/index.tsx +37 -102
- package/src/ProfileSelector/MetricsGraphSection.tsx +14 -115
- package/src/ProfileSelector/index.tsx +106 -109
- package/src/ProfileView/components/ProfileFilters/filterPresets.ts +15 -3
- package/src/{ProfileSelector/QueryControls.tsx → QueryControls/index.tsx} +66 -84
- package/src/SimpleMatchers/Select.tsx +1 -1
- package/src/SimpleMatchers/index.tsx +46 -85
- package/src/ViewMatchers/index.tsx +22 -30
- package/src/contexts/LabelsQueryProvider.tsx +142 -0
- package/src/contexts/UnifiedLabelsContext.tsx +155 -0
- package/src/contexts/utils.ts +43 -0
- package/src/hooks/useLabels.ts +121 -0
- package/src/hooks/useQueryState.ts +25 -0
- package/src/index.tsx +29 -3
- package/src/useSumBy.ts +1 -1
- package/dist/MetricsGraph/UtilizationMetrics/Throughput.d.ts +0 -29
- package/dist/MetricsGraph/UtilizationMetrics/Throughput.d.ts.map +0 -1
- package/dist/MetricsGraph/UtilizationMetrics/Throughput.js +0 -175
- package/dist/MetricsGraph/UtilizationMetrics/index.d.ts +0 -28
- package/dist/MetricsGraph/UtilizationMetrics/index.d.ts.map +0 -1
- package/dist/MetricsGraph/UtilizationMetrics/index.js +0 -186
- package/dist/ProfileSelector/QueryControls.d.ts +0 -43
- package/dist/ProfileSelector/QueryControls.d.ts.map +0 -1
- package/dist/contexts/MatchersInputLabelsContext.d.ts +0 -29
- package/dist/contexts/MatchersInputLabelsContext.d.ts.map +0 -1
- package/dist/contexts/MatchersInputLabelsContext.js +0 -79
- package/dist/contexts/SimpleMatchersLabelContext.d.ts +0 -25
- package/dist/contexts/SimpleMatchersLabelContext.d.ts.map +0 -1
- package/dist/contexts/SimpleMatchersLabelContext.js +0 -115
- package/dist/contexts/UtilizationLabelsContext.d.ts +0 -15
- package/dist/contexts/UtilizationLabelsContext.d.ts.map +0 -1
- package/dist/contexts/UtilizationLabelsContext.js +0 -25
- package/src/MetricsGraph/UtilizationMetrics/Throughput.tsx +0 -405
- package/src/MetricsGraph/UtilizationMetrics/index.tsx +0 -426
- package/src/contexts/MatchersInputLabelsContext.tsx +0 -141
- package/src/contexts/SimpleMatchersLabelContext.tsx +0 -189
- package/src/contexts/UtilizationLabelsContext.tsx +0 -45
|
@@ -1,43 +0,0 @@
|
|
|
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
|
|
@@ -1 +0,0 @@
|
|
|
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,kBAAkB,EAAC,MAAM,eAAe,CAAC;AACvE,OAAO,EAAS,aAAa,EAAuC,MAAM,mBAAmB,CAAC;AAC9F,OAAO,EAAC,WAAW,EAAE,KAAK,EAAC,MAAM,eAAe,CAAC;AAcjD,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,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"}
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import { QueryServiceClient } from '@parca/client';
|
|
3
|
-
interface LabelNameMapping {
|
|
4
|
-
displayName: string;
|
|
5
|
-
fullName: string;
|
|
6
|
-
}
|
|
7
|
-
interface LabelsContextType {
|
|
8
|
-
labelNames: string[];
|
|
9
|
-
labelValues: string[];
|
|
10
|
-
labelNameMappings: LabelNameMapping[];
|
|
11
|
-
isLabelNamesLoading: boolean;
|
|
12
|
-
isLabelValuesLoading: boolean;
|
|
13
|
-
currentLabelName: string | null;
|
|
14
|
-
setCurrentLabelName: (name: string | null) => void;
|
|
15
|
-
shouldHandlePrefixes: boolean;
|
|
16
|
-
refetchLabelValues: () => Promise<void>;
|
|
17
|
-
refetchLabelNames: () => Promise<void>;
|
|
18
|
-
}
|
|
19
|
-
interface LabelsProviderProps {
|
|
20
|
-
children: React.ReactNode;
|
|
21
|
-
queryClient: QueryServiceClient;
|
|
22
|
-
profileType: string;
|
|
23
|
-
start?: number;
|
|
24
|
-
end?: number;
|
|
25
|
-
}
|
|
26
|
-
export declare function LabelsProvider({ children, queryClient, profileType, start, end, }: LabelsProviderProps): JSX.Element;
|
|
27
|
-
export declare function useLabels(): LabelsContextType;
|
|
28
|
-
export {};
|
|
29
|
-
//# sourceMappingURL=MatchersInputLabelsContext.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"MatchersInputLabelsContext.d.ts","sourceRoot":"","sources":["../../src/contexts/MatchersInputLabelsContext.tsx"],"names":[],"mappings":"AAaA,OAAO,KAA2C,MAAM,OAAO,CAAC;AAEhE,OAAO,EAAC,kBAAkB,EAAC,MAAM,eAAe,CAAC;AAKjD,UAAU,gBAAgB;IACxB,WAAW,EAAE,MAAM,CAAC;IACpB,QAAQ,EAAE,MAAM,CAAC;CAClB;AAED,UAAU,iBAAiB;IACzB,UAAU,EAAE,MAAM,EAAE,CAAC;IACrB,WAAW,EAAE,MAAM,EAAE,CAAC;IACtB,iBAAiB,EAAE,gBAAgB,EAAE,CAAC;IACtC,mBAAmB,EAAE,OAAO,CAAC;IAC7B,oBAAoB,EAAE,OAAO,CAAC;IAC9B,gBAAgB,EAAE,MAAM,GAAG,IAAI,CAAC;IAChC,mBAAmB,EAAE,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI,KAAK,IAAI,CAAC;IACnD,oBAAoB,EAAE,OAAO,CAAC;IAC9B,kBAAkB,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC;IACxC,iBAAiB,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC;CACxC;AAID,UAAU,mBAAmB;IAC3B,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAC;IAC1B,WAAW,EAAE,kBAAkB,CAAC;IAChC,WAAW,EAAE,MAAM,CAAC;IACpB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,GAAG,CAAC,EAAE,MAAM,CAAC;CACd;AAID,wBAAgB,cAAc,CAAC,EAC7B,QAAQ,EACR,WAAW,EACX,WAAW,EACX,KAAK,EACL,GAAG,GACJ,EAAE,mBAAmB,GAAG,GAAG,CAAC,OAAO,CA4EnC;AAED,wBAAgB,SAAS,IAAI,iBAAiB,CAM7C"}
|
|
@@ -1,79 +0,0 @@
|
|
|
1
|
-
import { 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 React, { createContext, useContext, useMemo } from 'react';
|
|
15
|
-
import { useFetchUtilizationLabelValues, useLabelNames, useLabelValues } from '../MatchersInput';
|
|
16
|
-
import { useUtilizationLabels } from './UtilizationLabelsContext';
|
|
17
|
-
const LabelsContext = createContext(null);
|
|
18
|
-
// With there being the possibility of having utilization labels, we need to be able to determine whether the labels to be used are utilization labels or profiling data labels.
|
|
19
|
-
// This context is used to determine this.
|
|
20
|
-
export function LabelsProvider({ children, queryClient, profileType, start, end, }) {
|
|
21
|
-
const [currentLabelName, setCurrentLabelName] = React.useState(null);
|
|
22
|
-
const utilizationLabels = useUtilizationLabels();
|
|
23
|
-
const { result: labelNamesResponse, loading: isLabelNamesLoading, refetch: refetchLabelNames, } = useLabelNames(queryClient, profileType, start, end);
|
|
24
|
-
const labelNamesFromAPI = useMemo(() => {
|
|
25
|
-
return (labelNamesResponse.error === undefined || labelNamesResponse.error == null) &&
|
|
26
|
-
labelNamesResponse !== undefined &&
|
|
27
|
-
labelNamesResponse != null
|
|
28
|
-
? labelNamesResponse.response?.labelNames.filter(e => e !== '__name__') ?? []
|
|
29
|
-
: [];
|
|
30
|
-
}, [labelNamesResponse]);
|
|
31
|
-
const { result: labelValuesOriginal, loading: isLabelValuesLoading, refetch: refetchLabelValues, } = useLabelValues(queryClient, currentLabelName ?? '', profileType, start, end);
|
|
32
|
-
const utilizationLabelValues = useFetchUtilizationLabelValues(currentLabelName ?? '', utilizationLabels);
|
|
33
|
-
const shouldHandlePrefixes = utilizationLabels?.utilizationLabelNames !== undefined;
|
|
34
|
-
const labelNameMappings = useMemo(() => {
|
|
35
|
-
const names = utilizationLabels?.utilizationLabelNames ?? labelNamesFromAPI;
|
|
36
|
-
return names.map(name => ({
|
|
37
|
-
displayName: name.replace(/^(attributes\.|attributes_resource\.)/, ''),
|
|
38
|
-
fullName: name,
|
|
39
|
-
}));
|
|
40
|
-
}, [labelNamesFromAPI, utilizationLabels?.utilizationLabelNames]);
|
|
41
|
-
const labelNames = useMemo(() => {
|
|
42
|
-
return shouldHandlePrefixes ? labelNameMappings.map(m => m.displayName) : labelNamesFromAPI;
|
|
43
|
-
}, [labelNameMappings, labelNamesFromAPI, shouldHandlePrefixes]);
|
|
44
|
-
const labelValues = useMemo(() => {
|
|
45
|
-
return utilizationLabels?.utilizationFetchLabelValues !== undefined
|
|
46
|
-
? utilizationLabelValues
|
|
47
|
-
: labelValuesOriginal.response;
|
|
48
|
-
}, [labelValuesOriginal, utilizationLabelValues, utilizationLabels]);
|
|
49
|
-
const value = useMemo(() => ({
|
|
50
|
-
labelNames,
|
|
51
|
-
labelValues,
|
|
52
|
-
labelNameMappings,
|
|
53
|
-
isLabelNamesLoading,
|
|
54
|
-
isLabelValuesLoading,
|
|
55
|
-
currentLabelName,
|
|
56
|
-
setCurrentLabelName,
|
|
57
|
-
shouldHandlePrefixes,
|
|
58
|
-
refetchLabelValues,
|
|
59
|
-
refetchLabelNames,
|
|
60
|
-
}), [
|
|
61
|
-
labelNames,
|
|
62
|
-
labelValues,
|
|
63
|
-
labelNameMappings,
|
|
64
|
-
isLabelNamesLoading,
|
|
65
|
-
isLabelValuesLoading,
|
|
66
|
-
currentLabelName,
|
|
67
|
-
shouldHandlePrefixes,
|
|
68
|
-
refetchLabelValues,
|
|
69
|
-
refetchLabelNames,
|
|
70
|
-
]);
|
|
71
|
-
return _jsx(LabelsContext.Provider, { value: value, children: children });
|
|
72
|
-
}
|
|
73
|
-
export function useLabels() {
|
|
74
|
-
const context = useContext(LabelsContext);
|
|
75
|
-
if (context === null) {
|
|
76
|
-
throw new Error('useLabels must be used within a LabelsProvider');
|
|
77
|
-
}
|
|
78
|
-
return context;
|
|
79
|
-
}
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
import { QueryServiceClient } from '@parca/client';
|
|
2
|
-
import type { SelectItem } from '../SimpleMatchers/Select';
|
|
3
|
-
interface LabelNameSection {
|
|
4
|
-
type: string;
|
|
5
|
-
values: SelectItem[];
|
|
6
|
-
}
|
|
7
|
-
interface LabelContextValue {
|
|
8
|
-
labelNameOptions: LabelNameSection[];
|
|
9
|
-
isLoading: boolean;
|
|
10
|
-
error: Error | null;
|
|
11
|
-
refetchLabelValues: (labelName?: string) => Promise<void>;
|
|
12
|
-
refetchLabelNames: () => Promise<void>;
|
|
13
|
-
}
|
|
14
|
-
interface LabelProviderProps {
|
|
15
|
-
children: React.ReactNode;
|
|
16
|
-
queryClient: QueryServiceClient;
|
|
17
|
-
profileType: string;
|
|
18
|
-
labelNameFromMatchers: string[];
|
|
19
|
-
start?: number;
|
|
20
|
-
end?: number;
|
|
21
|
-
}
|
|
22
|
-
export declare function LabelProvider({ children, queryClient, profileType, labelNameFromMatchers, start, end, }: LabelProviderProps): JSX.Element;
|
|
23
|
-
export declare function useLabels(): LabelContextValue;
|
|
24
|
-
export {};
|
|
25
|
-
//# sourceMappingURL=SimpleMatchersLabelContext.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"SimpleMatchersLabelContext.d.ts","sourceRoot":"","sources":["../../src/contexts/SimpleMatchersLabelContext.tsx"],"names":[],"mappings":"AAiBA,OAAO,EAAC,kBAAkB,EAAC,MAAM,eAAe,CAAC;AAIjD,OAAO,KAAK,EAAC,UAAU,EAAC,MAAM,0BAA0B,CAAC;AAGzD,UAAU,gBAAgB;IACxB,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,UAAU,EAAE,CAAC;CACtB;AAED,UAAU,iBAAiB;IACzB,gBAAgB,EAAE,gBAAgB,EAAE,CAAC;IACrC,SAAS,EAAE,OAAO,CAAC;IACnB,KAAK,EAAE,KAAK,GAAG,IAAI,CAAC;IACpB,kBAAkB,EAAE,CAAC,SAAS,CAAC,EAAE,MAAM,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;IAC1D,iBAAiB,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC;CACxC;AAID,UAAU,kBAAkB;IAC1B,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAC;IAC1B,WAAW,EAAE,kBAAkB,CAAC;IAChC,WAAW,EAAE,MAAM,CAAC;IACpB,qBAAqB,EAAE,MAAM,EAAE,CAAC;IAChC,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,GAAG,CAAC,EAAE,MAAM,CAAC;CACd;AAKD,wBAAgB,aAAa,CAAC,EAC5B,QAAQ,EACR,WAAW,EACX,WAAW,EACX,qBAAqB,EACrB,KAAK,EACL,GAAG,GACJ,EAAE,kBAAkB,GAAG,GAAG,CAAC,OAAO,CA0HlC;AAED,wBAAgB,SAAS,IAAI,iBAAiB,CAM7C"}
|
|
@@ -1,115 +0,0 @@
|
|
|
1
|
-
import { 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 { createContext, useCallback, useContext, useMemo } from 'react';
|
|
15
|
-
import { useQueryClient } from '@tanstack/react-query';
|
|
16
|
-
import { useLabelNames } from '../MatchersInput';
|
|
17
|
-
import { transformLabelsForSelect } from '../SimpleMatchers';
|
|
18
|
-
import { useUtilizationLabels } from './UtilizationLabelsContext';
|
|
19
|
-
const LabelContext = createContext(null);
|
|
20
|
-
// With there being the possibility of having utilization labels, we need to be able to determine whether the labels to be used are utilization labels or profiling data labels.
|
|
21
|
-
// This context is used to determine this.
|
|
22
|
-
export function LabelProvider({ children, queryClient, profileType, labelNameFromMatchers, start, end, }) {
|
|
23
|
-
const reactQueryClient = useQueryClient();
|
|
24
|
-
const utilizationLabelResponse = useUtilizationLabels();
|
|
25
|
-
const { loading, result, refetch: refetchLabelNamesQuery, } = useLabelNames(queryClient, profileType, start, end);
|
|
26
|
-
const profileValues = useMemo(() => {
|
|
27
|
-
const profileLabelNames = result.error != null ? [] : result.response?.labelNames.filter(e => e !== '__name__') ?? [];
|
|
28
|
-
const uniqueProfileLabelNames = Array.from(new Set(profileLabelNames));
|
|
29
|
-
return {
|
|
30
|
-
labelNameOptions: uniqueProfileLabelNames,
|
|
31
|
-
isLoading: loading,
|
|
32
|
-
error: result.error ?? null,
|
|
33
|
-
};
|
|
34
|
-
}, [result, loading]);
|
|
35
|
-
const utilizationValues = useMemo(() => {
|
|
36
|
-
if (utilizationLabelResponse?.utilizationLabelNamesLoading === true) {
|
|
37
|
-
return { labelNameOptions: [], isLoading: true };
|
|
38
|
-
}
|
|
39
|
-
if (utilizationLabelResponse == null ||
|
|
40
|
-
utilizationLabelResponse.utilizationLabelNames == null) {
|
|
41
|
-
return { labelNameOptions: [], isLoading: false };
|
|
42
|
-
}
|
|
43
|
-
const uniqueUtilizationLabelNames = Array.from(new Set(utilizationLabelResponse.utilizationLabelNames));
|
|
44
|
-
return {
|
|
45
|
-
labelNameOptions: uniqueUtilizationLabelNames,
|
|
46
|
-
isLoading: utilizationLabelResponse.utilizationLabelNamesLoading,
|
|
47
|
-
};
|
|
48
|
-
}, [utilizationLabelResponse]);
|
|
49
|
-
const value = useMemo(() => {
|
|
50
|
-
if (profileValues.error != null ||
|
|
51
|
-
profileValues.isLoading ||
|
|
52
|
-
utilizationValues.isLoading === true) {
|
|
53
|
-
return {
|
|
54
|
-
labelNameOptions: [],
|
|
55
|
-
isLoading: (profileValues.isLoading || utilizationValues.isLoading) ?? false,
|
|
56
|
-
error: profileValues.error,
|
|
57
|
-
};
|
|
58
|
-
}
|
|
59
|
-
let nonMatchingLabels = labelNameFromMatchers.filter(label => !utilizationValues.labelNameOptions.includes(label));
|
|
60
|
-
nonMatchingLabels = nonMatchingLabels.filter(label => !profileValues.labelNameOptions.includes(label));
|
|
61
|
-
const nonMatchingLabelsSet = Array.from(new Set(nonMatchingLabels));
|
|
62
|
-
const options = [
|
|
63
|
-
{
|
|
64
|
-
type: 'cpu',
|
|
65
|
-
values: transformLabelsForSelect(profileValues.labelNameOptions),
|
|
66
|
-
},
|
|
67
|
-
{
|
|
68
|
-
type: 'gpu',
|
|
69
|
-
values: transformLabelsForSelect(utilizationValues.labelNameOptions),
|
|
70
|
-
},
|
|
71
|
-
{
|
|
72
|
-
type: '',
|
|
73
|
-
values: transformLabelsForSelect(nonMatchingLabelsSet),
|
|
74
|
-
},
|
|
75
|
-
];
|
|
76
|
-
return {
|
|
77
|
-
labelNameOptions: options.filter(e => e.values.length > 0),
|
|
78
|
-
isLoading: false,
|
|
79
|
-
error: null,
|
|
80
|
-
};
|
|
81
|
-
}, [profileValues, utilizationValues, labelNameFromMatchers]);
|
|
82
|
-
const refetchLabelValues = useCallback(async (labelName) => {
|
|
83
|
-
await reactQueryClient.refetchQueries({
|
|
84
|
-
predicate: query => {
|
|
85
|
-
const key = query.queryKey;
|
|
86
|
-
const matchesStructure = Array.isArray(key) &&
|
|
87
|
-
key.length === 4 &&
|
|
88
|
-
typeof key[0] === 'string' &&
|
|
89
|
-
key[1] === profileType;
|
|
90
|
-
if (!matchesStructure)
|
|
91
|
-
return false;
|
|
92
|
-
if (labelName !== undefined && labelName !== '') {
|
|
93
|
-
return key[0] === labelName;
|
|
94
|
-
}
|
|
95
|
-
return true;
|
|
96
|
-
},
|
|
97
|
-
});
|
|
98
|
-
}, [reactQueryClient, profileType]);
|
|
99
|
-
const refetchLabelNames = useCallback(async () => {
|
|
100
|
-
await refetchLabelNamesQuery();
|
|
101
|
-
}, [refetchLabelNamesQuery]);
|
|
102
|
-
const contextValue = useMemo(() => ({
|
|
103
|
-
...value,
|
|
104
|
-
refetchLabelValues,
|
|
105
|
-
refetchLabelNames,
|
|
106
|
-
}), [value, refetchLabelValues, refetchLabelNames]);
|
|
107
|
-
return _jsx(LabelContext.Provider, { value: contextValue, children: children });
|
|
108
|
-
}
|
|
109
|
-
export function useLabels() {
|
|
110
|
-
const context = useContext(LabelContext);
|
|
111
|
-
if (context === null) {
|
|
112
|
-
throw new Error('useLabels must be used within a LabelProvider');
|
|
113
|
-
}
|
|
114
|
-
return context;
|
|
115
|
-
}
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import { ReactNode } from 'react';
|
|
2
|
-
export interface UtilizationLabels {
|
|
3
|
-
utilizationLabelNames?: string[];
|
|
4
|
-
utilizationFetchLabelValues?: (key: string) => Promise<string[]>;
|
|
5
|
-
utilizationLabelValues?: string[];
|
|
6
|
-
utilizationLabelNamesLoading?: boolean;
|
|
7
|
-
}
|
|
8
|
-
interface UtilizationLabelsProviderProps {
|
|
9
|
-
children: ReactNode;
|
|
10
|
-
value: UtilizationLabels | undefined;
|
|
11
|
-
}
|
|
12
|
-
export declare function UtilizationLabelsProvider({ children, value, }: UtilizationLabelsProviderProps): JSX.Element;
|
|
13
|
-
export declare function useUtilizationLabels(): UtilizationLabels | undefined;
|
|
14
|
-
export {};
|
|
15
|
-
//# sourceMappingURL=UtilizationLabelsContext.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"UtilizationLabelsContext.d.ts","sourceRoot":"","sources":["../../src/contexts/UtilizationLabelsContext.tsx"],"names":[],"mappings":"AAaA,OAAO,EAAC,SAAS,EAA4B,MAAM,OAAO,CAAC;AAE3D,MAAM,WAAW,iBAAiB;IAChC,qBAAqB,CAAC,EAAE,MAAM,EAAE,CAAC;IACjC,2BAA2B,CAAC,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,OAAO,CAAC,MAAM,EAAE,CAAC,CAAC;IACjE,sBAAsB,CAAC,EAAE,MAAM,EAAE,CAAC;IAClC,4BAA4B,CAAC,EAAE,OAAO,CAAC;CACxC;AAED,UAAU,8BAA8B;IACtC,QAAQ,EAAE,SAAS,CAAC;IACpB,KAAK,EAAE,iBAAiB,GAAG,SAAS,CAAC;CACtC;AAOD,wBAAgB,yBAAyB,CAAC,EACxC,QAAQ,EACR,KAAK,GACN,EAAE,8BAA8B,GAAG,GAAG,CAAC,OAAO,CAI9C;AAED,wBAAgB,oBAAoB,IAAI,iBAAiB,GAAG,SAAS,CAGpE"}
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
import { 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 { createContext, useContext } from 'react';
|
|
15
|
-
// The UtilizationLabelsContext is used to store the utilization label names and values. It also
|
|
16
|
-
// contains the function utilizationFetchLabelValues to fetch the utilization label values.
|
|
17
|
-
// This context was created so as to avoid props drilling.
|
|
18
|
-
const UtilizationLabelsContext = createContext(undefined);
|
|
19
|
-
export function UtilizationLabelsProvider({ children, value, }) {
|
|
20
|
-
return (_jsx(UtilizationLabelsContext.Provider, { value: value, children: children }));
|
|
21
|
-
}
|
|
22
|
-
export function useUtilizationLabels() {
|
|
23
|
-
const context = useContext(UtilizationLabelsContext);
|
|
24
|
-
return context;
|
|
25
|
-
}
|