@perses-dev/tempo-plugin 0.46.0 → 0.47.0-rc0

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.
Files changed (37) hide show
  1. package/dist/cjs/model/api-types.js +23 -1
  2. package/dist/cjs/model/tempo-client.js +51 -28
  3. package/dist/cjs/plugins/tempo-datasource.js +3 -3
  4. package/dist/cjs/plugins/tempo-trace-query/TempoTraceQuery.js +1 -1
  5. package/dist/cjs/plugins/tempo-trace-query/get-trace-data.js +128 -32
  6. package/dist/cjs/test/mock-data.js +2461 -796
  7. package/dist/model/api-types.d.ts +88 -51
  8. package/dist/model/api-types.d.ts.map +1 -1
  9. package/dist/model/api-types.js +4 -4
  10. package/dist/model/api-types.js.map +1 -1
  11. package/dist/model/tempo-client.d.ts +18 -16
  12. package/dist/model/tempo-client.d.ts.map +1 -1
  13. package/dist/model/tempo-client.js +54 -33
  14. package/dist/model/tempo-client.js.map +1 -1
  15. package/dist/plugins/tempo-datasource.d.ts.map +1 -1
  16. package/dist/plugins/tempo-datasource.js +4 -4
  17. package/dist/plugins/tempo-datasource.js.map +1 -1
  18. package/dist/plugins/tempo-trace-query/TempoTraceQuery.js +1 -1
  19. package/dist/plugins/tempo-trace-query/TempoTraceQuery.js.map +1 -1
  20. package/dist/plugins/tempo-trace-query/get-trace-data.d.ts.map +1 -1
  21. package/dist/plugins/tempo-trace-query/get-trace-data.js +128 -32
  22. package/dist/plugins/tempo-trace-query/get-trace-data.js.map +1 -1
  23. package/dist/test/mock-data.d.ts +7 -3
  24. package/dist/test/mock-data.d.ts.map +1 -1
  25. package/dist/test/mock-data.js +2444 -791
  26. package/dist/test/mock-data.js.map +1 -1
  27. package/package.json +4 -4
  28. package/dist/cjs/plugins/TempoTraceQuery.js +0 -30
  29. package/dist/cjs/plugins/get-trace-data.js +0 -69
  30. package/dist/plugins/TempoTraceQuery.d.ts +0 -11
  31. package/dist/plugins/TempoTraceQuery.d.ts.map +0 -1
  32. package/dist/plugins/TempoTraceQuery.js +0 -24
  33. package/dist/plugins/TempoTraceQuery.js.map +0 -1
  34. package/dist/plugins/get-trace-data.d.ts +0 -4
  35. package/dist/plugins/get-trace-data.d.ts.map +0 -1
  36. package/dist/plugins/get-trace-data.js +0 -61
  37. package/dist/plugins/get-trace-data.js.map +0 -1
@@ -1,72 +1,109 @@
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;
1
+ /**
2
+ * Common types
3
+ */
4
+ export interface Attribute {
5
+ key: string;
6
+ value: AttributeValue;
7
+ }
8
+ export type AttributeValue = {
9
+ stringValue: string;
10
+ } | {
11
+ intValue: string;
12
+ } | {
13
+ boolValue: boolean;
14
+ } | {
15
+ arrayValue: {
16
+ values: AttributeValue[];
13
17
  };
14
- traceId?: string;
18
+ };
19
+ /**
20
+ * Parameters of Tempo HTTP API endpoint GET /api/search
21
+ */
22
+ export interface SearchRequestParameters {
23
+ q: string;
24
+ start?: number;
25
+ end?: number;
15
26
  }
16
- export interface Trace {
27
+ /**
28
+ * Response of Tempo HTTP API endpoint GET /api/search/<query>
29
+ */
30
+ export interface SearchTraceQueryResponse {
31
+ traces: TraceSearchResult[];
32
+ }
33
+ export interface TraceSearchResult {
17
34
  traceID: string;
18
35
  rootServiceName: string;
19
36
  rootTraceName: string;
20
37
  startTimeUnixNano: string;
21
- durationMs: number;
38
+ /** unset if duration is less than 1ms */
39
+ durationMs?: number;
40
+ /** @deprecated spanSet is deprecated in favor of spanSets */
41
+ spanSet?: {
42
+ spans: SpanSearchResult[];
43
+ matched: number;
44
+ };
22
45
  spanSets?: Array<{
23
- spans: Span[];
46
+ spans: SpanSearchResult[];
24
47
  matched: number;
25
48
  }>;
49
+ /** ServiceStats are only available in Tempo vParquet4+ blocks */
50
+ serviceStats?: Record<string, ServiceStats>;
51
+ }
52
+ export interface SpanSearchResult {
53
+ spanID: string;
54
+ name: string;
55
+ startTimeUnixNano: string;
56
+ durationNanos: string;
57
+ attributes: Attribute[];
58
+ }
59
+ export interface ServiceStats {
60
+ spanCount: number;
61
+ /** number of spans with errors, unset if zero */
62
+ errorCount?: number;
26
63
  }
27
64
  /**
28
- * Response of Tempo HTTP API endpoint GET /api/search/<query>
65
+ * Response of Tempo HTTP API endpoint GET /api/traces/<traceID>
66
+ * OTEL trace proto: https://github.com/open-telemetry/opentelemetry-proto-go/blob/main/otlp/trace/v1/trace.pb.go
29
67
  */
30
- export interface SearchTraceQueryResponse {
31
- traces: Trace[];
68
+ export interface SearchTraceIDResponse {
69
+ batches: Batch[];
32
70
  }
33
- export interface Attribute {
34
- key: string;
35
- value: {
36
- stringValue?: string;
37
- intValue?: string;
38
- };
71
+ export interface Batch {
72
+ resource: Resource;
73
+ scopeSpans: ScopeSpan[];
74
+ }
75
+ export interface Resource {
76
+ attributes: Attribute[];
39
77
  }
40
78
  export interface ScopeSpan {
41
- scope: {
42
- name: string;
43
- };
79
+ scope: Scope;
44
80
  spans: Span[];
45
81
  }
46
- export interface Batch {
47
- resource: {
48
- attributes: Attribute[];
49
- };
50
- scopeSpans: ScopeSpan[];
82
+ export interface Scope {
83
+ name: string;
51
84
  }
52
- /**
53
- * Response of Tempo HTTP API endpoint GET /api/traces/<traceID>
54
- */
55
- export interface SearchTraceIDResponse {
56
- batches: Batch[];
85
+ export interface Span {
86
+ traceId: string;
87
+ spanId: string;
88
+ parentSpanId?: string;
89
+ name: string;
90
+ kind: string;
91
+ startTimeUnixNano: string;
92
+ endTimeUnixNano: string;
93
+ attributes?: Attribute[];
94
+ events?: SpanEvent[];
95
+ status?: SpanStatus;
57
96
  }
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
- }>;
97
+ export interface SpanEvent {
98
+ timeUnixNano: string;
99
+ name: string;
100
+ attributes?: Attribute[];
101
+ }
102
+ export interface SpanStatus {
103
+ code?: typeof SpanStatusUnset | typeof SpanStatusOk | typeof SpanStatusError;
104
+ message?: string;
71
105
  }
106
+ export declare const SpanStatusUnset = "STATUS_CODE_UNSET";
107
+ export declare const SpanStatusOk = "STATUS_CODE_OK";
108
+ export declare const SpanStatusError = "STATUS_CODE_ERROR";
72
109
  //# sourceMappingURL=api-types.d.ts.map
@@ -1 +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"}
1
+ {"version":3,"file":"api-types.d.ts","sourceRoot":"","sources":["../../src/model/api-types.ts"],"names":[],"mappings":"AAaA;;GAEG;AACH,MAAM,WAAW,SAAS;IACxB,GAAG,EAAE,MAAM,CAAC;IACZ,KAAK,EAAE,cAAc,CAAC;CACvB;AAED,MAAM,MAAM,cAAc,GACtB;IAAE,WAAW,EAAE,MAAM,CAAA;CAAE,GACvB;IAAE,QAAQ,EAAE,MAAM,CAAA;CAAE,GACpB;IAAE,SAAS,EAAE,OAAO,CAAA;CAAE,GACtB;IAAE,UAAU,EAAE;QAA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AAE,QAAQ,CAAC;IACnB,UAAU,EAAE,SAAS,EAAE,CAAC;CACzB;AAED,MAAM,WAAW,QAAQ;IACvB,UAAU,EAAE,SAAS,EAAE,CAAC;CACzB;AAED,MAAM,WAAW,SAAS;IACxB,KAAK,EAAE,KAAK,CAAC;IACb,KAAK,EAAE,IAAI,EAAE,CAAC;CACf;AAED,MAAM,WAAW,KAAK;IACpB,IAAI,EAAE,MAAM,CAAC;CACd;AAED,MAAM,WAAW,IAAI;IACnB,OAAO,EAAE,MAAM,CAAC;IAChB,MAAM,EAAE,MAAM,CAAC;IACf,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,iBAAiB,EAAE,MAAM,CAAC;IAC1B,eAAe,EAAE,MAAM,CAAC;IACxB,UAAU,CAAC,EAAE,SAAS,EAAE,CAAC;IACzB,MAAM,CAAC,EAAE,SAAS,EAAE,CAAC;IACrB,MAAM,CAAC,EAAE,UAAU,CAAC;CACrB;AAED,MAAM,WAAW,SAAS;IACxB,YAAY,EAAE,MAAM,CAAC;IACrB,IAAI,EAAE,MAAM,CAAC;IACb,UAAU,CAAC,EAAE,SAAS,EAAE,CAAC;CAC1B;AAED,MAAM,WAAW,UAAU;IACzB,IAAI,CAAC,EAAE,OAAO,eAAe,GAAG,OAAO,YAAY,GAAG,OAAO,eAAe,CAAC;IAC7E,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB;AAED,eAAO,MAAM,eAAe,sBAAsB,CAAC;AACnD,eAAO,MAAM,YAAY,mBAAmB,CAAC;AAC7C,eAAO,MAAM,eAAe,sBAAsB,CAAC"}
@@ -11,9 +11,9 @@
11
11
  // See the License for the specific language governing permissions and
12
12
  // limitations under the License.
13
13
  /**
14
- * Combined Response of Tempo HTTP API endpoint GET /api/search/<query>
15
- * and GET /api/traces/<traceID>. For each trace returned from GET /api/search/<query>
16
- * a detailed trace report is fetched from GET /api/traces/<traceID>.
17
- */ export { };
14
+ * Common types
15
+ */ export const SpanStatusUnset = 'STATUS_CODE_UNSET';
16
+ export const SpanStatusOk = 'STATUS_CODE_OK';
17
+ export const SpanStatusError = 'STATUS_CODE_ERROR';
18
18
 
19
19
  //# sourceMappingURL=api-types.js.map
@@ -1 +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;AAkEjC;;;;CAIC,GACD,WAQC"}
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\n/**\n * Common types\n */\nexport interface Attribute {\n key: string;\n value: AttributeValue;\n}\n\nexport type AttributeValue =\n | { stringValue: string }\n | { intValue: string }\n | { boolValue: boolean }\n | { arrayValue: { values: AttributeValue[] } };\n\n/**\n * Parameters of Tempo HTTP API endpoint GET /api/search\n */\nexport interface SearchRequestParameters {\n q: string;\n start?: number;\n end?: number;\n}\n\n/**\n * Response of Tempo HTTP API endpoint GET /api/search/<query>\n */\nexport interface SearchTraceQueryResponse {\n traces: TraceSearchResult[];\n}\n\nexport interface TraceSearchResult {\n traceID: string;\n rootServiceName: string;\n rootTraceName: string;\n startTimeUnixNano: string;\n /** unset if duration is less than 1ms */\n durationMs?: number;\n /** @deprecated spanSet is deprecated in favor of spanSets */\n spanSet?: {\n spans: SpanSearchResult[];\n matched: number;\n };\n spanSets?: Array<{\n spans: SpanSearchResult[];\n matched: number;\n }>;\n /** ServiceStats are only available in Tempo vParquet4+ blocks */\n serviceStats?: Record<string, ServiceStats>;\n}\n\nexport interface SpanSearchResult {\n spanID: string;\n name: string;\n startTimeUnixNano: string;\n durationNanos: string;\n attributes: Attribute[];\n}\n\nexport interface ServiceStats {\n spanCount: number;\n /** number of spans with errors, unset if zero */\n errorCount?: number;\n}\n\n/**\n * Response of Tempo HTTP API endpoint GET /api/traces/<traceID>\n * OTEL trace proto: https://github.com/open-telemetry/opentelemetry-proto-go/blob/main/otlp/trace/v1/trace.pb.go\n */\nexport interface SearchTraceIDResponse {\n batches: Batch[];\n}\n\nexport interface Batch {\n resource: Resource;\n scopeSpans: ScopeSpan[];\n}\n\nexport interface Resource {\n attributes: Attribute[];\n}\n\nexport interface ScopeSpan {\n scope: Scope;\n spans: Span[];\n}\n\nexport interface Scope {\n name: string;\n}\n\nexport interface Span {\n traceId: string;\n spanId: string;\n parentSpanId?: string;\n name: string;\n kind: string;\n startTimeUnixNano: string;\n endTimeUnixNano: string;\n attributes?: Attribute[];\n events?: SpanEvent[];\n status?: SpanStatus;\n}\n\nexport interface SpanEvent {\n timeUnixNano: string;\n name: string;\n attributes?: Attribute[];\n}\n\nexport interface SpanStatus {\n code?: typeof SpanStatusUnset | typeof SpanStatusOk | typeof SpanStatusError;\n message?: string;\n}\n\nexport const SpanStatusUnset = 'STATUS_CODE_UNSET';\nexport const SpanStatusOk = 'STATUS_CODE_OK';\nexport const SpanStatusError = 'STATUS_CODE_ERROR';\n"],"names":["SpanStatusUnset","SpanStatusOk","SpanStatusError"],"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;;CAEC,GAgHD,OAAO,MAAMA,kBAAkB,oBAAoB;AACnD,OAAO,MAAMC,eAAe,iBAAiB;AAC7C,OAAO,MAAMC,kBAAkB,oBAAoB"}
@@ -1,36 +1,38 @@
1
1
  import { RequestHeaders } from '@perses-dev/core';
2
2
  import { DatasourceClient } from '@perses-dev/plugin-system';
3
- import { SearchTraceIDResponse, EnrichedTraceQueryResponse, SearchTraceQueryResponse } from './api-types';
3
+ import { SearchRequestParameters, SearchTraceIDResponse, SearchTraceQueryResponse } from './api-types';
4
4
  interface TempoClientOptions {
5
5
  datasourceUrl: string;
6
6
  headers?: RequestHeaders;
7
7
  }
8
8
  export interface TempoClient extends DatasourceClient {
9
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>;
10
+ searchTraceQuery(params: SearchRequestParameters, queryOptions: QueryOptions): Promise<SearchTraceQueryResponse>;
11
+ searchTraceQueryFallback(params: SearchRequestParameters, queryOptions: QueryOptions): Promise<SearchTraceQueryResponse>;
12
+ searchTraceID(traceID: string, queryOptions: QueryOptions): Promise<SearchTraceIDResponse>;
13
13
  }
14
- export declare const executeRequest: <T>(url: string) => Promise<T>;
14
+ export interface QueryOptions {
15
+ datasourceUrl: string;
16
+ headers?: RequestHeaders;
17
+ }
18
+ export declare const executeRequest: <T>(input: string | URL | Request, init?: RequestInit | undefined) => Promise<T>;
15
19
  /**
16
20
  * Returns a summary report of traces that satisfy the query.
17
21
  */
18
- export declare function searchTraceQuery(query: string, datasourceUrl: string): Promise<SearchTraceQueryResponse>;
22
+ export declare function searchTraceQuery(params: SearchRequestParameters, queryOptions: QueryOptions): Promise<SearchTraceQueryResponse>;
19
23
  /**
20
24
  * Returns a detailed report, including all the spans, for a given trace.
21
25
  */
22
- export declare function searchTraceID(traceID: string, datasourceUrl: string): Promise<SearchTraceIDResponse>;
26
+ export declare function searchTraceID(traceID: string, queryOptions: QueryOptions): Promise<SearchTraceIDResponse>;
23
27
  /**
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.
28
+ * Returns a summary report of traces that satisfy the query.
29
+ *
30
+ * If the serviceStats field is missing in the response, fetches all traces
31
+ * and calculates the serviceStats.
29
32
  *
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
+ * Tempo computes the serviceStats field during ingestion since vParquet4,
34
+ * this fallback is required for older block formats.
33
35
  */
34
- export declare function getEnrichedTraceQuery(query: string, datasourceUrl: string): Promise<EnrichedTraceQueryResponse>;
36
+ export declare function searchTraceQueryFallback(params: SearchRequestParameters, queryOptions: QueryOptions): Promise<SearchTraceQueryResponse>;
35
37
  export {};
36
38
  //# sourceMappingURL=tempo-client.d.ts.map
@@ -1 +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,EA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,OAAO,CAAC,qBAAqB,CAAC,CAAC;CAC5F;AAED,MAAM,WAAW,YAAY;IAC3B,aAAa,EAAE,MAAM,CAAC;IACtB,OAAO,CAAC,EAAE,cAAc,CAAC;CAC1B;AAED,eAAO,MAAM,cAAc,kFAI1B,CAAC;AAiBF;;GAEG;AACH,wBAAgB,gBAAgB,CAAC,MAAM,EAAE,uBAAuB,EAAE,YAAY,EAAE,YAAY,qCAE3F;AAED;;GAEG;AACH,wBAAgB,aAAa,CAAC,OAAO,EAAE,MAAM,EAAE,YAAY,EAAE,YAAY,kCAExE;AAED;;;;;;;;GAQG;AACH,wBAAsB,wBAAwB,CAC5C,MAAM,EAAE,uBAAuB,EAC/B,YAAY,EAAE,YAAY,GACzB,OAAO,CAAC,wBAAwB,CAAC,CAgDnC"}
@@ -11,67 +11,88 @@
11
11
  // See the License for the specific language governing permissions and
12
12
  // limitations under the License.
13
13
  import { fetch } from '@perses-dev/core';
14
- export const executeRequest = async (url)=>{
15
- const response = await fetch(url);
14
+ import { SpanStatusError } from './api-types';
15
+ export const executeRequest = async (...args)=>{
16
+ const response = await fetch(...args);
16
17
  const jsonData = await response.json();
17
18
  return jsonData;
18
19
  };
19
- function fetchWithGet(apiURI, datasourceUrl) {
20
- const url = `${datasourceUrl}${apiURI}`;
21
- return executeRequest(url);
20
+ function fetchWithGet(apiURI, params, queryOptions) {
21
+ const { datasourceUrl, headers = {} } = queryOptions;
22
+ let url = `${datasourceUrl}${apiURI}`;
23
+ if (params) {
24
+ url += '?' + new URLSearchParams(params);
25
+ }
26
+ const init = {
27
+ method: 'GET',
28
+ headers
29
+ };
30
+ return executeRequest(url, init);
22
31
  }
23
32
  /**
24
33
  * Returns a summary report of traces that satisfy the query.
25
- */ export function searchTraceQuery(query, datasourceUrl) {
26
- return fetchWithGet(`/api/search?q=${query}`, datasourceUrl);
34
+ */ export function searchTraceQuery(params, queryOptions) {
35
+ return fetchWithGet(`/api/search`, params, queryOptions);
27
36
  }
28
37
  /**
29
38
  * 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);
39
+ */ export function searchTraceID(traceID, queryOptions) {
40
+ return fetchWithGet(`/api/traces/${traceID}`, null, queryOptions);
32
41
  }
33
42
  /**
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.
43
+ * Returns a summary report of traces that satisfy the query.
44
+ *
45
+ * If the serviceStats field is missing in the response, fetches all traces
46
+ * and calculates the serviceStats.
39
47
  *
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) {
48
+ * Tempo computes the serviceStats field during ingestion since vParquet4,
49
+ * this fallback is required for older block formats.
50
+ */ export async function searchTraceQueryFallback(params, queryOptions) {
51
+ var _searchResponse_traces_;
44
52
  // Get a list of traces that satisfy the query.
45
- const searchResponse = await searchTraceQuery(query, datasourceUrl);
46
- if (!searchResponse.traces) {
53
+ const searchResponse = await searchTraceQuery(params, queryOptions);
54
+ if (!searchResponse.traces || searchResponse.traces.length === 0) {
47
55
  return {
48
- query,
49
56
  traces: []
50
57
  };
51
58
  }
59
+ // exit early if fallback is not required (serviceStats are contained in the response)
60
+ if ((_searchResponse_traces_ = searchResponse.traces[0]) === null || _searchResponse_traces_ === void 0 ? void 0 : _searchResponse_traces_.serviceStats) {
61
+ return searchResponse;
62
+ }
63
+ // calculate serviceStats (number of spans and errors) per service
52
64
  return {
53
- query,
54
65
  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.
66
+ const serviceStats = {};
67
+ const searchTraceIDResponse = await searchTraceID(trace.traceID, queryOptions);
68
+ // For every trace, get the full trace, and find the number of spans and errors.
59
69
  for (const batch of searchTraceIDResponse.batches){
70
+ let serviceName = '?';
71
+ for (const attr of batch.resource.attributes){
72
+ if (attr.key === 'service.name' && 'stringValue' in attr.value) {
73
+ serviceName = attr.value.stringValue;
74
+ break;
75
+ }
76
+ }
77
+ var _serviceStats_serviceName;
78
+ const stats = (_serviceStats_serviceName = serviceStats[serviceName]) !== null && _serviceStats_serviceName !== void 0 ? _serviceStats_serviceName : {
79
+ spanCount: 0
80
+ };
60
81
  for (const scopeSpan of batch.scopeSpans){
61
- spanCount += scopeSpan.spans.length;
82
+ stats.spanCount += scopeSpan.spans.length;
62
83
  for (const span of scopeSpan.spans){
63
84
  var _span_status;
64
- if ((_span_status = span.status) === null || _span_status === void 0 ? void 0 : _span_status.code) {
65
- errorCount++;
85
+ if (((_span_status = span.status) === null || _span_status === void 0 ? void 0 : _span_status.code) === SpanStatusError) {
86
+ var _stats_errorCount;
87
+ stats.errorCount = ((_stats_errorCount = stats.errorCount) !== null && _stats_errorCount !== void 0 ? _stats_errorCount : 0) + 1;
66
88
  }
67
89
  }
68
90
  }
91
+ serviceStats[serviceName] = stats;
69
92
  }
70
93
  return {
71
- summary: trace,
72
- traceDetails: searchTraceIDResponse,
73
- spanCount,
74
- errorCount
94
+ ...trace,
95
+ serviceStats
75
96
  };
76
97
  }))
77
98
  };
@@ -1 +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=${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","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,IAAI;IACpC,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,EAAEI,MAAM,CAAC,EAAEF;AAC1E;AAEA;;CAEC,GACD,OAAO,SAASG,cAAcC,OAAe,EAAEJ,aAAqB;IAClE,OAAOF,aAAoC,CAAC,YAAY,EAAEM,QAAQ,CAAC,EAAEJ;AACvE;AAEA;;;;;;;;;;CAUC,GACD,OAAO,eAAeK,sBAAsBH,KAAa,EAAEF,aAAqB;IAC9E,+CAA+C;IAC/C,MAAMM,iBAAiB,MAAML,iBAAiBC,OAAOF;IACrD,IAAI,CAACM,eAAeC,MAAM,EAAE;QAC1B,OAAO;YAAEL;YAAOK,QAAQ,EAAE;QAAC;IAC7B;IAEA,OAAO;QACLL;QACAK,QAAQ,MAAMC,QAAQC,GAAG,CACvBH,eAAeC,MAAM,CAACG,GAAG,CAAC,OAAOC;YAC/B,IAAIC,YAAY;YAChB,IAAIC,aAAa;YACjB,MAAMC,wBAAwB,MAAMX,cAAcQ,MAAMP,OAAO,EAAEJ;YAEjE,sFAAsF;YACtF,KAAK,MAAMe,SAASD,sBAAsBE,OAAO,CAAE;gBACjD,KAAK,MAAMC,aAAaF,MAAMG,UAAU,CAAE;oBACxCN,aAAaK,UAAUE,KAAK,CAACC,MAAM;oBACnC,KAAK,MAAMC,QAAQJ,UAAUE,KAAK,CAAE;4BAC9BE;wBAAJ,KAAIA,eAAAA,KAAKC,MAAM,cAAXD,mCAAAA,aAAaE,IAAI,EAAE;4BACrBV;wBACF;oBACF;gBACF;YACF;YAEA,OAAO;gBACLW,SAASb;gBACTc,cAAcX;gBACdF;gBACAC;YACF;QACF;IAEJ;AACF"}
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 {\n SearchRequestParameters,\n SearchTraceIDResponse,\n SearchTraceQueryResponse,\n ServiceStats,\n SpanStatusError,\n} from './api-types';\n\ninterface TempoClientOptions {\n datasourceUrl: string;\n headers?: RequestHeaders;\n}\n\nexport interface TempoClient extends DatasourceClient {\n options: TempoClientOptions;\n searchTraceQuery(params: SearchRequestParameters, queryOptions: QueryOptions): Promise<SearchTraceQueryResponse>;\n searchTraceQueryFallback(\n params: SearchRequestParameters,\n queryOptions: QueryOptions\n ): Promise<SearchTraceQueryResponse>;\n searchTraceID(traceID: string, queryOptions: QueryOptions): Promise<SearchTraceIDResponse>;\n}\n\nexport interface QueryOptions {\n datasourceUrl: string;\n headers?: RequestHeaders;\n}\n\nexport const executeRequest = async <T>(...args: Parameters<typeof global.fetch>): Promise<T> => {\n const response = await fetch(...args);\n const jsonData = await response.json();\n return jsonData;\n};\n\nfunction fetchWithGet<T, TResponse>(apiURI: string, params: T | null, queryOptions: QueryOptions) {\n const { datasourceUrl, headers = {} } = queryOptions;\n\n let url = `${datasourceUrl}${apiURI}`;\n if (params) {\n url += '?' + new URLSearchParams(params);\n }\n const init = {\n method: 'GET',\n headers,\n };\n\n return executeRequest<TResponse>(url, init);\n}\n\n/**\n * Returns a summary report of traces that satisfy the query.\n */\nexport function searchTraceQuery(params: SearchRequestParameters, queryOptions: QueryOptions) {\n return fetchWithGet<SearchRequestParameters, SearchTraceQueryResponse>(`/api/search`, params, queryOptions);\n}\n\n/**\n * Returns a detailed report, including all the spans, for a given trace.\n */\nexport function searchTraceID(traceID: string, queryOptions: QueryOptions) {\n return fetchWithGet<null, SearchTraceIDResponse>(`/api/traces/${traceID}`, null, queryOptions);\n}\n\n/**\n * Returns a summary report of traces that satisfy the query.\n *\n * If the serviceStats field is missing in the response, fetches all traces\n * and calculates the serviceStats.\n *\n * Tempo computes the serviceStats field during ingestion since vParquet4,\n * this fallback is required for older block formats.\n */\nexport async function searchTraceQueryFallback(\n params: SearchRequestParameters,\n queryOptions: QueryOptions\n): Promise<SearchTraceQueryResponse> {\n // Get a list of traces that satisfy the query.\n const searchResponse = await searchTraceQuery(params, queryOptions);\n if (!searchResponse.traces || searchResponse.traces.length === 0) {\n return { traces: [] };\n }\n\n // exit early if fallback is not required (serviceStats are contained in the response)\n if (searchResponse.traces[0]?.serviceStats) {\n return searchResponse;\n }\n\n // calculate serviceStats (number of spans and errors) per service\n return {\n traces: await Promise.all(\n searchResponse.traces.map(async (trace) => {\n const serviceStats: Record<string, ServiceStats> = {};\n const searchTraceIDResponse = await searchTraceID(trace.traceID, queryOptions);\n\n // For every trace, get the full trace, and find the number of spans and errors.\n for (const batch of searchTraceIDResponse.batches) {\n let serviceName = '?';\n for (const attr of batch.resource.attributes) {\n if (attr.key === 'service.name' && 'stringValue' in attr.value) {\n serviceName = attr.value.stringValue;\n break;\n }\n }\n\n const stats = serviceStats[serviceName] ?? { spanCount: 0 };\n for (const scopeSpan of batch.scopeSpans) {\n stats.spanCount += scopeSpan.spans.length;\n for (const span of scopeSpan.spans) {\n if (span.status?.code === SpanStatusError) {\n stats.errorCount = (stats.errorCount ?? 0) + 1;\n }\n }\n }\n serviceStats[serviceName] = stats;\n }\n\n return {\n ...trace,\n serviceStats,\n };\n })\n ),\n };\n}\n"],"names":["fetch","SpanStatusError","executeRequest","args","response","jsonData","json","fetchWithGet","apiURI","params","queryOptions","datasourceUrl","headers","url","URLSearchParams","init","method","searchTraceQuery","searchTraceID","traceID","searchTraceQueryFallback","searchResponse","traces","length","serviceStats","Promise","all","map","trace","searchTraceIDResponse","batch","batches","serviceName","attr","resource","attributes","key","value","stringValue","stats","spanCount","scopeSpan","scopeSpans","spans","span","status","code","errorCount"],"mappings":"AAAA,oCAAoC;AACpC,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACp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B,CAAC;AAC5G,OAAO,EAAE,mBAAmB,EAAE,MAAM,0BAA0B,CAAC;AAyB/D,eAAO,MAAM,eAAe,EAAE,gBAAgB,CAAC,mBAAmB,EAAE,WAAW,CAK9E,CAAC"}
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,EAA6D,WAAW,EAAE,MAAM,uBAAuB,CAAC;AAC/G,OAAO,EAAE,mBAAmB,EAAE,MAAM,0BAA0B,CAAC;AAyB/D,eAAO,MAAM,eAAe,EAAE,gBAAgB,CAAC,mBAAmB,EAAE,WAAW,CAK9E,CAAC"}
@@ -10,7 +10,7 @@
10
10
  // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11
11
  // See the License for the specific language governing permissions and
12
12
  // limitations under the License.
13
- import { searchTraceQuery, searchTraceID, getEnrichedTraceQuery } from '../model/tempo-client';
13
+ import { searchTraceQuery, searchTraceID, searchTraceQueryFallback } from '../model/tempo-client';
14
14
  /**
15
15
  * Creates a TempoClient for a specific datasource spec.
16
16
  */ const createClient = (spec, options)=>{
@@ -25,9 +25,9 @@ import { searchTraceQuery, searchTraceID, getEnrichedTraceQuery } from '../model
25
25
  options: {
26
26
  datasourceUrl
27
27
  },
28
- searchTraceQuery: (query)=>searchTraceQuery(query, datasourceUrl),
29
- searchTraceID: (traceID)=>searchTraceID(traceID, datasourceUrl),
30
- getEnrichedTraceQuery: (query)=>getEnrichedTraceQuery(query, datasourceUrl)
28
+ searchTraceQuery: (params, queryOptions)=>searchTraceQuery(params, queryOptions),
29
+ searchTraceQueryFallback: (params, queryOptions)=>searchTraceQueryFallback(params, queryOptions),
30
+ searchTraceID: (traceID, queryOptions)=>searchTraceID(traceID, queryOptions)
31
31
  };
32
32
  };
33
33
  export const TempoDatasource = {
@@ -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,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"}
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, searchTraceQueryFallback, 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: (params, queryOptions) => searchTraceQuery(params, queryOptions),\n searchTraceQueryFallback: (params, queryOptions) => searchTraceQueryFallback(params, queryOptions),\n searchTraceID: (traceID, queryOptions) => searchTraceID(traceID, queryOptions),\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","searchTraceQueryFallback","createClient","spec","options","directUrl","proxyUrl","datasourceUrl","undefined","Error","params","queryOptions","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,wBAAwB,QAAqB,wBAAwB;AAG/G;;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,QAAQC,eAAiBZ,iBAAiBW,QAAQC;QACrEV,0BAA0B,CAACS,QAAQC,eAAiBV,yBAAyBS,QAAQC;QACrFX,eAAe,CAACY,SAASD,eAAiBX,cAAcY,SAASD;IACnE;AACF;AAEA,OAAO,MAAME,kBAAsE;IACjFX;IACA,2DAA2D;IAC3D,iDAAiD;IACjDY,sBAAsB,IAAO,CAAA;YAAET,WAAW;QAAG,CAAA;AAC/C,EAAE"}
@@ -18,7 +18,7 @@ import { TempoTraceQueryEditor } from './TempoTraceQueryEditor';
18
18
  getTraceData,
19
19
  OptionsEditorComponent: TempoTraceQueryEditor,
20
20
  createInitialOptions: ()=>({
21
- query: '{}',
21
+ query: '',
22
22
  datasource: undefined
23
23
  })
24
24
  };
@@ -1 +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"}
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"}
@@ -1 +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"}
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,EAEL,iBAAiB,EAMlB,MAAM,kBAAkB,CAAC;AAG1B,OAAO,EAAE,mBAAmB,EAAE,MAAM,+BAA+B,CAAC;AAYpE,wBAAgB,gBAAgB,CAAC,SAAS,EAAE,iBAAiB;;;EAM5D;AAED,eAAO,MAAM,YAAY,EAAE,gBAAgB,CAAC,mBAAmB,CAAC,CAAC,cAAc,CAyD9E,CAAC"}