@perses-dev/tempo-plugin 0.43.0 → 0.44.0-rc1
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/dist/cjs/index.js +4 -4
- package/dist/cjs/model/tempo-client.js +5 -5
- package/dist/cjs/model/tempo-selectors.js +3 -3
- package/dist/cjs/plugins/tempo-datasource.js +2 -2
- package/dist/cjs/plugins/tempo-trace-query/DashboardTempoTraceQueryEditor.js +62 -0
- package/dist/cjs/plugins/tempo-trace-query/TempoTraceQuery.js +32 -0
- package/dist/cjs/plugins/tempo-trace-query/TempoTraceQueryEditor.js +55 -0
- package/dist/cjs/plugins/tempo-trace-query/TraceQLEditor.js +46 -0
- package/dist/cjs/plugins/tempo-trace-query/get-trace-data.js +101 -0
- package/dist/cjs/plugins/tempo-trace-query/query-editor-model.js +53 -0
- package/dist/cjs/test/mock-data.js +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/model/api-types.js +5 -1
- package/dist/model/api-types.js.map +1 -1
- package/dist/model/tempo-client.js +1 -1
- package/dist/model/tempo-client.js.map +1 -1
- package/dist/model/tempo-selectors.js.map +1 -1
- package/dist/model/trace-query-model.js +3 -1
- package/dist/model/trace-query-model.js.map +1 -1
- package/dist/plugins/get-trace-data.js.map +1 -1
- package/dist/plugins/tempo-datasource-types.js.map +1 -1
- package/dist/plugins/tempo-datasource.js +2 -2
- package/dist/plugins/tempo-datasource.js.map +1 -1
- package/dist/plugins/tempo-trace-query/DashboardTempoTraceQueryEditor.d.ts +13 -0
- package/dist/plugins/tempo-trace-query/DashboardTempoTraceQueryEditor.d.ts.map +1 -0
- package/dist/plugins/tempo-trace-query/DashboardTempoTraceQueryEditor.js +54 -0
- package/dist/plugins/tempo-trace-query/DashboardTempoTraceQueryEditor.js.map +1 -0
- package/dist/plugins/tempo-trace-query/TempoTraceQuery.d.ts +13 -0
- package/dist/plugins/tempo-trace-query/TempoTraceQuery.d.ts.map +1 -0
- package/dist/plugins/tempo-trace-query/TempoTraceQuery.js +26 -0
- package/dist/plugins/tempo-trace-query/TempoTraceQuery.js.map +1 -0
- package/dist/plugins/tempo-trace-query/TempoTraceQueryEditor.d.ts +3 -0
- package/dist/plugins/tempo-trace-query/TempoTraceQueryEditor.d.ts.map +1 -0
- package/dist/plugins/tempo-trace-query/TempoTraceQueryEditor.js +47 -0
- package/dist/plugins/tempo-trace-query/TempoTraceQueryEditor.js.map +1 -0
- package/dist/plugins/tempo-trace-query/TraceQLEditor.d.ts +4 -0
- package/dist/plugins/tempo-trace-query/TraceQLEditor.d.ts.map +1 -0
- package/dist/plugins/tempo-trace-query/TraceQLEditor.js +33 -0
- package/dist/plugins/tempo-trace-query/TraceQLEditor.js.map +1 -0
- package/dist/plugins/tempo-trace-query/get-trace-data.d.ts +9 -0
- package/dist/plugins/tempo-trace-query/get-trace-data.d.ts.map +1 -0
- package/dist/plugins/tempo-trace-query/get-trace-data.js +85 -0
- package/dist/plugins/tempo-trace-query/get-trace-data.js.map +1 -0
- package/dist/plugins/tempo-trace-query/query-editor-model.d.ts +15 -0
- package/dist/plugins/tempo-trace-query/query-editor-model.d.ts.map +1 -0
- package/dist/plugins/tempo-trace-query/query-editor-model.js +50 -0
- package/dist/plugins/tempo-trace-query/query-editor-model.js.map +1 -0
- package/dist/test/mock-data.js +1 -1
- package/dist/test/mock-data.js.map +1 -1
- package/package.json +4 -4
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/plugins/tempo-datasource.tsx"],"sourcesContent":["// Copyright 2023 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 { DatasourcePlugin } from '@perses-dev/plugin-system';\nimport { searchTraceQuery, searchTraceID, getEnrichedTraceQuery, TempoClient } from '../model/tempo-client';\nimport { TempoDatasourceSpec } from './tempo-datasource-types';\n\n/**\n * Creates a TempoClient for a specific datasource spec.\n */\nconst createClient: DatasourcePlugin<TempoDatasourceSpec, TempoClient>['createClient'] = (spec, options) => {\n const { directUrl } = spec;\n const { proxyUrl } = options;\n\n // Use the direct URL if specified, but fallback to the proxyUrl by default if not specified\n const datasourceUrl = directUrl ?? proxyUrl;\n if (datasourceUrl === undefined) {\n throw new Error('No URL specified for Tempo client. You can use directUrl in the spec to configure it.');\n }\n\n return {\n options: {\n datasourceUrl,\n },\n searchTraceQuery: (query: string) => searchTraceQuery(query, datasourceUrl),\n searchTraceID: (traceID: string) => searchTraceID(traceID, datasourceUrl),\n getEnrichedTraceQuery: (query: string) => getEnrichedTraceQuery(query, datasourceUrl),\n };\n};\n\nexport const TempoDatasource: DatasourcePlugin<TempoDatasourceSpec, TempoClient> = {\n createClient,\n // TODO add a options editor component for tempo datasource\n // OptionsEditorComponent: TempoDatasourceEditor,\n createInitialOptions: () => ({ directUrl: '' }),\n};\n"],"names":["searchTraceQuery","searchTraceID","getEnrichedTraceQuery","createClient","spec","options","directUrl","proxyUrl","datasourceUrl","undefined","Error","query","traceID","TempoDatasource","createInitialOptions"],"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;AAGjC,SAASA,gBAAgB,EAAEC,aAAa,EAAEC,qBAAqB,QAAqB,wBAAwB;AAG5G;;CAEC,GACD,MAAMC,eAAmF,CAACC,MAAMC;IAC9F,MAAM,EAAEC,
|
|
1
|
+
{"version":3,"sources":["../../src/plugins/tempo-datasource.tsx"],"sourcesContent":["// Copyright 2023 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 { DatasourcePlugin } from '@perses-dev/plugin-system';\nimport { searchTraceQuery, searchTraceID, getEnrichedTraceQuery, TempoClient } from '../model/tempo-client';\nimport { TempoDatasourceSpec } from './tempo-datasource-types';\n\n/**\n * Creates a TempoClient for a specific datasource spec.\n */\nconst createClient: DatasourcePlugin<TempoDatasourceSpec, TempoClient>['createClient'] = (spec, options) => {\n const { directUrl } = spec;\n const { proxyUrl } = options;\n\n // Use the direct URL if specified, but fallback to the proxyUrl by default if not specified\n const datasourceUrl = directUrl ?? proxyUrl;\n if (datasourceUrl === undefined) {\n throw new Error('No URL specified for Tempo client. You can use directUrl in the spec to configure it.');\n }\n\n return {\n options: {\n datasourceUrl,\n },\n searchTraceQuery: (query: string) => searchTraceQuery(query, datasourceUrl),\n searchTraceID: (traceID: string) => searchTraceID(traceID, datasourceUrl),\n getEnrichedTraceQuery: (query: string) => getEnrichedTraceQuery(query, datasourceUrl),\n };\n};\n\nexport const TempoDatasource: DatasourcePlugin<TempoDatasourceSpec, TempoClient> = {\n createClient,\n // TODO add a options editor component for tempo datasource\n // OptionsEditorComponent: TempoDatasourceEditor,\n createInitialOptions: () => ({ directUrl: '' }),\n};\n"],"names":["searchTraceQuery","searchTraceID","getEnrichedTraceQuery","createClient","spec","options","directUrl","proxyUrl","datasourceUrl","undefined","Error","query","traceID","TempoDatasource","createInitialOptions"],"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;AAGjC,SAASA,gBAAgB,EAAEC,aAAa,EAAEC,qBAAqB,QAAqB,wBAAwB;AAG5G;;CAEC,GACD,MAAMC,eAAmF,CAACC,MAAMC;IAC9F,MAAM,EAAEC,SAAS,EAAE,GAAGF;IACtB,MAAM,EAAEG,QAAQ,EAAE,GAAGF;IAErB,4FAA4F;IAC5F,MAAMG,gBAAgBF,sBAAAA,uBAAAA,YAAaC;IACnC,IAAIC,kBAAkBC,WAAW;QAC/B,MAAM,IAAIC,MAAM;IAClB;IAEA,OAAO;QACLL,SAAS;YACPG;QACF;QACAR,kBAAkB,CAACW,QAAkBX,iBAAiBW,OAAOH;QAC7DP,eAAe,CAACW,UAAoBX,cAAcW,SAASJ;QAC3DN,uBAAuB,CAACS,QAAkBT,sBAAsBS,OAAOH;IACzE;AACF;AAEA,OAAO,MAAMK,kBAAsE;IACjFV;IACA,2DAA2D;IAC3D,iDAAiD;IACjDW,sBAAsB,IAAO,CAAA;YAAER,WAAW;QAAG,CAAA;AAC/C,EAAE"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { DatasourceSelector } from '@perses-dev/core/dist/model';
|
|
2
|
+
import { TempoDatasourceSelector } from '../../model/tempo-selectors';
|
|
3
|
+
interface DashboardTempoTraceQueryEditorProps {
|
|
4
|
+
selectedDatasource: TempoDatasourceSelector;
|
|
5
|
+
handleDatasourceChange: (next: DatasourceSelector) => void;
|
|
6
|
+
datasourceURL: string | undefined;
|
|
7
|
+
query: string;
|
|
8
|
+
handleQueryChange: (e: string) => void;
|
|
9
|
+
handleQueryBlur: () => void;
|
|
10
|
+
}
|
|
11
|
+
export declare function DashboardTempoTraceQueryEditor(props: DashboardTempoTraceQueryEditorProps): import("react/jsx-runtime").JSX.Element;
|
|
12
|
+
export {};
|
|
13
|
+
//# sourceMappingURL=DashboardTempoTraceQueryEditor.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"DashboardTempoTraceQueryEditor.d.ts","sourceRoot":"","sources":["../../../src/plugins/tempo-trace-query/DashboardTempoTraceQueryEditor.tsx"],"names":[],"mappings":"AAeA,OAAO,EAAE,kBAAkB,EAAE,MAAM,6BAA6B,CAAC;AACjE,OAAO,EAAE,uBAAuB,EAAyB,MAAM,6BAA6B,CAAC;AAG7F,UAAU,mCAAmC;IAC3C,kBAAkB,EAAE,uBAAuB,CAAC;IAC5C,sBAAsB,EAAE,CAAC,IAAI,EAAE,kBAAkB,KAAK,IAAI,CAAC;IAC3D,aAAa,EAAE,MAAM,GAAG,SAAS,CAAC;IAClC,KAAK,EAAE,MAAM,CAAC;IACd,iBAAiB,EAAE,CAAC,CAAC,EAAE,MAAM,KAAK,IAAI,CAAC;IACvC,eAAe,EAAE,MAAM,IAAI,CAAC;CAC7B;AAED,wBAAgB,8BAA8B,CAAC,KAAK,EAAE,mCAAmC,2CA0BxF"}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
// Copyright 2023 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 { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
14
|
+
import { Stack, FormControl, InputLabel } from '@mui/material';
|
|
15
|
+
import { DatasourceSelect } from '@perses-dev/plugin-system';
|
|
16
|
+
import { TEMPO_DATASOURCE_KIND } from '../../model/tempo-selectors';
|
|
17
|
+
import { TraceQLEditor } from './TraceQLEditor';
|
|
18
|
+
export function DashboardTempoTraceQueryEditor(props) {
|
|
19
|
+
const { selectedDatasource, handleDatasourceChange, datasourceURL, query, handleQueryChange, handleQueryBlur } = props;
|
|
20
|
+
return /*#__PURE__*/ _jsxs(Stack, {
|
|
21
|
+
spacing: 2,
|
|
22
|
+
children: [
|
|
23
|
+
/*#__PURE__*/ _jsxs(FormControl, {
|
|
24
|
+
margin: "dense",
|
|
25
|
+
fullWidth: false,
|
|
26
|
+
children: [
|
|
27
|
+
/*#__PURE__*/ _jsx(InputLabel, {
|
|
28
|
+
id: "tempo-datasource-label",
|
|
29
|
+
children: "Tempo Datasource"
|
|
30
|
+
}),
|
|
31
|
+
/*#__PURE__*/ _jsx(DatasourceSelect, {
|
|
32
|
+
datasourcePluginKind: TEMPO_DATASOURCE_KIND,
|
|
33
|
+
value: selectedDatasource,
|
|
34
|
+
onChange: handleDatasourceChange,
|
|
35
|
+
labelId: "tempo-datasource-label",
|
|
36
|
+
label: "Tempo Datasource"
|
|
37
|
+
})
|
|
38
|
+
]
|
|
39
|
+
}),
|
|
40
|
+
/*#__PURE__*/ _jsx(TraceQLEditor, {
|
|
41
|
+
completeConfig: {
|
|
42
|
+
remote: {
|
|
43
|
+
url: datasourceURL
|
|
44
|
+
}
|
|
45
|
+
},
|
|
46
|
+
value: query,
|
|
47
|
+
onChange: handleQueryChange,
|
|
48
|
+
onBlur: handleQueryBlur
|
|
49
|
+
})
|
|
50
|
+
]
|
|
51
|
+
});
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
//# sourceMappingURL=DashboardTempoTraceQueryEditor.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/plugins/tempo-trace-query/DashboardTempoTraceQueryEditor.tsx"],"sourcesContent":["// Copyright 2023 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 { Stack, FormControl, InputLabel } from '@mui/material';\nimport { DatasourceSelect } from '@perses-dev/plugin-system';\nimport { DatasourceSelector } from '@perses-dev/core/dist/model';\nimport { TempoDatasourceSelector, TEMPO_DATASOURCE_KIND } from '../../model/tempo-selectors';\nimport { TraceQLEditor } from './TraceQLEditor';\n\ninterface DashboardTempoTraceQueryEditorProps {\n selectedDatasource: TempoDatasourceSelector;\n handleDatasourceChange: (next: DatasourceSelector) => void;\n datasourceURL: string | undefined;\n query: string;\n handleQueryChange: (e: string) => void;\n handleQueryBlur: () => void;\n}\n\nexport function DashboardTempoTraceQueryEditor(props: DashboardTempoTraceQueryEditorProps) {\n const { selectedDatasource, handleDatasourceChange, datasourceURL, query, handleQueryChange, handleQueryBlur } =\n props;\n\n return (\n <Stack spacing={2}>\n <FormControl margin=\"dense\" fullWidth={false}>\n {/* TODO: How do we ensure unique ID values if there are multiple of these? Can we use React 18 useId and\n maintain 17 compatibility somehow with a polyfill/shim? */}\n <InputLabel id=\"tempo-datasource-label\">Tempo Datasource</InputLabel>\n <DatasourceSelect\n datasourcePluginKind={TEMPO_DATASOURCE_KIND}\n value={selectedDatasource}\n onChange={handleDatasourceChange}\n labelId=\"tempo-datasource-label\"\n label=\"Tempo Datasource\"\n />\n </FormControl>\n <TraceQLEditor\n completeConfig={{ remote: { url: datasourceURL } }}\n value={query}\n onChange={handleQueryChange}\n onBlur={handleQueryBlur}\n />\n </Stack>\n );\n}\n"],"names":["Stack","FormControl","InputLabel","DatasourceSelect","TEMPO_DATASOURCE_KIND","TraceQLEditor","DashboardTempoTraceQueryEditor","props","selectedDatasource","handleDatasourceChange","datasourceURL","query","handleQueryChange","handleQueryBlur","spacing","margin","fullWidth","id","datasourcePluginKind","value","onChange","labelId","label","completeConfig","remote","url","onBlur"],"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,KAAK,EAAEC,WAAW,EAAEC,UAAU,QAAQ,gBAAgB;AAC/D,SAASC,gBAAgB,QAAQ,4BAA4B;AAE7D,SAAkCC,qBAAqB,QAAQ,8BAA8B;AAC7F,SAASC,aAAa,QAAQ,kBAAkB;AAWhD,OAAO,SAASC,+BAA+BC,KAA0C;IACvF,MAAM,EAAEC,kBAAkB,EAAEC,sBAAsB,EAAEC,aAAa,EAAEC,KAAK,EAAEC,iBAAiB,EAAEC,eAAe,EAAE,GAC5GN;IAEF,qBACE,MAACP;QAAMc,SAAS;;0BACd,MAACb;gBAAYc,QAAO;gBAAQC,WAAW;;kCAGrC,KAACd;wBAAWe,IAAG;kCAAyB;;kCACxC,KAACd;wBACCe,sBAAsBd;wBACtBe,OAAOX;wBACPY,UAAUX;wBACVY,SAAQ;wBACRC,OAAM;;;;0BAGV,KAACjB;gBACCkB,gBAAgB;oBAAEC,QAAQ;wBAAEC,KAAKf;oBAAc;gBAAE;gBACjDS,OAAOR;gBACPS,UAAUR;gBACVc,QAAQb;;;;AAIhB"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { TempoTraceQueryEditor } from './TempoTraceQueryEditor';
|
|
2
|
+
/**
|
|
3
|
+
* The core Tempo TraceQuery plugin for Perses.
|
|
4
|
+
*/
|
|
5
|
+
export declare const TempoTraceQuery: {
|
|
6
|
+
getTraceData: (spec: import("../../model/trace-query-model").TempoTraceQuerySpec, ctx: import("@perses-dev/plugin-system").TraceQueryContext) => Promise<import("@perses-dev/core").TraceData>;
|
|
7
|
+
OptionsEditorComponent: typeof TempoTraceQueryEditor;
|
|
8
|
+
createInitialOptions: () => {
|
|
9
|
+
query: string;
|
|
10
|
+
datasource: undefined;
|
|
11
|
+
};
|
|
12
|
+
};
|
|
13
|
+
//# sourceMappingURL=TempoTraceQuery.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"TempoTraceQuery.d.ts","sourceRoot":"","sources":["../../../src/plugins/tempo-trace-query/TempoTraceQuery.ts"],"names":[],"mappings":"AAcA,OAAO,EAAE,qBAAqB,EAAE,MAAM,yBAAyB,CAAC;AAEhE;;GAEG;AACH,eAAO,MAAM,eAAe;;;;;;;CAO3B,CAAC"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
// Copyright 2023 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 { getTraceData } from './get-trace-data';
|
|
14
|
+
import { TempoTraceQueryEditor } from './TempoTraceQueryEditor';
|
|
15
|
+
/**
|
|
16
|
+
* The core Tempo TraceQuery plugin for Perses.
|
|
17
|
+
*/ export const TempoTraceQuery = {
|
|
18
|
+
getTraceData,
|
|
19
|
+
OptionsEditorComponent: TempoTraceQueryEditor,
|
|
20
|
+
createInitialOptions: ()=>({
|
|
21
|
+
query: '{}',
|
|
22
|
+
datasource: undefined
|
|
23
|
+
})
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
//# sourceMappingURL=TempoTraceQuery.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/plugins/tempo-trace-query/TempoTraceQuery.ts"],"sourcesContent":["// Copyright 2023 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 { getTraceData } from './get-trace-data';\nimport { TempoTraceQueryEditor } from './TempoTraceQueryEditor';\n\n/**\n * The core Tempo TraceQuery plugin for Perses.\n */\nexport const TempoTraceQuery = {\n getTraceData,\n OptionsEditorComponent: TempoTraceQueryEditor,\n createInitialOptions: () => ({\n query: '{}',\n datasource: undefined,\n }),\n};\n"],"names":["getTraceData","TempoTraceQueryEditor","TempoTraceQuery","OptionsEditorComponent","createInitialOptions","query","datasource","undefined"],"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,YAAY,QAAQ,mBAAmB;AAChD,SAASC,qBAAqB,QAAQ,0BAA0B;AAEhE;;CAEC,GACD,OAAO,MAAMC,kBAAkB;IAC7BF;IACAG,wBAAwBF;IACxBG,sBAAsB,IAAO,CAAA;YAC3BC,OAAO;YACPC,YAAYC;QACd,CAAA;AACF,EAAE"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"TempoTraceQueryEditor.d.ts","sourceRoot":"","sources":["../../../src/plugins/tempo-trace-query/TempoTraceQueryEditor.tsx"],"names":[],"mappings":"AAiBA,OAAO,EAAE,qBAAqB,EAAiB,MAAM,sBAAsB,CAAC;AAG5E,wBAAgB,qBAAqB,CAAC,KAAK,EAAE,qBAAqB,2CAmCjE"}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
// Copyright 2023 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 { jsx as _jsx } from "react/jsx-runtime";
|
|
14
|
+
import { useDatasourceClient } from '@perses-dev/plugin-system';
|
|
15
|
+
import { produce } from 'immer';
|
|
16
|
+
import { DEFAULT_TEMPO, isDefaultTempoSelector, isTempoDatasourceSelector } from '../../model/tempo-selectors';
|
|
17
|
+
import { useQueryState } from './query-editor-model';
|
|
18
|
+
import { DashboardTempoTraceQueryEditor } from './DashboardTempoTraceQueryEditor';
|
|
19
|
+
export function TempoTraceQueryEditor(props) {
|
|
20
|
+
const { onChange, value } = props;
|
|
21
|
+
const { datasource } = value;
|
|
22
|
+
const selectedDatasource = datasource !== null && datasource !== void 0 ? datasource : DEFAULT_TEMPO;
|
|
23
|
+
const { data: client } = useDatasourceClient(selectedDatasource);
|
|
24
|
+
const datasourceURL = client === null || client === void 0 ? void 0 : client.options.datasourceUrl;
|
|
25
|
+
const { query, handleQueryChange, handleQueryBlur } = useQueryState(props);
|
|
26
|
+
const handleDatasourceChange = (next)=>{
|
|
27
|
+
if (isTempoDatasourceSelector(next)) {
|
|
28
|
+
onChange(produce(value, (draft)=>{
|
|
29
|
+
// If they're using the default, just omit the datasource prop (i.e. set to undefined)
|
|
30
|
+
const nextDatasource = isDefaultTempoSelector(next) ? undefined : next;
|
|
31
|
+
draft.datasource = nextDatasource;
|
|
32
|
+
}));
|
|
33
|
+
return;
|
|
34
|
+
}
|
|
35
|
+
throw new Error('Got unexpected non-Tempo datasource selector');
|
|
36
|
+
};
|
|
37
|
+
return /*#__PURE__*/ _jsx(DashboardTempoTraceQueryEditor, {
|
|
38
|
+
selectedDatasource: selectedDatasource,
|
|
39
|
+
handleDatasourceChange: handleDatasourceChange,
|
|
40
|
+
datasourceURL: datasourceURL,
|
|
41
|
+
query: query,
|
|
42
|
+
handleQueryChange: handleQueryChange,
|
|
43
|
+
handleQueryBlur: handleQueryBlur
|
|
44
|
+
});
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
//# sourceMappingURL=TempoTraceQueryEditor.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/plugins/tempo-trace-query/TempoTraceQueryEditor.tsx"],"sourcesContent":["// Copyright 2023 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 { DatasourceSelectProps, useDatasourceClient } from '@perses-dev/plugin-system';\nimport { produce } from 'immer';\nimport { DEFAULT_TEMPO, isDefaultTempoSelector, isTempoDatasourceSelector } from '../../model/tempo-selectors';\nimport { TempoClient } from '../../model/tempo-client';\nimport { TraceQueryEditorProps, useQueryState } from './query-editor-model';\nimport { DashboardTempoTraceQueryEditor } from './DashboardTempoTraceQueryEditor';\n\nexport function TempoTraceQueryEditor(props: TraceQueryEditorProps) {\n const { onChange, value } = props;\n const { datasource } = value;\n const selectedDatasource = datasource ?? DEFAULT_TEMPO;\n\n const { data: client } = useDatasourceClient<TempoClient>(selectedDatasource);\n const datasourceURL = client?.options.datasourceUrl;\n\n const { query, handleQueryChange, handleQueryBlur } = useQueryState(props);\n\n const handleDatasourceChange: DatasourceSelectProps['onChange'] = (next) => {\n if (isTempoDatasourceSelector(next)) {\n onChange(\n produce(value, (draft) => {\n // If they're using the default, just omit the datasource prop (i.e. set to undefined)\n const nextDatasource = isDefaultTempoSelector(next) ? undefined : next;\n draft.datasource = nextDatasource;\n })\n );\n return;\n }\n\n throw new Error('Got unexpected non-Tempo datasource selector');\n };\n\n return (\n <DashboardTempoTraceQueryEditor\n selectedDatasource={selectedDatasource}\n handleDatasourceChange={handleDatasourceChange}\n datasourceURL={datasourceURL}\n query={query}\n handleQueryChange={handleQueryChange}\n handleQueryBlur={handleQueryBlur}\n />\n );\n}\n"],"names":["useDatasourceClient","produce","DEFAULT_TEMPO","isDefaultTempoSelector","isTempoDatasourceSelector","useQueryState","DashboardTempoTraceQueryEditor","TempoTraceQueryEditor","props","onChange","value","datasource","selectedDatasource","data","client","datasourceURL","options","datasourceUrl","query","handleQueryChange","handleQueryBlur","handleDatasourceChange","next","draft","nextDatasource","undefined","Error"],"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,SAAgCA,mBAAmB,QAAQ,4BAA4B;AACvF,SAASC,OAAO,QAAQ,QAAQ;AAChC,SAASC,aAAa,EAAEC,sBAAsB,EAAEC,yBAAyB,QAAQ,8BAA8B;AAE/G,SAAgCC,aAAa,QAAQ,uBAAuB;AAC5E,SAASC,8BAA8B,QAAQ,mCAAmC;AAElF,OAAO,SAASC,sBAAsBC,KAA4B;IAChE,MAAM,EAAEC,QAAQ,EAAEC,KAAK,EAAE,GAAGF;IAC5B,MAAM,EAAEG,UAAU,EAAE,GAAGD;IACvB,MAAME,qBAAqBD,uBAAAA,wBAAAA,aAAcT;IAEzC,MAAM,EAAEW,MAAMC,MAAM,EAAE,GAAGd,oBAAiCY;IAC1D,MAAMG,gBAAgBD,mBAAAA,6BAAAA,OAAQE,OAAO,CAACC,aAAa;IAEnD,MAAM,EAAEC,KAAK,EAAEC,iBAAiB,EAAEC,eAAe,EAAE,GAAGf,cAAcG;IAEpE,MAAMa,yBAA4D,CAACC;QACjE,IAAIlB,0BAA0BkB,OAAO;YACnCb,SACER,QAAQS,OAAO,CAACa;gBACd,sFAAsF;gBACtF,MAAMC,iBAAiBrB,uBAAuBmB,QAAQG,YAAYH;gBAClEC,MAAMZ,UAAU,GAAGa;YACrB;YAEF;QACF;QAEA,MAAM,IAAIE,MAAM;IAClB;IAEA,qBACE,KAACpB;QACCM,oBAAoBA;QACpBS,wBAAwBA;QACxBN,eAAeA;QACfG,OAAOA;QACPC,mBAAmBA;QACnBC,iBAAiBA;;AAGvB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"TraceQLEditor.d.ts","sourceRoot":"","sources":["../../../src/plugins/tempo-trace-query/TraceQLEditor.tsx"],"names":[],"mappings":"AAgBA,wBAAgB,aAAa,CAAC,EAAE,GAAG,IAAI,EAAE;;CAAA,2CAgBxC"}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
// Copyright 2023 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 { jsx as _jsx } from "react/jsx-runtime";
|
|
14
|
+
import { useTheme } from '@mui/material';
|
|
15
|
+
import CodeMirror from '@uiw/react-codemirror';
|
|
16
|
+
export function TraceQLEditor({ ...rest }) {
|
|
17
|
+
const theme = useTheme();
|
|
18
|
+
const isDarkMode = theme.palette.mode === 'dark';
|
|
19
|
+
return /*#__PURE__*/ _jsx(CodeMirror, {
|
|
20
|
+
...rest,
|
|
21
|
+
style: {
|
|
22
|
+
border: `1px solid ${theme.palette.divider}`
|
|
23
|
+
},
|
|
24
|
+
theme: isDarkMode ? 'dark' : 'light',
|
|
25
|
+
basicSetup: {
|
|
26
|
+
highlightActiveLine: false,
|
|
27
|
+
highlightActiveLineGutter: false,
|
|
28
|
+
foldGutter: false
|
|
29
|
+
}
|
|
30
|
+
});
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
//# sourceMappingURL=TraceQLEditor.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/plugins/tempo-trace-query/TraceQLEditor.tsx"],"sourcesContent":["// Copyright 2023 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 { useTheme } from '@mui/material';\nimport CodeMirror from '@uiw/react-codemirror';\n\nexport function TraceQLEditor({ ...rest }) {\n const theme = useTheme();\n const isDarkMode = theme.palette.mode === 'dark';\n\n return (\n <CodeMirror\n {...rest}\n style={{ border: `1px solid ${theme.palette.divider}` }}\n theme={isDarkMode ? 'dark' : 'light'}\n basicSetup={{\n highlightActiveLine: false,\n highlightActiveLineGutter: false,\n foldGutter: false,\n }}\n />\n );\n}\n"],"names":["useTheme","CodeMirror","TraceQLEditor","rest","theme","isDarkMode","palette","mode","style","border","divider","basicSetup","highlightActiveLine","highlightActiveLineGutter","foldGutter"],"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,gBAAgB;AACzC,OAAOC,gBAAgB,wBAAwB;AAE/C,OAAO,SAASC,cAAc,EAAE,GAAGC,MAAM;IACvC,MAAMC,QAAQJ;IACd,MAAMK,aAAaD,MAAME,OAAO,CAACC,IAAI,KAAK;IAE1C,qBACE,KAACN;QACE,GAAGE,IAAI;QACRK,OAAO;YAAEC,QAAQ,CAAC,UAAU,EAAEL,MAAME,OAAO,CAACI,OAAO,CAAC,CAAC;QAAC;QACtDN,OAAOC,aAAa,SAAS;QAC7BM,YAAY;YACVC,qBAAqB;YACrBC,2BAA2B;YAC3BC,YAAY;QACd;;AAGN"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { TraceQueryPlugin } from '@perses-dev/plugin-system';
|
|
2
|
+
import { AbsoluteTimeRange } from '@perses-dev/core';
|
|
3
|
+
import { TempoTraceQuerySpec } from '../../model/trace-query-model';
|
|
4
|
+
export declare function getUnixTimeRange(timeRange: AbsoluteTimeRange): {
|
|
5
|
+
start: number;
|
|
6
|
+
end: number;
|
|
7
|
+
};
|
|
8
|
+
export declare const getTraceData: TraceQueryPlugin<TempoTraceQuerySpec>['getTraceData'];
|
|
9
|
+
//# sourceMappingURL=get-trace-data.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"get-trace-data.d.ts","sourceRoot":"","sources":["../../../src/plugins/tempo-trace-query/get-trace-data.ts"],"names":[],"mappings":"AAaA,OAAO,EAAE,gBAAgB,EAAE,MAAM,2BAA2B,CAAC;AAC7D,OAAO,EAAyB,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AAE5E,OAAO,EAAE,mBAAmB,EAAE,MAAM,+BAA+B,CAAC;AAIpE,wBAAgB,gBAAgB,CAAC,SAAS,EAAE,iBAAiB;;;EAM5D;AAED,eAAO,MAAM,YAAY,EAAE,gBAAgB,CAAC,mBAAmB,CAAC,CAAC,cAAc,CAkE9E,CAAC"}
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
// Copyright 2023 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 { TEMPO_DATASOURCE_KIND } from '../../model/tempo-selectors';
|
|
15
|
+
export function getUnixTimeRange(timeRange) {
|
|
16
|
+
const { start, end } = timeRange;
|
|
17
|
+
return {
|
|
18
|
+
start: Math.ceil(getUnixTime(start)),
|
|
19
|
+
end: Math.ceil(getUnixTime(end))
|
|
20
|
+
};
|
|
21
|
+
}
|
|
22
|
+
export const getTraceData = async (spec, context)=>{
|
|
23
|
+
var _client_options;
|
|
24
|
+
if (spec.query === undefined || spec.query === null || spec.query === '') {
|
|
25
|
+
// Do not make a request to the backend, instead return an empty TraceData
|
|
26
|
+
console.error('TempoTraceQuery is undefined, null, or an empty string.');
|
|
27
|
+
return {
|
|
28
|
+
traces: []
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
const defaultTempoDatasource = {
|
|
32
|
+
kind: TEMPO_DATASOURCE_KIND
|
|
33
|
+
};
|
|
34
|
+
var _spec_datasource;
|
|
35
|
+
const client = await context.datasourceStore.getDatasourceClient((_spec_datasource = spec.datasource) !== null && _spec_datasource !== void 0 ? _spec_datasource : defaultTempoDatasource);
|
|
36
|
+
const datasourceUrl = client === null || client === void 0 ? void 0 : (_client_options = client.options) === null || _client_options === void 0 ? void 0 : _client_options.datasourceUrl;
|
|
37
|
+
if (datasourceUrl === undefined || datasourceUrl === null || datasourceUrl === '') {
|
|
38
|
+
console.error('TempoDatasource is undefined, null, or an empty string.');
|
|
39
|
+
return {
|
|
40
|
+
traces: []
|
|
41
|
+
};
|
|
42
|
+
}
|
|
43
|
+
const getQuery = ()=>{
|
|
44
|
+
// if time range not defined -- only return the query from the spec
|
|
45
|
+
if (context.absoluteTimeRange === undefined) {
|
|
46
|
+
return spec.query;
|
|
47
|
+
}
|
|
48
|
+
// if the query already contains a time range (i.e.start and end times)
|
|
49
|
+
if (spec.query.includes('start=') || spec.query.includes('end=')) {
|
|
50
|
+
return spec.query;
|
|
51
|
+
}
|
|
52
|
+
// handle time range selection from UI drop down (e.g. last 5 minutes, last 1 hour )
|
|
53
|
+
const { start, end } = getUnixTimeRange(context === null || context === void 0 ? void 0 : context.absoluteTimeRange);
|
|
54
|
+
const queryStartTime = '&start=' + start;
|
|
55
|
+
const queryEndTime = '&end=' + end;
|
|
56
|
+
const queryWithTimeRange = encodeURI(spec.query) + queryStartTime + queryEndTime;
|
|
57
|
+
return queryWithTimeRange;
|
|
58
|
+
};
|
|
59
|
+
const enrichedTraceResponse = await client.getEnrichedTraceQuery(getQuery(), datasourceUrl);
|
|
60
|
+
const traces = enrichedTraceResponse.traces.map((traceValue)=>{
|
|
61
|
+
const startTimeUnixMs = parseInt(traceValue.summary.startTimeUnixNano) * 1e-6; // convert to millisecond for eChart time format
|
|
62
|
+
const durationMs = traceValue.summary.durationMs;
|
|
63
|
+
const spanCount = traceValue.spanCount;
|
|
64
|
+
const errorCount = traceValue.errorCount;
|
|
65
|
+
const traceId = traceValue.summary.traceID;
|
|
66
|
+
const name = `rootServiceName="${traceValue.summary.rootServiceName.trim()}", rootTraceName="${traceValue.summary.rootServiceName.trim()}"`;
|
|
67
|
+
return {
|
|
68
|
+
startTimeUnixMs,
|
|
69
|
+
durationMs,
|
|
70
|
+
spanCount,
|
|
71
|
+
errorCount,
|
|
72
|
+
traceId,
|
|
73
|
+
name
|
|
74
|
+
};
|
|
75
|
+
});
|
|
76
|
+
const traceData = {
|
|
77
|
+
traces,
|
|
78
|
+
metadata: {
|
|
79
|
+
executedQueryString: spec.query
|
|
80
|
+
}
|
|
81
|
+
};
|
|
82
|
+
return traceData;
|
|
83
|
+
};
|
|
84
|
+
|
|
85
|
+
//# sourceMappingURL=get-trace-data.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/plugins/tempo-trace-query/get-trace-data.ts"],"sourcesContent":["// Copyright 2023 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 { TraceQueryPlugin } from '@perses-dev/plugin-system';\nimport { TraceData, TraceValue, AbsoluteTimeRange } from '@perses-dev/core';\nimport { getUnixTime } from 'date-fns';\nimport { TempoTraceQuerySpec } from '../../model/trace-query-model';\nimport { TEMPO_DATASOURCE_KIND, TempoDatasourceSelector } from '../../model/tempo-selectors';\nimport { TempoClient } from '../../model/tempo-client';\n\nexport function getUnixTimeRange(timeRange: AbsoluteTimeRange) {\n const { start, end } = timeRange;\n return {\n start: Math.ceil(getUnixTime(start)),\n end: Math.ceil(getUnixTime(end)),\n };\n}\n\nexport const getTraceData: TraceQueryPlugin<TempoTraceQuerySpec>['getTraceData'] = async (spec, context) => {\n if (spec.query === undefined || spec.query === null || spec.query === '') {\n // Do not make a request to the backend, instead return an empty TraceData\n console.error('TempoTraceQuery is undefined, null, or an empty string.');\n return { traces: [] };\n }\n\n const defaultTempoDatasource: TempoDatasourceSelector = {\n kind: TEMPO_DATASOURCE_KIND,\n };\n\n const client: TempoClient = await context.datasourceStore.getDatasourceClient(\n spec.datasource ?? defaultTempoDatasource\n );\n\n const datasourceUrl = client?.options?.datasourceUrl;\n if (datasourceUrl === undefined || datasourceUrl === null || datasourceUrl === '') {\n console.error('TempoDatasource is undefined, null, or an empty string.');\n return { traces: [] };\n }\n\n const getQuery = () => {\n // if time range not defined -- only return the query from the spec\n if (context.absoluteTimeRange === undefined) {\n return spec.query;\n }\n // if the query already contains a time range (i.e.start and end times)\n if (spec.query.includes('start=') || spec.query.includes('end=')) {\n return spec.query;\n }\n // handle time range selection from UI drop down (e.g. last 5 minutes, last 1 hour )\n const { start, end } = getUnixTimeRange(context?.absoluteTimeRange);\n const queryStartTime = '&start=' + start;\n const queryEndTime = '&end=' + end;\n const queryWithTimeRange = encodeURI(spec.query) + queryStartTime + queryEndTime;\n return queryWithTimeRange;\n };\n\n const enrichedTraceResponse = await client.getEnrichedTraceQuery(getQuery(), datasourceUrl);\n\n const traces: TraceValue[] = enrichedTraceResponse.traces.map((traceValue) => {\n const startTimeUnixMs = parseInt(traceValue.summary.startTimeUnixNano) * 1e-6; // convert to millisecond for eChart time format\n const durationMs = traceValue.summary.durationMs;\n const spanCount = traceValue.spanCount;\n const errorCount = traceValue.errorCount;\n const traceId = traceValue.summary.traceID;\n const name = `rootServiceName=\"${traceValue.summary.rootServiceName.trim()}\", rootTraceName=\"${traceValue.summary.rootServiceName.trim()}\"`;\n\n return {\n startTimeUnixMs,\n durationMs,\n spanCount,\n errorCount,\n traceId,\n name,\n };\n });\n\n const traceData: TraceData = {\n traces,\n metadata: {\n executedQueryString: spec.query,\n },\n };\n\n return traceData;\n};\n"],"names":["getUnixTime","TEMPO_DATASOURCE_KIND","getUnixTimeRange","timeRange","start","end","Math","ceil","getTraceData","spec","context","client","query","undefined","console","error","traces","defaultTempoDatasource","kind","datasourceStore","getDatasourceClient","datasource","datasourceUrl","options","getQuery","absoluteTimeRange","includes","queryStartTime","queryEndTime","queryWithTimeRange","encodeURI","enrichedTraceResponse","getEnrichedTraceQuery","map","traceValue","startTimeUnixMs","parseInt","summary","startTimeUnixNano","durationMs","spanCount","errorCount","traceId","traceID","name","rootServiceName","trim","traceData","metadata","executedQueryString"],"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;AAEvC,SAASC,qBAAqB,QAAiC,8BAA8B;AAG7F,OAAO,SAASC,iBAAiBC,SAA4B;IAC3D,MAAM,EAAEC,KAAK,EAAEC,GAAG,EAAE,GAAGF;IACvB,OAAO;QACLC,OAAOE,KAAKC,IAAI,CAACP,YAAYI;QAC7BC,KAAKC,KAAKC,IAAI,CAACP,YAAYK;IAC7B;AACF;AAEA,OAAO,MAAMG,eAAsE,OAAOC,MAAMC;QAexEC;IAdtB,IAAIF,KAAKG,KAAK,KAAKC,aAAaJ,KAAKG,KAAK,KAAK,QAAQH,KAAKG,KAAK,KAAK,IAAI;QACxE,0EAA0E;QAC1EE,QAAQC,KAAK,CAAC;QACd,OAAO;YAAEC,QAAQ,EAAE;QAAC;IACtB;IAEA,MAAMC,yBAAkD;QACtDC,MAAMjB;IACR;QAGEQ;IADF,MAAME,SAAsB,MAAMD,QAAQS,eAAe,CAACC,mBAAmB,CAC3EX,CAAAA,mBAAAA,KAAKY,UAAU,cAAfZ,8BAAAA,mBAAmBQ;IAGrB,MAAMK,gBAAgBX,mBAAAA,8BAAAA,kBAAAA,OAAQY,OAAO,cAAfZ,sCAAAA,gBAAiBW,aAAa;IACpD,IAAIA,kBAAkBT,aAAaS,kBAAkB,QAAQA,kBAAkB,IAAI;QACjFR,QAAQC,KAAK,CAAC;QACd,OAAO;YAAEC,QAAQ,EAAE;QAAC;IACtB;IAEA,MAAMQ,WAAW;QACf,mEAAmE;QACnE,IAAId,QAAQe,iBAAiB,KAAKZ,WAAW;YAC3C,OAAOJ,KAAKG,KAAK;QACnB;QACA,uEAAuE;QACvE,IAAIH,KAAKG,KAAK,CAACc,QAAQ,CAAC,aAAajB,KAAKG,KAAK,CAACc,QAAQ,CAAC,SAAS;YAChE,OAAOjB,KAAKG,KAAK;QACnB;QACA,oFAAoF;QACpF,MAAM,EAAER,KAAK,EAAEC,GAAG,EAAE,GAAGH,iBAAiBQ,oBAAAA,8BAAAA,QAASe,iBAAiB;QAClE,MAAME,iBAAiB,YAAYvB;QACnC,MAAMwB,eAAe,UAAUvB;QAC/B,MAAMwB,qBAAqBC,UAAUrB,KAAKG,KAAK,IAAIe,iBAAiBC;QACpE,OAAOC;IACT;IAEA,MAAME,wBAAwB,MAAMpB,OAAOqB,qBAAqB,CAACR,YAAYF;IAE7E,MAAMN,SAAuBe,sBAAsBf,MAAM,CAACiB,GAAG,CAAC,CAACC;QAC7D,MAAMC,kBAAkBC,SAASF,WAAWG,OAAO,CAACC,iBAAiB,IAAI,MAAM,gDAAgD;QAC/H,MAAMC,aAAaL,WAAWG,OAAO,CAACE,UAAU;QAChD,MAAMC,YAAYN,WAAWM,SAAS;QACtC,MAAMC,aAAaP,WAAWO,UAAU;QACxC,MAAMC,UAAUR,WAAWG,OAAO,CAACM,OAAO;QAC1C,MAAMC,OAAO,CAAC,iBAAiB,EAAEV,WAAWG,OAAO,CAACQ,eAAe,CAACC,IAAI,GAAG,kBAAkB,EAAEZ,WAAWG,OAAO,CAACQ,eAAe,CAACC,IAAI,GAAG,CAAC,CAAC;QAE3I,OAAO;YACLX;YACAI;YACAC;YACAC;YACAC;YACAE;QACF;IACF;IAEA,MAAMG,YAAuB;QAC3B/B;QACAgC,UAAU;YACRC,qBAAqBxC,KAAKG,KAAK;QACjC;IACF;IAEA,OAAOmC;AACT,EAAE"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { OptionsEditorProps } from '@perses-dev/plugin-system';
|
|
2
|
+
import { TempoTraceQuerySpec } from '../../model/trace-query-model';
|
|
3
|
+
export type TraceQueryEditorProps = OptionsEditorProps<TempoTraceQuerySpec>;
|
|
4
|
+
/**
|
|
5
|
+
* A hook for managing the `query` state in PrometheusTimeSeriesQuerySpec. Returns the `query` value, along with
|
|
6
|
+
* `onChange` and `onBlur` event handlers to the input. Keeps a local copy of the user's input and only syncs those
|
|
7
|
+
* changes with the overall spec value once the input is blurred to prevent re-running queries in the panel's preview
|
|
8
|
+
* every time the user types.
|
|
9
|
+
*/
|
|
10
|
+
export declare function useQueryState(props: TraceQueryEditorProps): {
|
|
11
|
+
query: string;
|
|
12
|
+
handleQueryChange: (e: string) => void;
|
|
13
|
+
handleQueryBlur: () => void;
|
|
14
|
+
};
|
|
15
|
+
//# sourceMappingURL=query-editor-model.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"query-editor-model.d.ts","sourceRoot":"","sources":["../../../src/plugins/tempo-trace-query/query-editor-model.ts"],"names":[],"mappings":"AAeA,OAAO,EAAE,kBAAkB,EAAE,MAAM,2BAA2B,CAAC;AAC/D,OAAO,EAAE,mBAAmB,EAAE,MAAM,+BAA+B,CAAC;AAEpE,MAAM,MAAM,qBAAqB,GAAG,kBAAkB,CAAC,mBAAmB,CAAC,CAAC;AAE5E;;;;;GAKG;AACH,wBAAgB,aAAa,CAAC,KAAK,EAAE,qBAAqB;;2BAe1B,MAAM;;EAgBrC"}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
// Copyright 2023 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
|
+
* A hook for managing the `query` state in PrometheusTimeSeriesQuerySpec. Returns the `query` value, along with
|
|
17
|
+
* `onChange` and `onBlur` event handlers to the input. Keeps a local copy of the user's input and only syncs those
|
|
18
|
+
* changes with the overall spec value once the input is blurred to prevent re-running queries in the panel's preview
|
|
19
|
+
* every time the user types.
|
|
20
|
+
*/ export function useQueryState(props) {
|
|
21
|
+
const { onChange, value } = props;
|
|
22
|
+
// Local copy of the query's value
|
|
23
|
+
const [query, setQuery] = useState(value.query);
|
|
24
|
+
// This is basically "getDerivedStateFromProps" to make sure if spec's value changes external to this component,
|
|
25
|
+
// we render with the latest value
|
|
26
|
+
const [lastSyncedQuery, setLastSyncedQuery] = useState(value.query);
|
|
27
|
+
if (value.query !== lastSyncedQuery) {
|
|
28
|
+
setQuery(value.query);
|
|
29
|
+
setLastSyncedQuery(value.query);
|
|
30
|
+
}
|
|
31
|
+
// Update our local state's copy as the user types
|
|
32
|
+
const handleQueryChange = (e)=>{
|
|
33
|
+
setQuery(e);
|
|
34
|
+
};
|
|
35
|
+
// Propagate changes to the query's value when the input is blurred to avoid constantly re-running queries in the
|
|
36
|
+
// PanelPreview
|
|
37
|
+
const handleQueryBlur = ()=>{
|
|
38
|
+
setLastSyncedQuery(query);
|
|
39
|
+
onChange(produce(value, (draft)=>{
|
|
40
|
+
draft.query = query;
|
|
41
|
+
}));
|
|
42
|
+
};
|
|
43
|
+
return {
|
|
44
|
+
query,
|
|
45
|
+
handleQueryChange,
|
|
46
|
+
handleQueryBlur
|
|
47
|
+
};
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
//# sourceMappingURL=query-editor-model.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/plugins/tempo-trace-query/query-editor-model.ts"],"sourcesContent":["// Copyright 2023 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 { TempoTraceQuerySpec } from '../../model/trace-query-model';\n\nexport type TraceQueryEditorProps = OptionsEditorProps<TempoTraceQuerySpec>;\n\n/**\n * A hook for managing the `query` state in PrometheusTimeSeriesQuerySpec. Returns the `query` value, along with\n * `onChange` and `onBlur` event handlers to the input. Keeps a local copy of the user's input and only syncs those\n * changes with the overall spec value once the input is blurred to prevent re-running queries in the panel's preview\n * every time the user types.\n */\nexport function useQueryState(props: TraceQueryEditorProps) {\n const { onChange, value } = props;\n\n // Local copy of the query's value\n const [query, setQuery] = useState(value.query);\n\n // This is basically \"getDerivedStateFromProps\" to make sure if spec's value changes external to this component,\n // we render with the latest value\n const [lastSyncedQuery, setLastSyncedQuery] = useState(value.query);\n if (value.query !== lastSyncedQuery) {\n setQuery(value.query);\n setLastSyncedQuery(value.query);\n }\n\n // Update our local state's copy as the user types\n const handleQueryChange = (e: string) => {\n setQuery(e);\n };\n\n // Propagate changes to the query's value when the input is blurred to avoid constantly re-running queries in the\n // PanelPreview\n const handleQueryBlur = () => {\n setLastSyncedQuery(query);\n onChange(\n produce(value, (draft) => {\n draft.query = query;\n })\n );\n };\n\n return { query, handleQueryChange, handleQueryBlur };\n}\n"],"names":["useState","produce","useQueryState","props","onChange","value","query","setQuery","lastSyncedQuery","setLastSyncedQuery","handleQueryChange","e","handleQueryBlur","draft"],"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;AAMhC;;;;;CAKC,GACD,OAAO,SAASC,cAAcC,KAA4B;IACxD,MAAM,EAAEC,QAAQ,EAAEC,KAAK,EAAE,GAAGF;IAE5B,kCAAkC;IAClC,MAAM,CAACG,OAAOC,SAAS,GAAGP,SAASK,MAAMC,KAAK;IAE9C,gHAAgH;IAChH,kCAAkC;IAClC,MAAM,CAACE,iBAAiBC,mBAAmB,GAAGT,SAASK,MAAMC,KAAK;IAClE,IAAID,MAAMC,KAAK,KAAKE,iBAAiB;QACnCD,SAASF,MAAMC,KAAK;QACpBG,mBAAmBJ,MAAMC,KAAK;IAChC;IAEA,kDAAkD;IAClD,MAAMI,oBAAoB,CAACC;QACzBJ,SAASI;IACX;IAEA,iHAAiH;IACjH,eAAe;IACf,MAAMC,kBAAkB;QACtBH,mBAAmBH;QACnBF,SACEH,QAAQI,OAAO,CAACQ;YACdA,MAAMP,KAAK,GAAGA;QAChB;IAEJ;IAEA,OAAO;QAAEA;QAAOI;QAAmBE;IAAgB;AACrD"}
|
package/dist/test/mock-data.js
CHANGED