@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.
- package/CHANGELOG.md +6 -0
- package/dist/MatchersInput/index.d.ts +34 -2
- package/dist/MatchersInput/index.d.ts.map +1 -1
- package/dist/MatchersInput/index.js +91 -14
- package/dist/MetricsGraph/UtilizationMetrics/Throughput.d.ts +29 -0
- package/dist/MetricsGraph/UtilizationMetrics/Throughput.d.ts.map +1 -0
- package/dist/MetricsGraph/UtilizationMetrics/Throughput.js +175 -0
- package/dist/MetricsGraph/UtilizationMetrics/index.d.ts +28 -0
- package/dist/MetricsGraph/UtilizationMetrics/index.d.ts.map +1 -0
- package/dist/MetricsGraph/UtilizationMetrics/index.js +186 -0
- package/dist/MetricsGraph/index.d.ts.map +1 -1
- package/dist/MetricsGraph/index.js +1 -13
- package/dist/ProfileMetricsGraph/index.d.ts.map +1 -1
- package/dist/ProfileMetricsGraph/index.js +29 -6
- package/dist/ProfileSelector/MetricsGraphSection.d.ts +9 -2
- package/dist/ProfileSelector/MetricsGraphSection.d.ts.map +1 -1
- package/dist/ProfileSelector/MetricsGraphSection.js +38 -3
- package/dist/ProfileSelector/QueryControls.d.ts +43 -0
- package/dist/ProfileSelector/QueryControls.d.ts.map +1 -0
- package/dist/{QueryControls/index.js → ProfileSelector/QueryControls.js} +13 -16
- package/dist/ProfileSelector/index.d.ts +29 -1
- package/dist/ProfileSelector/index.d.ts.map +1 -1
- package/dist/ProfileSelector/index.js +9 -12
- package/dist/SimpleMatchers/Select.js +1 -1
- package/dist/SimpleMatchers/index.d.ts +11 -2
- package/dist/SimpleMatchers/index.d.ts.map +1 -1
- package/dist/SimpleMatchers/index.js +45 -34
- package/dist/ViewMatchers/index.d.ts +9 -0
- package/dist/ViewMatchers/index.d.ts.map +1 -1
- package/dist/ViewMatchers/index.js +12 -20
- package/dist/contexts/MatchersInputLabelsContext.d.ts +29 -0
- package/dist/contexts/MatchersInputLabelsContext.d.ts.map +1 -0
- package/dist/contexts/MatchersInputLabelsContext.js +79 -0
- package/dist/contexts/SimpleMatchersLabelContext.d.ts +25 -0
- package/dist/contexts/SimpleMatchersLabelContext.d.ts.map +1 -0
- package/dist/contexts/SimpleMatchersLabelContext.js +115 -0
- package/dist/contexts/UtilizationLabelsContext.d.ts +15 -0
- package/dist/contexts/UtilizationLabelsContext.d.ts.map +1 -0
- package/dist/contexts/UtilizationLabelsContext.js +25 -0
- package/dist/hooks/useQueryState.d.ts +0 -2
- package/dist/hooks/useQueryState.d.ts.map +1 -1
- package/dist/hooks/useQueryState.js +0 -18
- package/dist/index.d.ts +3 -9
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3 -9
- package/dist/styles.css +1 -1
- package/dist/useSumBy.js +1 -1
- package/package.json +2 -2
- package/src/MatchersInput/index.tsx +163 -17
- package/src/MetricsGraph/UtilizationMetrics/Throughput.tsx +405 -0
- package/src/MetricsGraph/UtilizationMetrics/index.tsx +426 -0
- package/src/MetricsGraph/index.tsx +1 -17
- package/src/ProfileMetricsGraph/index.tsx +98 -17
- package/src/ProfileSelector/MetricsGraphSection.tsx +115 -14
- package/src/{QueryControls/index.tsx → ProfileSelector/QueryControls.tsx} +84 -66
- package/src/ProfileSelector/index.tsx +109 -106
- package/src/SimpleMatchers/Select.tsx +1 -1
- package/src/SimpleMatchers/index.tsx +85 -46
- package/src/ViewMatchers/index.tsx +30 -22
- package/src/contexts/MatchersInputLabelsContext.tsx +141 -0
- package/src/contexts/SimpleMatchersLabelContext.tsx +189 -0
- package/src/contexts/UtilizationLabelsContext.tsx +45 -0
- package/src/hooks/useQueryState.ts +0 -25
- package/src/index.tsx +3 -29
- package/src/useSumBy.ts +1 -1
- package/dist/QueryControls/index.d.ts +0 -42
- package/dist/QueryControls/index.d.ts.map +0 -1
- package/dist/contexts/LabelsQueryProvider.d.ts +0 -35
- package/dist/contexts/LabelsQueryProvider.d.ts.map +0 -1
- package/dist/contexts/LabelsQueryProvider.js +0 -70
- package/dist/contexts/UnifiedLabelsContext.d.ts +0 -37
- package/dist/contexts/UnifiedLabelsContext.d.ts.map +0 -1
- package/dist/contexts/UnifiedLabelsContext.js +0 -88
- package/dist/contexts/utils.d.ts +0 -10
- package/dist/contexts/utils.d.ts.map +0 -1
- package/dist/contexts/utils.js +0 -31
- package/dist/hooks/useLabels.d.ts +0 -23
- package/dist/hooks/useLabels.d.ts.map +0 -1
- package/dist/hooks/useLabels.js +0 -75
- package/src/contexts/LabelsQueryProvider.tsx +0 -142
- package/src/contexts/UnifiedLabelsContext.tsx +0 -155
- package/src/contexts/utils.ts +0 -43
- package/src/hooks/useLabels.ts +0 -121
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
// Copyright 2022 The Parca Authors
|
|
2
|
+
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
3
|
+
// you may not use this file except in compliance with the License.
|
|
4
|
+
// You may obtain a copy of the License at
|
|
5
|
+
//
|
|
6
|
+
// http://www.apache.org/licenses/LICENSE-2.0
|
|
7
|
+
//
|
|
8
|
+
// Unless required by applicable law or agreed to in writing, software
|
|
9
|
+
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
10
|
+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
11
|
+
// See the License for the specific language governing permissions and
|
|
12
|
+
// limitations under the License.
|
|
13
|
+
|
|
14
|
+
import {ReactNode, createContext, useContext} from 'react';
|
|
15
|
+
|
|
16
|
+
export interface UtilizationLabels {
|
|
17
|
+
utilizationLabelNames?: string[];
|
|
18
|
+
utilizationFetchLabelValues?: (key: string) => Promise<string[]>;
|
|
19
|
+
utilizationLabelValues?: string[];
|
|
20
|
+
utilizationLabelNamesLoading?: boolean;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
interface UtilizationLabelsProviderProps {
|
|
24
|
+
children: ReactNode;
|
|
25
|
+
value: UtilizationLabels | undefined;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
// The UtilizationLabelsContext is used to store the utilization label names and values. It also
|
|
29
|
+
// contains the function utilizationFetchLabelValues to fetch the utilization label values.
|
|
30
|
+
// This context was created so as to avoid props drilling.
|
|
31
|
+
const UtilizationLabelsContext = createContext<UtilizationLabels | undefined>(undefined);
|
|
32
|
+
|
|
33
|
+
export function UtilizationLabelsProvider({
|
|
34
|
+
children,
|
|
35
|
+
value,
|
|
36
|
+
}: UtilizationLabelsProviderProps): JSX.Element {
|
|
37
|
+
return (
|
|
38
|
+
<UtilizationLabelsContext.Provider value={value}>{children}</UtilizationLabelsContext.Provider>
|
|
39
|
+
);
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
export function useUtilizationLabels(): UtilizationLabels | undefined {
|
|
43
|
+
const context = useContext(UtilizationLabelsContext);
|
|
44
|
+
return context;
|
|
45
|
+
}
|
|
@@ -58,12 +58,6 @@ interface UseQueryStateReturn {
|
|
|
58
58
|
|
|
59
59
|
// Loading state for sumBy computation
|
|
60
60
|
sumByLoading: boolean;
|
|
61
|
-
|
|
62
|
-
// draft parsed query
|
|
63
|
-
draftParsedQuery: Query | null;
|
|
64
|
-
|
|
65
|
-
// parsed query
|
|
66
|
-
parsedQuery: Query | null;
|
|
67
61
|
}
|
|
68
62
|
|
|
69
63
|
export const useQueryState = (options: UseQueryStateOptions = {}): UseQueryStateReturn => {
|
|
@@ -396,22 +390,6 @@ export const useQueryState = (options: UseQueryStateOptions = {}): UseQueryState
|
|
|
396
390
|
[batchUpdates, setSelectionParam, setMergeFromState, setMergeToState]
|
|
397
391
|
);
|
|
398
392
|
|
|
399
|
-
const draftParsedQuery = useMemo(() => {
|
|
400
|
-
try {
|
|
401
|
-
return Query.parse(draftSelection.expression ?? '');
|
|
402
|
-
} catch {
|
|
403
|
-
return Query.parse('');
|
|
404
|
-
}
|
|
405
|
-
}, [draftSelection.expression]);
|
|
406
|
-
|
|
407
|
-
const parsedQuery = useMemo(() => {
|
|
408
|
-
try {
|
|
409
|
-
return Query.parse(querySelection.expression ?? '');
|
|
410
|
-
} catch {
|
|
411
|
-
return Query.parse('');
|
|
412
|
-
}
|
|
413
|
-
}, [querySelection.expression]);
|
|
414
|
-
|
|
415
393
|
return {
|
|
416
394
|
// Current committed state
|
|
417
395
|
querySelection,
|
|
@@ -436,8 +414,5 @@ export const useQueryState = (options: UseQueryStateOptions = {}): UseQueryState
|
|
|
436
414
|
|
|
437
415
|
// Loading state
|
|
438
416
|
sumByLoading: sumBySelectionLoading,
|
|
439
|
-
|
|
440
|
-
draftParsedQuery,
|
|
441
|
-
parsedQuery,
|
|
442
417
|
};
|
|
443
418
|
};
|
package/src/index.tsx
CHANGED
|
@@ -13,21 +13,11 @@
|
|
|
13
13
|
|
|
14
14
|
import type {ParamPreferences} from '@parca/components';
|
|
15
15
|
|
|
16
|
-
import
|
|
16
|
+
import {useLabelNames} from './MatchersInput';
|
|
17
17
|
import ProfileExplorer from './ProfileExplorer';
|
|
18
18
|
import ProfileTypeSelector from './ProfileTypeSelector';
|
|
19
|
-
import
|
|
19
|
+
import SelectWithRefresh from './SelectWithRefresh';
|
|
20
20
|
import CustomSelect from './SimpleMatchers/Select';
|
|
21
|
-
import {
|
|
22
|
-
LabelsQueryProvider,
|
|
23
|
-
useLabelsQueryProvider,
|
|
24
|
-
type LabelsQueryProviderContextType,
|
|
25
|
-
} from './contexts/LabelsQueryProvider';
|
|
26
|
-
import {UnifiedLabelsProvider, useUnifiedLabels} from './contexts/UnifiedLabelsContext';
|
|
27
|
-
import {useLabelNames} from './hooks/useLabels';
|
|
28
|
-
import {useQueryState} from './hooks/useQueryState';
|
|
29
|
-
|
|
30
|
-
export {useMetricsGraphDimensions} from './MetricsGraph/useMetricsGraphDimensions';
|
|
31
21
|
|
|
32
22
|
export * from './ProfileFlameGraph';
|
|
33
23
|
export * from './ProfileSource';
|
|
@@ -42,7 +32,6 @@ export * from './ProfileTypeSelector';
|
|
|
42
32
|
export * from './SourceView';
|
|
43
33
|
export * from './ProfileMetricsGraph';
|
|
44
34
|
export * from './useSumBy';
|
|
45
|
-
export {QueryControls} from './QueryControls';
|
|
46
35
|
|
|
47
36
|
export {default as ProfileFilters} from './ProfileView/components/ProfileFilters';
|
|
48
37
|
export {useProfileFiltersUrlState} from './ProfileView/components/ProfileFilters/useProfileFiltersUrlState';
|
|
@@ -54,19 +43,4 @@ export const DEFAULT_PROFILE_EXPLORER_PARAM_VALUES: ParamPreferences = {
|
|
|
54
43
|
},
|
|
55
44
|
};
|
|
56
45
|
|
|
57
|
-
export {
|
|
58
|
-
ProfileExplorer,
|
|
59
|
-
ProfileTypeSelector,
|
|
60
|
-
CustomSelect,
|
|
61
|
-
SelectWithRefresh,
|
|
62
|
-
useLabelNames,
|
|
63
|
-
MetricsGraph,
|
|
64
|
-
type ContextMenuItemOrSubmenu,
|
|
65
|
-
type Series,
|
|
66
|
-
LabelsQueryProvider,
|
|
67
|
-
useLabelsQueryProvider,
|
|
68
|
-
UnifiedLabelsProvider,
|
|
69
|
-
useUnifiedLabels,
|
|
70
|
-
useQueryState,
|
|
71
|
-
type LabelsQueryProviderContextType,
|
|
72
|
-
};
|
|
46
|
+
export {ProfileExplorer, ProfileTypeSelector, CustomSelect, SelectWithRefresh, useLabelNames};
|
package/src/useSumBy.ts
CHANGED
|
@@ -17,7 +17,7 @@ import {QueryServiceClient} from '@parca/client';
|
|
|
17
17
|
import {DateTimeRange} from '@parca/components';
|
|
18
18
|
import {ProfileType} from '@parca/parser';
|
|
19
19
|
|
|
20
|
-
import {useLabelNames} from './
|
|
20
|
+
import {useLabelNames} from './MatchersInput/index';
|
|
21
21
|
|
|
22
22
|
export const DEFAULT_EMPTY_SUM_BY: string[] = [];
|
|
23
23
|
|
|
@@ -1,42 +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
|
-
queryClient: QueryServiceClient;
|
|
8
|
-
query: Query;
|
|
9
|
-
profileType: string | ProfileType;
|
|
10
|
-
timeRangeSelection: DateTimeRange;
|
|
11
|
-
setTimeRangeSelection: (range: DateTimeRange) => void;
|
|
12
|
-
setMatchersString: (matchers: string) => void;
|
|
13
|
-
setQueryExpression: (updateTs?: boolean) => void;
|
|
14
|
-
searchDisabled: boolean;
|
|
15
|
-
showProfileTypeSelector?: boolean;
|
|
16
|
-
showSumBySelector?: boolean;
|
|
17
|
-
showAdvancedMode?: boolean;
|
|
18
|
-
disableExplorativeQuerying?: boolean;
|
|
19
|
-
profileTypesData?: ProfileTypesResponse;
|
|
20
|
-
profileTypesLoading?: boolean;
|
|
21
|
-
selectedProfileName?: string;
|
|
22
|
-
setProfileName?: (name: string | undefined) => void;
|
|
23
|
-
profileTypesError?: RpcError;
|
|
24
|
-
viewComponent?: {
|
|
25
|
-
disableProfileTypesDropdown?: boolean;
|
|
26
|
-
disableExplorativeQuerying?: boolean;
|
|
27
|
-
labelnames?: string[];
|
|
28
|
-
createViewComponent?: React.ReactNode;
|
|
29
|
-
};
|
|
30
|
-
setQueryBrowserMode?: (mode: string) => void;
|
|
31
|
-
advancedModeForQueryBrowser?: boolean;
|
|
32
|
-
setAdvancedModeForQueryBrowser?: (mode: boolean) => void;
|
|
33
|
-
queryBrowserRef?: React.RefObject<HTMLDivElement>;
|
|
34
|
-
labels?: string[];
|
|
35
|
-
sumBySelection?: string[];
|
|
36
|
-
sumBySelectionLoading?: boolean;
|
|
37
|
-
setUserSumBySelection?: (sumBy: string[]) => void;
|
|
38
|
-
sumByRef?: React.RefObject<SelectInstance>;
|
|
39
|
-
}
|
|
40
|
-
export declare function QueryControls({ profileType, timeRangeSelection, setTimeRangeSelection, setQueryExpression, searchDisabled, showProfileTypeSelector, showSumBySelector, showAdvancedMode, profileTypesData, profileTypesLoading, selectedProfileName, setProfileName, profileTypesError, viewComponent, setQueryBrowserMode, advancedModeForQueryBrowser, setAdvancedModeForQueryBrowser, queryBrowserRef, labels, sumBySelection, sumBySelectionLoading, setUserSumBySelection, sumByRef, queryClient, }: QueryControlsProps): JSX.Element;
|
|
41
|
-
export {};
|
|
42
|
-
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/QueryControls/index.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;AAejD,UAAU,kBAAkB;IAC1B,WAAW,EAAE,kBAAkB,CAAC;IAChC,KAAK,EAAE,KAAK,CAAC;IACb,WAAW,EAAE,MAAM,GAAG,WAAW,CAAC;IAClC,kBAAkB,EAAE,aAAa,CAAC;IAClC,qBAAqB,EAAE,CAAC,KAAK,EAAE,aAAa,KAAK,IAAI,CAAC;IACtD,iBAAiB,EAAE,CAAC,QAAQ,EAAE,MAAM,KAAK,IAAI,CAAC;IAC9C,kBAAkB,EAAE,CAAC,QAAQ,CAAC,EAAE,OAAO,KAAK,IAAI,CAAC;IACjD,cAAc,EAAE,OAAO,CAAC;IACxB,uBAAuB,CAAC,EAAE,OAAO,CAAC;IAClC,iBAAiB,CAAC,EAAE,OAAO,CAAC;IAC5B,gBAAgB,CAAC,EAAE,OAAO,CAAC;IAC3B,0BAA0B,CAAC,EAAE,OAAO,CAAC;IACrC,gBAAgB,CAAC,EAAE,oBAAoB,CAAC;IACxC,mBAAmB,CAAC,EAAE,OAAO,CAAC;IAC9B,mBAAmB,CAAC,EAAE,MAAM,CAAC;IAC7B,cAAc,CAAC,EAAE,CAAC,IAAI,EAAE,MAAM,GAAG,SAAS,KAAK,IAAI,CAAC;IACpD,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,mBAAmB,CAAC,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,CAAC;IAC7C,2BAA2B,CAAC,EAAE,OAAO,CAAC;IACtC,8BAA8B,CAAC,EAAE,CAAC,IAAI,EAAE,OAAO,KAAK,IAAI,CAAC;IACzD,eAAe,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC,cAAc,CAAC,CAAC;IAClD,MAAM,CAAC,EAAE,MAAM,EAAE,CAAC;IAClB,cAAc,CAAC,EAAE,MAAM,EAAE,CAAC;IAC1B,qBAAqB,CAAC,EAAE,OAAO,CAAC;IAChC,qBAAqB,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,EAAE,KAAK,IAAI,CAAC;IAClD,QAAQ,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC,cAAc,CAAC,CAAC;CAC5C;AAED,wBAAgB,aAAa,CAAC,EAC5B,WAAW,EACX,kBAAkB,EAClB,qBAAqB,EACrB,kBAAkB,EAClB,cAAc,EACd,uBAA+B,EAC/B,iBAAyB,EACzB,gBAAuB,EACvB,gBAAgB,EAChB,mBAA2B,EAC3B,mBAAmB,EACnB,cAAc,EACd,iBAAiB,EACjB,aAAa,EACb,mBAAmB,EACnB,2BAAmC,EACnC,8BAA8B,EAC9B,eAAe,EACf,MAAW,EACX,cAAmB,EACnB,qBAA6B,EAC7B,qBAAqB,EACrB,QAAQ,EACR,WAAW,GACZ,EAAE,kBAAkB,GAAG,GAAG,CAAC,OAAO,CAmLlC"}
|
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
import { QueryServiceClient } from '@parca/client';
|
|
2
|
-
import { Query } from '@parca/parser';
|
|
3
|
-
export interface LabelsQueryProviderContextType {
|
|
4
|
-
isLabelNamesLoading: boolean;
|
|
5
|
-
isLabelValuesLoading: boolean;
|
|
6
|
-
currentLabelName: string | null;
|
|
7
|
-
setCurrentLabelName: (name: string | null) => void;
|
|
8
|
-
refetchLabelValues: () => Promise<void>;
|
|
9
|
-
refetchLabelNames: () => Promise<void>;
|
|
10
|
-
labelNames: string[];
|
|
11
|
-
labelValues: string[];
|
|
12
|
-
queryClient: QueryServiceClient;
|
|
13
|
-
setMatchersString: (arg: string) => void;
|
|
14
|
-
runQuery: () => void;
|
|
15
|
-
currentQuery: Query;
|
|
16
|
-
profileType: string;
|
|
17
|
-
start?: number;
|
|
18
|
-
end?: number;
|
|
19
|
-
suffix?: '_a' | '_b';
|
|
20
|
-
}
|
|
21
|
-
interface LabelsQueryProviderProps {
|
|
22
|
-
children: React.ReactNode;
|
|
23
|
-
queryClient: QueryServiceClient;
|
|
24
|
-
setMatchersString: (arg: string) => void;
|
|
25
|
-
runQuery: () => void;
|
|
26
|
-
currentQuery: Query;
|
|
27
|
-
profileType: string;
|
|
28
|
-
start?: number;
|
|
29
|
-
end?: number;
|
|
30
|
-
suffix?: '_a' | '_b';
|
|
31
|
-
}
|
|
32
|
-
export declare function LabelsQueryProvider({ children, queryClient, setMatchersString, runQuery, currentQuery, profileType, start, end, suffix, }: LabelsQueryProviderProps): JSX.Element;
|
|
33
|
-
export declare function useLabelsQueryProvider(): LabelsQueryProviderContextType;
|
|
34
|
-
export {};
|
|
35
|
-
//# sourceMappingURL=LabelsQueryProvider.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"LabelsQueryProvider.d.ts","sourceRoot":"","sources":["../../src/contexts/LabelsQueryProvider.tsx"],"names":[],"mappings":"AAoCA,OAAO,EAAC,kBAAkB,EAAC,MAAM,eAAe,CAAC;AACjD,OAAO,EAAC,KAAK,EAAC,MAAM,eAAe,CAAC;AAKpC,MAAM,WAAW,8BAA8B;IAC7C,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,kBAAkB,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC;IACxC,iBAAiB,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC;IAEvC,UAAU,EAAE,MAAM,EAAE,CAAC;IACrB,WAAW,EAAE,MAAM,EAAE,CAAC;IAEtB,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,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,GAAG,CAAC,EAAE,MAAM,CAAC;IAEb,MAAM,CAAC,EAAE,IAAI,GAAG,IAAI,CAAC;CACtB;AAID,UAAU,wBAAwB;IAChC,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAC;IAE1B,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,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,GAAG,CAAC,EAAE,MAAM,CAAC;IAEb,MAAM,CAAC,EAAE,IAAI,GAAG,IAAI,CAAC;CACtB;AAED,wBAAgB,mBAAmB,CAAC,EAClC,QAAQ,EACR,WAAW,EACX,iBAAiB,EACjB,QAAQ,EACR,YAAY,EACZ,WAAW,EACX,KAAK,EACL,GAAG,EACH,MAAM,GACP,EAAE,wBAAwB,GAAG,GAAG,CAAC,OAAO,CA2CxC;AAED,wBAAgB,sBAAsB,IAAI,8BAA8B,CAMvE"}
|
|
@@ -1,70 +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
|
-
/**
|
|
15
|
-
* LabelsQueryProvider - Data Fetching Layer
|
|
16
|
-
*
|
|
17
|
-
* This context provider is responsible for fetching label data from the Parca API
|
|
18
|
-
* and making it available to child components through React Context.
|
|
19
|
-
*
|
|
20
|
-
* Purpose:
|
|
21
|
-
* - Fetches label names and values from the Parca profiling API
|
|
22
|
-
* - Manages loading states for label data
|
|
23
|
-
* - Provides refetch functions for manual data refresh
|
|
24
|
-
* - Acts as the primary data source in the label provider architecture
|
|
25
|
-
*
|
|
26
|
-
* Architecture Pattern:
|
|
27
|
-
* This is the first layer in a three-layer architecture:
|
|
28
|
-
* 1. LabelsQueryProvider (this file) - Fetches data from API
|
|
29
|
-
* 2. LabelsSource (in ProfileSelector) - Transforms/merges data
|
|
30
|
-
* 3. UnifiedLabelsProvider - Provides unified interface to UI components
|
|
31
|
-
*
|
|
32
|
-
* Consumer Hook: useLabelsQueryProvider()
|
|
33
|
-
*/
|
|
34
|
-
import { createContext, useContext, useState } from 'react';
|
|
35
|
-
import { useLabelNames, useLabelValues } from '../hooks/useLabels';
|
|
36
|
-
import { useExtractedLabelNames } from './utils';
|
|
37
|
-
const LabelsQueryProviderContext = createContext(null);
|
|
38
|
-
export function LabelsQueryProvider({ children, queryClient, setMatchersString, runQuery, currentQuery, profileType, start, end, suffix, }) {
|
|
39
|
-
const [currentLabelName, setCurrentLabelName] = useState(null);
|
|
40
|
-
const { result: labelNamesResponse, loading: isLabelNamesLoading, refetch: labelNamesRefetch, } = useLabelNames(queryClient, profileType, start, end);
|
|
41
|
-
const labelNames = useExtractedLabelNames(labelNamesResponse.response, labelNamesResponse.error);
|
|
42
|
-
const { result: labelValuesOriginal, loading: isLabelValuesLoading, refetch: labelValuesRefetch, } = useLabelValues(queryClient, currentLabelName ?? '', profileType, start, end);
|
|
43
|
-
const labelValues = labelValuesOriginal.response;
|
|
44
|
-
const value = {
|
|
45
|
-
labelNames,
|
|
46
|
-
labelValues,
|
|
47
|
-
isLabelNamesLoading,
|
|
48
|
-
isLabelValuesLoading,
|
|
49
|
-
refetchLabelValues: labelValuesRefetch,
|
|
50
|
-
refetchLabelNames: labelNamesRefetch,
|
|
51
|
-
queryClient,
|
|
52
|
-
setMatchersString,
|
|
53
|
-
runQuery,
|
|
54
|
-
currentQuery,
|
|
55
|
-
profileType,
|
|
56
|
-
start,
|
|
57
|
-
end,
|
|
58
|
-
setCurrentLabelName,
|
|
59
|
-
currentLabelName,
|
|
60
|
-
suffix,
|
|
61
|
-
};
|
|
62
|
-
return (_jsx(LabelsQueryProviderContext.Provider, { value: value, children: children }));
|
|
63
|
-
}
|
|
64
|
-
export function useLabelsQueryProvider() {
|
|
65
|
-
const context = useContext(LabelsQueryProviderContext);
|
|
66
|
-
if (context === null) {
|
|
67
|
-
throw new Error('useLabelsQueryProvider must be used within a LabelsQueryProvider');
|
|
68
|
-
}
|
|
69
|
-
return context;
|
|
70
|
-
}
|
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
import type { SelectItem } from '../SimpleMatchers/Select';
|
|
2
|
-
import { type LabelNameMapping } from './utils';
|
|
3
|
-
interface LabelNameSection {
|
|
4
|
-
type: string;
|
|
5
|
-
values: SelectItem[];
|
|
6
|
-
}
|
|
7
|
-
interface UnifiedLabelsContextType {
|
|
8
|
-
labelNameMappingsForMatchersInput: LabelNameMapping[];
|
|
9
|
-
labelNameMappingsForSimpleMatchers: LabelNameSection[];
|
|
10
|
-
labelNames: string[];
|
|
11
|
-
labelValues: string[];
|
|
12
|
-
isLabelNamesLoading: boolean;
|
|
13
|
-
isLabelValuesLoading: boolean;
|
|
14
|
-
currentLabelName: string | null;
|
|
15
|
-
setCurrentLabelName: (name: string | null) => void;
|
|
16
|
-
shouldHandlePrefixes: boolean;
|
|
17
|
-
refetchLabelValues: () => Promise<void>;
|
|
18
|
-
refetchLabelNames: () => Promise<void>;
|
|
19
|
-
labelNameFromMatchers: string[];
|
|
20
|
-
suffix?: '_a' | '_b';
|
|
21
|
-
}
|
|
22
|
-
interface UnifiedLabelsProviderProps {
|
|
23
|
-
children: React.ReactNode;
|
|
24
|
-
currentLabelName: string | null;
|
|
25
|
-
setCurrentLabelName: (name: string | null) => void;
|
|
26
|
-
labelNames: string[];
|
|
27
|
-
labelValues: string[];
|
|
28
|
-
isLabelNamesLoading: boolean;
|
|
29
|
-
isLabelValuesLoading: boolean;
|
|
30
|
-
refetchLabelValues: () => Promise<void>;
|
|
31
|
-
refetchLabelNames: () => Promise<void>;
|
|
32
|
-
suffix?: '_a' | '_b';
|
|
33
|
-
}
|
|
34
|
-
export declare function UnifiedLabelsProvider({ children, labelNames, isLabelNamesLoading, isLabelValuesLoading, refetchLabelValues, refetchLabelNames, currentLabelName, setCurrentLabelName, labelValues, suffix, }: UnifiedLabelsProviderProps): JSX.Element;
|
|
35
|
-
export declare function useUnifiedLabels(): UnifiedLabelsContextType;
|
|
36
|
-
export {};
|
|
37
|
-
//# sourceMappingURL=UnifiedLabelsContext.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"UnifiedLabelsContext.d.ts","sourceRoot":"","sources":["../../src/contexts/UnifiedLabelsContext.tsx"],"names":[],"mappings":"AAqCA,OAAO,KAAK,EAAC,UAAU,EAAC,MAAM,0BAA0B,CAAC;AACzD,OAAO,EAAuB,KAAK,gBAAgB,EAAC,MAAM,SAAS,CAAC;AAEpE,UAAU,gBAAgB;IACxB,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,UAAU,EAAE,CAAC;CACtB;AAED,UAAU,wBAAwB;IAChC,iCAAiC,EAAE,gBAAgB,EAAE,CAAC;IACtD,kCAAkC,EAAE,gBAAgB,EAAE,CAAC;IACvD,UAAU,EAAE,MAAM,EAAE,CAAC;IACrB,WAAW,EAAE,MAAM,EAAE,CAAC;IAEtB,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;IACvC,qBAAqB,EAAE,MAAM,EAAE,CAAC;IAEhC,MAAM,CAAC,EAAE,IAAI,GAAG,IAAI,CAAC;CACtB;AAID,UAAU,0BAA0B;IAClC,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAC;IAE1B,gBAAgB,EAAE,MAAM,GAAG,IAAI,CAAC;IAChC,mBAAmB,EAAE,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI,KAAK,IAAI,CAAC;IAEnD,UAAU,EAAE,MAAM,EAAE,CAAC;IACrB,WAAW,EAAE,MAAM,EAAE,CAAC;IACtB,mBAAmB,EAAE,OAAO,CAAC;IAC7B,oBAAoB,EAAE,OAAO,CAAC;IAE9B,kBAAkB,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC;IACxC,iBAAiB,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC;IAEvC,MAAM,CAAC,EAAE,IAAI,GAAG,IAAI,CAAC;CACtB;AAED,wBAAgB,qBAAqB,CAAC,EACpC,QAAQ,EACR,UAAU,EACV,mBAAmB,EACnB,oBAAoB,EACpB,kBAAkB,EAClB,iBAAiB,EACjB,gBAAgB,EAChB,mBAAmB,EACnB,WAAW,EACX,MAAM,GACP,EAAE,0BAA0B,GAAG,GAAG,CAAC,OAAO,CAqD1C;AAED,wBAAgB,gBAAgB,IAAI,wBAAwB,CAM3D"}
|
|
@@ -1,88 +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
|
-
/**
|
|
15
|
-
* UnifiedLabelsProvider - UI Presentation Layer
|
|
16
|
-
*
|
|
17
|
-
* This context provider transforms raw label data into a format optimized for
|
|
18
|
-
* UI components (QueryControls, SimpleMatchers, etc.).
|
|
19
|
-
*
|
|
20
|
-
* Purpose:
|
|
21
|
-
* - Transforms label arrays into structured formats for dropdowns and selectors
|
|
22
|
-
* - Groups labels by type (e.g., 'cpu', 'gpu') for organized display
|
|
23
|
-
* - Handles label name prefixes and mappings for user-friendly display
|
|
24
|
-
* - Provides a unified interface regardless of data source(s)
|
|
25
|
-
*
|
|
26
|
-
* Architecture Pattern:
|
|
27
|
-
* This is the final layer in a three-layer architecture:
|
|
28
|
-
* 1. LabelsQueryProvider - Fetches data from API
|
|
29
|
-
* 2. LabelsSource (in ProfileSelector) - Transforms/merges data
|
|
30
|
-
* 3. UnifiedLabelsProvider (this file) - Presents data to UI components
|
|
31
|
-
*
|
|
32
|
-
* Consumer Hook: useUnifiedLabels()
|
|
33
|
-
*/
|
|
34
|
-
import { createContext, useContext } from 'react';
|
|
35
|
-
import { transformLabelsForSelect } from '../SimpleMatchers';
|
|
36
|
-
import { useLabelNameMappings } from './utils';
|
|
37
|
-
const UnifiedLabelsContext = createContext(null);
|
|
38
|
-
export function UnifiedLabelsProvider({ children, labelNames, isLabelNamesLoading, isLabelValuesLoading, refetchLabelValues, refetchLabelNames, currentLabelName, setCurrentLabelName, labelValues, suffix, }) {
|
|
39
|
-
const labelNameFromMatchers = [];
|
|
40
|
-
const labelNamesFromAPI = labelNames;
|
|
41
|
-
const labelNameMappingsForMatchersInput = useLabelNameMappings(labelNamesFromAPI);
|
|
42
|
-
const allLabelNames = new Set(labelNamesFromAPI);
|
|
43
|
-
const nonMatchingLabels = labelNameFromMatchers.filter(label => !allLabelNames.has(label));
|
|
44
|
-
const labelNameMappingsForSimpleMatchers = [];
|
|
45
|
-
const labels = {
|
|
46
|
-
type: 'cpu',
|
|
47
|
-
labelNames: labelNamesFromAPI,
|
|
48
|
-
isLoading: isLabelNamesLoading,
|
|
49
|
-
};
|
|
50
|
-
labelNameMappingsForSimpleMatchers.push({
|
|
51
|
-
type: labels.type,
|
|
52
|
-
values: transformLabelsForSelect(labels.labelNames),
|
|
53
|
-
});
|
|
54
|
-
if (nonMatchingLabels.length > 0) {
|
|
55
|
-
const uniqueNonMatchingLabels = Array.from(new Set(nonMatchingLabels));
|
|
56
|
-
labelNameMappingsForSimpleMatchers.push({
|
|
57
|
-
type: '',
|
|
58
|
-
values: transformLabelsForSelect(uniqueNonMatchingLabels),
|
|
59
|
-
});
|
|
60
|
-
}
|
|
61
|
-
const value = {
|
|
62
|
-
labelNames: labelNamesFromAPI,
|
|
63
|
-
labelNameMappingsForMatchersInput,
|
|
64
|
-
isLabelNamesLoading,
|
|
65
|
-
isLabelValuesLoading,
|
|
66
|
-
currentLabelName,
|
|
67
|
-
labelValues,
|
|
68
|
-
setCurrentLabelName,
|
|
69
|
-
shouldHandlePrefixes: false,
|
|
70
|
-
refetchLabelValues: async () => {
|
|
71
|
-
await refetchLabelValues();
|
|
72
|
-
},
|
|
73
|
-
refetchLabelNames: async () => {
|
|
74
|
-
await refetchLabelNames();
|
|
75
|
-
},
|
|
76
|
-
labelNameFromMatchers,
|
|
77
|
-
labelNameMappingsForSimpleMatchers,
|
|
78
|
-
suffix,
|
|
79
|
-
};
|
|
80
|
-
return _jsx(UnifiedLabelsContext.Provider, { value: value, children: children });
|
|
81
|
-
}
|
|
82
|
-
export function useUnifiedLabels() {
|
|
83
|
-
const context = useContext(UnifiedLabelsContext);
|
|
84
|
-
if (context === null) {
|
|
85
|
-
throw new Error('useUnifiedLabels must be used within a UnifiedLabelsProvider');
|
|
86
|
-
}
|
|
87
|
-
return context;
|
|
88
|
-
}
|
package/dist/contexts/utils.d.ts
DELETED
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
export interface LabelNameMapping {
|
|
2
|
-
displayName: string;
|
|
3
|
-
fullName: string;
|
|
4
|
-
}
|
|
5
|
-
export declare const transformLabelName: (labelName: string) => string;
|
|
6
|
-
export declare const useLabelNameMappings: (labelNames: string[]) => LabelNameMapping[];
|
|
7
|
-
export declare const useExtractedLabelNames: (response: {
|
|
8
|
-
labelNames?: string[];
|
|
9
|
-
} | undefined, error: Error | undefined | null) => string[];
|
|
10
|
-
//# sourceMappingURL=utils.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../src/contexts/utils.ts"],"names":[],"mappings":"AAeA,MAAM,WAAW,gBAAgB;IAC/B,WAAW,EAAE,MAAM,CAAC;IACpB,QAAQ,EAAE,MAAM,CAAC;CAClB;AAED,eAAO,MAAM,kBAAkB,GAAI,WAAW,MAAM,KAAG,MAEtD,CAAC;AAEF,eAAO,MAAM,oBAAoB,GAAI,YAAY,MAAM,EAAE,KAAG,gBAAgB,EAO3E,CAAC;AAEF,eAAO,MAAM,sBAAsB,GACjC,UAAU;IAAC,UAAU,CAAC,EAAE,MAAM,EAAE,CAAA;CAAC,GAAG,SAAS,EAC7C,OAAO,KAAK,GAAG,SAAS,GAAG,IAAI,KAC9B,MAAM,EAMR,CAAC"}
|
package/dist/contexts/utils.js
DELETED
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
// Copyright 2022 The Parca Authors
|
|
2
|
-
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
3
|
-
// you may not use this file except in compliance with the License.
|
|
4
|
-
// You may obtain a copy of the License at
|
|
5
|
-
//
|
|
6
|
-
// http://www.apache.org/licenses/LICENSE-2.0
|
|
7
|
-
//
|
|
8
|
-
// Unless required by applicable law or agreed to in writing, software
|
|
9
|
-
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
10
|
-
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
11
|
-
// See the License for the specific language governing permissions and
|
|
12
|
-
// limitations under the License.
|
|
13
|
-
import { useMemo } from 'react';
|
|
14
|
-
export const transformLabelName = (labelName) => {
|
|
15
|
-
return labelName.replace(/^(attributes\.|attributes_resource\.)/, '');
|
|
16
|
-
};
|
|
17
|
-
export const useLabelNameMappings = (labelNames) => {
|
|
18
|
-
return useMemo(() => {
|
|
19
|
-
return labelNames.map(name => ({
|
|
20
|
-
displayName: transformLabelName(name),
|
|
21
|
-
fullName: name,
|
|
22
|
-
}));
|
|
23
|
-
}, [labelNames]);
|
|
24
|
-
};
|
|
25
|
-
export const useExtractedLabelNames = (response, error) => {
|
|
26
|
-
return useMemo(() => {
|
|
27
|
-
return (error === undefined || error == null) && response !== undefined && response != null
|
|
28
|
-
? response.labelNames?.filter(e => e !== '__name__') ?? []
|
|
29
|
-
: [];
|
|
30
|
-
}, [response, error]);
|
|
31
|
-
};
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
import { LabelsResponse, QueryServiceClient } from '@parca/client';
|
|
2
|
-
export interface ILabelValuesResult {
|
|
3
|
-
response: string[];
|
|
4
|
-
error?: Error;
|
|
5
|
-
}
|
|
6
|
-
interface UseLabelValues {
|
|
7
|
-
result: ILabelValuesResult;
|
|
8
|
-
loading: boolean;
|
|
9
|
-
refetch: () => Promise<void>;
|
|
10
|
-
}
|
|
11
|
-
export interface ILabelNamesResult {
|
|
12
|
-
response?: LabelsResponse;
|
|
13
|
-
error?: Error;
|
|
14
|
-
}
|
|
15
|
-
interface UseLabelNames {
|
|
16
|
-
result: ILabelNamesResult;
|
|
17
|
-
loading: boolean;
|
|
18
|
-
refetch: () => Promise<void>;
|
|
19
|
-
}
|
|
20
|
-
export declare const useLabelNames: (client: QueryServiceClient, profileType: string, start?: number, end?: number, match?: string[]) => UseLabelNames;
|
|
21
|
-
export declare const useLabelValues: (client: QueryServiceClient, labelName: string, profileType: string, start?: number, end?: number) => UseLabelValues;
|
|
22
|
-
export {};
|
|
23
|
-
//# sourceMappingURL=useLabels.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"useLabels.d.ts","sourceRoot":"","sources":["../../src/hooks/useLabels.ts"],"names":[],"mappings":"AAaA,OAAO,EAAgB,cAAc,EAAE,kBAAkB,EAAgB,MAAM,eAAe,CAAC;AAM/F,MAAM,WAAW,kBAAkB;IACjC,QAAQ,EAAE,MAAM,EAAE,CAAC;IACnB,KAAK,CAAC,EAAE,KAAK,CAAC;CACf;AAED,UAAU,cAAc;IACtB,MAAM,EAAE,kBAAkB,CAAC;IAC3B,OAAO,EAAE,OAAO,CAAC;IACjB,OAAO,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC;CAC9B;AAED,MAAM,WAAW,iBAAiB;IAChC,QAAQ,CAAC,EAAE,cAAc,CAAC;IAC1B,KAAK,CAAC,EAAE,KAAK,CAAC;CACf;AAED,UAAU,aAAa;IACrB,MAAM,EAAE,iBAAiB,CAAC;IAC1B,OAAO,EAAE,OAAO,CAAC;IACjB,OAAO,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC;CAC9B;AAED,eAAO,MAAM,aAAa,GACxB,QAAQ,kBAAkB,EAC1B,aAAa,MAAM,EACnB,QAAQ,MAAM,EACd,MAAM,MAAM,EACZ,QAAQ,MAAM,EAAE,KACf,aAgCF,CAAC;AAEF,eAAO,MAAM,cAAc,GACzB,QAAQ,kBAAkB,EAC1B,WAAW,MAAM,EACjB,aAAa,MAAM,EACnB,QAAQ,MAAM,EACd,MAAM,MAAM,KACX,cAiCF,CAAC"}
|
package/dist/hooks/useLabels.js
DELETED
|
@@ -1,75 +0,0 @@
|
|
|
1
|
-
// Copyright 2022 The Parca Authors
|
|
2
|
-
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
3
|
-
// you may not use this file except in compliance with the License.
|
|
4
|
-
// You may obtain a copy of the License at
|
|
5
|
-
//
|
|
6
|
-
// http://www.apache.org/licenses/LICENSE-2.0
|
|
7
|
-
//
|
|
8
|
-
// Unless required by applicable law or agreed to in writing, software
|
|
9
|
-
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
10
|
-
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
11
|
-
// See the License for the specific language governing permissions and
|
|
12
|
-
// limitations under the License.
|
|
13
|
-
import { useGrpcMetadata } from '@parca/components';
|
|
14
|
-
import { millisToProtoTimestamp, sanitizeLabelValue } from '@parca/utilities';
|
|
15
|
-
import useGrpcQuery from '../useGrpcQuery';
|
|
16
|
-
export const useLabelNames = (client, profileType, start, end, match) => {
|
|
17
|
-
const metadata = useGrpcMetadata();
|
|
18
|
-
const { data, isLoading, error, refetch } = useGrpcQuery({
|
|
19
|
-
key: ['labelNames', profileType, match?.join(','), start, end],
|
|
20
|
-
queryFn: async (signal) => {
|
|
21
|
-
const request = { match: match !== undefined ? match : [] };
|
|
22
|
-
if (start !== undefined && end !== undefined) {
|
|
23
|
-
request.start = millisToProtoTimestamp(start);
|
|
24
|
-
request.end = millisToProtoTimestamp(end);
|
|
25
|
-
}
|
|
26
|
-
if (profileType !== undefined) {
|
|
27
|
-
request.profileType = profileType;
|
|
28
|
-
}
|
|
29
|
-
const { response } = await client.labels(request, { meta: metadata, abort: signal });
|
|
30
|
-
return response;
|
|
31
|
-
},
|
|
32
|
-
options: {
|
|
33
|
-
enabled: profileType !== undefined && profileType !== '',
|
|
34
|
-
keepPreviousData: false,
|
|
35
|
-
},
|
|
36
|
-
});
|
|
37
|
-
console.log('Label names query result:', { data, error, isLoading });
|
|
38
|
-
return {
|
|
39
|
-
result: { response: data, error: error },
|
|
40
|
-
loading: isLoading,
|
|
41
|
-
refetch: async () => {
|
|
42
|
-
await refetch();
|
|
43
|
-
},
|
|
44
|
-
};
|
|
45
|
-
};
|
|
46
|
-
export const useLabelValues = (client, labelName, profileType, start, end) => {
|
|
47
|
-
const metadata = useGrpcMetadata();
|
|
48
|
-
const { data, isLoading, error, refetch } = useGrpcQuery({
|
|
49
|
-
key: ['labelValues', labelName, profileType, start, end],
|
|
50
|
-
queryFn: async (signal) => {
|
|
51
|
-
const request = { labelName, match: [], profileType };
|
|
52
|
-
if (start !== undefined && end !== undefined) {
|
|
53
|
-
request.start = millisToProtoTimestamp(start);
|
|
54
|
-
request.end = millisToProtoTimestamp(end);
|
|
55
|
-
}
|
|
56
|
-
const { response } = await client.values(request, { meta: metadata, abort: signal });
|
|
57
|
-
return sanitizeLabelValue(response.labelValues);
|
|
58
|
-
},
|
|
59
|
-
options: {
|
|
60
|
-
enabled: profileType !== undefined &&
|
|
61
|
-
profileType !== '' &&
|
|
62
|
-
labelName !== undefined &&
|
|
63
|
-
labelName !== '',
|
|
64
|
-
keepPreviousData: false,
|
|
65
|
-
},
|
|
66
|
-
});
|
|
67
|
-
console.log('Label values query result:', { data, error, isLoading, labelName });
|
|
68
|
-
return {
|
|
69
|
-
result: { response: data ?? [], error: error },
|
|
70
|
-
loading: isLoading,
|
|
71
|
-
refetch: async () => {
|
|
72
|
-
await refetch();
|
|
73
|
-
},
|
|
74
|
-
};
|
|
75
|
-
};
|