@perses-dev/tempo-plugin 0.47.0 → 0.48.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 (58) hide show
  1. package/dist/cjs/components/TraceQLEditor.js +98 -0
  2. package/dist/cjs/components/TraceQLExtension.js +73 -0
  3. package/dist/cjs/components/complete.js +322 -0
  4. package/dist/cjs/components/highlight.js +41 -0
  5. package/dist/cjs/components/index.js +30 -0
  6. package/dist/cjs/index.js +1 -0
  7. package/dist/cjs/model/tempo-client.js +28 -13
  8. package/dist/cjs/plugins/tempo-datasource.js +22 -4
  9. package/dist/cjs/plugins/tempo-trace-query/DashboardTempoTraceQueryEditor.js +6 -2
  10. package/dist/cjs/plugins/tempo-trace-query/get-trace-data.js +3 -13
  11. package/dist/components/TraceQLEditor.d.ts +7 -0
  12. package/dist/components/TraceQLEditor.d.ts.map +1 -0
  13. package/dist/{plugins/tempo-trace-query → components}/TraceQLEditor.js +20 -4
  14. package/dist/components/TraceQLEditor.js.map +1 -0
  15. package/dist/components/TraceQLExtension.d.ts +8 -0
  16. package/dist/components/TraceQLExtension.d.ts.map +1 -0
  17. package/dist/components/TraceQLExtension.js +65 -0
  18. package/dist/components/TraceQLExtension.js.map +1 -0
  19. package/dist/components/complete.d.ts +36 -0
  20. package/dist/components/complete.d.ts.map +1 -0
  21. package/dist/components/complete.js +313 -0
  22. package/dist/components/complete.js.map +1 -0
  23. package/dist/components/highlight.d.ts +2 -0
  24. package/dist/components/highlight.d.ts.map +1 -0
  25. package/dist/components/highlight.js +33 -0
  26. package/dist/components/highlight.js.map +1 -0
  27. package/dist/components/index.d.ts +2 -0
  28. package/dist/components/index.d.ts.map +1 -0
  29. package/dist/components/index.js +15 -0
  30. package/dist/components/index.js.map +1 -0
  31. package/dist/index.d.ts +1 -0
  32. package/dist/index.d.ts.map +1 -1
  33. package/dist/index.js +2 -0
  34. package/dist/index.js.map +1 -1
  35. package/dist/model/api-types.d.ts +60 -9
  36. package/dist/model/api-types.d.ts.map +1 -1
  37. package/dist/model/api-types.js.map +1 -1
  38. package/dist/model/tempo-client.d.ts +18 -8
  39. package/dist/model/tempo-client.d.ts.map +1 -1
  40. package/dist/model/tempo-client.js +21 -8
  41. package/dist/model/tempo-client.js.map +1 -1
  42. package/dist/plugins/tempo-datasource.d.ts.map +1 -1
  43. package/dist/plugins/tempo-datasource.js +23 -5
  44. package/dist/plugins/tempo-datasource.js.map +1 -1
  45. package/dist/plugins/tempo-trace-query/DashboardTempoTraceQueryEditor.d.ts.map +1 -1
  46. package/dist/plugins/tempo-trace-query/DashboardTempoTraceQueryEditor.js +6 -2
  47. package/dist/plugins/tempo-trace-query/DashboardTempoTraceQueryEditor.js.map +1 -1
  48. package/dist/plugins/tempo-trace-query/get-trace-data.d.ts.map +1 -1
  49. package/dist/plugins/tempo-trace-query/get-trace-data.js +3 -13
  50. package/dist/plugins/tempo-trace-query/get-trace-data.js.map +1 -1
  51. package/dist/test/mock-data.d.ts +5 -5
  52. package/dist/test/mock-data.d.ts.map +1 -1
  53. package/dist/test/mock-data.js.map +1 -1
  54. package/package.json +8 -4
  55. package/dist/cjs/plugins/tempo-trace-query/TraceQLEditor.js +0 -46
  56. package/dist/plugins/tempo-trace-query/TraceQLEditor.d.ts +0 -4
  57. package/dist/plugins/tempo-trace-query/TraceQLEditor.d.ts.map +0 -1
  58. package/dist/plugins/tempo-trace-query/TraceQLEditor.js.map +0 -1
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/components/complete.ts"],"sourcesContent":["// Copyright 2024 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 { Completion, CompletionContext, CompletionResult } from '@codemirror/autocomplete';\nimport { syntaxTree } from '@codemirror/language';\nimport { EditorState } from '@codemirror/state';\nimport { Tree } from '@lezer/common';\nimport {\n String as StringType,\n FieldExpression,\n AttributeField,\n Resource,\n Identifier,\n Span,\n SpansetFilter,\n FieldOp,\n} from '@grafana/lezer-traceql';\nimport { TempoClient } from '../model/tempo-client';\n\n/** CompletionScope specifies the completion kind, e.g. whether to complete tag names or values etc. */\ntype CompletionScope =\n | { kind: 'Scopes' } // 'resource'|'span'\n | { kind: 'TagName'; scope: 'resource' | 'span' | 'intrinsic' }\n | { kind: 'TagValue'; tag: string; quotes?: boolean };\n\n/**\n * Completions specifies the identified scopes and position of the completion in the current editor text.\n * For example, when entering '{' the following completions are possible: Scopes(), TagName(scope=intrinsic)\n */\nexport interface Completions {\n scopes: CompletionScope[];\n from: number;\n to?: number;\n}\n\nexport async function complete(\n { state, pos }: CompletionContext,\n client?: TempoClient\n): Promise<CompletionResult | null> {\n // First, identify the completion scopes, for example Scopes() and TagName(scope=intrinsic)\n const completions = identifyCompletions(state, pos, syntaxTree(state));\n if (!completions) {\n // No completion scopes found for current cursor position.\n return null;\n }\n\n // Then, retrieve completion options for all identified scopes (from the Tempo API).\n const options = await retrieveOptions(completions.scopes, client);\n return { options, from: completions.from, to: completions.to };\n}\n\n/**\n * Identify completion scopes (e.g. TagValue) and position, based on the current node in the syntax tree.\n *\n * For development, you can visualize the tree of a TraceQL query using this tool:\n * https://github.com/grafana/lezer-traceql/blob/main/tools/tree-viz.html\n *\n * Function is exported for tests only.\n */\nexport function identifyCompletions(state: EditorState, pos: number, tree: Tree): Completions | undefined {\n const node = tree.resolveInner(pos, -1);\n\n switch (node.type.id) {\n case SpansetFilter:\n // autocomplete {\n // autocomplete {}\n // do not autocomplete if cursor is after } or { status=ok }\n if (\n (node.firstChild === null || node.firstChild?.type.id === 0) &&\n !state.sliceDoc(node.from, pos).includes('}')\n ) {\n return {\n scopes: [{ kind: 'Scopes' }, { kind: 'TagName', scope: 'intrinsic' }],\n from: pos,\n };\n }\n break;\n\n case FieldExpression:\n // autocomplete { status=ok &&\n return {\n scopes: [{ kind: 'Scopes' }, { kind: 'TagName', scope: 'intrinsic' }],\n from: pos,\n };\n\n case AttributeField:\n // autocomplete { resource.\n if (node.firstChild?.type.id === Resource) {\n return { scopes: [{ kind: 'TagName', scope: 'resource' }], from: pos };\n }\n\n // autocomplete { span.\n if (node.firstChild?.type.id === Span) {\n return { scopes: [{ kind: 'TagName', scope: 'span' }], from: pos };\n }\n\n // autocomplete { .\n if (state.sliceDoc(node.from, node.to) === '.') {\n return {\n scopes: [\n { kind: 'TagName', scope: 'resource' },\n { kind: 'TagName', scope: 'span' },\n ],\n from: pos,\n };\n }\n break;\n\n case Identifier:\n if (node.parent?.type.id === AttributeField) {\n const text = state.sliceDoc(node.parent.from, node.parent.to);\n // autocomplete { span:s\n // only intrinsic fields can have a : in the name.\n if (text.includes(':')) {\n return { scopes: [{ kind: 'TagName', scope: 'intrinsic' }], from: node.parent.from };\n }\n\n // autocomplete { resource.s\n if (node.parent?.firstChild?.type.id === Resource) {\n return { scopes: [{ kind: 'TagName', scope: 'resource' }], from: node.from };\n }\n\n // autocomplete { span.s\n if (node.parent?.firstChild?.type.id === Span) {\n return { scopes: [{ kind: 'TagName', scope: 'span' }], from: node.from };\n }\n\n // autocomplete { .s\n if (node.parent?.firstChild?.type.id === Identifier) {\n return {\n scopes: [\n { kind: 'TagName', scope: 'resource' },\n { kind: 'TagName', scope: 'span' },\n ],\n from: node.from,\n };\n }\n }\n break;\n\n case FieldOp:\n // autocomplete { status=\n // autocomplete { span.http.method=\n if (node.parent?.firstChild?.type.id === FieldExpression) {\n const fieldExpr = node.parent.firstChild;\n const attribute = state.sliceDoc(fieldExpr.from, fieldExpr.to);\n return { scopes: [{ kind: 'TagValue', tag: attribute, quotes: true }], from: pos };\n }\n break;\n\n case StringType:\n // autocomplete { resource.service.name=\"\n if (node.parent?.parent?.parent?.firstChild?.type.id === FieldExpression) {\n const fieldExpr = node.parent.parent.parent.firstChild;\n const attribute = state.sliceDoc(fieldExpr.from, fieldExpr.to);\n return { scopes: [{ kind: 'TagValue', tag: attribute }], from: node.from + 1 }; // node.from+1 to ignore leading \"\n }\n break;\n\n case 0 /* error node */:\n // autocomplete { status=e\n if (node.prevSibling?.type.id === FieldOp && node.parent?.firstChild?.type.id === FieldExpression) {\n const fieldExpr = node.parent.firstChild;\n const attribute = state.sliceDoc(fieldExpr.from, fieldExpr.to);\n return { scopes: [{ kind: 'TagValue', tag: attribute }], from: node.from };\n }\n\n // autocomplete { s\n // autocomplete { status=ok && s\n if (node.parent?.type.id === SpansetFilter || node.parent?.type.id === FieldExpression) {\n return {\n scopes: [{ kind: 'Scopes' }, { kind: 'TagName', scope: 'intrinsic' }],\n from: node.from,\n };\n }\n break;\n }\n}\n\n/**\n * Retrieve all completion options based on the previously identified completion scopes.\n */\nasync function retrieveOptions(completions: CompletionScope[], client?: TempoClient): Promise<Completion[]> {\n const results: Array<Promise<Completion[]>> = [];\n\n for (const completion of completions) {\n switch (completion.kind) {\n case 'Scopes':\n results.push(Promise.resolve([{ label: 'span' }, { label: 'resource' }]));\n break;\n\n case 'TagName':\n if (client) {\n results.push(completeTagName(client, completion.scope));\n }\n break;\n\n case 'TagValue':\n if (client) {\n results.push(completeTagValue(client, completion.tag, completion.quotes));\n }\n break;\n }\n }\n\n // Retrieve options concurrently\n // e.g. for unscoped attribute fields, retrieve list of span and resource attributes concurrently.\n const options = await Promise.all(results);\n return options.flat();\n}\n\nasync function completeTagName(client: TempoClient, scope: 'resource' | 'span' | 'intrinsic'): Promise<Completion[]> {\n const response = await client.searchTags({ scope });\n return response.scopes.flatMap((scope) => scope.tags).map((tag) => ({ label: tag }));\n}\n\nasync function completeTagValue(client: TempoClient, tag: string, quotes?: boolean): Promise<Completion[]> {\n const response = await client.searchTagValues({ tag });\n const completions: Completion[] = [];\n for (const { type, value } of response.tagValues) {\n switch (type) {\n case 'string':\n completions.push({ displayLabel: value, label: quotes ? `\"${value}\"` : value });\n break;\n\n case 'keyword':\n case 'int':\n completions.push({ label: value });\n break;\n }\n }\n return completions;\n}\n"],"names":["syntaxTree","String","StringType","FieldExpression","AttributeField","Resource","Identifier","Span","SpansetFilter","FieldOp","complete","state","pos","client","completions","identifyCompletions","options","retrieveOptions","scopes","from","to","tree","node","resolveInner","type","id","firstChild","sliceDoc","includes","kind","scope","parent","text","fieldExpr","attribute","tag","quotes","prevSibling","results","completion","push","Promise","resolve","label","completeTagName","completeTagValue","all","flat","response","searchTags","flatMap","tags","map","searchTagValues","value","tagValues","displayLabel"],"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,UAAU,QAAQ,uBAAuB;AAGlD,SACEC,UAAUC,UAAU,EACpBC,eAAe,EACfC,cAAc,EACdC,QAAQ,EACRC,UAAU,EACVC,IAAI,EACJC,aAAa,EACbC,OAAO,QACF,yBAAyB;AAmBhC,OAAO,eAAeC,SACpB,EAAEC,KAAK,EAAEC,GAAG,EAAqB,EACjCC,MAAoB;IAEpB,2FAA2F;IAC3F,MAAMC,cAAcC,oBAAoBJ,OAAOC,KAAKZ,WAAWW;IAC/D,IAAI,CAACG,aAAa;QAChB,0DAA0D;QAC1D,OAAO;IACT;IAEA,oFAAoF;IACpF,MAAME,UAAU,MAAMC,gBAAgBH,YAAYI,MAAM,EAAEL;IAC1D,OAAO;QAAEG;QAASG,MAAML,YAAYK,IAAI;QAAEC,IAAIN,YAAYM,EAAE;IAAC;AAC/D;AAEA;;;;;;;CAOC,GACD,OAAO,SAASL,oBAAoBJ,KAAkB,EAAEC,GAAW,EAAES,IAAU;IAC7E,MAAMC,OAAOD,KAAKE,YAAY,CAACX,KAAK,CAAC;I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ropSource;
2
+ //# sourceMappingURL=highlight.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"highlight.d.ts","sourceRoot":"","sources":["../../src/components/highlight.ts"],"names":[],"mappings":"AAeA,eAAO,MAAM,gBAAgB,wCAiB3B,CAAC"}
@@ -0,0 +1,33 @@
1
+ // Copyright 2024 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 { styleTags, tags } from '@lezer/highlight';
14
+ export const traceQLHighlight = styleTags({
15
+ LineComment: tags.comment,
16
+ 'Parent Resource Span Identifier': tags.labelName,
17
+ IntrinsicField: tags.labelName,
18
+ String: tags.string,
19
+ 'Integer Float Duration': tags.number,
20
+ Static: tags.literal,
21
+ 'Aggregate AggregateExpression': tags.function(tags.keyword),
22
+ 'And Or': tags.logicOperator,
23
+ 'Gt Lt Desc Anc tilde ExperimentalOp': tags.bitwiseOperator,
24
+ ComparisonOp: tags.compareOperator,
25
+ Pipe: tags.operator,
26
+ ScalarOp: tags.arithmeticOperator,
27
+ '( )': tags.paren,
28
+ '[ ]': tags.squareBracket,
29
+ '{ }': tags.brace,
30
+ '⚠': tags.invalid
31
+ });
32
+
33
+ //# sourceMappingURL=highlight.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/components/highlight.ts"],"sourcesContent":["// Copyright 2024 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 { styleTags, tags } from '@lezer/highlight';\n\nexport const traceQLHighlight = styleTags({\n LineComment: tags.comment,\n 'Parent Resource Span Identifier': tags.labelName,\n IntrinsicField: tags.labelName,\n String: tags.string,\n 'Integer Float Duration': tags.number,\n Static: tags.literal,\n 'Aggregate AggregateExpression': tags.function(tags.keyword),\n 'And Or': tags.logicOperator,\n 'Gt Lt Desc Anc tilde ExperimentalOp': tags.bitwiseOperator, // structural operators\n ComparisonOp: tags.compareOperator,\n Pipe: tags.operator,\n ScalarOp: tags.arithmeticOperator,\n '( )': tags.paren,\n '[ ]': tags.squareBracket,\n '{ }': tags.brace,\n '⚠': tags.invalid,\n});\n"],"names":["styleTags","tags","traceQLHighlight","LineComment","comment","labelName","IntrinsicField","String","string","number","Static","literal","function","keyword","logicOperator","bitwiseOperator","ComparisonOp","compareOperator","Pipe","operator","ScalarOp","arithmeticOperator","paren","squareBracket","brace","invalid"],"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,SAAS,EAAEC,IAAI,QAAQ,mBAAmB;AAEnD,OAAO,MAAMC,mBAAmBF,UAAU;IACxCG,aAAaF,KAAKG,OAAO;IACzB,mCAAmCH,KAAKI,SAAS;IACjDC,gBAAgBL,KAAKI,SAAS;IAC9BE,QAAQN,KAAKO,MAAM;IACnB,0BAA0BP,KAAKQ,MAAM;IACrCC,QAAQT,KAAKU,OAAO;IACpB,iCAAiCV,KAAKW,QAAQ,CAACX,KAAKY,OAAO;IAC3D,UAAUZ,KAAKa,aAAa;IAC5B,uCAAuCb,KAAKc,eAAe;IAC3DC,cAAcf,KAAKgB,eAAe;IAClCC,MAAMjB,KAAKkB,QAAQ;IACnBC,UAAUnB,KAAKoB,kBAAkB;IACjC,OAAOpB,KAAKqB,KAAK;IACjB,OAAOrB,KAAKsB,aAAa;IACzB,OAAOtB,KAAKuB,KAAK;IACjB,KAAKvB,KAAKwB,OAAO;AACnB,GAAG"}
@@ -0,0 +1,2 @@
1
+ export * from './TraceQLEditor';
2
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/components/index.ts"],"names":[],"mappings":"AAaA,cAAc,iBAAiB,CAAC"}
@@ -0,0 +1,15 @@
1
+ // Copyright 2024 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 './TraceQLEditor';
14
+
15
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/components/index.ts"],"sourcesContent":["// Copyright 2024 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 './TraceQLEditor';\n"],"names":[],"mappings":"AAAA,oCAAoC;AACpC,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AAEjC,cAAc,kBAAkB"}
package/dist/index.d.ts CHANGED
@@ -3,4 +3,5 @@ import { TempoTraceQuery } from './plugins/tempo-trace-query/TempoTraceQuery';
3
3
  export { TempoTraceQuery, TempoDatasource };
4
4
  export * from './model/tempo-client';
5
5
  export * from './model/tempo-selectors';
6
+ export * from './components/TraceQLExtension';
6
7
  //# sourceMappingURL=index.d.ts.map
@@ -1 +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,6CAA6C,CAAC;AAG9E,OAAO,EAAE,eAAe,EAAE,eAAe,EAAE,CAAC;AAG5C,cAAc,sBAAsB,CAAC;AACrC,cAAc,yBAAyB,CAAC"}
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,6CAA6C,CAAC;AAG9E,OAAO,EAAE,eAAe,EAAE,eAAe,EAAE,CAAC;AAG5C,cAAc,sBAAsB,CAAC;AACrC,cAAc,yBAAyB,CAAC;AAGxC,cAAc,+BAA+B,CAAC"}
package/dist/index.js CHANGED
@@ -17,5 +17,7 @@ export { TempoTraceQuery, TempoDatasource };
17
17
  // For consumers to leverage in DatasourceStoreProvider onCreate
18
18
  export * from './model/tempo-client';
19
19
  export * from './model/tempo-selectors';
20
+ // For consumers of TraceQLExtension
21
+ export * from './components/TraceQLExtension';
20
22
 
21
23
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +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/tempo-trace-query/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,8CAA8C;AAE9E,mFAAmF;AACnF,SAASA,eAAe,EAAED,eAAe,GAAG;AAE5C,gEAAgE;AAChE,cAAc,uBAAuB;AACrC,cAAc,0BAA0B"}
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/tempo-trace-query/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\n// For consumers of TraceQLExtension\nexport * from './components/TraceQLExtension';\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,8CAA8C;AAE9E,mFAAmF;AACnF,SAASA,eAAe,EAAED,eAAe,GAAG;AAE5C,gEAAgE;AAChE,cAAc,uBAAuB;AACrC,cAAc,0BAA0B;AAExC,oCAAoC;AACpC,cAAc,gCAAgC"}
@@ -17,7 +17,8 @@ export type AttributeValue = {
17
17
  };
18
18
  };
19
19
  /**
20
- * Parameters of Tempo HTTP API endpoint GET /api/search
20
+ * Request parameters of Tempo HTTP API endpoint GET /api/search
21
+ * https://grafana.com/docs/tempo/latest/api_docs/#search
21
22
  */
22
23
  export interface SearchRequestParameters {
23
24
  q: string;
@@ -25,12 +26,13 @@ export interface SearchRequestParameters {
25
26
  end?: number;
26
27
  }
27
28
  /**
28
- * Response of Tempo HTTP API endpoint GET /api/search/<query>
29
+ * Response of Tempo HTTP API endpoint GET /api/search
30
+ * https://grafana.com/docs/tempo/latest/api_docs/#search
29
31
  */
30
- export interface SearchTraceQueryResponse {
31
- traces: TraceSearchResult[];
32
+ export interface SearchResponse {
33
+ traces: TraceSearchResponse[];
32
34
  }
33
- export interface TraceSearchResult {
35
+ export interface TraceSearchResponse {
34
36
  traceID: string;
35
37
  rootServiceName: string;
36
38
  rootTraceName: string;
@@ -39,17 +41,17 @@ export interface TraceSearchResult {
39
41
  durationMs?: number;
40
42
  /** @deprecated spanSet is deprecated in favor of spanSets */
41
43
  spanSet?: {
42
- spans: SpanSearchResult[];
44
+ spans: SpanSearchResponse[];
43
45
  matched: number;
44
46
  };
45
47
  spanSets?: Array<{
46
- spans: SpanSearchResult[];
48
+ spans: SpanSearchResponse[];
47
49
  matched: number;
48
50
  }>;
49
51
  /** ServiceStats are only available in Tempo vParquet4+ blocks */
50
52
  serviceStats?: Record<string, ServiceStats>;
51
53
  }
52
- export interface SpanSearchResult {
54
+ export interface SpanSearchResponse {
53
55
  spanID: string;
54
56
  name: string;
55
57
  startTimeUnixNano: string;
@@ -61,11 +63,18 @@ export interface ServiceStats {
61
63
  /** number of spans with errors, unset if zero */
62
64
  errorCount?: number;
63
65
  }
66
+ /**
67
+ * Request parameters of Tempo HTTP API endpoint GET /api/traces/<traceID>
68
+ * https://grafana.com/docs/tempo/latest/api_docs/#query
69
+ */
70
+ export interface QueryRequestParameters {
71
+ traceId: string;
72
+ }
64
73
  /**
65
74
  * Response of Tempo HTTP API endpoint GET /api/traces/<traceID>
66
75
  * OTEL trace proto: https://github.com/open-telemetry/opentelemetry-proto-go/blob/main/otlp/trace/v1/trace.pb.go
67
76
  */
68
- export interface SearchTraceIDResponse {
77
+ export interface QueryResponse {
69
78
  batches: Batch[];
70
79
  }
71
80
  export interface Batch {
@@ -106,4 +115,46 @@ export interface SpanStatus {
106
115
  export declare const SpanStatusUnset = "STATUS_CODE_UNSET";
107
116
  export declare const SpanStatusOk = "STATUS_CODE_OK";
108
117
  export declare const SpanStatusError = "STATUS_CODE_ERROR";
118
+ /**
119
+ * Request parameters of Tempo HTTP API endpoint GET /api/v2/search/tags
120
+ * https://grafana.com/docs/tempo/latest/api_docs/#search-tags-v2
121
+ */
122
+ export interface SearchTagsRequestParameters {
123
+ scope?: 'resource' | 'span' | 'intrinsic';
124
+ q?: string;
125
+ start?: number;
126
+ end?: number;
127
+ }
128
+ /**
129
+ * Response of Tempo HTTP API endpoint GET /api/v2/search/tags
130
+ * https://grafana.com/docs/tempo/latest/api_docs/#search-tags-v2
131
+ */
132
+ export interface SearchTagsResponse {
133
+ scopes: SearchTagsScope[];
134
+ }
135
+ export interface SearchTagsScope {
136
+ name: 'resource' | 'span' | 'intrinsic';
137
+ tags: string[];
138
+ }
139
+ /**
140
+ * Request parameters of Tempo HTTP API endpoint GET /api/v2/search/tag/<tag>/values
141
+ * https://grafana.com/docs/tempo/latest/api_docs/#search-tag-values-v2
142
+ */
143
+ export interface SearchTagValuesRequestParameters {
144
+ tag: string;
145
+ q?: string;
146
+ start?: number;
147
+ end?: number;
148
+ }
149
+ /**
150
+ * Response of Tempo HTTP API endpoint GET /api/v2/search/tag/<tag>/values
151
+ * https://grafana.com/docs/tempo/latest/api_docs/#search-tag-values-v2
152
+ */
153
+ export interface SearchTagValuesResponse {
154
+ tagValues: SearchTagValue[];
155
+ }
156
+ export interface SearchTagValue {
157
+ type: string;
158
+ value: string;
159
+ }
109
160
  //# 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;;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;QAAE,MAAM,EAAE,cAAc,EAAE,CAAA;KAAE,CAAA;CAAE,CAAC;AAEjD;;GAEG;AACH,MAAM,WAAW,uBAAuB;IACtC,CAAC,EAAE,MAAM,CAAC;IACV,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,GAAG,CAAC,EAAE,MAAM,CAAC;CACd;AAED;;GAEG;AACH,MAAM,WAAW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,MAAM,CAAC;CACd;AAED;;;GAGG;AACH,MAAM,WAAW,kBAAkB;IACjC,MAAM,EAAE,eAAe,EAAE,CAAC;CAC3B;AAED,MAAM,WAAW,eAAe;IAC9B,IAAI,EAAE,UAAU,GAAG,MAAM,GAAG,WAAW,CAAC;IACxC,IAAI,EAAE,MAAM,EAAE,CAAC;CAChB;AAED;;;GAGG;AACH,MAAM,WAAW,gCAAgC;IAC/C,GAAG,EAAE,MAAM,CAAC;IACZ,CAAC,CAAC,EAAE,MAAM,CAAC;IACX,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,GAAG,CAAC,EAAE,MAAM,CAAC;CACd;AAED;;;GAGG;AACH,MAAM,WAAW,uBAAuB;IACtC,SAAS,EAAE,cAAc,EAAE,CAAC;CAC7B;AAED,MAAM,WAAW,cAAc;IAC7B,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,CAAC;CACf"}
@@ -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\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
+ {"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 * Request parameters of Tempo HTTP API endpoint GET /api/search\n * https://grafana.com/docs/tempo/latest/api_docs/#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\n * https://grafana.com/docs/tempo/latest/api_docs/#search\n */\nexport interface SearchResponse {\n traces: TraceSearchResponse[];\n}\n\nexport interface TraceSearchResponse {\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: SpanSearchResponse[];\n matched: number;\n };\n spanSets?: Array<{\n spans: SpanSearchResponse[];\n matched: number;\n }>;\n /** ServiceStats are only available in Tempo vParquet4+ blocks */\n serviceStats?: Record<string, ServiceStats>;\n}\n\nexport interface SpanSearchResponse {\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 * Request parameters of Tempo HTTP API endpoint GET /api/traces/<traceID>\n * https://grafana.com/docs/tempo/latest/api_docs/#query\n */\nexport interface QueryRequestParameters {\n traceId: string;\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 QueryResponse {\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\n/**\n * Request parameters of Tempo HTTP API endpoint GET /api/v2/search/tags\n * https://grafana.com/docs/tempo/latest/api_docs/#search-tags-v2\n */\nexport interface SearchTagsRequestParameters {\n scope?: 'resource' | 'span' | 'intrinsic';\n q?: string;\n start?: number;\n end?: number;\n}\n\n/**\n * Response of Tempo HTTP API endpoint GET /api/v2/search/tags\n * https://grafana.com/docs/tempo/latest/api_docs/#search-tags-v2\n */\nexport interface SearchTagsResponse {\n scopes: SearchTagsScope[];\n}\n\nexport interface SearchTagsScope {\n name: 'resource' | 'span' | 'intrinsic';\n tags: string[];\n}\n\n/**\n * Request parameters of Tempo HTTP API endpoint GET /api/v2/search/tag/<tag>/values\n * https://grafana.com/docs/tempo/latest/api_docs/#search-tag-values-v2\n */\nexport interface SearchTagValuesRequestParameters {\n tag: string;\n q?: string;\n start?: number;\n end?: number;\n}\n\n/**\n * Response of Tempo HTTP API endpoint GET /api/v2/search/tag/<tag>/values\n * https://grafana.com/docs/tempo/latest/api_docs/#search-tag-values-v2\n */\nexport interface SearchTagValuesResponse {\n tagValues: SearchTagValue[];\n}\n\nexport interface SearchTagValue {\n type: string;\n value: string;\n}\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,GA0HD,OAAO,MAAMA,kBAAkB,oBAAoB;AACnD,OAAO,MAAMC,eAAe,iBAAiB;AAC7C,OAAO,MAAMC,kBAAkB,oBAAoB"}
@@ -1,15 +1,17 @@
1
1
  import { RequestHeaders } from '@perses-dev/core';
2
2
  import { DatasourceClient } from '@perses-dev/plugin-system';
3
- import { SearchRequestParameters, SearchTraceIDResponse, SearchTraceQueryResponse } from './api-types';
3
+ import { QueryRequestParameters, SearchRequestParameters, SearchTagsRequestParameters, SearchTagsResponse, QueryResponse, SearchResponse, SearchTagValuesRequestParameters, SearchTagValuesResponse } 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
- searchTraceQuery(params: SearchRequestParameters, queryOptions: QueryOptions): Promise<SearchTraceQueryResponse>;
11
- searchTraceQueryFallback(params: SearchRequestParameters, queryOptions: QueryOptions): Promise<SearchTraceQueryResponse>;
12
- searchTraceID(traceID: string, queryOptions: QueryOptions): Promise<SearchTraceIDResponse>;
10
+ query(params: QueryRequestParameters, headers?: RequestHeaders): Promise<QueryResponse>;
11
+ search(params: SearchRequestParameters, headers?: RequestHeaders): Promise<SearchResponse>;
12
+ searchWithFallback(params: SearchRequestParameters, headers?: RequestHeaders): Promise<SearchResponse>;
13
+ searchTags(params: SearchTagsRequestParameters, headers?: RequestHeaders): Promise<SearchTagsResponse>;
14
+ searchTagValues(params: SearchTagValuesRequestParameters, headers?: RequestHeaders): Promise<SearchTagValuesResponse>;
13
15
  }
14
16
  export interface QueryOptions {
15
17
  datasourceUrl: string;
@@ -19,11 +21,11 @@ export declare const executeRequest: <T>(input: string | URL | Request, init?: R
19
21
  /**
20
22
  * Returns a summary report of traces that satisfy the query.
21
23
  */
22
- export declare function searchTraceQuery(params: SearchRequestParameters, queryOptions: QueryOptions): Promise<SearchTraceQueryResponse>;
24
+ export declare function search(params: SearchRequestParameters, queryOptions: QueryOptions): Promise<SearchResponse>;
23
25
  /**
24
- * Returns a detailed report, including all the spans, for a given trace.
26
+ * Returns an entire trace.
25
27
  */
26
- export declare function searchTraceID(traceID: string, queryOptions: QueryOptions): Promise<SearchTraceIDResponse>;
28
+ export declare function query(params: QueryRequestParameters, queryOptions: QueryOptions): Promise<QueryResponse>;
27
29
  /**
28
30
  * Returns a summary report of traces that satisfy the query.
29
31
  *
@@ -33,6 +35,14 @@ export declare function searchTraceID(traceID: string, queryOptions: QueryOption
33
35
  * Tempo computes the serviceStats field during ingestion since vParquet4,
34
36
  * this fallback is required for older block formats.
35
37
  */
36
- export declare function searchTraceQueryFallback(params: SearchRequestParameters, queryOptions: QueryOptions): Promise<SearchTraceQueryResponse>;
38
+ export declare function searchWithFallback(params: SearchRequestParameters, queryOptions: QueryOptions): Promise<SearchResponse>;
39
+ /**
40
+ * Returns a list of all tag names for a given scope.
41
+ */
42
+ export declare function searchTags(params: SearchTagsRequestParameters, queryOptions: QueryOptions): Promise<SearchTagsResponse>;
43
+ /**
44
+ * Returns a list of all tag values for a given tag.
45
+ */
46
+ export declare function searchTagValues(params: SearchTagValuesRequestParameters, queryOptions: QueryOptions): Promise<SearchTagValuesResponse>;
37
47
  export {};
38
48
  //# 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,EACL,uBAAuB,EACvB,qBAAqB,EACrB,wBAAwB,EAGzB,MAAM,aAAa,CAAC;AAErB,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,gBAAgB,CAAC,MAAM,EAAE,uBAAuB,EAAE,YAAY,EAAE,YAAY,GAAG,OAAO,CAAC,wBAAwB,CAAC,CAAC;IACjH,wBAAwB,CACtB,MAAM,EAAE,uBAAuB,EAC/B,YAAY,EAAE,YAAY,GACzB,OAAO,CAAC,wBAAwB,CAAC,CAAC;IACrC,aAAa,CAAC,OAAO,EAAE,MAAM,EAAE,YAAY,EAAE,YAAY,GAAG,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,EAA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AG,OAAO,CAAC,uBAAuB,CAAC,CAAC;CACvH;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,MAAM,CAAC,MAAM,EAAE,uBAAuB,EAAE,YAAY,EAAE,YAAY,2BAEjF;AAED;;GAEG;AACH,wBAAgB,KAAK,CAAC,MAAM,EAAE,sBAAsB,EAAE,YAAY,EAAE,YAAY,0BAE/E;AAED;;;;;;;;GAQG;AACH,wBAAsB,kBAAkB,CACtC,MAAM,EAAE,uBAAuB,EAC/B,YAAY,EAAE,YAAY,GACzB,OAAO,CAAC,cAAc,CAAC,CAgDzB;AAED;;GAEG;AACH,wBAAgB,UAAU,CAAC,MAAM,EAAE,2BAA2B,EAAE,YAAY,EAAE,YAAY,+BAEzF;AAED;;GAEG;AACH,wBAAgB,eAAe,CAAC,MAAM,EAAE,gCAAgC,EAAE,YAAY,EAAE,YAAY,oCAOnG"}
@@ -31,13 +31,13 @@ function fetchWithGet(apiURI, params, queryOptions) {
31
31
  }
32
32
  /**
33
33
  * Returns a summary report of traces that satisfy the query.
34
- */ export function searchTraceQuery(params, queryOptions) {
35
- return fetchWithGet(`/api/search`, params, queryOptions);
34
+ */ export function search(params, queryOptions) {
35
+ return fetchWithGet('/api/search', params, queryOptions);
36
36
  }
37
37
  /**
38
- * Returns a detailed report, including all the spans, for a given trace.
39
- */ export function searchTraceID(traceID, queryOptions) {
40
- return fetchWithGet(`/api/traces/${traceID}`, null, queryOptions);
38
+ * Returns an entire trace.
39
+ */ export function query(params, queryOptions) {
40
+ return fetchWithGet(`/api/traces/${encodeURIComponent(params.traceId)}`, null, queryOptions);
41
41
  }
42
42
  /**
43
43
  * Returns a summary report of traces that satisfy the query.
@@ -47,10 +47,10 @@ function fetchWithGet(apiURI, params, queryOptions) {
47
47
  *
48
48
  * Tempo computes the serviceStats field during ingestion since vParquet4,
49
49
  * this fallback is required for older block formats.
50
- */ export async function searchTraceQueryFallback(params, queryOptions) {
50
+ */ export async function searchWithFallback(params, queryOptions) {
51
51
  var _searchResponse_traces_;
52
52
  // Get a list of traces that satisfy the query.
53
- const searchResponse = await searchTraceQuery(params, queryOptions);
53
+ const searchResponse = await search(params, queryOptions);
54
54
  if (!searchResponse.traces || searchResponse.traces.length === 0) {
55
55
  return {
56
56
  traces: []
@@ -64,7 +64,9 @@ function fetchWithGet(apiURI, params, queryOptions) {
64
64
  return {
65
65
  traces: await Promise.all(searchResponse.traces.map(async (trace)=>{
66
66
  const serviceStats = {};
67
- const searchTraceIDResponse = await searchTraceID(trace.traceID, queryOptions);
67
+ const searchTraceIDResponse = await query({
68
+ traceId: trace.traceID
69
+ }, queryOptions);
68
70
  // For every trace, get the full trace, and find the number of spans and errors.
69
71
  for (const batch of searchTraceIDResponse.batches){
70
72
  let serviceName = '?';
@@ -97,5 +99,16 @@ function fetchWithGet(apiURI, params, queryOptions) {
97
99
  }))
98
100
  };
99
101
  }
102
+ /**
103
+ * Returns a list of all tag names for a given scope.
104
+ */ export function searchTags(params, queryOptions) {
105
+ return fetchWithGet('/api/v2/search/tags', params, queryOptions);
106
+ }
107
+ /**
108
+ * Returns a list of all tag values for a given tag.
109
+ */ export function searchTagValues(params, queryOptions) {
110
+ const { tag, ...rest } = params;
111
+ return fetchWithGet(`/api/v2/search/tag/${encodeURIComponent(tag)}/values`, rest, queryOptions);
112
+ }
100
113
 
101
114
  //# sourceMappingURL=tempo-client.js.map
@@ -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 {\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,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AA0BG,YAAY,EAAE;QAC1C,OAAOH;IACT;IAEA,kEAAkE;IAClE,OAAO;QACLC,QAAQ,MAAMG,QAAQC,GAAG,CACvBL,eAAeC,MAAM,CAACK,GAAG,CAAC,OAAOC;YAC/B,MAAMJ,eAA6C,CAAC;YACpD,MAAMK,wBAAwB,MAAMX,cAAcU,MAAMT,OAAO,EAAET;YAEjE,gFAAgF;YAChF,KAAK,MAAMoB,SAASD,sBAAsBE,OAAO,CAAE;gBACjD,IAAIC,cAAc;gBAClB,KAAK,MAAMC,QAAQH,MAAMI,QAAQ,CAACC,UAAU,CAAE;oBAC5C,IAAIF,KAAKG,GAAG,KAAK,kBAAkB,iBAAiBH,KAAKI,KAAK,EAAE;wBAC9DL,cAAcC,KAAKI,KAAK,CAACC,WAAW;wBACpC;oBACF;gBACF;oBAEcd;gBAAd,MAAMe,QAAQf,CAAAA,4BAAAA,YAAY,CAACQ,YAAY,cAAzBR,uCAAAA,4BAA6B;oBAAEgB,WAAW;gBAAE;gBAC1D,KAAK,MAAMC,aAAaX,MAAMY,UAAU,CAAE;oBACxCH,MAAMC,SAAS,IAAIC,UAAUE,KAAK,CAACpB,MAAM;oBACzC,KAAK,MAAMqB,QAAQH,UAAUE,KAAK,CAAE;4BAC9BC;wBAAJ,IAAIA,EAAAA,eAAAA,KAAKC,MAAM,cAAXD,mCAAAA,aAAaE,IAAI,MAAK7C,iBAAiB;gCACrBsC;4BAApBA,MAAMQ,UAAU,GAAG,AAACR,CAAAA,CAAAA,oBAAAA,MAAMQ,UAAU,cAAhBR,+BAAAA,oBAAoB,CAAA,IAAK;wBAC/C;oBACF;gBACF;gBACAf,YAAY,CAACQ,YAAY,GAAGO;YAC9B;YAEA,OAAO;gBACL,GAAGX,KAAK;gBACRJ;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 QueryRequestParameters,\n SearchRequestParameters,\n SearchTagsRequestParameters,\n SearchTagsResponse,\n QueryResponse,\n ServiceStats,\n SpanStatusError,\n SearchResponse,\n SearchTagValuesRequestParameters,\n SearchTagValuesResponse,\n} from './api-types';\n\ninterface TempoClientOptions {\n datasourceUrl: string;\n headers?: RequestHeaders;\n}\n\nexport interface TempoClient extends DatasourceClient {\n options: TempoClientOptions;\n // https://grafana.com/docs/tempo/latest/api_docs/\n query(params: QueryRequestParameters, headers?: RequestHeaders): Promise<QueryResponse>;\n search(params: SearchRequestParameters, headers?: RequestHeaders): Promise<SearchResponse>;\n searchWithFallback(params: SearchRequestParameters, headers?: RequestHeaders): Promise<SearchResponse>;\n searchTags(params: SearchTagsRequestParameters, headers?: RequestHeaders): Promise<SearchTagsResponse>;\n searchTagValues(params: SearchTagValuesRequestParameters, headers?: RequestHeaders): Promise<SearchTagValuesResponse>;\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 search(params: SearchRequestParameters, queryOptions: QueryOptions) {\n return fetchWithGet<SearchRequestParameters, SearchResponse>('/api/search', params, queryOptions);\n}\n\n/**\n * Returns an entire trace.\n */\nexport function query(params: QueryRequestParameters, queryOptions: QueryOptions) {\n return fetchWithGet<null, QueryResponse>(`/api/traces/${encodeURIComponent(params.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 searchWithFallback(\n params: SearchRequestParameters,\n queryOptions: QueryOptions\n): Promise<SearchResponse> {\n // Get a list of traces that satisfy the query.\n const searchResponse = await search(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 query({ traceId: 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\n/**\n * Returns a list of all tag names for a given scope.\n */\nexport function searchTags(params: SearchTagsRequestParameters, queryOptions: QueryOptions) {\n return fetchWithGet<SearchTagsRequestParameters, SearchTagsResponse>('/api/v2/search/tags', params, queryOptions);\n}\n\n/**\n * Returns a list of all tag values for a given tag.\n */\nexport function searchTagValues(params: SearchTagValuesRequestParameters, queryOptions: QueryOptions) {\n const { tag, ...rest } = params;\n return fetchWithGet<Omit<SearchTagValuesRequestParameters, 'tag'>, SearchTagValuesResponse>(\n `/api/v2/search/tag/${encodeURIComponent(tag)}/values`,\n rest,\n queryOptions\n );\n}\n"],"names":["fetch","SpanStatusError","executeRequest","args","response","jsonData","json","fetchWithGet","apiURI","params","queryOptions","datasourceUrl","headers","url","URLSearchParams","init","method","search","query","encodeURIComponent","traceId","searchWithFallback","searchResponse","traces","length","serviceStats","Promise","all","map","trace","searchTraceIDResponse","traceID","batch","batches","serviceName","attr","resource","attributes","key","value","stringValue","stats","spanCount","scopeSpan","scopeSpans","spans","span","status","code","errorCount","searchTags","searchTagValues","tag","rest"],"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;AAEzD,SAOEC,eAAe,QAIV,cAAc;AAsBrB,OAAO,MAAMC,iBAAiB,OAAU,GAAGC;IACzC,MAAMC,WAAW,MAAMJ,SAASG;IAChC,MAAME,WAAW,MAAMD,SAASE,IAAI;IACpC,OAAOD;AACT,EAAE;AAEF,SAASE,aAA2BC,MAAc,EAAEC,MAAgB,EAAEC,YAA0B;IAC9F,MAAM,EAAEC,aAAa,EAAEC,UAAU,CAAC,CAAC,EAAE,GAAGF;IAExC,IAAIG,MAAM,CAAC,EAAEF,cAAc,EAAEH,OAAO,CAAC;IACrC,IAAIC,QAAQ;QACVI,OAAO,MAAM,IAAIC,gBAAgBL;IACnC;IACA,MA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":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,EAAE,WAAW,EAAkE,MAAM,uBAAuB,CAAC;AACpH,OAAO,EAAE,mBAAmB,EAAE,MAAM,0BAA0B,CAAC;AA8B/D,eAAO,MAAM,eAAe,EAAE,gBAAgB,CAAC,mBAAmB,EAAE,WAAW,CAK9E,CAAC"}
@@ -10,24 +10,42 @@
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, searchTraceQueryFallback } from '../model/tempo-client';
13
+ import { query, search, searchTagValues, searchTags, searchWithFallback } from '../model/tempo-client';
14
14
  /**
15
15
  * Creates a TempoClient for a specific datasource spec.
16
16
  */ const createClient = (spec, options)=>{
17
- const { directUrl } = spec;
17
+ const { directUrl, proxy } = spec;
18
18
  const { proxyUrl } = options;
19
19
  // Use the direct URL if specified, but fallback to the proxyUrl by default if not specified
20
20
  const datasourceUrl = directUrl !== null && directUrl !== void 0 ? directUrl : proxyUrl;
21
21
  if (datasourceUrl === undefined) {
22
22
  throw new Error('No URL specified for Tempo client. You can use directUrl in the spec to configure it.');
23
23
  }
24
+ const specHeaders = proxy === null || proxy === void 0 ? void 0 : proxy.spec.headers;
24
25
  return {
25
26
  options: {
26
27
  datasourceUrl
27
28
  },
28
- searchTraceQuery: (params, queryOptions)=>searchTraceQuery(params, queryOptions),
29
- searchTraceQueryFallback: (params, queryOptions)=>searchTraceQueryFallback(params, queryOptions),
30
- searchTraceID: (traceID, queryOptions)=>searchTraceID(traceID, queryOptions)
29
+ query: (params, headers)=>query(params, {
30
+ datasourceUrl,
31
+ headers: headers !== null && headers !== void 0 ? headers : specHeaders
32
+ }),
33
+ search: (params, headers)=>search(params, {
34
+ datasourceUrl,
35
+ headers: headers !== null && headers !== void 0 ? headers : specHeaders
36
+ }),
37
+ searchWithFallback: (params, headers)=>searchWithFallback(params, {
38
+ datasourceUrl,
39
+ headers: headers !== null && headers !== void 0 ? headers : specHeaders
40
+ }),
41
+ searchTags: (params, headers)=>searchTags(params, {
42
+ datasourceUrl,
43
+ headers: headers !== null && headers !== void 0 ? headers : specHeaders
44
+ }),
45
+ searchTagValues: (params, headers)=>searchTagValues(params, {
46
+ datasourceUrl,
47
+ headers: headers !== null && headers !== void 0 ? headers : specHeaders
48
+ })
31
49
  };
32
50
  };
33
51
  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, 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"}
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 { TempoClient, query, search, searchTagValues, searchTags, searchWithFallback } 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, proxy } = 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 const specHeaders = proxy?.spec.headers;\n\n return {\n options: {\n datasourceUrl,\n },\n query: (params, headers) => query(params, { datasourceUrl, headers: headers ?? specHeaders }),\n search: (params, headers) => search(params, { datasourceUrl, headers: headers ?? specHeaders }),\n searchWithFallback: (params, headers) =>\n searchWithFallback(params, { datasourceUrl, headers: headers ?? specHeaders }),\n searchTags: (params, headers) => searchTags(params, { datasourceUrl, headers: headers ?? specHeaders }),\n searchTagValues: (params, headers) => searchTagValues(params, { datasourceUrl, headers: headers ?? specHeaders }),\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":["query","search","searchTagValues","searchTags","searchWithFallback","createClient","spec","options","directUrl","proxy","proxyUrl","datasourceUrl","undefined","Error","specHeaders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;IACA,2DAA2D;IAC3D,iDAAiD;IACjDa,sBAAsB,IAAO,CAAA;YAAEV,WAAW;QAAG,CAAA;AAC/C,EAAE"}
@@ -1 +1 @@
1
- {"version":3,"file":"DashboardTempoTraceQueryEditor.d.ts","sourceRoot":"","sources":["../../../src/plugins/tempo-trace-query/DashboardTempoTraceQueryEditor.tsx"],"names":[],"mappings":"AAeA,OAAO,EAAE,kBAAkB,EAAE,MAAM,kBAAkB,CAAC;AACtD,OAAO,EAAE,uBAAuB,EAAyB,MAAM,6BAA6B,CAAC;AAG7F,UAAU,mCAAmC;IAC3C,kBAAkB,EAAE,uBAAuB,CAAC;IAC5C,sBAAsB,EAAE,CAAC,IAAI,EAAE,kBAAkB,KAAK,IAAI,CAAC;IAC3D,aAAa,EAAE,MAAM,GAAG,SAAS,CAAC;IAClC,KAAK,EAAE,MAAM,CAAC;IACd,iBAAiB,EAAE,CAAC,CAAC,EAAE,MAAM,KAAK,IAAI,CAAC;IACvC,eAAe,EAAE,MAAM,IAAI,CAAC;CAC7B;AAED,wBAAgB,8BAA8B,CAAC,KAAK,EAAE,mCAAmC,2CAoBxF"}
1
+ {"version":3,"file":"DashboardTempoTraceQueryEditor.d.ts","sourceRoot":"","sources":["../../../src/plugins/tempo-trace-query/DashboardTempoTraceQueryEditor.tsx"],"names":[],"mappings":"AAeA,OAAO,EAAE,kBAAkB,EAAE,MAAM,kBAAkB,CAAC;AACtD,OAAO,EAAE,uBAAuB,EAAyB,MAAM,6BAA6B,CAAC;AAI7F,UAAU,mCAAmC;IAC3C,kBAAkB,EAAE,uBAAuB,CAAC;IAC5C,sBAAsB,EAAE,CAAC,IAAI,EAAE,kBAAkB,KAAK,IAAI,CAAC;IAC3D,aAAa,EAAE,MAAM,GAAG,SAAS,CAAC;IAClC,KAAK,EAAE,MAAM,CAAC;IACd,iBAAiB,EAAE,CAAC,CAAC,EAAE,MAAM,KAAK,IAAI,CAAC;IACvC,eAAe,EAAE,MAAM,IAAI,CAAC;CAC7B;AAED,wBAAgB,8BAA8B,CAAC,KAAK,EAAE,mCAAmC,2CAqBxF"}
@@ -12,11 +12,12 @@
12
12
  // limitations under the License.
13
13
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
14
14
  import { Stack, FormControl, InputLabel } from '@mui/material';
15
- import { DatasourceSelect } from '@perses-dev/plugin-system';
15
+ import { DatasourceSelect, useDatasourceClient } from '@perses-dev/plugin-system';
16
16
  import { TEMPO_DATASOURCE_KIND } from '../../model/tempo-selectors';
17
- import { TraceQLEditor } from './TraceQLEditor';
17
+ import { TraceQLEditor } from '../../components';
18
18
  export function DashboardTempoTraceQueryEditor(props) {
19
19
  const { selectedDatasource, handleDatasourceChange, query, handleQueryChange, handleQueryBlur } = props;
20
+ const { data: client } = useDatasourceClient(selectedDatasource);
20
21
  return /*#__PURE__*/ _jsxs(Stack, {
21
22
  spacing: 2,
22
23
  children: [
@@ -38,6 +39,9 @@ export function DashboardTempoTraceQueryEditor(props) {
38
39
  ]
39
40
  }),
40
41
  /*#__PURE__*/ _jsx(TraceQLEditor, {
42
+ completeConfig: {
43
+ client
44
+ },
41
45
  value: query,
42
46
  onChange: handleQueryChange,
43
47
  onBlur: handleQueryBlur