@perses-dev/pyroscope-plugin 0.2.0
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/LICENSE +201 -0
- package/README.md +23 -0
- package/__mf/css/async/1339.6763d50b.css +1 -0
- package/__mf/css/async/4758.6763d50b.css +1 -0
- package/__mf/css/async/9633.6763d50b.css +1 -0
- package/__mf/font/lato-all-300-normal.322bdf14.woff +0 -0
- package/__mf/font/lato-all-400-normal.63513b00.woff +0 -0
- package/__mf/font/lato-all-700-normal.bb27db94.woff +0 -0
- package/__mf/font/lato-all-900-normal.a27049a3.woff +0 -0
- package/__mf/font/lato-latin-300-normal.c5195215.woff2 +0 -0
- package/__mf/font/lato-latin-400-normal.b7ffde23.woff2 +0 -0
- package/__mf/font/lato-latin-700-normal.d5eb20bc.woff2 +0 -0
- package/__mf/font/lato-latin-900-normal.d884a71c.woff2 +0 -0
- package/__mf/font/lato-latin-ext-300-normal.abcc64a9.woff2 +0 -0
- package/__mf/font/lato-latin-ext-400-normal.6ebed106.woff2 +0 -0
- package/__mf/font/lato-latin-ext-700-normal.8697d1d5.woff2 +0 -0
- package/__mf/font/lato-latin-ext-900-normal.20a2b415.woff2 +0 -0
- package/__mf/js/Pyroscope.24cb38f3.js +5 -0
- package/__mf/js/async/1101.380fb9ae.js +73 -0
- package/__mf/js/async/1101.380fb9ae.js.LICENSE.txt +19 -0
- package/__mf/js/async/1339.e58b309f.js +1 -0
- package/__mf/js/async/1964.88ffca96.js +2 -0
- package/__mf/js/async/1964.88ffca96.js.LICENSE.txt +9 -0
- package/__mf/js/async/2002.8fc3eb19.js +1 -0
- package/__mf/js/async/2114.6befeb2d.js +1 -0
- package/__mf/js/async/2292.ed7843fc.js +2 -0
- package/__mf/js/async/2292.ed7843fc.js.LICENSE.txt +24 -0
- package/__mf/js/async/2911.ec166b7f.js +38 -0
- package/__mf/js/async/3224.755c2f09.js +1 -0
- package/__mf/js/async/3431.bc5c0624.js +1 -0
- package/__mf/js/async/3863.dbe40473.js +2 -0
- package/__mf/js/async/3863.dbe40473.js.LICENSE.txt +9 -0
- package/__mf/js/async/3960.a5d41140.js +2 -0
- package/__mf/js/async/3960.a5d41140.js.LICENSE.txt +8 -0
- package/__mf/js/async/3980.f1ef0ece.js +2 -0
- package/__mf/js/async/3980.f1ef0ece.js.LICENSE.txt +9 -0
- package/__mf/js/async/4075.cde93ec7.js +1 -0
- package/__mf/js/async/4238.f154b81c.js +1 -0
- package/__mf/js/async/424.edb69d58.js +1 -0
- package/__mf/js/async/4368.2d817d5d.js +2 -0
- package/__mf/js/async/4368.2d817d5d.js.LICENSE.txt +15 -0
- package/__mf/js/async/4421.d44d1d6f.js +1 -0
- package/__mf/js/async/4556.aabe5dff.js +2 -0
- package/__mf/js/async/4556.aabe5dff.js.LICENSE.txt +9 -0
- package/__mf/js/async/4758.a629b413.js +1 -0
- package/__mf/js/async/5214.8d3dd135.js +1 -0
- package/__mf/js/async/5215.6fd5cc14.js +1 -0
- package/__mf/js/async/5220.d1e40fff.js +10 -0
- package/__mf/js/async/5220.d1e40fff.js.LICENSE.txt +17 -0
- package/__mf/js/async/5358.40b9537e.js +7 -0
- package/__mf/js/async/5358.40b9537e.js.LICENSE.txt +21 -0
- package/__mf/js/async/5409.0df9c301.js +1 -0
- package/__mf/js/async/5790.677172d7.js +1 -0
- package/__mf/js/async/5876.38b119d5.js +2 -0
- package/__mf/js/async/5876.38b119d5.js.LICENSE.txt +21 -0
- package/__mf/js/async/5924.582b0cc4.js +2 -0
- package/__mf/js/async/5924.582b0cc4.js.LICENSE.txt +9 -0
- package/__mf/js/async/5981.9c662ef8.js +2 -0
- package/__mf/js/async/5981.9c662ef8.js.LICENSE.txt +8 -0
- package/__mf/js/async/6292.e30a4c42.js +1 -0
- package/__mf/js/async/6377.f6e824aa.js +2 -0
- package/__mf/js/async/6377.f6e824aa.js.LICENSE.txt +32 -0
- package/__mf/js/async/6770.2f87fe88.js +1 -0
- package/__mf/js/async/694.5e15c44d.js +1 -0
- package/__mf/js/async/7376.c4cd77b0.js +1 -0
- package/__mf/js/async/738.fa73528b.js +1 -0
- package/__mf/js/async/7740.474defbd.js +1 -0
- package/__mf/js/async/8216.be450b83.js +1 -0
- package/__mf/js/async/8488.00c7f348.js +1 -0
- package/__mf/js/async/8930.496019db.js +1 -0
- package/__mf/js/async/9092.cfd47472.js +101 -0
- package/__mf/js/async/9173.5959814f.js +2 -0
- package/__mf/js/async/9173.5959814f.js.LICENSE.txt +19 -0
- package/__mf/js/async/9478.c76fe552.js +2 -0
- package/__mf/js/async/9478.c76fe552.js.LICENSE.txt +9 -0
- package/__mf/js/async/9633.a7997138.js +2 -0
- package/__mf/js/async/9633.a7997138.js.LICENSE.txt +9 -0
- package/__mf/js/async/__federation_expose_PyroscopeDatasource.76f63abf.js +2 -0
- package/__mf/js/async/__federation_expose_PyroscopeDatasource.76f63abf.js.LICENSE.txt +9 -0
- package/__mf/js/async/__federation_expose_PyroscopeExplorer.88d5e4fb.js +2 -0
- package/__mf/js/async/__federation_expose_PyroscopeExplorer.88d5e4fb.js.LICENSE.txt +9 -0
- package/__mf/js/async/__federation_expose_PyroscopeProfileQuery.75c9c11b.js +2 -0
- package/__mf/js/async/__federation_expose_PyroscopeProfileQuery.75c9c11b.js.LICENSE.txt +9 -0
- package/__mf/js/main.4caf1064.js +5 -0
- package/lib/bootstrap.d.ts +2 -0
- package/lib/bootstrap.d.ts.map +1 -0
- package/lib/bootstrap.js +19 -0
- package/lib/bootstrap.js.map +1 -0
- package/lib/cjs/bootstrap.js +26 -0
- package/lib/cjs/components/AddFilterItem.js +38 -0
- package/lib/cjs/components/DeleteFilterItem.js +42 -0
- package/lib/cjs/components/FilterItem.js +83 -0
- package/lib/cjs/components/Filters.js +106 -0
- package/lib/cjs/components/LabelName.js +59 -0
- package/lib/cjs/components/LabelValue.js +59 -0
- package/lib/cjs/components/Operator.js +45 -0
- package/lib/cjs/components/ProfileTypeSelector.js +57 -0
- package/lib/cjs/components/Service.js +60 -0
- package/lib/cjs/components/index.js +32 -0
- package/lib/cjs/env.d.js +14 -0
- package/lib/cjs/explore/PyroscopeExplorer.js +90 -0
- package/lib/cjs/explore/index.js +30 -0
- package/lib/cjs/getPluginModule.js +39 -0
- package/lib/cjs/index-federation.js +55 -0
- package/lib/cjs/index.js +40 -0
- package/lib/cjs/model/api-types.js +19 -0
- package/lib/cjs/model/index.js +33 -0
- package/lib/cjs/model/profile-query-model.js +16 -0
- package/lib/cjs/model/pyroscope-client.js +94 -0
- package/lib/cjs/model/pyroscope-selectors.js +46 -0
- package/lib/cjs/plugins/PyroscopeDatasourceEditor.js +70 -0
- package/lib/cjs/plugins/index.js +33 -0
- package/lib/cjs/plugins/pyroscope-datasource-types.js +16 -0
- package/lib/cjs/plugins/pyroscope-datasource.js +68 -0
- package/lib/cjs/plugins/pyroscope-profile-query/PyroscopeProfileQuery.js +41 -0
- package/lib/cjs/plugins/pyroscope-profile-query/PyroscopeProfileQueryEditor.js +114 -0
- package/lib/cjs/plugins/pyroscope-profile-query/get-profile-data.js +201 -0
- package/lib/cjs/plugins/pyroscope-profile-query/index.js +33 -0
- package/lib/cjs/plugins/pyroscope-profile-query/query-editor-model.js +120 -0
- package/lib/cjs/setup-tests.js +19 -0
- package/lib/cjs/test/index.js +30 -0
- package/lib/cjs/test/mock-data.js +151 -0
- package/lib/cjs/test/setup-tests.js +17 -0
- package/lib/cjs/utils/types.js +25 -0
- package/lib/cjs/utils/use-query.js +112 -0
- package/lib/components/AddFilterItem.d.ts +6 -0
- package/lib/components/AddFilterItem.d.ts.map +1 -0
- package/lib/components/AddFilterItem.js +25 -0
- package/lib/components/AddFilterItem.js.map +1 -0
- package/lib/components/DeleteFilterItem.d.ts +6 -0
- package/lib/components/DeleteFilterItem.d.ts.map +1 -0
- package/lib/components/DeleteFilterItem.js +29 -0
- package/lib/components/DeleteFilterItem.js.map +1 -0
- package/lib/components/FilterItem.d.ts +11 -0
- package/lib/components/FilterItem.d.ts.map +1 -0
- package/lib/components/FilterItem.js +75 -0
- package/lib/components/FilterItem.js.map +1 -0
- package/lib/components/Filters.d.ts +10 -0
- package/lib/components/Filters.d.ts.map +1 -0
- package/lib/components/Filters.js +98 -0
- package/lib/components/Filters.js.map +1 -0
- package/lib/components/LabelName.d.ts +9 -0
- package/lib/components/LabelName.d.ts.map +1 -0
- package/lib/components/LabelName.js +51 -0
- package/lib/components/LabelName.js.map +1 -0
- package/lib/components/LabelValue.d.ts +10 -0
- package/lib/components/LabelValue.d.ts.map +1 -0
- package/lib/components/LabelValue.js +51 -0
- package/lib/components/LabelValue.js.map +1 -0
- package/lib/components/Operator.d.ts +7 -0
- package/lib/components/Operator.d.ts.map +1 -0
- package/lib/components/Operator.js +37 -0
- package/lib/components/Operator.js.map +1 -0
- package/lib/components/ProfileTypeSelector.d.ts +9 -0
- package/lib/components/ProfileTypeSelector.d.ts.map +1 -0
- package/lib/components/ProfileTypeSelector.js +49 -0
- package/lib/components/ProfileTypeSelector.js.map +1 -0
- package/lib/components/Service.d.ts +9 -0
- package/lib/components/Service.d.ts.map +1 -0
- package/lib/components/Service.js +52 -0
- package/lib/components/Service.js.map +1 -0
- package/lib/components/index.d.ts +4 -0
- package/lib/components/index.d.ts.map +1 -0
- package/lib/components/index.js +17 -0
- package/lib/components/index.js.map +1 -0
- package/lib/env.d.js +15 -0
- package/lib/env.d.js.map +1 -0
- package/lib/explore/PyroscopeExplorer.d.ts +3 -0
- package/lib/explore/PyroscopeExplorer.d.ts.map +1 -0
- package/lib/explore/PyroscopeExplorer.js +82 -0
- package/lib/explore/PyroscopeExplorer.js.map +1 -0
- package/lib/explore/index.d.ts +2 -0
- package/lib/explore/index.d.ts.map +1 -0
- package/lib/explore/index.js +15 -0
- package/lib/explore/index.js.map +1 -0
- package/lib/getPluginModule.d.ts +6 -0
- package/lib/getPluginModule.d.ts.map +1 -0
- package/lib/getPluginModule.js +28 -0
- package/lib/getPluginModule.js.map +1 -0
- package/lib/index-federation.d.ts +1 -0
- package/lib/index-federation.d.ts.map +1 -0
- package/lib/index-federation.js +15 -0
- package/lib/index-federation.js.map +1 -0
- package/lib/index.d.ts +6 -0
- package/lib/index.d.ts.map +1 -0
- package/lib/index.js +19 -0
- package/lib/index.js.map +1 -0
- package/lib/model/api-types.d.ts +82 -0
- package/lib/model/api-types.d.ts.map +1 -0
- package/lib/model/api-types.js +20 -0
- package/lib/model/api-types.js.map +1 -0
- package/lib/model/index.d.ts +5 -0
- package/lib/model/index.d.ts.map +1 -0
- package/lib/model/index.js +18 -0
- package/lib/model/index.js.map +1 -0
- package/lib/model/profile-query-model.d.ts +13 -0
- package/lib/model/profile-query-model.d.ts.map +1 -0
- package/lib/model/profile-query-model.js +17 -0
- package/lib/model/profile-query-model.js.map +1 -0
- package/lib/model/pyroscope-client.d.ts +43 -0
- package/lib/model/pyroscope-client.d.ts.map +1 -0
- package/lib/model/pyroscope-client.js +77 -0
- package/lib/model/pyroscope-client.js.map +1 -0
- package/lib/model/pyroscope-selectors.d.ts +21 -0
- package/lib/model/pyroscope-selectors.d.ts.map +1 -0
- package/lib/model/pyroscope-selectors.js +30 -0
- package/lib/model/pyroscope-selectors.js.map +1 -0
- package/lib/plugins/PyroscopeDatasourceEditor.d.ts +9 -0
- package/lib/plugins/PyroscopeDatasourceEditor.d.ts.map +1 -0
- package/lib/plugins/PyroscopeDatasourceEditor.js +57 -0
- package/lib/plugins/PyroscopeDatasourceEditor.js.map +1 -0
- package/lib/plugins/index.d.ts +5 -0
- package/lib/plugins/index.d.ts.map +1 -0
- package/lib/plugins/index.js +18 -0
- package/lib/plugins/index.js.map +1 -0
- package/lib/plugins/pyroscope-datasource-types.d.ts +6 -0
- package/lib/plugins/pyroscope-datasource-types.d.ts.map +1 -0
- package/lib/plugins/pyroscope-datasource-types.js +15 -0
- package/lib/plugins/pyroscope-datasource-types.js.map +1 -0
- package/lib/plugins/pyroscope-datasource.d.ts +5 -0
- package/lib/plugins/pyroscope-datasource.d.ts.map +1 -0
- package/lib/plugins/pyroscope-datasource.js +60 -0
- package/lib/plugins/pyroscope-datasource.js.map +1 -0
- package/lib/plugins/pyroscope-profile-query/PyroscopeProfileQuery.d.ts +14 -0
- package/lib/plugins/pyroscope-profile-query/PyroscopeProfileQuery.d.ts.map +1 -0
- package/lib/plugins/pyroscope-profile-query/PyroscopeProfileQuery.js +33 -0
- package/lib/plugins/pyroscope-profile-query/PyroscopeProfileQuery.js.map +1 -0
- package/lib/plugins/pyroscope-profile-query/PyroscopeProfileQueryEditor.d.ts +4 -0
- package/lib/plugins/pyroscope-profile-query/PyroscopeProfileQueryEditor.d.ts.map +1 -0
- package/lib/plugins/pyroscope-profile-query/PyroscopeProfileQueryEditor.js +106 -0
- package/lib/plugins/pyroscope-profile-query/PyroscopeProfileQueryEditor.js.map +1 -0
- package/lib/plugins/pyroscope-profile-query/get-profile-data.d.ts +9 -0
- package/lib/plugins/pyroscope-profile-query/get-profile-data.d.ts.map +1 -0
- package/lib/plugins/pyroscope-profile-query/get-profile-data.js +185 -0
- package/lib/plugins/pyroscope-profile-query/get-profile-data.js.map +1 -0
- package/lib/plugins/pyroscope-profile-query/index.d.ts +5 -0
- package/lib/plugins/pyroscope-profile-query/index.d.ts.map +1 -0
- package/lib/plugins/pyroscope-profile-query/index.js +18 -0
- package/lib/plugins/pyroscope-profile-query/index.js.map +1 -0
- package/lib/plugins/pyroscope-profile-query/query-editor-model.d.ts +34 -0
- package/lib/plugins/pyroscope-profile-query/query-editor-model.d.ts.map +1 -0
- package/lib/plugins/pyroscope-profile-query/query-editor-model.js +106 -0
- package/lib/plugins/pyroscope-profile-query/query-editor-model.js.map +1 -0
- package/lib/setup-tests.d.ts +2 -0
- package/lib/setup-tests.d.ts.map +1 -0
- package/lib/setup-tests.js +17 -0
- package/lib/setup-tests.js.map +1 -0
- package/lib/test/index.d.ts +2 -0
- package/lib/test/index.d.ts.map +1 -0
- package/lib/test/index.js +15 -0
- package/lib/test/index.js.map +1 -0
- package/lib/test/mock-data.d.ts +5 -0
- package/lib/test/mock-data.d.ts.map +1 -0
- package/lib/test/mock-data.js +133 -0
- package/lib/test/mock-data.js.map +1 -0
- package/lib/test/setup-tests.d.ts +2 -0
- package/lib/test/setup-tests.d.ts.map +1 -0
- package/lib/test/setup-tests.js +15 -0
- package/lib/test/setup-tests.js.map +1 -0
- package/lib/utils/types.d.ts +8 -0
- package/lib/utils/types.d.ts.map +1 -0
- package/lib/utils/types.js +17 -0
- package/lib/utils/types.js.map +1 -0
- package/lib/utils/use-query.d.ts +9 -0
- package/lib/utils/use-query.d.ts.map +1 -0
- package/lib/utils/use-query.js +87 -0
- package/lib/utils/use-query.js.map +1 -0
- package/mf-manifest.json +455 -0
- package/mf-stats.json +539 -0
- package/package.json +88 -0
|
@@ -0,0 +1,185 @@
|
|
|
1
|
+
// Copyright 2025 The Perses 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 { getUnixTime } from 'date-fns';
|
|
14
|
+
import { PYROSCOPE_DATASOURCE_KIND } from '../../model';
|
|
15
|
+
import { computeFilterExpr } from '../../utils/types';
|
|
16
|
+
export function getUnixTimeRange(timeRange) {
|
|
17
|
+
const { start, end } = timeRange;
|
|
18
|
+
return {
|
|
19
|
+
start: Math.ceil(getUnixTime(start)),
|
|
20
|
+
end: Math.ceil(getUnixTime(end))
|
|
21
|
+
};
|
|
22
|
+
}
|
|
23
|
+
export const getProfileData = async (spec, context)=>{
|
|
24
|
+
const defaultPyroscopeDatasource = {
|
|
25
|
+
kind: PYROSCOPE_DATASOURCE_KIND
|
|
26
|
+
};
|
|
27
|
+
const client = await context.datasourceStore.getDatasourceClient(spec.datasource ?? defaultPyroscopeDatasource);
|
|
28
|
+
const buildQueryString = ()=>{
|
|
29
|
+
let query = '';
|
|
30
|
+
if (spec.service) {
|
|
31
|
+
query = `service_name="${spec.service}"`;
|
|
32
|
+
}
|
|
33
|
+
if (spec.filters && spec.filters.length > 0) {
|
|
34
|
+
const filterExpr = computeFilterExpr(spec.filters);
|
|
35
|
+
if (query === '') {
|
|
36
|
+
query = filterExpr;
|
|
37
|
+
} else {
|
|
38
|
+
query += ',' + filterExpr;
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
query = spec.profileType + (query === '' ? '' : '{' + query + '}');
|
|
42
|
+
return query;
|
|
43
|
+
};
|
|
44
|
+
const getParams = ()=>{
|
|
45
|
+
const params = {
|
|
46
|
+
// example of query
|
|
47
|
+
// query: `process_cpu:cpu:nanoseconds:cpu:nanoseconds{service_name="pyroscope"}`,
|
|
48
|
+
query: buildQueryString(),
|
|
49
|
+
// the default value is now-1h
|
|
50
|
+
from: 'now-1h'
|
|
51
|
+
};
|
|
52
|
+
// handle time range selection from UI drop down (e.g. last 5 minutes, last 1 hour )
|
|
53
|
+
if (context.absoluteTimeRange) {
|
|
54
|
+
const { start, end } = getUnixTimeRange(context.absoluteTimeRange);
|
|
55
|
+
params.from = start;
|
|
56
|
+
params.until = end;
|
|
57
|
+
}
|
|
58
|
+
if (spec.maxNodes) {
|
|
59
|
+
params.maxNodes = spec.maxNodes;
|
|
60
|
+
}
|
|
61
|
+
return params;
|
|
62
|
+
};
|
|
63
|
+
const response = await client.searchProfiles(getParams());
|
|
64
|
+
// return a profile data
|
|
65
|
+
return transformProfileResponse(response);
|
|
66
|
+
};
|
|
67
|
+
/**
|
|
68
|
+
* This function transform the Pyroscope response into the Perses profile format
|
|
69
|
+
*/ function transformProfileResponse(response) {
|
|
70
|
+
const newResponse = {
|
|
71
|
+
profile: {
|
|
72
|
+
stackTrace: {}
|
|
73
|
+
},
|
|
74
|
+
numTicks: 0,
|
|
75
|
+
maxSelf: 0,
|
|
76
|
+
metadata: {
|
|
77
|
+
spyName: '',
|
|
78
|
+
sampleRate: 0,
|
|
79
|
+
units: '',
|
|
80
|
+
name: ''
|
|
81
|
+
},
|
|
82
|
+
timeline: {
|
|
83
|
+
startTime: 0,
|
|
84
|
+
samples: [],
|
|
85
|
+
durationDelta: 0
|
|
86
|
+
}
|
|
87
|
+
};
|
|
88
|
+
if (!response) {
|
|
89
|
+
return newResponse;
|
|
90
|
+
}
|
|
91
|
+
const stackTraces = [];
|
|
92
|
+
// stackTraces id from 1
|
|
93
|
+
let id = 1;
|
|
94
|
+
// Set the profile stackTrace property
|
|
95
|
+
for(let i = 0; i < response.flamebearer.levels.length; i++){
|
|
96
|
+
let current = 0;
|
|
97
|
+
const row = [];
|
|
98
|
+
const level = response.flamebearer.levels[i];
|
|
99
|
+
if (!level) {
|
|
100
|
+
continue;
|
|
101
|
+
}
|
|
102
|
+
for(let j = 0; j < level.length; j += 4){
|
|
103
|
+
const temp = {};
|
|
104
|
+
temp.id = id;
|
|
105
|
+
id += 1;
|
|
106
|
+
const indexInNamesArray = level[j + 3]; // index in names array
|
|
107
|
+
if (indexInNamesArray !== undefined) {
|
|
108
|
+
const name = response.flamebearer.names[indexInNamesArray];
|
|
109
|
+
if (name) {
|
|
110
|
+
temp.name = name;
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
temp.level = i;
|
|
114
|
+
const total = level[j + 1];
|
|
115
|
+
if (total !== undefined) {
|
|
116
|
+
temp.total = total;
|
|
117
|
+
}
|
|
118
|
+
const self = level[j + 2];
|
|
119
|
+
if (self !== undefined) {
|
|
120
|
+
temp.self = self;
|
|
121
|
+
}
|
|
122
|
+
// start and end
|
|
123
|
+
const offset = level[j];
|
|
124
|
+
if (offset !== undefined) {
|
|
125
|
+
current += offset; // current += offset
|
|
126
|
+
}
|
|
127
|
+
temp.start = current;
|
|
128
|
+
if (total !== undefined) {
|
|
129
|
+
current += total; // current += total
|
|
130
|
+
}
|
|
131
|
+
temp.end = current;
|
|
132
|
+
temp.children = [];
|
|
133
|
+
row.push(temp);
|
|
134
|
+
}
|
|
135
|
+
stackTraces.push(row);
|
|
136
|
+
}
|
|
137
|
+
addChildren(stackTraces); // adding children to nodes
|
|
138
|
+
if (stackTraces[0]?.[0]) {
|
|
139
|
+
newResponse.profile.stackTrace = stackTraces[0][0];
|
|
140
|
+
}
|
|
141
|
+
// Set other properties
|
|
142
|
+
newResponse.numTicks = response.flamebearer.numTicks;
|
|
143
|
+
newResponse.maxSelf = response.flamebearer.maxSelf;
|
|
144
|
+
newResponse.metadata = {
|
|
145
|
+
spyName: response.metadata.spyName,
|
|
146
|
+
sampleRate: response.metadata.sampleRate,
|
|
147
|
+
units: response.metadata.units,
|
|
148
|
+
name: response.metadata.name
|
|
149
|
+
};
|
|
150
|
+
newResponse.timeline = {
|
|
151
|
+
startTime: response.timeline.startTime,
|
|
152
|
+
samples: response.timeline.samples,
|
|
153
|
+
durationDelta: response.timeline.durationDelta
|
|
154
|
+
};
|
|
155
|
+
return newResponse;
|
|
156
|
+
}
|
|
157
|
+
// todo: optimize this method as soon as possible
|
|
158
|
+
function addChildren(stackTraces) {
|
|
159
|
+
// for (let i = stackTraces.length - 1; i > 0; i--) {
|
|
160
|
+
for(let i = 1; i < stackTraces.length; i++){
|
|
161
|
+
const currentLevel = stackTraces[i];
|
|
162
|
+
const parentLevel = stackTraces[i - 1];
|
|
163
|
+
if (!currentLevel || !parentLevel) {
|
|
164
|
+
continue;
|
|
165
|
+
}
|
|
166
|
+
for(let j = 0; j < currentLevel.length; j++){
|
|
167
|
+
const currentStack = currentLevel[j];
|
|
168
|
+
if (!currentStack) {
|
|
169
|
+
continue;
|
|
170
|
+
}
|
|
171
|
+
for(let k = 0; k < parentLevel.length; k++){
|
|
172
|
+
const parentStack = parentLevel[k];
|
|
173
|
+
if (!parentStack) {
|
|
174
|
+
continue;
|
|
175
|
+
}
|
|
176
|
+
if (currentStack.start >= parentStack.start && currentStack.end <= parentStack.end) {
|
|
177
|
+
parentStack.children.push(currentStack);
|
|
178
|
+
break;
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
//# sourceMappingURL=get-profile-data.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../src/plugins/pyroscope-profile-query/get-profile-data.ts"],"sourcesContent":["// Copyright 2025 The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport { ProfileQueryPlugin } from '@perses-dev/plugin-system';\nimport { AbsoluteTimeRange, StackTrace, ProfileData } from '@perses-dev/core';\nimport { getUnixTime } from 'date-fns';\nimport { PyroscopeProfileQuerySpec, PYROSCOPE_DATASOURCE_KIND, PyroscopeDatasourceSelector } from '../../model';\nimport { PyroscopeClient } from '../../model/pyroscope-client';\nimport { SearchProfilesParameters, SearchProfilesResponse } from '../../model/api-types';\nimport { computeFilterExpr } from '../../utils/types';\n\nexport function getUnixTimeRange(timeRange: AbsoluteTimeRange): { start: number; end: number } {\n const { start, end } = timeRange;\n return {\n start: Math.ceil(getUnixTime(start)),\n end: Math.ceil(getUnixTime(end)),\n };\n}\n\nexport const getProfileData: ProfileQueryPlugin<PyroscopeProfileQuerySpec>['getProfileData'] = async (\n spec,\n context\n) => {\n const defaultPyroscopeDatasource: PyroscopeDatasourceSelector = {\n kind: PYROSCOPE_DATASOURCE_KIND,\n };\n\n const client: PyroscopeClient = await context.datasourceStore.getDatasourceClient(\n spec.datasource ?? defaultPyroscopeDatasource\n );\n\n const buildQueryString = () => {\n let query: string = '';\n if (spec.service) {\n query = `service_name=\"${spec.service}\"`;\n }\n if (spec.filters && spec.filters.length > 0) {\n const filterExpr = computeFilterExpr(spec.filters);\n if (query === '') {\n query = filterExpr;\n } else {\n query += ',' + filterExpr;\n }\n }\n query = spec.profileType + (query === '' ? '' : '{' + query + '}');\n return query;\n };\n\n const getParams = (): SearchProfilesParameters => {\n const params: SearchProfilesParameters = {\n // example of query\n // query: `process_cpu:cpu:nanoseconds:cpu:nanoseconds{service_name=\"pyroscope\"}`,\n query: buildQueryString(),\n // the default value is now-1h\n from: 'now-1h',\n };\n\n // handle time range selection from UI drop down (e.g. last 5 minutes, last 1 hour )\n if (context.absoluteTimeRange) {\n const { start, end } = getUnixTimeRange(context.absoluteTimeRange);\n params.from = start;\n params.until = end;\n }\n\n if (spec.maxNodes) {\n params.maxNodes = spec.maxNodes;\n }\n\n return params;\n };\n\n const response = await client.searchProfiles(getParams());\n\n // return a profile data\n return transformProfileResponse(response);\n};\n\n/**\n * This function transform the Pyroscope response into the Perses profile format\n */\nfunction transformProfileResponse(response: SearchProfilesResponse): ProfileData {\n const newResponse: ProfileData = {\n profile: {\n stackTrace: {} as StackTrace,\n },\n numTicks: 0,\n maxSelf: 0,\n metadata: {\n spyName: '',\n sampleRate: 0,\n units: '',\n name: '',\n },\n timeline: {\n startTime: 0,\n samples: [],\n durationDelta: 0,\n },\n };\n\n if (!response) {\n return newResponse;\n }\n\n const stackTraces: StackTrace[][] = [];\n\n // stackTraces id from 1\n let id = 1;\n // Set the profile stackTrace property\n for (let i = 0; i < response.flamebearer.levels.length; i++) {\n let current = 0;\n const row: StackTrace[] = [];\n\n const level = response.flamebearer.levels[i];\n\n if (!level) {\n continue;\n }\n\n for (let j = 0; j < level.length; j += 4) {\n const temp: StackTrace = {} as StackTrace;\n temp.id = id;\n id += 1;\n const indexInNamesArray = level[j + 3]; // index in names array\n if (indexInNamesArray !== undefined) {\n const name = response.flamebearer.names[indexInNamesArray];\n\n if (name) {\n temp.name = name;\n }\n }\n temp.level = i;\n\n const total = level[j + 1];\n if (total !== undefined) {\n temp.total = total;\n }\n\n const self = level[j + 2];\n\n if (self !== undefined) {\n temp.self = self;\n }\n\n // start and end\n const offset = level[j];\n if (offset !== undefined) {\n current += offset; // current += offset\n }\n temp.start = current;\n if (total !== undefined) {\n current += total; // current += total\n }\n temp.end = current;\n\n temp.children = [];\n\n row.push(temp);\n }\n\n stackTraces.push(row);\n }\n\n addChildren(stackTraces); // adding children to nodes\n if (stackTraces[0]?.[0]) {\n newResponse.profile.stackTrace = stackTraces[0][0];\n }\n\n // Set other properties\n newResponse.numTicks = response.flamebearer.numTicks;\n newResponse.maxSelf = response.flamebearer.maxSelf;\n\n newResponse.metadata = {\n spyName: response.metadata.spyName,\n sampleRate: response.metadata.sampleRate,\n units: response.metadata.units,\n name: response.metadata.name,\n };\n\n newResponse.timeline = {\n startTime: response.timeline.startTime,\n samples: response.timeline.samples,\n durationDelta: response.timeline.durationDelta,\n };\n\n return newResponse;\n}\n\n// todo: optimize this method as soon as possible\nfunction addChildren(stackTraces: StackTrace[][]): void {\n // for (let i = stackTraces.length - 1; i > 0; i--) {\n for (let i = 1; i < stackTraces.length; i++) {\n const currentLevel = stackTraces[i];\n const parentLevel = stackTraces[i - 1];\n\n if (!currentLevel || !parentLevel) {\n continue;\n }\n\n for (let j = 0; j < currentLevel.length; j++) {\n const currentStack = currentLevel[j];\n if (!currentStack) {\n continue;\n }\n\n for (let k = 0; k < parentLevel.length; k++) {\n const parentStack = parentLevel[k];\n if (!parentStack) {\n continue;\n }\n\n if (currentStack.start >= parentStack.start && currentStack.end <= parentStack.end) {\n parentStack.children.push(currentStack);\n break;\n }\n }\n }\n }\n}\n"],"names":["getUnixTime","PYROSCOPE_DATASOURCE_KIND","computeFilterExpr","getUnixTimeRange","timeRange","start","end","Math","ceil","getProfileData","spec","context","defaultPyroscopeDatasource","kind","client","datasourceStore","getDatasourceClient","datasource","buildQueryString","query","service","filters","length","filterExpr","profileType","getParams","params","from","absoluteTimeRange","until","maxNodes","response","searchProfiles","transformProfileResponse","newResponse","profile","stackTrace","numTicks","maxSelf","metadata","spyName","sampleRate","units","name","timeline","startTime","samples","durationDelta","stackTraces","id","i","flamebearer","levels","current","row","level","j","temp","indexInNamesArray","undefined","names","total","self","offset","children","push","addChildren","currentLevel","parentLevel","currentStack","k","parentStack"],"mappings":"AAAA,oCAAoC;AACpC,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AAIjC,SAASA,WAAW,QAAQ,WAAW;AACvC,SAAoCC,yBAAyB,QAAqC,cAAc;AAGhH,SAASC,iBAAiB,QAAQ,oBAAoB;AAEtD,OAAO,SAASC,iBAAiBC,SAA4B;IAC3D,MAAM,EAAEC,KAAK,EAAEC,GAAG,EAAE,GAAGF;IACvB,OAAO;QACLC,OAAOE,KAAKC,IAAI,CAACR,YAAYK;QAC7BC,KAAKC,KAAKC,IAAI,CAACR,YAAYM;IAC7B;AACF;AAEA,OAAO,MAAMG,iBAAkF,OAC7FC,MACAC;IAEA,MAAMC,6BAA0D;QAC9DC,MAAMZ;IACR;IAEA,MAAMa,SAA0B,MAAMH,QAAQI,eAAe,CAACC,mBAAmB,CAC/EN,KAAKO,UAAU,IAAIL;IAGrB,MAAMM,mBAAmB;QACvB,IAAIC,QAAgB;QACpB,IAAIT,KAAKU,OAAO,EAAE;YAChBD,QAAQ,CAAC,cAAc,EAAET,KAAKU,OAAO,CAAC,CAAC,CAAC;QAC1C;QACA,IAAIV,KAAKW,OAAO,IAAIX,KAAKW,OAAO,CAACC,MAAM,GAAG,GAAG;YAC3C,MAAMC,aAAarB,kBAAkBQ,KAAKW,OAAO;YACjD,IAA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../../src/plugins/pyroscope-profile-query/index.ts"],"names":[],"mappings":"AAaA,cAAc,oBAAoB,CAAC;AACnC,cAAc,yBAAyB,CAAC;AACxC,cAAc,+BAA+B,CAAC;AAC9C,cAAc,sBAAsB,CAAC"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
// Copyright 2025 The Perses 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
|
+
export * from './get-profile-data';
|
|
14
|
+
export * from './PyroscopeProfileQuery';
|
|
15
|
+
export * from './PyroscopeProfileQueryEditor';
|
|
16
|
+
export * from './query-editor-model';
|
|
17
|
+
|
|
18
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../src/plugins/pyroscope-profile-query/index.ts"],"sourcesContent":["// Copyright 2025 The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nexport * from './get-profile-data';\nexport * from './PyroscopeProfileQuery';\nexport * from './PyroscopeProfileQueryEditor';\nexport * from './query-editor-model';\n"],"names":[],"mappings":"AAAA,oCAAoC;AACpC,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AAEjC,cAAc,qBAAqB;AACnC,cAAc,0BAA0B;AACxC,cAAc,gCAAgC;AAC9C,cAAc,uBAAuB"}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { OptionsEditorProps } from '@perses-dev/plugin-system';
|
|
2
|
+
import { PyroscopeProfileQuerySpec } from '../../model/profile-query-model';
|
|
3
|
+
import { LabelFilter } from '../../utils/types';
|
|
4
|
+
export type ProfileQueryEditorProps = OptionsEditorProps<PyroscopeProfileQuerySpec>;
|
|
5
|
+
/**
|
|
6
|
+
* Hook to manage `maxNodes` state to ensure panel preview rerender when maxNodes is changed.
|
|
7
|
+
*/
|
|
8
|
+
export declare function useMaxNodesState(props: ProfileQueryEditorProps): {
|
|
9
|
+
maxNodes: string;
|
|
10
|
+
handleMaxNodesChange: (e: string) => void;
|
|
11
|
+
maxNodesHasError: boolean;
|
|
12
|
+
};
|
|
13
|
+
/**
|
|
14
|
+
* Hook to manage `profileType` state to ensure panel preview rerender when profileType is changed.
|
|
15
|
+
*/
|
|
16
|
+
export declare function useProfileTypeState(props: ProfileQueryEditorProps): {
|
|
17
|
+
profileType: string;
|
|
18
|
+
handleProfileTypeChange: (e: string) => void;
|
|
19
|
+
};
|
|
20
|
+
/**
|
|
21
|
+
* Hook to manage `service` state to ensure panel preview rerender when service is changed.
|
|
22
|
+
*/
|
|
23
|
+
export declare function useServiceState(props: ProfileQueryEditorProps): {
|
|
24
|
+
service: string;
|
|
25
|
+
handleServiceChange: (e: string) => void;
|
|
26
|
+
};
|
|
27
|
+
/**
|
|
28
|
+
* Hook to manage `filters` state to ensure panel preview rerender when filters is changed.
|
|
29
|
+
*/
|
|
30
|
+
export declare function useFiltersState(props: ProfileQueryEditorProps): {
|
|
31
|
+
filters: LabelFilter[];
|
|
32
|
+
handleFiltersChange: (f: LabelFilter[]) => void;
|
|
33
|
+
};
|
|
34
|
+
//# sourceMappingURL=query-editor-model.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"query-editor-model.d.ts","sourceRoot":"","sources":["../../../../src/plugins/pyroscope-profile-query/query-editor-model.ts"],"names":[],"mappings":"AAeA,OAAO,EAAE,kBAAkB,EAAE,MAAM,2BAA2B,CAAC;AAC/D,OAAO,EAAE,yBAAyB,EAAE,MAAM,iCAAiC,CAAC;AAC5E,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAEhD,MAAM,MAAM,uBAAuB,GAAG,kBAAkB,CAAC,yBAAyB,CAAC,CAAC;AAEpF;;GAEG;AACH,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,uBAAuB,GAAG;IAChE,QAAQ,EAAE,MAAM,CAAC;IACjB,oBAAoB,EAAE,CAAC,CAAC,EAAE,MAAM,KAAK,IAAI,CAAC;IAC1C,gBAAgB,EAAE,OAAO,CAAC;CAC3B,CA4BA;AAED;;GAEG;AACH,wBAAgB,mBAAmB,CAAC,KAAK,EAAE,uBAAuB,GAAG;IACnE,WAAW,EAAE,MAAM,CAAC;IACpB,uBAAuB,EAAE,CAAC,CAAC,EAAE,MAAM,KAAK,IAAI,CAAC;CAC9C,CAuBA;AAED;;GAEG;AACH,wBAAgB,eAAe,CAAC,KAAK,EAAE,uBAAuB,GAAG;IAC/D,OAAO,EAAE,MAAM,CAAC;IAChB,mBAAmB,EAAE,CAAC,CAAC,EAAE,MAAM,KAAK,IAAI,CAAC;CAC1C,CAuBA;AAED;;GAEG;AACH,wBAAgB,eAAe,CAAC,KAAK,EAAE,uBAAuB,GAAG;IAC/D,OAAO,EAAE,WAAW,EAAE,CAAC;IACvB,mBAAmB,EAAE,CAAC,CAAC,EAAE,WAAW,EAAE,KAAK,IAAI,CAAC;CACjD,CAgBA"}
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
// Copyright 2025 The Perses 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 { useState } from 'react';
|
|
14
|
+
import { produce } from 'immer';
|
|
15
|
+
/**
|
|
16
|
+
* Hook to manage `maxNodes` state to ensure panel preview rerender when maxNodes is changed.
|
|
17
|
+
*/ export function useMaxNodesState(props) {
|
|
18
|
+
const { onChange, value } = props;
|
|
19
|
+
const [maxNodes, setMaxNodes] = useState(value.maxNodes ? value.maxNodes.toString() : '');
|
|
20
|
+
const [lastSyncedMaxNodes, setLastSyncedMaxNodes] = useState(value.maxNodes);
|
|
21
|
+
if (value.maxNodes !== lastSyncedMaxNodes) {
|
|
22
|
+
setMaxNodes(value.maxNodes ? value.maxNodes.toString() : '');
|
|
23
|
+
setLastSyncedMaxNodes(value.maxNodes);
|
|
24
|
+
}
|
|
25
|
+
// maxNodes must be empty or an integer between 0 and max_flamegraph_nodes_max (0 < maxNodes <= max_flamegraph_nodes_max)
|
|
26
|
+
// what is the actual value of max_flamegraph_nodes_max?
|
|
27
|
+
// todo: add a constraint to the maxNodes related to max_flamegraph_nodes_max
|
|
28
|
+
const maxNodesHasError = !(maxNodes === '' || /^[0-9]+$/.test(maxNodes) && parseInt(maxNodes) > 0);
|
|
29
|
+
// Update our local state as the user types
|
|
30
|
+
const handleMaxNodesChange = (e)=>{
|
|
31
|
+
setMaxNodes(e);
|
|
32
|
+
// Propagate changes to the panel immediately
|
|
33
|
+
onChange(produce(value, (draft)=>{
|
|
34
|
+
draft.maxNodes = e === '' ? undefined : parseInt(e);
|
|
35
|
+
}));
|
|
36
|
+
};
|
|
37
|
+
return {
|
|
38
|
+
maxNodes,
|
|
39
|
+
handleMaxNodesChange,
|
|
40
|
+
maxNodesHasError
|
|
41
|
+
};
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* Hook to manage `profileType` state to ensure panel preview rerender when profileType is changed.
|
|
45
|
+
*/ export function useProfileTypeState(props) {
|
|
46
|
+
const { onChange, value } = props;
|
|
47
|
+
const [profileType, setProfileType] = useState(value.profileType ? value.profileType : '');
|
|
48
|
+
const [lastSyncedProfileType, setLastSyncedProfileType] = useState(value.profileType);
|
|
49
|
+
if (value.profileType !== lastSyncedProfileType) {
|
|
50
|
+
setProfileType(value.profileType);
|
|
51
|
+
setLastSyncedProfileType(value.profileType);
|
|
52
|
+
}
|
|
53
|
+
// Update our local state as the user types
|
|
54
|
+
const handleProfileTypeChange = (e)=>{
|
|
55
|
+
setProfileType(e);
|
|
56
|
+
// Propagate changes to the panel immediately
|
|
57
|
+
onChange(produce(value, (draft)=>{
|
|
58
|
+
draft.profileType = e;
|
|
59
|
+
}));
|
|
60
|
+
};
|
|
61
|
+
return {
|
|
62
|
+
profileType,
|
|
63
|
+
handleProfileTypeChange
|
|
64
|
+
};
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* Hook to manage `service` state to ensure panel preview rerender when service is changed.
|
|
68
|
+
*/ export function useServiceState(props) {
|
|
69
|
+
const { onChange, value } = props;
|
|
70
|
+
const [service, setService] = useState(value.service ? value.service : '');
|
|
71
|
+
const [lastSyncedService, setLastSyncedService] = useState(value.service);
|
|
72
|
+
if (value.service !== lastSyncedService) {
|
|
73
|
+
setService(value.service || '');
|
|
74
|
+
setLastSyncedService(value.service);
|
|
75
|
+
}
|
|
76
|
+
// Update our local state as the user types
|
|
77
|
+
const handleServiceChange = (e)=>{
|
|
78
|
+
setService(e);
|
|
79
|
+
// Propagate changes to the panel immediately
|
|
80
|
+
onChange(produce(value, (draft)=>{
|
|
81
|
+
draft.service = e;
|
|
82
|
+
}));
|
|
83
|
+
};
|
|
84
|
+
return {
|
|
85
|
+
service,
|
|
86
|
+
handleServiceChange
|
|
87
|
+
};
|
|
88
|
+
}
|
|
89
|
+
/**
|
|
90
|
+
* Hook to manage `filters` state to ensure panel preview rerender when filters is changed.
|
|
91
|
+
*/ export function useFiltersState(props) {
|
|
92
|
+
const { onChange, value } = props;
|
|
93
|
+
const [filters, setFilters] = useState(value.filters ? value.filters : []);
|
|
94
|
+
const handleFiltersChange = (f)=>{
|
|
95
|
+
setFilters(f);
|
|
96
|
+
onChange(produce(value, (draft)=>{
|
|
97
|
+
draft.filters = f;
|
|
98
|
+
}));
|
|
99
|
+
};
|
|
100
|
+
return {
|
|
101
|
+
filters,
|
|
102
|
+
handleFiltersChange
|
|
103
|
+
};
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
//# sourceMappingURL=query-editor-model.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../src/plugins/pyroscope-profile-query/query-editor-model.ts"],"sourcesContent":["// Copyright 2025 The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport { useState } from 'react';\nimport { produce } from 'immer';\nimport { OptionsEditorProps } from '@perses-dev/plugin-system';\nimport { PyroscopeProfileQuerySpec } from '../../model/profile-query-model';\nimport { LabelFilter } from '../../utils/types';\n\nexport type ProfileQueryEditorProps = OptionsEditorProps<PyroscopeProfileQuerySpec>;\n\n/**\n * Hook to manage `maxNodes` state to ensure panel preview rerender when maxNodes is changed.\n */\nexport function useMaxNodesState(props: ProfileQueryEditorProps): {\n maxNodes: string;\n handleMaxNodesChange: (e: string) => void;\n maxNodesHasError: boolean;\n} {\n const { onChange, value } = props;\n\n const [maxNodes, setMaxNodes] = useState(value.maxNodes ? value.maxNodes.toString() : '');\n const [lastSyncedMaxNodes, setLastSyncedMaxNodes] = useState(value.maxNodes);\n\n if (value.maxNodes !== lastSyncedMaxNodes) {\n setMaxNodes(value.maxNodes ? value.maxNodes.toString() : '');\n setLastSyncedMaxNodes(value.maxNodes);\n }\n\n // maxNodes must be empty or an integer between 0 and max_flamegraph_nodes_max (0 < maxNodes <= max_flamegraph_nodes_max)\n // what is the actual value of max_flamegraph_nodes_max?\n // todo: add a constraint to the maxNodes related to max_flamegraph_nodes_max\n const maxNodesHasError = !(maxNodes === '' || (/^[0-9]+$/.test(maxNodes) && parseInt(maxNodes) > 0));\n\n // Update our local state as the user types\n const handleMaxNodesChange = (e: string): void => {\n setMaxNodes(e);\n // Propagate changes to the panel immediately\n onChange(\n produce(value, (draft) => {\n draft.maxNodes = e === '' ? undefined : parseInt(e);\n })\n );\n };\n\n return { maxNodes, handleMaxNodesChange, maxNodesHasError };\n}\n\n/**\n * Hook to manage `profileType` state to ensure panel preview rerender when profileType is changed.\n */\nexport function useProfileTypeState(props: ProfileQueryEditorProps): {\n profileType: string;\n handleProfileTypeChange: (e: string) => void;\n} {\n const { onChange, value } = props;\n\n const [profileType, setProfileType] = useState(value.profileType ? value.profileType : '');\n const [lastSyncedProfileType, setLastSyncedProfileType] = useState(value.profileType);\n\n if (value.profileType !== lastSyncedProfileType) {\n setProfileType(value.profileType);\n setLastSyncedProfileType(value.profileType);\n }\n\n // Update our local state as the user types\n const handleProfileTypeChange = (e: string): void => {\n setProfileType(e);\n // Propagate changes to the panel immediately\n onChange(\n produce(value, (draft) => {\n draft.profileType = e;\n })\n );\n };\n\n return { profileType, handleProfileTypeChange };\n}\n\n/**\n * Hook to manage `service` state to ensure panel preview rerender when service is changed.\n */\nexport function useServiceState(props: ProfileQueryEditorProps): {\n service: string;\n handleServiceChange: (e: string) => void;\n} {\n const { onChange, value } = props;\n\n const [service, setService] = useState(value.service ? value.service : '');\n const [lastSyncedService, setLastSyncedService] = useState(value.service);\n\n if (value.service !== lastSyncedService) {\n setService(value.service || '');\n setLastSyncedService(value.service);\n }\n\n // Update our local state as the user types\n const handleServiceChange = (e: string): void => {\n setService(e);\n // Propagate changes to the panel immediately\n onChange(\n produce(value, (draft) => {\n draft.service = e;\n })\n );\n };\n\n return { service, handleServiceChange };\n}\n\n/**\n * Hook to manage `filters` state to ensure panel preview rerender when filters is changed.\n */\nexport function useFiltersState(props: ProfileQueryEditorProps): {\n filters: LabelFilter[];\n handleFiltersChange: (f: LabelFilter[]) => void;\n} {\n const { onChange, value } = props;\n\n const [filters, setFilters] = useState(value.filters ? value.filters : []);\n\n const handleFiltersChange = (f: LabelFilter[]): void => {\n setFilters(f);\n\n onChange(\n produce(value, (draft) => {\n draft.filters = f;\n })\n );\n };\n\n return { filters, handleFiltersChange };\n}\n"],"names":["useState","produce","useMaxNodesState","props","onChange","value","maxNodes","setMaxNodes","toString","lastSyncedMaxNodes","setLastSyncedMaxNodes","maxNodesHasError","test","parseInt","handleMaxNodesChange","e","draft","undefined","useProfileTypeState","profileType","setProfileType","lastSyncedProfileType","setLastSyncedProfileType","handleProfileTypeChange","useServiceState","service","setService","lastSyncedService","setLastSyncedService","handleServiceChange","useFiltersState","filters","setFilters","handleFiltersChange","f"],"mappings":"AAAA,oCAAoC;AACpC,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AAEjC,SAASA,QAAQ,QAAQ,QAAQ;AACjC,SAASC,OAAO,QAAQ,QAAQ;AAOhC;;CAEC,GACD,OAAO,SAASC,iBAAiBC,K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;QACtB;IAEJ;IAEA,OAAO;QAAEI;QAAaI;IAAwB;AAChD;AAEA;;CAEC,GACD,OAAO,SAASC,gBAAgBrB,KAA8B;IAI5D,MAAM,EAAEC,QAAQ,EAAEC,KAAK,EAAE,GAAGF;IAE5B,MAAM,CAACsB,SAASC,WAAW,GAAG1B,SAASK,MAAMoB,OAAO,GAAGpB,MAAMoB,OAAO,GAAG;IACvE,MAAM,CAACE,mBAAmBC,qBAAqB,GAAG5B,SAASK,MAAMoB,OAAO;IAExE,IAAIpB,MAAMoB,OAAO,KAAKE,mBAAmB;QACvCD,WAAWrB,MAAMoB,OAAO,IAAI;QAC5BG,qBAAqBvB,MAAMoB,OAAO;IACpC;IAEA,2CAA2C;IAC3C,MAAMI,sBAAsB,CAACd;QAC3BW,WAAWX;QACX,6CAA6C;QAC7CX,SACEH,QAAQI,OAAO,CAACW;YACdA,MAAMS,OAAO,GAAGV;QAClB;IAEJ;IAEA,OAAO;QAAEU;QAASI;IAAoB;AACxC;AAEA;;CAEC,GACD,OAAO,SAASC,gBAAgB3B,KAA8B;IAI5D,MAAM,EAAEC,QAAQ,EAAEC,KAAK,EAAE,GAAGF;IAE5B,MAAM,CAAC4B,SAASC,WAAW,GAAGhC,SAASK,MAAM0B,OAAO,GAAG1B,MAAM0B,OAAO,GAAG,EAAE;IAEzE,MAAME,sBAAsB,CAACC;QAC3BF,WAAWE;QAEX9B,SACEH,QAAQI,OAAO,CAACW;YACdA,MAAMe,OAAO,GAAGG;QAClB;IAEJ;IAEA,OAAO;QAAEH;QAASE;IAAoB;AACxC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"setup-tests.d.ts","sourceRoot":"","sources":["../../src/setup-tests.ts"],"names":[],"mappings":"AAaA,OAAO,2BAA2B,CAAC"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
// Copyright 2025 The Perses 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 '@testing-library/jest-dom';
|
|
14
|
+
// Always mock e-charts during tests since we don't have a proper canvas in jsdom
|
|
15
|
+
jest.mock('echarts/core');
|
|
16
|
+
|
|
17
|
+
//# sourceMappingURL=setup-tests.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/setup-tests.ts"],"sourcesContent":["// Copyright 2025 The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport '@testing-library/jest-dom';\n\n// Always mock e-charts during tests since we don't have a proper canvas in jsdom\njest.mock('echarts/core');\n"],"names":["jest","mock"],"mappings":"AAAA,oCAAoC;AACpC,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AAEjC,OAAO,4BAA4B;AAEnC,iFAAiF;AACjFA,KAAKC,IAAI,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/test/index.ts"],"names":[],"mappings":"AAaA,cAAc,aAAa,CAAC"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
// Copyright 2025 The Perses 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
|
+
export * from './mock-data';
|
|
14
|
+
|
|
15
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/test/index.ts"],"sourcesContent":["// Copyright 2025 The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nexport * from './mock-data';\n"],"names":[],"mappings":"AAAA,oCAAoC;AACpC,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AAEjC,cAAc,cAAc"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { SearchProfileTypesResponse, SearchLabelNamesResponse, SearchLabelValuesResponse } from '../model/api-types';
|
|
2
|
+
export declare const MOCK_PROFILE_TYPES_RESPONSE: SearchProfileTypesResponse;
|
|
3
|
+
export declare const MOCK_LABEL_NAMES_RESPONSE: SearchLabelNamesResponse;
|
|
4
|
+
export declare const MOCK_LABEL_VALUES_RESPONSE_NAME_REGION: SearchLabelValuesResponse;
|
|
5
|
+
//# sourceMappingURL=mock-data.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mock-data.d.ts","sourceRoot":"","sources":["../../../src/test/mock-data.ts"],"names":[],"mappings":"AAaA,OAAO,EAAE,0BAA0B,EAAE,wBAAwB,EAAE,yBAAyB,EAAE,MAAM,oBAAoB,CAAC;AAErH,eAAO,MAAM,2BAA2B,EAAE,0BA2FzC,CAAC;AAEF,eAAO,MAAM,yBAAyB,EAAE,wBAkBvC,CAAC;AAGF,eAAO,MAAM,sCAAsC,EAAE,yBAEpD,CAAC"}
|
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
// Copyright 2025 The Perses 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
|
+
export const MOCK_PROFILE_TYPES_RESPONSE = {
|
|
14
|
+
profileTypes: [
|
|
15
|
+
{
|
|
16
|
+
ID: 'block:contentions:count:contentions:count',
|
|
17
|
+
name: 'block',
|
|
18
|
+
sampleType: 'contentions',
|
|
19
|
+
sampleUnit: 'count',
|
|
20
|
+
periodType: 'contentions',
|
|
21
|
+
periodUnit: 'count'
|
|
22
|
+
},
|
|
23
|
+
{
|
|
24
|
+
ID: 'block:delay:nanoseconds:contentions:count',
|
|
25
|
+
name: 'block',
|
|
26
|
+
sampleType: 'delay',
|
|
27
|
+
sampleUnit: 'nanoseconds',
|
|
28
|
+
periodType: 'contentions',
|
|
29
|
+
periodUnit: 'count'
|
|
30
|
+
},
|
|
31
|
+
{
|
|
32
|
+
ID: 'goroutines:goroutine:count:goroutine:count',
|
|
33
|
+
name: 'goroutines',
|
|
34
|
+
sampleType: 'goroutine',
|
|
35
|
+
sampleUnit: 'count',
|
|
36
|
+
periodType: 'goroutine',
|
|
37
|
+
periodUnit: 'count'
|
|
38
|
+
},
|
|
39
|
+
{
|
|
40
|
+
ID: 'memory:alloc_objects:count:space:bytes',
|
|
41
|
+
name: 'memory',
|
|
42
|
+
sampleType: 'alloc_objects',
|
|
43
|
+
sampleUnit: 'count',
|
|
44
|
+
periodType: 'space',
|
|
45
|
+
periodUnit: 'bytes'
|
|
46
|
+
},
|
|
47
|
+
{
|
|
48
|
+
ID: 'memory:alloc_space:bytes:space:bytes',
|
|
49
|
+
name: 'memory',
|
|
50
|
+
sampleType: 'alloc_space',
|
|
51
|
+
sampleUnit: 'bytes',
|
|
52
|
+
periodType: 'space',
|
|
53
|
+
periodUnit: 'bytes'
|
|
54
|
+
},
|
|
55
|
+
{
|
|
56
|
+
ID: 'memory:inuse_objects:count:space:bytes',
|
|
57
|
+
name: 'memory',
|
|
58
|
+
sampleType: 'inuse_objects',
|
|
59
|
+
sampleUnit: 'count',
|
|
60
|
+
periodType: 'space',
|
|
61
|
+
periodUnit: 'bytes'
|
|
62
|
+
},
|
|
63
|
+
{
|
|
64
|
+
ID: 'memory:inuse_space:bytes:space:bytes',
|
|
65
|
+
name: 'memory',
|
|
66
|
+
sampleType: 'inuse_space',
|
|
67
|
+
sampleUnit: 'bytes',
|
|
68
|
+
periodType: 'space',
|
|
69
|
+
periodUnit: 'bytes'
|
|
70
|
+
},
|
|
71
|
+
{
|
|
72
|
+
ID: 'mutex:contentions:count:contentions:count',
|
|
73
|
+
name: 'mutex',
|
|
74
|
+
sampleType: 'contentions',
|
|
75
|
+
sampleUnit: 'count',
|
|
76
|
+
periodType: 'contentions',
|
|
77
|
+
periodUnit: 'count'
|
|
78
|
+
},
|
|
79
|
+
{
|
|
80
|
+
ID: 'mutex:delay:nanoseconds:contentions:count',
|
|
81
|
+
name: 'mutex',
|
|
82
|
+
sampleType: 'delay',
|
|
83
|
+
sampleUnit: 'nanoseconds',
|
|
84
|
+
periodType: 'contentions',
|
|
85
|
+
periodUnit: 'count'
|
|
86
|
+
},
|
|
87
|
+
{
|
|
88
|
+
ID: 'process_cpu:cpu:nanoseconds:cpu:nanoseconds',
|
|
89
|
+
name: 'process_cpu',
|
|
90
|
+
sampleType: 'cpu',
|
|
91
|
+
sampleUnit: 'nanoseconds',
|
|
92
|
+
periodType: 'cpu',
|
|
93
|
+
periodUnit: 'nanoseconds'
|
|
94
|
+
},
|
|
95
|
+
{
|
|
96
|
+
ID: 'process_cpu:samples:count:cpu:nanoseconds',
|
|
97
|
+
name: 'process_cpu',
|
|
98
|
+
sampleType: 'samples',
|
|
99
|
+
sampleUnit: 'count',
|
|
100
|
+
periodType: 'cpu',
|
|
101
|
+
periodUnit: 'nanoseconds'
|
|
102
|
+
}
|
|
103
|
+
]
|
|
104
|
+
};
|
|
105
|
+
export const MOCK_LABEL_NAMES_RESPONSE = {
|
|
106
|
+
names: [
|
|
107
|
+
'__name__',
|
|
108
|
+
'__period_type__',
|
|
109
|
+
'__period_unit__',
|
|
110
|
+
'__profile_type__',
|
|
111
|
+
'__service_name__',
|
|
112
|
+
'__type__',
|
|
113
|
+
'__unit__',
|
|
114
|
+
'hostname',
|
|
115
|
+
'pyroscope_spy',
|
|
116
|
+
'region',
|
|
117
|
+
'service_git_ref',
|
|
118
|
+
'service_name',
|
|
119
|
+
'service_repository',
|
|
120
|
+
'target',
|
|
121
|
+
'vehicle'
|
|
122
|
+
]
|
|
123
|
+
};
|
|
124
|
+
// label values for "name" : "region"
|
|
125
|
+
export const MOCK_LABEL_VALUES_RESPONSE_NAME_REGION = {
|
|
126
|
+
names: [
|
|
127
|
+
'ap-south',
|
|
128
|
+
'eu-north',
|
|
129
|
+
'us-east'
|
|
130
|
+
]
|
|
131
|
+
};
|
|
132
|
+
|
|
133
|
+
//# sourceMappingURL=mock-data.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/test/mock-data.ts"],"sourcesContent":["// Copyright 2025 The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport { SearchProfileTypesResponse, SearchLabelNamesResponse, SearchLabelValuesResponse } from '../model/api-types';\n\nexport const MOCK_PROFILE_TYPES_RESPONSE: SearchProfileTypesResponse = {\n profileTypes: [\n {\n ID: 'block:contentions:count:contentions:count',\n name: 'block',\n sampleType: 'contentions',\n sampleUnit: 'count',\n periodType: 'contentions',\n periodUnit: 'count',\n },\n {\n ID: 'block:delay:nanoseconds:contentions:count',\n name: 'block',\n sampleType: 'delay',\n sampleUnit: 'nanoseconds',\n periodType: 'contentions',\n periodUnit: 'count',\n },\n {\n ID: 'goroutines:goroutine:count:goroutine:count',\n name: 'goroutines',\n sampleType: 'goroutine',\n sampleUnit: 'count',\n periodType: 'goroutine',\n periodUnit: 'count',\n },\n {\n ID: 'memory:alloc_objects:count:space:bytes',\n name: 'memory',\n sampleType: 'alloc_objects',\n sampleUnit: 'count',\n periodType: 'space',\n periodUnit: 'bytes',\n },\n {\n ID: 'memory:alloc_space:bytes:space:bytes',\n name: 'memory',\n sampleType: 'alloc_space',\n sampleUnit: 'bytes',\n periodType: 'space',\n periodUnit: 'bytes',\n },\n {\n ID: 'memory:inuse_objects:count:space:bytes',\n name: 'memory',\n sampleType: 'inuse_objects',\n sampleUnit: 'count',\n periodType: 'space',\n periodUnit: 'bytes',\n },\n {\n ID: 'memory:inuse_space:bytes:space:bytes',\n name: 'memory',\n sampleType: 'inuse_space',\n sampleUnit: 'bytes',\n periodType: 'space',\n periodUnit: 'bytes',\n },\n {\n ID: 'mutex:contentions:count:contentions:count',\n name: 'mutex',\n sampleType: 'contentions',\n sampleUnit: 'count',\n periodType: 'contentions',\n periodUnit: 'count',\n },\n {\n ID: 'mutex:delay:nanoseconds:contentions:count',\n name: 'mutex',\n sampleType: 'delay',\n sampleUnit: 'nanoseconds',\n periodType: 'contentions',\n periodUnit: 'count',\n },\n {\n ID: 'process_cpu:cpu:nanoseconds:cpu:nanoseconds',\n name: 'process_cpu',\n sampleType: 'cpu',\n sampleUnit: 'nanoseconds',\n periodType: 'cpu',\n periodUnit: 'nanoseconds',\n },\n {\n ID: 'process_cpu:samples:count:cpu:nanoseconds',\n name: 'process_cpu',\n sampleType: 'samples',\n sampleUnit: 'count',\n periodType: 'cpu',\n periodUnit: 'nanoseconds',\n },\n ],\n};\n\nexport const MOCK_LABEL_NAMES_RESPONSE: SearchLabelNamesResponse = {\n names: [\n '__name__',\n '__period_type__',\n '__period_unit__',\n '__profile_type__',\n '__service_name__',\n '__type__',\n '__unit__',\n 'hostname',\n 'pyroscope_spy',\n 'region',\n 'service_git_ref',\n 'service_name',\n 'service_repository',\n 'target',\n 'vehicle',\n ],\n};\n\n// label values for \"name\" : \"region\"\nexport const MOCK_LABEL_VALUES_RESPONSE_NAME_REGION: SearchLabelValuesResponse = {\n names: ['ap-south', 'eu-north', 'us-east'],\n};\n"],"names":["MOCK_PROFILE_TYPES_RESPONSE","profileTypes","ID","name","sampleType","sampleUnit","periodType","periodUnit","MOCK_LABEL_NAMES_RESPONSE","names","MOCK_LABEL_VALUES_RESPONSE_NAME_REGION"],"mappings":"AAAA,oCAAoC;AACpC,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AAIjC,OAAO,MAAMA,8BAA0D;IACrEC,cAAc;QACZ;YACEC,IAAI;YACJC,MAAM;YACNC,YAAY;YACZC,YAAY;YACZC,YAAY;YACZC,YAAY;QACd;QACA;YACEL,IAAI;YACJC,MAAM;YACNC,YAAY;YACZC,YAAY;YACZC,YAAY;YACZC,YAAY;QACd;QACA;YACEL,IAAI;YACJC,MAAM;YACNC,YAAY;YACZC,YAAY;YACZC,YAAY;YACZC,YAAY;QACd;QACA;YACEL,IAAI;YACJC,MAAM;YACNC,YAAY;YACZC,YAAY;YACZC,YAAY;YACZC,YAAY;QACd;QACA;YACEL,IAAI;YACJC,MAAM;YACNC,YAAY;YACZC,YAAY;YACZC,YAAY;YACZC,YAAY;QACd;QACA;YACEL,IAAI;YACJC,MAAM;YACNC,YAAY;YACZC,YAAY;YACZC,YAAY;YACZC,YAAY;QACd;QACA;YACEL,IAAI;YACJC,MAAM;YACNC,YAAY;YACZC,YAAY;YACZC,YAAY;YACZC,YAAY;QACd;QACA;YACEL,IAAI;YACJC,MAAM;YACNC,YAAY;YACZC,YAAY;YACZC,YAAY;YACZC,YAAY;QACd;QACA;YACEL,IAAI;YACJC,MAAM;YACNC,YAAY;YACZC,YAAY;YACZC,YAAY;YACZC,YAAY;QACd;QACA;YACEL,IAAI;YACJC,MAAM;YACNC,YAAY;YACZC,YAAY;YACZC,YAAY;YACZC,YAAY;QACd;QACA;YACEL,IAAI;YACJC,MAAM;YACNC,YAAY;YACZC,YAAY;YACZC,YAAY;YACZC,YAAY;QACd;KACD;AACH,EAAE;AAEF,OAAO,MAAMC,4BAAsD;IACjEC,OAAO;QACL;QACA;QACA;QACA;QACA;QACA;QACA;QACA;QACA;QACA;QACA;QACA;QACA;QACA;QACA;KACD;AACH,EAAE;AAEF,qCAAqC;AACrC,OAAO,MAAMC,yCAAoE;IAC/ED,OAAO;QAAC;QAAY;QAAY;KAAU;AAC5C,EAAE"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"setup-tests.d.ts","sourceRoot":"","sources":["../../../src/test/setup-tests.ts"],"names":[],"mappings":"AAaA,OAAO,yCAAyC,CAAC"}
|