@perses-dev/tempo-plugin 0.42.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/dist/cjs/index.js +47 -0
- package/dist/cjs/model/api-types.js +16 -0
- package/dist/cjs/model/index.js +33 -0
- package/dist/cjs/model/tempo-client.js +88 -0
- package/dist/cjs/model/tempo-selectors.js +46 -0
- package/dist/cjs/model/trace-query-model.js +16 -0
- package/dist/cjs/plugins/TempoTraceQuery.js +30 -0
- package/dist/cjs/plugins/get-trace-data.js +69 -0
- package/dist/cjs/plugins/tempo-datasource-types.js +16 -0
- package/dist/cjs/plugins/tempo-datasource.js +50 -0
- package/dist/cjs/test/index.js +30 -0
- package/dist/cjs/test/mock-data.js +887 -0
- package/dist/cjs/test/setup-tests.js +17 -0
- package/dist/index.d.ts +6 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +21 -0
- package/dist/index.js.map +1 -0
- package/dist/model/api-types.d.ts +72 -0
- package/dist/model/api-types.d.ts.map +1 -0
- package/dist/model/api-types.js +15 -0
- package/dist/model/api-types.js.map +1 -0
- package/dist/model/index.js +18 -0
- package/dist/model/index.js.map +1 -0
- package/dist/model/tempo-client.d.ts +36 -0
- package/dist/model/tempo-client.d.ts.map +1 -0
- package/dist/model/tempo-client.js +80 -0
- package/dist/model/tempo-client.js.map +1 -0
- package/dist/model/tempo-selectors.d.ts +21 -0
- package/dist/model/tempo-selectors.d.ts.map +1 -0
- package/dist/model/tempo-selectors.js +30 -0
- package/dist/model/tempo-selectors.js.map +1 -0
- package/dist/model/trace-query-model.d.ts +9 -0
- package/dist/model/trace-query-model.d.ts.map +1 -0
- package/dist/model/trace-query-model.js +15 -0
- package/dist/model/trace-query-model.js.map +1 -0
- package/dist/plugins/TempoTraceQuery.d.ts +11 -0
- package/dist/plugins/TempoTraceQuery.d.ts.map +1 -0
- package/dist/plugins/TempoTraceQuery.js +24 -0
- package/dist/plugins/TempoTraceQuery.js.map +1 -0
- package/dist/plugins/get-trace-data.d.ts +4 -0
- package/dist/plugins/get-trace-data.d.ts.map +1 -0
- package/dist/plugins/get-trace-data.js +61 -0
- package/dist/plugins/get-trace-data.js.map +1 -0
- package/dist/plugins/tempo-datasource-types.d.ts +6 -0
- package/dist/plugins/tempo-datasource-types.d.ts.map +1 -0
- package/dist/plugins/tempo-datasource-types.js +15 -0
- package/dist/plugins/tempo-datasource-types.js.map +1 -0
- package/dist/plugins/tempo-datasource.d.ts +5 -0
- package/dist/plugins/tempo-datasource.d.ts.map +1 -0
- package/dist/plugins/tempo-datasource.js +42 -0
- package/dist/plugins/tempo-datasource.js.map +1 -0
- package/dist/test/index.d.ts +2 -0
- package/dist/test/index.d.ts.map +1 -0
- package/dist/test/index.js +15 -0
- package/dist/test/index.js.map +1 -0
- package/dist/test/mock-data.d.ts +5 -0
- package/dist/test/mock-data.d.ts.map +1 -0
- package/dist/test/mock-data.js +871 -0
- package/dist/test/mock-data.js.map +1 -0
- package/dist/test/setup-tests.d.ts +2 -0
- package/dist/test/setup-tests.d.ts.map +1 -0
- package/dist/test/setup-tests.js +15 -0
- package/dist/test/setup-tests.js.map +1 -0
- package/package.json +43 -0
- package/plugin.json +26 -0
|
@@ -0,0 +1,17 @@
|
|
|
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
|
+
"use strict";
|
|
14
|
+
Object.defineProperty(exports, "__esModule", {
|
|
15
|
+
value: true
|
|
16
|
+
});
|
|
17
|
+
require("@testing-library/jest-dom/extend-expect");
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { TempoDatasource } from './plugins/tempo-datasource';
|
|
2
|
+
import { TempoTraceQuery } from './plugins/TempoTraceQuery';
|
|
3
|
+
export { TempoTraceQuery, TempoDatasource };
|
|
4
|
+
export * from './model/tempo-client';
|
|
5
|
+
export * from './model/tempo-selectors';
|
|
6
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAaA,OAAO,EAAE,eAAe,EAAE,MAAM,4BAA4B,CAAC;AAC7D,OAAO,EAAE,eAAe,EAAE,MAAM,2BAA2B,CAAC;AAG5D,OAAO,EAAE,eAAe,EAAE,eAAe,EAAE,CAAC;AAG5C,cAAc,sBAAsB,CAAC;AACrC,cAAc,yBAAyB,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
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 { TempoDatasource } from './plugins/tempo-datasource';
|
|
14
|
+
import { TempoTraceQuery } from './plugins/TempoTraceQuery';
|
|
15
|
+
// Export plugins under the same name as the kinds they handle from the plugin.json
|
|
16
|
+
export { TempoTraceQuery, TempoDatasource };
|
|
17
|
+
// For consumers to leverage in DatasourceStoreProvider onCreate
|
|
18
|
+
export * from './model/tempo-client';
|
|
19
|
+
export * from './model/tempo-selectors';
|
|
20
|
+
|
|
21
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/index.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 { TempoDatasource } from './plugins/tempo-datasource';\nimport { TempoTraceQuery } from './plugins/TempoTraceQuery';\n\n// Export plugins under the same name as the kinds they handle from the plugin.json\nexport { TempoTraceQuery, TempoDatasource };\n\n// For consumers to leverage in DatasourceStoreProvider onCreate\nexport * from './model/tempo-client';\nexport * from './model/tempo-selectors';\n"],"names":["TempoDatasource","TempoTraceQuery"],"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,eAAe,QAAQ,6BAA6B;AAC7D,SAASC,eAAe,QAAQ,4BAA4B;AAE5D,mFAAmF;AACnF,SAASA,eAAe,EAAED,eAAe,GAAG;AAE5C,gEAAgE;AAChE,cAAc,uBAAuB;AACrC,cAAc,0BAA0B"}
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
export interface Span {
|
|
2
|
+
startTimeUnixNano: string;
|
|
3
|
+
spanId?: string;
|
|
4
|
+
spanID?: string;
|
|
5
|
+
attributes?: Attribute[];
|
|
6
|
+
durationNanos?: string;
|
|
7
|
+
endTimeUnixNano?: string;
|
|
8
|
+
kind?: string;
|
|
9
|
+
name?: string;
|
|
10
|
+
parentSpanId?: string;
|
|
11
|
+
status?: {
|
|
12
|
+
code?: string;
|
|
13
|
+
};
|
|
14
|
+
traceId?: string;
|
|
15
|
+
}
|
|
16
|
+
export interface Trace {
|
|
17
|
+
traceID: string;
|
|
18
|
+
rootServiceName: string;
|
|
19
|
+
rootTraceName: string;
|
|
20
|
+
startTimeUnixNano: string;
|
|
21
|
+
durationMs: number;
|
|
22
|
+
spanSets?: Array<{
|
|
23
|
+
spans: Span[];
|
|
24
|
+
matched: number;
|
|
25
|
+
}>;
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Response of Tempo HTTP API endpoint GET /api/search/<query>
|
|
29
|
+
*/
|
|
30
|
+
export interface SearchTraceQueryResponse {
|
|
31
|
+
traces: Trace[];
|
|
32
|
+
}
|
|
33
|
+
export interface Attribute {
|
|
34
|
+
key: string;
|
|
35
|
+
value: {
|
|
36
|
+
stringValue?: string;
|
|
37
|
+
intValue?: string;
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
export interface ScopeSpan {
|
|
41
|
+
scope: {
|
|
42
|
+
name: string;
|
|
43
|
+
};
|
|
44
|
+
spans: Span[];
|
|
45
|
+
}
|
|
46
|
+
export interface Batch {
|
|
47
|
+
resource: {
|
|
48
|
+
attributes: Attribute[];
|
|
49
|
+
};
|
|
50
|
+
scopeSpans: ScopeSpan[];
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* Response of Tempo HTTP API endpoint GET /api/traces/<traceID>
|
|
54
|
+
*/
|
|
55
|
+
export interface SearchTraceIDResponse {
|
|
56
|
+
batches: Batch[];
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* Combined Response of Tempo HTTP API endpoint GET /api/search/<query>
|
|
60
|
+
* and GET /api/traces/<traceID>. For each trace returned from GET /api/search/<query>
|
|
61
|
+
* a detailed trace report is fetched from GET /api/traces/<traceID>.
|
|
62
|
+
*/
|
|
63
|
+
export interface EnrichedTraceQueryResponse {
|
|
64
|
+
query: string;
|
|
65
|
+
traces: Array<{
|
|
66
|
+
spanCount: number;
|
|
67
|
+
errorCount: number;
|
|
68
|
+
summary: Trace;
|
|
69
|
+
traceDetails: SearchTraceIDResponse;
|
|
70
|
+
}>;
|
|
71
|
+
}
|
|
72
|
+
//# sourceMappingURL=api-types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"api-types.d.ts","sourceRoot":"","sources":["../../src/model/api-types.ts"],"names":[],"mappings":"AAaA,MAAM,WAAW,IAAI;IACnB,iBAAiB,EAAE,MAAM,CAAC;IAC1B,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,UAAU,CAAC,EAAE,SAAS,EAAE,CAAC;IACzB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,MAAM,CAAC,EAAE;QACP,IAAI,CAAC,EAAE,MAAM,CAAC;KACf,CAAC;IACF,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB;AAED,MAAM,WAAW,KAAK;IACpB,OAAO,EAAE,MAAM,CAAC;IAChB,eAAe,EAAE,MAAM,CAAC;IACxB,aAAa,EAAE,MAAM,CAAC;IACtB,iBAAiB,EAAE,MAAM,CAAC;IAC1B,UAAU,EAAE,MAAM,CAAC;IACnB,QAAQ,CAAC,EAAE,KAAK,CAAC;QACf,KAAK,EAAE,IAAI,EAAE,CAAC;QACd,OAAO,EAAE,MAAM,CAAC;KACjB,CAAC,CAAC;CACJ;AAED;;GAEG;AACH,MAAM,WAAW,wBAAwB;IACvC,MAAM,EAAE,KAAK,EAAE,CAAC;CACjB;AAED,MAAM,WAAW,SAAS;IACxB,GAAG,EAAE,MAAM,CAAC;IACZ,KAAK,EAAE;QACL,WAAW,CAAC,EAAE,MAAM,CAAC;QACrB,QAAQ,CAAC,EAAE,MAAM,CAAC;KACnB,CAAC;CACH;AAED,MAAM,WAAW,SAAS;IACxB,KAAK,EAAE;QACL,IAAI,EAAE,MAAM,CAAC;KACd,CAAC;IACF,KAAK,EAAE,IAAI,EAAE,CAAC;CACf;AAED,MAAM,WAAW,KAAK;IACpB,QAAQ,EAAE;QACR,UAAU,EAAE,SAAS,EAAE,CAAC;KACzB,CAAC;IACF,UAAU,EAAE,SAAS,EAAE,CAAC;CACzB;AAED;;GAEG;AACH,MAAM,WAAW,qBAAqB;IACpC,OAAO,EAAE,KAAK,EAAE,CAAC;CAClB;AAED;;;;GAIG;AACH,MAAM,WAAW,0BAA0B;IACzC,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,KAAK,CAAC;QACZ,SAAS,EAAE,MAAM,CAAC;QAClB,UAAU,EAAE,MAAM,CAAC;QACnB,OAAO,EAAE,KAAK,CAAC;QACf,YAAY,EAAE,qBAAqB,CAAC;KACrC,CAAC,CAAC;CACJ"}
|
|
@@ -0,0 +1,15 @@
|
|
|
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
|
+
export { };
|
|
14
|
+
|
|
15
|
+
//# sourceMappingURL=api-types.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/model/api-types.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\nexport interface Span {\n startTimeUnixNano: string;\n spanId?: string; // Span from api/search/<query>\n spanID?: string; // Span from api/traces/<traceID>\n attributes?: Attribute[];\n durationNanos?: string;\n endTimeUnixNano?: string;\n kind?: string;\n name?: string;\n parentSpanId?: string;\n status?: {\n code?: string;\n };\n traceId?: string;\n}\n\nexport interface Trace {\n traceID: string;\n rootServiceName: string;\n rootTraceName: string;\n startTimeUnixNano: string;\n durationMs: number;\n spanSets?: Array<{\n spans: Span[];\n matched: number;\n }>;\n}\n\n/**\n * Response of Tempo HTTP API endpoint GET /api/search/<query>\n */\nexport interface SearchTraceQueryResponse {\n traces: Trace[];\n}\n\nexport interface Attribute {\n key: string;\n value: {\n stringValue?: string;\n intValue?: string;\n };\n}\n\nexport interface ScopeSpan {\n scope: {\n name: string;\n };\n spans: Span[];\n}\n\nexport interface Batch {\n resource: {\n attributes: Attribute[];\n };\n scopeSpans: ScopeSpan[];\n}\n\n/**\n * Response of Tempo HTTP API endpoint GET /api/traces/<traceID>\n */\nexport interface SearchTraceIDResponse {\n batches: Batch[];\n}\n\n/**\n * Combined Response of Tempo HTTP API endpoint GET /api/search/<query>\n * and GET /api/traces/<traceID>. For each trace returned from GET /api/search/<query>\n * a detailed trace report is fetched from GET /api/traces/<traceID>.\n */\nexport interface EnrichedTraceQueryResponse {\n query: string;\n traces: Array<{\n spanCount: number;\n errorCount: number;\n summary: Trace;\n traceDetails: SearchTraceIDResponse;\n }>;\n}\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,WA6EC"}
|
|
@@ -0,0 +1,18 @@
|
|
|
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
|
+
export * from './tempo-client';
|
|
14
|
+
export * from './tempo-selectors';
|
|
15
|
+
export * from './trace-query-model';
|
|
16
|
+
export * from './types';
|
|
17
|
+
|
|
18
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/model/index.js"],"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\nexport * from './tempo-client'\nexport * from './tempo-selectors'\nexport * from './trace-query-model'\nexport * from './types'"],"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,iBAAgB;AAC9B,cAAc,oBAAmB;AACjC,cAAc,sBAAqB;AACnC,cAAc,UAAS"}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { RequestHeaders } from '@perses-dev/core';
|
|
2
|
+
import { DatasourceClient } from '@perses-dev/plugin-system';
|
|
3
|
+
import { SearchTraceIDResponse, EnrichedTraceQueryResponse, SearchTraceQueryResponse } from './api-types';
|
|
4
|
+
interface TempoClientOptions {
|
|
5
|
+
datasourceUrl: string;
|
|
6
|
+
headers?: RequestHeaders;
|
|
7
|
+
}
|
|
8
|
+
export interface TempoClient extends DatasourceClient {
|
|
9
|
+
options: TempoClientOptions;
|
|
10
|
+
getEnrichedTraceQuery(query: string, datasourceUrl: string): Promise<EnrichedTraceQueryResponse>;
|
|
11
|
+
searchTraceQuery(query: string, datasourceUrl: string): Promise<SearchTraceQueryResponse>;
|
|
12
|
+
searchTraceID(traceID: string, datasourceUrl: string): Promise<SearchTraceIDResponse>;
|
|
13
|
+
}
|
|
14
|
+
export declare const executeRequest: <T>(url: string) => Promise<T>;
|
|
15
|
+
/**
|
|
16
|
+
* Returns a summary report of traces that satisfy the query.
|
|
17
|
+
*/
|
|
18
|
+
export declare function searchTraceQuery(query: string, datasourceUrl: string): Promise<SearchTraceQueryResponse>;
|
|
19
|
+
/**
|
|
20
|
+
* Returns a detailed report, including all the spans, for a given trace.
|
|
21
|
+
*/
|
|
22
|
+
export declare function searchTraceID(traceID: string, datasourceUrl: string): Promise<SearchTraceIDResponse>;
|
|
23
|
+
/**
|
|
24
|
+
* Combined response of Tempo HTTP API endpoints GET /api/search/<query>
|
|
25
|
+
* and GET /api/traces/<traceID>. For each trace returned from GET /api/search/<query>
|
|
26
|
+
* a detailed trace report is fetched from GET /api/traces/<traceID>. This is a
|
|
27
|
+
* temporary workaround to obtain the total number of spans and total number
|
|
28
|
+
* of errors for a trace.
|
|
29
|
+
*
|
|
30
|
+
* TODO: This workaround should be replaced once this issue,
|
|
31
|
+
* https://github.com/grafana/tempo/issues/2940, is resolved upstream in
|
|
32
|
+
* Tempo.
|
|
33
|
+
*/
|
|
34
|
+
export declare function getEnrichedTraceQuery(query: string, datasourceUrl: string): Promise<EnrichedTraceQueryResponse>;
|
|
35
|
+
export {};
|
|
36
|
+
//# sourceMappingURL=tempo-client.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tempo-client.d.ts","sourceRoot":"","sources":["../../src/model/tempo-client.ts"],"names":[],"mappings":"AAaA,OAAO,EAAS,cAAc,EAAE,MAAM,kBAAkB,CAAC;AACzD,OAAO,EAAE,gBAAgB,EAAE,MAAM,2BAA2B,CAAC;AAC7D,OAAO,EAAE,qBAAqB,EAAE,0BAA0B,EAAE,wBAAwB,EAAE,MAAM,aAAa,CAAC;AAE1G,UAAU,kBAAkB;IAC1B,aAAa,EAAE,MAAM,CAAC;IACtB,OAAO,CAAC,EAAE,cAAc,CAAC;CAC1B;AAED,MAAM,WAAW,WAAY,SAAQ,gBAAgB;IACnD,OAAO,EAAE,kBAAkB,CAAC;IAC5B,qBAAqB,CAAC,KAAK,EAAE,MAAM,EAAE,aAAa,EAAE,MAAM,GAAG,OAAO,CAAC,0BAA0B,CAAC,CAAC;IACjG,gBAAgB,CAAC,KAAK,EAAE,MAAM,EAAE,aAAa,EAAE,MAAM,GAAG,OAAO,CAAC,wBAAwB,CAAC,CAAC;IAC1F,aAAa,CAAC,OAAO,EAAE,MAAM,EAAE,aAAa,EAAE,MAAM,GAAG,OAAO,CAAC,qBAAqB,CAAC,CAAC;CACvF;AAED,eAAO,MAAM,cAAc,WAAkB,MAAM,eAIlD,CAAC;AAOF;;GAEG;AACH,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,MAAM,EAAE,aAAa,EAAE,MAAM,qCAEpE;AAED;;GAEG;AACH,wBAAgB,aAAa,CAAC,OAAO,EAAE,MAAM,EAAE,aAAa,EAAE,MAAM,kCAEnE;AAED;;;;;;;;;;GAUG;AACH,wBAAsB,qBAAqB,CAAC,KAAK,EAAE,MAAM,EAAE,aAAa,EAAE,MAAM,GAAG,OAAO,CAAC,0BAA0B,CAAC,CAoCrH"}
|
|
@@ -0,0 +1,80 @@
|
|
|
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 { fetch } from '@perses-dev/core';
|
|
14
|
+
export const executeRequest = async (url)=>{
|
|
15
|
+
const response = await fetch(url);
|
|
16
|
+
const jsonData = await response.json();
|
|
17
|
+
return jsonData;
|
|
18
|
+
};
|
|
19
|
+
function fetchWithGet(apiURI, datasourceUrl) {
|
|
20
|
+
const url = `${datasourceUrl}${apiURI}`;
|
|
21
|
+
return executeRequest(url);
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Returns a summary report of traces that satisfy the query.
|
|
25
|
+
*/ export function searchTraceQuery(query, datasourceUrl) {
|
|
26
|
+
return fetchWithGet(`/api/search?q=${encodeURIComponent(query)}`, datasourceUrl);
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Returns a detailed report, including all the spans, for a given trace.
|
|
30
|
+
*/ export function searchTraceID(traceID, datasourceUrl) {
|
|
31
|
+
return fetchWithGet(`/api/traces/${traceID}`, datasourceUrl);
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Combined response of Tempo HTTP API endpoints GET /api/search/<query>
|
|
35
|
+
* and GET /api/traces/<traceID>. For each trace returned from GET /api/search/<query>
|
|
36
|
+
* a detailed trace report is fetched from GET /api/traces/<traceID>. This is a
|
|
37
|
+
* temporary workaround to obtain the total number of spans and total number
|
|
38
|
+
* of errors for a trace.
|
|
39
|
+
*
|
|
40
|
+
* TODO: This workaround should be replaced once this issue,
|
|
41
|
+
* https://github.com/grafana/tempo/issues/2940, is resolved upstream in
|
|
42
|
+
* Tempo.
|
|
43
|
+
*/ export async function getEnrichedTraceQuery(query, datasourceUrl) {
|
|
44
|
+
// Get a list of traces that satisfy the query.
|
|
45
|
+
const searchResponse = await searchTraceQuery(query, datasourceUrl);
|
|
46
|
+
if (!searchResponse.traces) {
|
|
47
|
+
return {
|
|
48
|
+
query,
|
|
49
|
+
traces: []
|
|
50
|
+
};
|
|
51
|
+
}
|
|
52
|
+
return {
|
|
53
|
+
query,
|
|
54
|
+
traces: await Promise.all(searchResponse.traces.map(async (trace)=>{
|
|
55
|
+
let spanCount = 0;
|
|
56
|
+
let errorCount = 0;
|
|
57
|
+
const searchTraceIDResponse = await searchTraceID(trace.traceID, datasourceUrl);
|
|
58
|
+
// For every trace, get the full trace, and find the total number of spans and errors.
|
|
59
|
+
for (const batch of searchTraceIDResponse.batches){
|
|
60
|
+
for (const scopeSpan of batch.scopeSpans){
|
|
61
|
+
spanCount += scopeSpan.spans.length;
|
|
62
|
+
for (const span of scopeSpan.spans){
|
|
63
|
+
var _span_status;
|
|
64
|
+
if ((_span_status = span.status) === null || _span_status === void 0 ? void 0 : _span_status.code) {
|
|
65
|
+
errorCount++;
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
return {
|
|
71
|
+
summary: trace,
|
|
72
|
+
traceDetails: searchTraceIDResponse,
|
|
73
|
+
spanCount,
|
|
74
|
+
errorCount
|
|
75
|
+
};
|
|
76
|
+
}))
|
|
77
|
+
};
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
//# sourceMappingURL=tempo-client.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/model/tempo-client.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 { fetch, RequestHeaders } from '@perses-dev/core';\nimport { DatasourceClient } from '@perses-dev/plugin-system';\nimport { SearchTraceIDResponse, EnrichedTraceQueryResponse, SearchTraceQueryResponse } from './api-types';\n\ninterface TempoClientOptions {\n datasourceUrl: string;\n headers?: RequestHeaders;\n}\n\nexport interface TempoClient extends DatasourceClient {\n options: TempoClientOptions;\n getEnrichedTraceQuery(query: string, datasourceUrl: string): Promise<EnrichedTraceQueryResponse>;\n searchTraceQuery(query: string, datasourceUrl: string): Promise<SearchTraceQueryResponse>;\n searchTraceID(traceID: string, datasourceUrl: string): Promise<SearchTraceIDResponse>;\n}\n\nexport const executeRequest = async <T>(url: string): Promise<T> => {\n const response = await fetch(url);\n const jsonData = await response.json();\n return jsonData;\n};\n\nfunction fetchWithGet<TResponse>(apiURI: string, datasourceUrl: string) {\n const url = `${datasourceUrl}${apiURI}`;\n return executeRequest<TResponse>(url);\n}\n\n/**\n * Returns a summary report of traces that satisfy the query.\n */\nexport function searchTraceQuery(query: string, datasourceUrl: string) {\n return fetchWithGet<SearchTraceQueryResponse>(`/api/search?q=${encodeURIComponent(query)}`, datasourceUrl);\n}\n\n/**\n * Returns a detailed report, including all the spans, for a given trace.\n */\nexport function searchTraceID(traceID: string, datasourceUrl: string) {\n return fetchWithGet<SearchTraceIDResponse>(`/api/traces/${traceID}`, datasourceUrl);\n}\n\n/**\n * Combined response of Tempo HTTP API endpoints GET /api/search/<query>\n * and GET /api/traces/<traceID>. For each trace returned from GET /api/search/<query>\n * a detailed trace report is fetched from GET /api/traces/<traceID>. This is a\n * temporary workaround to obtain the total number of spans and total number\n * of errors for a trace.\n *\n * TODO: This workaround should be replaced once this issue,\n * https://github.com/grafana/tempo/issues/2940, is resolved upstream in\n * Tempo.\n */\nexport async function getEnrichedTraceQuery(query: string, datasourceUrl: string): Promise<EnrichedTraceQueryResponse> {\n // Get a list of traces that satisfy the query.\n const searchResponse = await searchTraceQuery(query, datasourceUrl);\n if (!searchResponse.traces) {\n return { query, traces: [] };\n }\n\n return {\n query,\n traces: await Promise.all(\n searchResponse.traces.map(async (trace) => {\n let spanCount = 0;\n let errorCount = 0;\n const searchTraceIDResponse = await searchTraceID(trace.traceID, datasourceUrl);\n\n // For every trace, get the full trace, and find the total number of spans and errors.\n for (const batch of searchTraceIDResponse.batches) {\n for (const scopeSpan of batch.scopeSpans) {\n spanCount += scopeSpan.spans.length;\n for (const span of scopeSpan.spans) {\n if (span.status?.code) {\n errorCount++;\n }\n }\n }\n }\n\n return {\n summary: trace,\n traceDetails: searchTraceIDResponse,\n spanCount,\n errorCount,\n };\n })\n ),\n };\n}\n"],"names":["fetch","executeRequest","url","response","jsonData","json","fetchWithGet","apiURI","datasourceUrl","searchTraceQuery","query","encodeURIComponent","searchTraceID","traceID","getEnrichedTraceQuery","searchResponse","traces","Promise","all","map","trace","spanCount","errorCount","searchTraceIDResponse","batch","batches","scopeSpan","scopeSpans","spans","length","span","status","code","summary","traceDetails"],"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,QAAwB,mBAAmB;AAgBzD,OAAO,MAAMC,iBAAiB,OAAUC;IACtC,MAAMC,WAAW,MAAMH,MAAME;IAC7B,MAAME,WAAW,MAAMD,SAASE;IAChC,OAAOD;AACT,EAAE;AAEF,SAASE,aAAwBC,MAAc,EAAEC,aAAqB;IACpE,MAAMN,MAAM,CAAC,EAAEM,cAAc,EAAED,OAAO,CAAC;IACvC,OAAON,eAA0BC;AACnC;AAEA;;CAEC,GACD,OAAO,SAASO,iBAAiBC,KAAa,EAAEF,aAAqB;IACnE,OAAOF,aAAuC,CAAC,cAAc,EAAEK,mBAAmBD,OAAO,CAAC,EAAEF;AAC9F;AAEA;;CAEC,GACD,OAAO,SAASI,cAAcC,OAAe,EAAEL,aAAqB;IAClE,OAAOF,aAAoC,CAAC,YAAY,EAAEO,QAAQ,CAAC,EAAEL;AACvE;AAEA;;;;;;;;;;CAUC,GACD,OAAO,eAAeM,sBAAsBJ,KAAa,EAAEF,aAAqB;IAC9E,+CAA+C;IAC/C,MAAMO,iBAAiB,MAAMN,iBAAiBC,OAAOF;IACrD,IAAI,CAACO,eAAeC,QAAQ;QAC1B,OAAO;YAAEN;YAAOM,QAAQ,EAAE;QAAC;IAC7B;IAEA,OAAO;QACLN;QACAM,QAAQ,MAAMC,QAAQC,IACpBH,eAAeC,OAAOG,IAAI,OAAOC;YAC/B,IAAIC,YAAY;YAChB,IAAIC,aAAa;YACjB,MAAMC,wBAAwB,MAAMX,cAAcQ,MAAMP,SAASL;YAEjE,sFAAsF;YACtF,KAAK,MAAMgB,SAASD,sBAAsBE,QAAS;gBACjD,KAAK,MAAMC,aAAaF,MAAMG,WAAY;oBACxCN,aAAaK,UAAUE,MAAMC;oBAC7B,KAAK,MAAMC,QAAQJ,UAAUE,MAAO;4BAC9BE;wBAAJ,IAAIA,CAAAA,eAAAA,KAAKC,oBAALD,0BAAAA,KAAAA,IAAAA,aAAaE,MAAM;4BACrBV;wBACF;oBACF;gBACF;YACF;YAEA,OAAO;gBACLW,SAASb;gBACTc,cAAcX;gBACdF;gBACAC;YACF;QACF;IAEJ;AACF"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { DatasourceSelector } from '@perses-dev/core';
|
|
2
|
+
export declare const TEMPO_DATASOURCE_KIND: "TempoDatasource";
|
|
3
|
+
/**
|
|
4
|
+
* DatasourceSelector for Tempo Datasources.
|
|
5
|
+
*/
|
|
6
|
+
export interface TempoDatasourceSelector extends DatasourceSelector {
|
|
7
|
+
kind: typeof TEMPO_DATASOURCE_KIND;
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* A default selector that asks for the default Tempo Datasource.
|
|
11
|
+
*/
|
|
12
|
+
export declare const DEFAULT_TEMPO: TempoDatasourceSelector;
|
|
13
|
+
/**
|
|
14
|
+
* Returns true if the provided TempoDatasourceSelector is the default one.
|
|
15
|
+
*/
|
|
16
|
+
export declare function isDefaultTempoSelector(selector: TempoDatasourceSelector): boolean;
|
|
17
|
+
/**
|
|
18
|
+
* Type guard to make sure a DatasourceSelector is a Tempo one.
|
|
19
|
+
*/
|
|
20
|
+
export declare function isTempoDatasourceSelector(selector: DatasourceSelector): selector is TempoDatasourceSelector;
|
|
21
|
+
//# sourceMappingURL=tempo-selectors.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tempo-selectors.d.ts","sourceRoot":"","sources":["../../src/model/tempo-selectors.ts"],"names":[],"mappings":"AAaA,OAAO,EAAE,kBAAkB,EAAE,MAAM,kBAAkB,CAAC;AAEtD,eAAO,MAAM,qBAAqB,mBAA6B,CAAC;AAEhE;;GAEG;AACH,MAAM,WAAW,uBAAwB,SAAQ,kBAAkB;IACjE,IAAI,EAAE,OAAO,qBAAqB,CAAC;CACpC;AAED;;GAEG;AACH,eAAO,MAAM,aAAa,EAAE,uBAAyD,CAAC;AAEtF;;GAEG;AACH,wBAAgB,sBAAsB,CAAC,QAAQ,EAAE,uBAAuB,WAEvE;AAED;;GAEG;AACH,wBAAgB,yBAAyB,CAAC,QAAQ,EAAE,kBAAkB,GAAG,QAAQ,IAAI,uBAAuB,CAE3G"}
|
|
@@ -0,0 +1,30 @@
|
|
|
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
|
+
export const TEMPO_DATASOURCE_KIND = 'TempoDatasource';
|
|
14
|
+
/**
|
|
15
|
+
* A default selector that asks for the default Tempo Datasource.
|
|
16
|
+
*/ export const DEFAULT_TEMPO = {
|
|
17
|
+
kind: TEMPO_DATASOURCE_KIND
|
|
18
|
+
};
|
|
19
|
+
/**
|
|
20
|
+
* Returns true if the provided TempoDatasourceSelector is the default one.
|
|
21
|
+
*/ export function isDefaultTempoSelector(selector) {
|
|
22
|
+
return selector.name === undefined;
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Type guard to make sure a DatasourceSelector is a Tempo one.
|
|
26
|
+
*/ export function isTempoDatasourceSelector(selector) {
|
|
27
|
+
return selector.kind === TEMPO_DATASOURCE_KIND;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
//# sourceMappingURL=tempo-selectors.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/model/tempo-selectors.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 { DatasourceSelector } from '@perses-dev/core';\n\nexport const TEMPO_DATASOURCE_KIND = 'TempoDatasource' as const;\n\n/**\n * DatasourceSelector for Tempo Datasources.\n */\nexport interface TempoDatasourceSelector extends DatasourceSelector {\n kind: typeof TEMPO_DATASOURCE_KIND;\n}\n\n/**\n * A default selector that asks for the default Tempo Datasource.\n */\nexport const DEFAULT_TEMPO: TempoDatasourceSelector = { kind: TEMPO_DATASOURCE_KIND };\n\n/**\n * Returns true if the provided TempoDatasourceSelector is the default one.\n */\nexport function isDefaultTempoSelector(selector: TempoDatasourceSelector) {\n return selector.name === undefined;\n}\n\n/**\n * Type guard to make sure a DatasourceSelector is a Tempo one.\n */\nexport function isTempoDatasourceSelector(selector: DatasourceSelector): selector is TempoDatasourceSelector {\n return selector.kind === TEMPO_DATASOURCE_KIND;\n}\n"],"names":["TEMPO_DATASOURCE_KIND","DEFAULT_TEMPO","kind","isDefaultTempoSelector","selector","name","undefined","isTempoDatasourceSelector"],"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,wBAAwB,kBAA2B;AAShE;;CAEC,GACD,OAAO,MAAMC,gBAAyC;IAAEC,MAAMF;AAAsB,EAAE;AAEtF;;CAEC,GACD,OAAO,SAASG,uBAAuBC,QAAiC;IACtE,OAAOA,SAASC,SAASC;AAC3B;AAEA;;CAEC,GACD,OAAO,SAASC,0BAA0BH,QAA4B;IACpE,OAAOA,SAASF,SAASF;AAC3B"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { TempoDatasourceSelector } from './tempo-selectors';
|
|
2
|
+
/**
|
|
3
|
+
* The spec/options for the TempoTraceQuery plugin.
|
|
4
|
+
*/
|
|
5
|
+
export interface TempoTraceQuerySpec {
|
|
6
|
+
query: string;
|
|
7
|
+
datasource?: TempoDatasourceSelector;
|
|
8
|
+
}
|
|
9
|
+
//# sourceMappingURL=trace-query-model.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"trace-query-model.d.ts","sourceRoot":"","sources":["../../src/model/trace-query-model.ts"],"names":[],"mappings":"AAaA,OAAO,EAAE,uBAAuB,EAAE,MAAM,mBAAmB,CAAC;AAC5D;;GAEG;AACH,MAAM,WAAW,mBAAmB;IAClC,KAAK,EAAE,MAAM,CAAC;IACd,UAAU,CAAC,EAAE,uBAAuB,CAAC;CACtC"}
|
|
@@ -0,0 +1,15 @@
|
|
|
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
|
+
export { };
|
|
14
|
+
|
|
15
|
+
//# sourceMappingURL=trace-query-model.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/model/trace-query-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 { TempoDatasourceSelector } from './tempo-selectors';\n/**\n * The spec/options for the TempoTraceQuery plugin.\n */\nexport interface TempoTraceQuerySpec {\n query: string;\n datasource?: TempoDatasourceSelector;\n}\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,WAOC"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The core Tempo TraceQuery plugin for Perses.
|
|
3
|
+
*/
|
|
4
|
+
export declare const TempoTraceQuery: {
|
|
5
|
+
getTraceData: (spec: import("../model/trace-query-model").TempoTraceQuerySpec, ctx: import("@perses-dev/plugin-system").TraceQueryContext) => Promise<import("@perses-dev/core").TraceData>;
|
|
6
|
+
createInitialOptions: () => {
|
|
7
|
+
query: string;
|
|
8
|
+
datasource: undefined;
|
|
9
|
+
};
|
|
10
|
+
};
|
|
11
|
+
//# sourceMappingURL=TempoTraceQuery.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"TempoTraceQuery.d.ts","sourceRoot":"","sources":["../../src/plugins/TempoTraceQuery.tsx"],"names":[],"mappings":"AAeA;;GAEG;AACH,eAAO,MAAM,eAAe;;;;;;CAM3B,CAAC"}
|
|
@@ -0,0 +1,24 @@
|
|
|
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
|
+
/**
|
|
15
|
+
* The core Tempo TraceQuery plugin for Perses.
|
|
16
|
+
*/ export const TempoTraceQuery = {
|
|
17
|
+
getTraceData,
|
|
18
|
+
createInitialOptions: ()=>({
|
|
19
|
+
query: '{}',
|
|
20
|
+
datasource: undefined
|
|
21
|
+
})
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
//# sourceMappingURL=TempoTraceQuery.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/plugins/TempoTraceQuery.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 { getTraceData } from './get-trace-data';\n\n/**\n * The core Tempo TraceQuery plugin for Perses.\n */\nexport const TempoTraceQuery = {\n getTraceData,\n createInitialOptions: () => ({\n query: '{}',\n datasource: undefined,\n }),\n};\n"],"names":["getTraceData","TempoTraceQuery","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;AAEhD;;CAEC,GACD,OAAO,MAAMC,kBAAkB;IAC7BD;IACAE,sBAAsB,IAAO,CAAA;YAC3BC,OAAO;YACPC,YAAYC;QACd,CAAA;AACF,EAAE"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"get-trace-data.d.ts","sourceRoot":"","sources":["../../src/plugins/get-trace-data.ts"],"names":[],"mappings":"AAaA,OAAO,EAAE,gBAAgB,EAAE,MAAM,2BAA2B,CAAC;AAE7D,OAAO,EAAE,mBAAmB,EAAE,MAAM,4BAA4B,CAAC;AAIjE,eAAO,MAAM,YAAY,EAAE,gBAAgB,CAAC,mBAAmB,CAAC,CAAC,cAAc,CAiD9E,CAAC"}
|
|
@@ -0,0 +1,61 @@
|
|
|
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 { TEMPO_DATASOURCE_KIND } from '../model/tempo-selectors';
|
|
14
|
+
export const getTraceData = async (spec, context)=>{
|
|
15
|
+
var _client_options;
|
|
16
|
+
if (spec.query === undefined || spec.query === null || spec.query === '') {
|
|
17
|
+
// Do not make a request to the backend, instead return an empty TraceData
|
|
18
|
+
console.error('TempoTraceQuery is undefined, null, or an empty string.');
|
|
19
|
+
return {
|
|
20
|
+
traces: []
|
|
21
|
+
};
|
|
22
|
+
}
|
|
23
|
+
const defaultTempoDatasource = {
|
|
24
|
+
kind: TEMPO_DATASOURCE_KIND
|
|
25
|
+
};
|
|
26
|
+
var _spec_datasource;
|
|
27
|
+
const client = await context.datasourceStore.getDatasourceClient((_spec_datasource = spec.datasource) !== null && _spec_datasource !== void 0 ? _spec_datasource : defaultTempoDatasource);
|
|
28
|
+
const datasourceUrl = client === null || client === void 0 ? void 0 : (_client_options = client.options) === null || _client_options === void 0 ? void 0 : _client_options.datasourceUrl;
|
|
29
|
+
if (datasourceUrl === undefined || datasourceUrl === null || datasourceUrl === '') {
|
|
30
|
+
console.error('TempoDatasource is undefined, null, or an empty string.');
|
|
31
|
+
return {
|
|
32
|
+
traces: []
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
const enrichedTraceResponse = await client.getEnrichedTraceQuery(spec.query, datasourceUrl);
|
|
36
|
+
const traces = enrichedTraceResponse.traces.map((traceValue)=>{
|
|
37
|
+
const startTimeUnixMs = parseInt(traceValue.summary.startTimeUnixNano) / 1000;
|
|
38
|
+
const durationMs = traceValue.summary.durationMs;
|
|
39
|
+
const spanCount = traceValue.spanCount;
|
|
40
|
+
const errorCount = traceValue.errorCount;
|
|
41
|
+
const traceId = traceValue.summary.traceID;
|
|
42
|
+
const name = `rootServiceName="${traceValue.summary.rootServiceName.trim()}", rootTraceName="${traceValue.summary.rootServiceName.trim()}"`;
|
|
43
|
+
return {
|
|
44
|
+
startTimeUnixMs,
|
|
45
|
+
durationMs,
|
|
46
|
+
spanCount,
|
|
47
|
+
errorCount,
|
|
48
|
+
traceId,
|
|
49
|
+
name
|
|
50
|
+
};
|
|
51
|
+
});
|
|
52
|
+
const traceData = {
|
|
53
|
+
traces,
|
|
54
|
+
metadata: {
|
|
55
|
+
executedQueryString: spec.query
|
|
56
|
+
}
|
|
57
|
+
};
|
|
58
|
+
return traceData;
|
|
59
|
+
};
|
|
60
|
+
|
|
61
|
+
//# sourceMappingURL=get-trace-data.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/plugins/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 } from '@perses-dev/core';\nimport { TempoTraceQuerySpec } from '../model/trace-query-model';\nimport { TEMPO_DATASOURCE_KIND, TempoDatasourceSelector } from '../model/tempo-selectors';\nimport { TempoClient } from '../model/tempo-client';\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 enrichedTraceResponse = await client.getEnrichedTraceQuery(spec.query, datasourceUrl);\n\n const traces: TraceValue[] = enrichedTraceResponse.traces.map((traceValue) => {\n const startTimeUnixMs = parseInt(traceValue.summary.startTimeUnixNano) / 1000;\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":["TEMPO_DATASOURCE_KIND","getTraceData","spec","context","client","query","undefined","console","error","traces","defaultTempoDatasource","kind","datasourceStore","getDatasourceClient","datasource","datasourceUrl","options","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;AAKjC,SAASA,qBAAqB,QAAiC,2BAA2B;AAG1F,OAAO,MAAMC,eAAsE,OAAOC,MAAMC;QAexEC;IAdtB,IAAIF,KAAKG,UAAUC,aAAaJ,KAAKG,UAAU,QAAQH,KAAKG,UAAU,IAAI;QACxE,0EAA0E;QAC1EE,QAAQC,MAAM;QACd,OAAO;YAAEC,QAAQ,EAAE;QAAC;IACtB;IAEA,MAAMC,yBAAkD;QACtDC,MAAMX;IACR;QAGEE;IADF,MAAME,SAAsB,MAAMD,QAAQS,gBAAgBC,oBACxDX,CAAAA,mBAAAA,KAAKY,wBAALZ,8BAAAA,mBAAmBQ;IAGrB,MAAMK,gBAAgBX,mBAAAA,oBAAAA,KAAAA,IAAAA,CAAAA,kBAAAA,OAAQY,qBAARZ,6BAAAA,KAAAA,IAAAA,gBAAiBW;IACvC,IAAIA,kBAAkBT,aAAaS,kBAAkB,QAAQA,kBAAkB,IAAI;QACjFR,QAAQC,MAAM;QACd,OAAO;YAAEC,QAAQ,EAAE;QAAC;IACtB;IAEA,MAAMQ,wBAAwB,MAAMb,OAAOc,sBAAsBhB,KAAKG,OAAOU;IAE7E,MAAMN,SAAuBQ,sBAAsBR,OAAOU,IAAI,CAACC;QAC7D,MAAMC,kBAAkBC,SAASF,WAAWG,QAAQC,qBAAqB;QACzE,MAAMC,aAAaL,WAAWG,QAAQE;QACtC,MAAMC,YAAYN,WAAWM;QAC7B,MAAMC,aAAaP,WAAWO;QAC9B,MAAMC,UAAUR,WAAWG,QAAQM;QACnC,MAAMC,OAAO,CAAC,iBAAiB,EAAEV,WAAWG,QAAQQ,gBAAgBC,OAAO,kBAAkB,EAAEZ,WAAWG,QAAQQ,gBAAgBC,OAAO,CAAC,CAAC;QAE3I,OAAO;YACLX;YACAI;YACAC;YACAC;YACAC;YACAE;QACF;IACF;IAEA,MAAMG,YAAuB;QAC3BxB;QACAyB,UAAU;YACRC,qBAAqBjC,KAAKG;QAC5B;IACF;IAEA,OAAO4B;AACT,EAAE"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tempo-datasource-types.d.ts","sourceRoot":"","sources":["../../src/plugins/tempo-datasource-types.tsx"],"names":[],"mappings":"AAaA,OAAO,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAE7C,MAAM,WAAW,mBAAmB;IAClC,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,KAAK,CAAC,EAAE,SAAS,CAAC;CACnB"}
|
|
@@ -0,0 +1,15 @@
|
|
|
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
|
+
export { };
|
|
14
|
+
|
|
15
|
+
//# sourceMappingURL=tempo-datasource-types.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/plugins/tempo-datasource-types.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 { HTTPProxy } from '@perses-dev/core';\n\nexport interface TempoDatasourceSpec {\n directUrl?: string;\n proxy?: HTTPProxy;\n}\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,WAKC"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { DatasourcePlugin } from '@perses-dev/plugin-system';
|
|
2
|
+
import { TempoClient } from '../model/tempo-client';
|
|
3
|
+
import { TempoDatasourceSpec } from './tempo-datasource-types';
|
|
4
|
+
export declare const TempoDatasource: DatasourcePlugin<TempoDatasourceSpec, TempoClient>;
|
|
5
|
+
//# sourceMappingURL=tempo-datasource.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tempo-datasource.d.ts","sourceRoot":"","sources":["../../src/plugins/tempo-datasource.tsx"],"names":[],"mappings":"AAaA,OAAO,EAAE,gBAAgB,EAAE,MAAM,2BAA2B,CAAC;AAC7D,OAAO,EAA0D,WAAW,EAAE,MAAM,uBAAuB,CAAC;AAC5G,OAAO,EAAE,mBAAmB,EAAE,MAAM,0BAA0B,CAAC;AAyB/D,eAAO,MAAM,eAAe,EAAE,gBAAgB,CAAC,mBAAmB,EAAE,WAAW,CAK9E,CAAC"}
|