/usr/share/grafana/public/app/plugins/datasource/jaeger/dist
/*! For license information please see module.js.LICENSE.txt */ /* [create-plugin] version: 5.22.0 */ define(["module","@grafana/data","react","@emotion/css","@grafana/ui","@grafana/runtime","rxjs","rxjs/operators"],((e,t,n,r,a,o,i,s)=>(()=>{"use strict";var l={7:e=>{e.exports=a},44:(e,t,n)=>{var r=n(959),a=Symbol.for("react.element"),o=Symbol.for("react.fragment"),i=Object.prototype.hasOwnProperty,s=r.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,l={key:!0,ref:!0,__self:!0,__source:!0};function c(e,t,n){var r,o={},c=null,u=null;for(r in void 0!==n&&(c=""+n),void 0!==t.key&&(c=""+t.key),void 0!==t.ref&&(u=t.ref),t)i.call(t,r)&&!l.hasOwnProperty(r)&&(o[r]=t[r]);if(e&&e.defaultProps)for(r in t=e.defaultProps)void 0===o[r]&&(o[r]=t[r]);return{$$typeof:a,type:e,key:c,ref:u,props:o,_owner:s.current}}t.Fragment=o,t.jsx=c,t.jsxs=c},59:e=>{e.exports=s},89:e=>{e.exports=r},269:e=>{e.exports=i},308:t=>{t.exports=e},531:e=>{e.exports=o},728:(e,t,n)=>{e.exports=n(44)},781:e=>{e.exports=t},959:e=>{e.exports=n}},c={};function u(e){var t=c[e];if(void 0!==t)return t.exports;var n=c[e]={exports:{}};return l[e](n,n.exports,u),n.exports}u.n=e=>{var t=e&&e.__esModule?()=>e.default:()=>e;return u.d(t,{a:t}),t},u.d=(e,t)=>{for(var n in t)u.o(t,n)&&!u.o(e,n)&&Object.defineProperty(e,n,{enumerable:!0,get:t[n]})},u.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),u.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},u.p="public/plugins/jaeger/";var d={};u.r(d),u.d(d,{plugin:()=>Ct});var p=u(308),h=u.n(p);u.p=h()&&h().uri?h().uri.slice(0,h().uri.lastIndexOf("/")+1):"public/plugins/jaeger/";var m=u(781),g=u(728),f=u(89),b=u(7);const y=e=>({unorderedList:(0,f.css)({listStyleType:"none"})});var v=u(959);const O={error:7e3,info:3e3,success:3e3,warning:5e3},j=e=>{const t=(n=(0,b.useTheme2)(),(0,f.css)({position:"absolute",zIndex:n.zIndex.portal,top:0,right:10}));var n;const[r,a]=(0,v.useState)(!1),[o,i]=(0,v.useState)();return(0,v.useEffect)((()=>()=>{o&&clearTimeout(o)}),[o]),(0,v.useEffect)((()=>{if(""!==e.text){a(!0);const t=setTimeout((()=>{a(!1)}),O[e.severity]);i(t)}}),[e.severity,e.text]),(0,g.jsx)(g.Fragment,{children:r&&(0,g.jsx)(b.Alert,{className:t,elevated:!0,onRemove:()=>a(!1),severity:e.severity,title:e.text})})};var w=u(531);function D(e,t,n,r,a,o,i){try{var s=e[o](i),l=s.value}catch(e){return void n(e)}s.done?t(l):Promise.resolve(l).then(r,a)}function T(e){return function(){var t=this,n=arguments;return new Promise((function(r,a){var o=e.apply(t,n);function i(e){D(o,r,a,i,s,"next",e)}function s(e){D(o,r,a,i,s,"throw",e)}i(void 0)}))}}function x(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function C(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{},r=Object.keys(n);"function"==typeof Object.getOwnPropertySymbols&&(r=r.concat(Object.getOwnPropertySymbols(n).filter((function(e){return Object.getOwnPropertyDescriptor(n,e).enumerable})))),r.forEach((function(t){x(e,t,n[t])}))}return e}function F(e,t){return t=null!=t?t:{},Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(t)):function(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}(Object(t)).forEach((function(n){Object.defineProperty(e,n,Object.getOwnPropertyDescriptor(t,n))})),e}const S="e.g. 1.2s, 100ms, 500us",I={label:"All",value:void 0};function P({datasource:e,query:t,onChange:n}){const[r,a]=(0,v.useState)(""),[o,i]=(0,v.useState)(),[s,l]=(0,v.useState)(),[c,u]=(0,v.useState)({services:!1,operations:!1}),d=(0,v.useCallback)(((t,n,r="")=>T((function*(){u((e=>F(C({},e),{[n]:!0})));try{const o=yield e.metadataRequest(t);if(!o)return[{label:`No ${n} found`,value:`No ${n} found`}];const i=o.sort().map((e=>({label:e,value:e}))).filter((e=>!!e.value&&(0,b.fuzzyMatch)(e.value,r).found));return a(""),i}catch(e){return e instanceof Error&&a(`Error: ${e.message}`),[]}finally{u((e=>F(C({},e),{[n]:!1})))}}))()),[e]);return(0,v.useEffect)((()=>{T((function*(){const e=yield d("services","services");t.service&&(0,w.getTemplateSrv)().containsTemplate(t.service)&&e.push((0,m.toOption)(t.service)),i(e)}))()}),[e,d,t.service]),(0,v.useEffect)((()=>{t.service&&T((function*(){const e=yield d(`services/${encodeURIComponent((0,w.getTemplateSrv)().replace(t.service))}/operations`,"operations");t.operation&&(0,w.getTemplateSrv)().containsTemplate(t.operation)&&e.push((0,m.toOption)(t.operation)),l([I,...e])}))()}),[e,t.service,d,t.operation]),(0,g.jsxs)(g.Fragment,{children:[(0,g.jsxs)("div",{className:(0,f.css)({maxWidth:"500px"}),children:[(0,g.jsx)(b.InlineFieldRow,{children:(0,g.jsx)(b.InlineField,{label:"Service Name",labelWidth:14,grow:!0,children:(0,g.jsx)(b.Select,{inputId:"service",options:o,onOpenMenu:()=>d("services","services"),isLoading:c.services,value:(null==o?void 0:o.find((e=>(null==e?void 0:e.value)===t.service)))||void 0,placeholder:"Select a service",onChange:e=>n(F(C({},t),{service:null==e?void 0:e.value,operation:t.service!==(null==e?void 0:e.value)?void 0:t.operation})),menuPlacement:"bottom",isClearable:!0,"aria-label":"select-service-name",allowCustomValue:!0})})}),(0,g.jsx)(b.InlineFieldRow,{children:(0,g.jsx)(b.InlineField,{label:"Operation Name",labelWidth:14,grow:!0,disabled:!t.service,children:(0,g.jsx)(b.Select,{inputId:"operation",options:s,onOpenMenu:()=>d(`services/${encodeURIComponent((0,w.getTemplateSrv)().replace(t.service))}/operations`,"operations"),isLoading:c.operations,value:(null==s?void 0:s.find((e=>e.value===t.operation)))||null,placeholder:"Select an operation",onChange:e=>n(F(C({},t),{operation:(null==e?void 0:e.value)||void 0})),menuPlacement:"bottom",isClearable:!0,"aria-label":"select-operation-name",allowCustomValue:!0})})}),(0,g.jsx)(b.InlineFieldRow,{children:(0,g.jsx)(b.InlineField,{label:"Tags",labelWidth:14,grow:!0,tooltip:"Values should be in logfmt.",children:(0,g.jsx)(b.Input,{id:"tags",value:t.tags,placeholder:"http.status_code=200 error=true",onChange:e=>n(F(C({},t),{tags:e.currentTarget.value}))})})}),(0,g.jsx)(b.InlineFieldRow,{children:(0,g.jsx)(b.InlineField,{label:"Min Duration",labelWidth:14,grow:!0,children:(0,g.jsx)(b.Input,{id:"minDuration",name:"minDuration",value:t.minDuration||"",placeholder:S,onChange:e=>n(F(C({},t),{minDuration:e.currentTarget.value}))})})}),(0,g.jsx)(b.InlineFieldRow,{children:(0,g.jsx)(b.InlineField,{label:"Max Duration",labelWidth:14,grow:!0,children:(0,g.jsx)(b.Input,{id:"maxDuration",name:"maxDuration",value:t.maxDuration||"",placeholder:S,onChange:e=>n(F(C({},t),{maxDuration:e.currentTarget.value}))})})}),(0,g.jsx)(b.InlineFieldRow,{children:(0,g.jsx)(b.InlineField,{label:"Limit",labelWidth:14,grow:!0,tooltip:"Maximum number of returned results",children:(0,g.jsx)(b.Input,{id:"limit",name:"limit",value:t.limit||"",type:"number",onChange:e=>n(F(C({},t),{limit:e.currentTarget.value?parseInt(e.currentTarget.value,10):void 0}))})})})]}),r&&(0,g.jsx)(j,{text:r,severity:"error"})]})}function N(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function E(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{},r=Object.keys(n);"function"==typeof Object.getOwnPropertySymbols&&(r=r.concat(Object.getOwnPropertySymbols(n).filter((function(e){return Object.getOwnPropertyDescriptor(n,e).enumerable})))),r.forEach((function(t){N(e,t,n[t])}))}return e}function k(e,t){return t=null!=t?t:{},Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(t)):function(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}(Object(t)).forEach((function(n){Object.defineProperty(e,n,Object.getOwnPropertyDescriptor(t,n))})),e}const A=()=>({container:(0,f.css)({width:"100%"})}),R=({children:e,title:t,description:n,isCollapsible:r=!1,isInitiallyOpen:a=!0,kind:o="section",className:i})=>{const{colors:s,typography:l,spacing:c}=(0,b.useTheme2)(),[u,d]=(0,v.useState)(!r||a),p=u?"angle-up":"angle-down",h="sub-section"===o,m=`${u?"Collapse":"Expand"} section ${t}`,g={header:(0,f.css)({display:"flex",justifyContent:"space-between",alignItems:"center"}),title:(0,f.css)({margin:0}),subtitle:(0,f.css)({margin:0,fontWeight:l.fontWeightRegular}),descriptionText:(0,f.css)({marginTop:c(h?.25:.5),marginBottom:0,...l.bodySmall,color:s.text.secondary}),content:(0,f.css)({marginTop:c(2)})};return v.createElement("div",{className:i},v.createElement("div",{className:g.header},"section"===o?v.createElement("h3",{className:g.title},t):v.createElement("h6",{className:g.subtitle},t),r&&v.createElement(b.IconButton,{name:p,onClick:()=>d(!u),type:"button",size:"xl","aria-label":m})),n&&v.createElement("p",{className:g.descriptionText},n),u&&v.createElement("div",{className:g.content},e))},M=({children:e,...t})=>v.createElement(R,{...t,kind:"section"},e);function q(e){const{description:t,suffix:n,feature:r}=e,a=`Learn more about ${r}`,o=(0,b.useStyles2)(J);return v.createElement("span",{className:o.container},t,v.createElement("a",{"aria-label":a,href:`https://grafana.com/docs/grafana/next/datasources/${n}`,rel:"noreferrer",target:"_blank"},a))}const J=e=>({container:(0,f.css)({color:e.colors.text.secondary,a:(0,f.css)({color:e.colors.text.link,textDecoration:"underline",marginLeft:"5px","&:hover":{textDecoration:"none"}})})});function B(e,t,n){void 0===t&&(t=0),void 0===n&&(n=[]);var r=function(e,t){void 0===t&&(t=0);var n=(0,v.useRef)(!1),r=(0,v.useRef)(),a=(0,v.useRef)(e),o=(0,v.useCallback)((function(){return n.current}),[]),i=(0,v.useCallback)((function(){n.current=!1,r.current&&clearTimeout(r.current),r.current=setTimeout((function(){n.current=!0,a.current()}),t)}),[t]),s=(0,v.useCallback)((function(){n.current=null,r.current&&clearTimeout(r.current)}),[]);return(0,v.useEffect)((function(){a.current=e}),[e]),(0,v.useEffect)((function(){return i(),s}),[t]),[o,s,i]}(e,t),a=r[0],o=r[1],i=r[2];return(0,v.useEffect)(i,n),[a,o]}const L=/^(-?\d+(?:\.\d+)?)(ms|[Mwdhmsy])$/,W=(e,t=L)=>!(e.match(t)||!e);function G(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function $(e,t){return t=null!=t?t:{},Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(t)):function(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}(Object(t)).forEach((function(n){Object.defineProperty(e,n,Object.getOwnPropertyDescriptor(t,n))})),e}const _=e=>{const[t,n]=(0,v.useState)((()=>!!e.value&&W(e.value,e.validationRegex)));var r;B((()=>{n(W(e.value,e.validationRegex))}),500,[e.value]);const a={labelWidth:26,disabled:null!==(r=e.disabled)&&void 0!==r&&r,invalid:t,error:e.isInvalidError};return e.label&&(a.label=e.label,a.tooltip=e.tooltip||""),(0,g.jsx)(b.InlineField,$(function(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{},r=Object.keys(n);"function"==typeof Object.getOwnPropertySymbols&&(r=r.concat(Object.getOwnPropertySymbols(n).filter((function(e){return Object.getOwnPropertyDescriptor(n,e).enumerable})))),r.forEach((function(t){G(e,t,n[t])}))}return e}({},a),{children:(0,g.jsx)(b.Input,{type:"text",placeholder:e.placeholder||"0",width:e.width||40,onChange:t=>{e.onChange(t.currentTarget.value)},value:e.value,"aria-label":e.ariaLabel||"interval input"})}))};function U(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function V(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{},r=Object.keys(n);"function"==typeof Object.getOwnPropertySymbols&&(r=r.concat(Object.getOwnPropertySymbols(n).filter((function(e){return Object.getOwnPropertyDescriptor(n,e).enumerable})))),r.forEach((function(t){U(e,t,n[t])}))}return e}function H(e,t){return t=null!=t?t:{},Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(t)):function(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}(Object(t)).forEach((function(n){Object.defineProperty(e,n,Object.getOwnPropertyDescriptor(t,n))})),e}const Q=({values:e,onChange:t,id:n})=>{const r=(0,b.useStyles2)(K);return(0,g.jsx)("div",{className:r.wrapper,children:e.length?e.map(((a,o)=>(0,g.jsxs)("div",{className:r.pair,children:[(0,g.jsx)(b.SegmentInput,{id:`${n}-key-${o}`,placeholder:"Tag name",value:a.key,onChange:n=>{t(e.map(((e,t)=>t===o?H(V({},e),{key:String(n)}):e)))}}),(0,g.jsx)(b.InlineLabel,{"aria-label":"equals",className:r.operator,children:"as"}),(0,g.jsx)(b.SegmentInput,{id:`${n}-value-${o}`,placeholder:"New name (optional)",value:a.value||"",onChange:n=>{t(e.map(((e,t)=>t===o?H(V({},e),{value:String(n)}):e)))}}),(0,g.jsx)(b.ToolbarButton,{onClick:()=>t([...e.slice(0,o),...e.slice(o+1)]),className:(0,f.cx)(r.removeTag,"query-part"),"aria-label":"Remove tag",type:"button",icon:"times"}),o===e.length-1?(0,g.jsx)(b.ToolbarButton,{onClick:()=>t([...e,{key:"",value:""}]),className:"query-part","aria-label":"Add tag",type:"button",icon:"plus"}):null]},o))):(0,g.jsx)(b.ToolbarButton,{icon:"plus",onClick:()=>t([...e,{key:"",value:""}]),className:"query-part","aria-label":"Add tag",type:"button"})})},K=e=>({wrapper:(0,f.css)({display:"flex",flexDirection:"column",gap:`${e.spacing(.5)} 0`}),pair:(0,f.css)({display:"flex",justifyContent:"start",alignItems:"center"}),operator:(0,f.css)({color:e.v1.palette.orange,width:"auto"}),removeTag:(0,f.css)({marginRight:e.spacing(.5)})});function z(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function Y(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{},r=Object.keys(n);"function"==typeof Object.getOwnPropertySymbols&&(r=r.concat(Object.getOwnPropertySymbols(n).filter((function(e){return Object.getOwnPropertyDescriptor(n,e).enumerable})))),r.forEach((function(t){z(e,t,n[t])}))}return e}function X(e,t){return t=null!=t?t:{},Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(t)):function(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}(Object(t)).forEach((function(n){Object.defineProperty(e,n,Object.getOwnPropertyDescriptor(t,n))})),e}function Z({options:e,onOptionsChange:t}){const n=["loki","elasticsearch","grafana-splunk-datasource","grafana-opensearch-datasource","grafana-falconlogscale-datasource","googlecloud-logging-datasource","victoriametrics-logs-datasource"],r=(0,v.useMemo)((()=>function(e){var t;if(null==e?void 0:e.tracesToLogsV2)return e.tracesToLogsV2;if(!(null==e?void 0:e.tracesToLogs))return;const n={customQuery:!1};return n.datasourceUid=e.tracesToLogs.datasourceUid,n.tags=e.tracesToLogs.mapTagNamesEnabled?e.tracesToLogs.mappedTags:null===(t=e.tracesToLogs.tags)||void 0===t?void 0:t.map((e=>({key:e}))),n.filterByTraceID=e.tracesToLogs.filterByTraceID,n.filterBySpanID=e.tracesToLogs.filterBySpanID,n.spanStartTimeShift=e.tracesToLogs.spanStartTimeShift,n.spanEndTimeShift=e.tracesToLogs.spanEndTimeShift,n}(e.jsonData)||{customQuery:!1}),[e.jsonData]),{query:a="",tags:o,customQuery:i}=r,s=(0,v.useCallback)((n=>{t(X(Y({},e),{jsonData:X(Y({},e.jsonData),{tracesToLogsV2:Y({},r,n),tracesToLogs:void 0})}))}),[t,e,r]);return(0,g.jsxs)("div",{className:(0,f.css)({width:"100%"}),children:[(0,g.jsx)(b.InlineFieldRow,{children:(0,g.jsx)(b.InlineField,{tooltip:"The logs data source the trace is going to navigate to",label:"Data source",labelWidth:26,children:(0,g.jsx)(w.DataSourcePicker,{inputId:"trace-to-logs-data-source-picker",filter:e=>n.includes(e.type),current:r.datasourceUid,noDefault:!0,width:40,onChange:e=>s({datasourceUid:e.uid}),onClear:()=>s({datasourceUid:void 0})})})}),(0,g.jsx)(b.InlineFieldRow,{children:(0,g.jsx)(_,{label:te("start"),tooltip:ne("start","0"),value:r.spanStartTimeShift||"",onChange:e=>{s({spanStartTimeShift:e})},isInvalidError:re})}),(0,g.jsx)(b.InlineFieldRow,{children:(0,g.jsx)(_,{label:te("end"),tooltip:ne("end","0"),value:r.spanEndTimeShift||"",onChange:e=>{s({spanEndTimeShift:e})},isInvalidError:re})}),(0,g.jsx)(b.InlineFieldRow,{children:(0,g.jsx)(b.InlineField,{tooltip:"Tags that will be used in the query. Default tags: 'cluster', 'hostname', 'namespace', 'pod', 'service.name', 'service.namespace'",label:"Tags",labelWidth:26,children:(0,g.jsx)(Q,{values:null!=o?o:[],onChange:e=>s({tags:e})})})}),(0,g.jsx)(ee,{disabled:i,type:"trace",id:"filterByTraceID",value:Boolean(r.filterByTraceID),onChange:e=>s({filterByTraceID:e})}),(0,g.jsx)(ee,{disabled:i,type:"span",id:"filterBySpanID",value:Boolean(r.filterBySpanID),onChange:e=>s({filterBySpanID:e})}),(0,g.jsx)(b.InlineFieldRow,{children:(0,g.jsx)(b.InlineField,{tooltip:"Use a custom query with the possibility to interpolate variables from the trace or span",label:"Use custom query",labelWidth:26,children:(0,g.jsx)(b.InlineSwitch,{id:"customQuerySwitch",value:i,onChange:e=>s({customQuery:e.currentTarget.checked})})})}),i&&(0,g.jsx)(b.InlineField,{label:"Query",labelWidth:26,tooltip:"The query that will run when navigating from a trace to logs data source. Interpolate tags using the `$__tags` keyword",grow:!0,children:(0,g.jsx)(b.Input,{label:"Query",type:"text",allowFullScreen:!0,value:a,onChange:e=>s({query:e.currentTarget.value})})})]})}function ee(e){return(0,g.jsx)(b.InlineFieldRow,{children:(0,g.jsx)(b.InlineField,{disabled:e.disabled,label:`Filter by ${e.type} ID`,labelWidth:26,grow:!0,tooltip:`Filters logs by ${e.type} ID, where the ${e.type} ID should be part of the log line`,children:(0,g.jsx)(b.InlineSwitch,{id:e.id,value:e.value,onChange:t=>e.onChange(t.currentTarget.checked)})})})}const te=e=>`Span ${e} time shift`,ne=(e,t)=>`Shifts the ${e} time of the span. Default: ${t} (Time units can be used here, for example: 5s, -1m, 3h)`,re="Invalid time shift. See tooltip for examples.",ae=({options:e,onOptionsChange:t})=>{let n=e.type;return n+="tempo"===e.type?"/configure-tempo-data-source/#trace-to-logs":"/#trace-to-logs",(0,g.jsx)(M,{title:"Trace to logs",description:(0,g.jsx)(q,{description:"Navigate from a trace span to the selected data source's logs.",suffix:n,feature:"trace to logs"}),isCollapsible:!0,isInitiallyOpen:!0,children:(0,g.jsx)(Z,{options:e,onOptionsChange:t})})};function oe(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function ie(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{},r=Object.keys(n);"function"==typeof Object.getOwnPropertySymbols&&(r=r.concat(Object.getOwnPropertySymbols(n).filter((function(e){return Object.getOwnPropertyDescriptor(n,e).enumerable})))),r.forEach((function(t){oe(e,t,n[t])}))}return e}function se(e,t){return t=null!=t?t:{},Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(t)):function(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}(Object(t)).forEach((function(n){Object.defineProperty(e,n,Object.getOwnPropertyDescriptor(t,n))})),e}function le({options:e,onOptionsChange:t}){var n,r,a,o,i,s;const l=(0,b.useStyles2)(ue);var c;return(0,g.jsxs)("div",{className:(0,f.css)({width:"100%"}),children:[(0,g.jsx)(b.InlineFieldRow,{className:l.row,children:(0,g.jsx)(b.InlineField,{tooltip:"The Prometheus data source the trace is going to navigate to",label:"Data source",labelWidth:26,children:(0,g.jsx)(w.DataSourcePicker,{inputId:"trace-to-metrics-data-source-picker",pluginId:"prometheus",current:null===(n=e.jsonData.tracesToMetrics)||void 0===n?void 0:n.datasourceUid,noDefault:!0,width:40,onChange:n=>(0,m.updateDatasourcePluginJsonDataOption)({onOptionsChange:t,options:e},"tracesToMetrics",se(ie({},e.jsonData.tracesToMetrics),{datasourceUid:n.uid})),onClear:()=>(0,m.updateDatasourcePluginJsonDataOption)({onOptionsChange:t,options:e},"tracesToMetrics",se(ie({},e.jsonData.tracesToMetrics),{datasourceUid:void 0}))})})}),(0,g.jsx)(b.InlineFieldRow,{children:(0,g.jsx)(_,{label:te("start"),tooltip:ne("start","-2m"),value:(null===(r=e.jsonData.tracesToMetrics)||void 0===r?void 0:r.spanStartTimeShift)||"",onChange:n=>{(0,m.updateDatasourcePluginJsonDataOption)({onOptionsChange:t,options:e},"tracesToMetrics",se(ie({},e.jsonData.tracesToMetrics),{spanStartTimeShift:n}))},placeholder:"-2m",isInvalidError:re})}),(0,g.jsx)(b.InlineFieldRow,{children:(0,g.jsx)(_,{label:te("end"),tooltip:ne("end","2m"),value:(null===(a=e.jsonData.tracesToMetrics)||void 0===a?void 0:a.spanEndTimeShift)||"",onChange:n=>{(0,m.updateDatasourcePluginJsonDataOption)({onOptionsChange:t,options:e},"tracesToMetrics",se(ie({},e.jsonData.tracesToMetrics),{spanEndTimeShift:n}))},placeholder:"2m",isInvalidError:re})}),(0,g.jsx)(b.InlineFieldRow,{children:(0,g.jsx)(b.InlineField,{tooltip:"Tags that will be used in the metrics query",label:"Tags",labelWidth:26,children:(0,g.jsx)(Q,{values:null!==(c=null===(o=e.jsonData.tracesToMetrics)||void 0===o?void 0:o.tags)&&void 0!==c?c:[],onChange:n=>(0,m.updateDatasourcePluginJsonDataOption)({onOptionsChange:t,options:e},"tracesToMetrics",se(ie({},e.jsonData.tracesToMetrics),{tags:n}))})})}),null===(s=e.jsonData.tracesToMetrics)||void 0===s||null===(i=s.queries)||void 0===i?void 0:i.map(((n,r)=>(0,g.jsxs)("div",{className:l.queryRow,children:[(0,g.jsx)(b.InlineField,{label:"Link Label",labelWidth:26,tooltip:"Descriptive label for the linked query",children:(0,g.jsx)(b.Input,{label:"Link Label",type:"text",allowFullScreen:!0,value:n.name,width:40,onChange:n=>{var a,o;const i=(null!==(o=null===(a=e.jsonData.tracesToMetrics)||void 0===a?void 0:a.queries)&&void 0!==o?o:[]).map(((e,t)=>t===r?se(ie({},e),{name:n.currentTarget.value}):e));(0,m.updateDatasourcePluginJsonDataOption)({onOptionsChange:t,options:e},"tracesToMetrics",se(ie({},e.jsonData.tracesToMetrics),{queries:i}))}})}),(0,g.jsx)(b.InlineField,{label:"Query",labelWidth:10,tooltip:"The Prometheus query that will run when navigating from a trace to metrics. Interpolate tags using the `$__tags` keyword",grow:!0,children:(0,g.jsx)(b.Input,{label:"Query",type:"text",allowFullScreen:!0,value:n.query,onChange:n=>{var a,o;const i=(null!==(o=null===(a=e.jsonData.tracesToMetrics)||void 0===a?void 0:a.queries)&&void 0!==o?o:[]).map(((e,t)=>t===r?se(ie({},e),{query:n.currentTarget.value}):e));(0,m.updateDatasourcePluginJsonDataOption)({onOptionsChange:t,options:e},"tracesToMetrics",se(ie({},e.jsonData.tracesToMetrics),{queries:i}))}})}),(0,g.jsx)(b.Button,{variant:"destructive","aria-label":"Remove query",icon:"times",type:"button",onClick:()=>{var n;const a=null===(n=e.jsonData.tracesToMetrics)||void 0===n?void 0:n.queries.filter(((e,t)=>t!==r));(0,m.updateDatasourcePluginJsonDataOption)({onOptionsChange:t,options:e},"tracesToMetrics",se(ie({},e.jsonData.tracesToMetrics),{queries:a}))}})]},r))),(0,g.jsx)(b.Button,{variant:"secondary",title:"Add query",icon:"plus",type:"button",onClick:()=>{var n,r;(0,m.updateDatasourcePluginJsonDataOption)({onOptionsChange:t,options:e},"tracesToMetrics",se(ie({},e.jsonData.tracesToMetrics),{queries:[...null!==(r=null===(n=e.jsonData.tracesToMetrics)||void 0===n?void 0:n.queries)&&void 0!==r?r:[],{query:""}]}))},children:"Add query"})]})}const ce=({options:e,onOptionsChange:t})=>{let n=e.type;return n+="tempo"===e.type?"/configure-tempo-data-source/#trace-to-metrics":"/#trace-to-metrics",(0,g.jsx)(M,{title:"Trace to metrics",description:(0,g.jsx)(q,{description:"Navigate from a trace span to the selected data source's metrics.",suffix:n,feature:"trace to metrics"}),isCollapsible:!0,isInitiallyOpen:!0,children:(0,g.jsx)(le,{options:e,onOptionsChange:t})})},ue=e=>({infoText:{paddingBottom:e.spacing(2),color:e.colors.text.secondary},row:(0,f.css)({label:"row",alignItems:"baseline"}),queryRow:(0,f.css)({label:"queryRow",display:"flex",flexFlow:"wrap"})}),de=({children:e,...t})=>v.createElement(R,{...t,kind:"sub-section"},e);function pe(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function he(e,t){return t=null!=t?t:{},Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(t)):function(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}(Object(t)).forEach((function(n){Object.defineProperty(e,n,Object.getOwnPropertyDescriptor(t,n))})),e}function me({options:e,onOptionsChange:t}){var n;const r=(0,b.useStyles2)(fe);return(0,g.jsx)("div",{className:r.container,children:(0,g.jsx)(b.InlineFieldRow,{className:r.row,children:(0,g.jsx)(b.InlineField,{tooltip:"Displays the node graph above the trace view. Default: disabled",label:"Enable node graph",labelWidth:26,children:(0,g.jsx)(b.InlineSwitch,{id:"enableNodeGraph",value:null===(n=e.jsonData.nodeGraph)||void 0===n?void 0:n.enabled,onChange:n=>(0,m.updateDatasourcePluginJsonDataOption)({onOptionsChange:t,options:e},"nodeGraph",he(function(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{},r=Object.keys(n);"function"==typeof Object.getOwnPropertySymbols&&(r=r.concat(Object.getOwnPropertySymbols(n).filter((function(e){return Object.getOwnPropertyDescriptor(n,e).enumerable})))),r.forEach((function(t){pe(e,t,n[t])}))}return e}({},e.jsonData.nodeGraph),{enabled:n.currentTarget.checked}))})})})})}const ge=({options:e,onOptionsChange:t})=>{let n=e.type;return n+="tempo"===e.type?"/configure-tempo-data-source/#node-graph":"/#node-graph",(0,g.jsx)(de,{title:"Node graph",description:(0,g.jsx)(q,{description:"Show or hide the node graph visualization.",suffix:n,feature:"the node graph"}),children:(0,g.jsx)(me,{options:e,onOptionsChange:t})})},fe=e=>({infoText:(0,f.css)({label:"infoText",paddingBottom:e.spacing(2),color:e.colors.text.secondary}),container:(0,f.css)({label:"container",width:"100%"}),row:(0,f.css)({label:"row",alignItems:"baseline"})});function be(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function ye(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{},r=Object.keys(n);"function"==typeof Object.getOwnPropertySymbols&&(r=r.concat(Object.getOwnPropertySymbols(n).filter((function(e){return Object.getOwnPropertyDescriptor(n,e).enumerable})))),r.forEach((function(t){be(e,t,n[t])}))}return e}function ve(e,t){return t=null!=t?t:{},Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(t)):function(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}(Object(t)).forEach((function(n){Object.defineProperty(e,n,Object.getOwnPropertyDescriptor(t,n))})),e}const Oe="None",je="Duration",we="Tag";function De({options:e,onOptionsChange:t}){var n,r,a;const o=(0,b.useStyles2)(xe),i=[Oe,je,we].map(m.toOption);return(0,g.jsxs)("div",{className:(0,f.css)({width:"100%"}),children:[(0,g.jsx)(b.InlineFieldRow,{className:o.row,children:(0,g.jsx)(b.InlineField,{label:"Label",labelWidth:26,tooltip:"Default: duration",grow:!0,children:(0,g.jsx)(b.Select,{inputId:"label",options:i,value:(null===(n=e.jsonData.spanBar)||void 0===n?void 0:n.type)||"",onChange:n=>{var r;(0,m.updateDatasourcePluginJsonDataOption)({onOptionsChange:t,options:e},"spanBar",ve(ye({},e.jsonData.spanBar),{type:null!==(r=null==n?void 0:n.value)&&void 0!==r?r:""}))},placeholder:"Duration",isClearable:!0,"aria-label":"select-label-name",width:40})})}),(null===(r=e.jsonData.spanBar)||void 0===r?void 0:r.type)===we&&(0,g.jsx)(b.InlineFieldRow,{className:o.row,children:(0,g.jsx)(b.InlineField,{label:"Tag key",labelWidth:26,tooltip:"Tag key which will be used to get the tag value. A span's attributes and resources will be searched for the tag key",children:(0,g.jsx)(b.Input,{type:"text",placeholder:"Enter tag key",onChange:n=>(0,m.updateDatasourcePluginJsonDataOption)({onOptionsChange:t,options:e},"spanBar",ve(ye({},e.jsonData.spanBar),{tag:n.currentTarget.value})),value:(null===(a=e.jsonData.spanBar)||void 0===a?void 0:a.tag)||"",width:40})})})]})}const Te=({options:e,onOptionsChange:t})=>{let n=e.type;return n+="tempo"===e.type?"/configure-tempo-data-source/#span-bar":"/#span-bar",(0,g.jsx)(de,{title:"Span bar",description:(0,g.jsx)(q,{description:"Add additional info next to the service and operation on a span bar row in the trace view.",suffix:n,feature:"the span bar"}),children:(0,g.jsx)(De,{options:e,onOptionsChange:t})})},xe=e=>({infoText:(0,f.css)({label:"infoText",paddingBottom:e.spacing(2),color:e.colors.text.secondary}),row:(0,f.css)({label:"row",alignItems:"baseline"})}),Ce=({dataSourceName:e,docsLink:t,hasRequiredFields:n=!0,className:r})=>{const a=(0,b.useTheme2)(),o={container:(0,f.css)({p:{margin:0},"p + p":{marginTop:a.spacing(2)}}),text:(0,f.css)({...a.typography.body,color:a.colors.text.secondary,a:(0,f.css)({color:a.colors.text.link,textDecoration:"underline","&:hover":{textDecoration:"none"}})})};return v.createElement("div",{className:(0,f.cx)(o.container,r)},v.createElement("p",{className:o.text},"Before you can use the ",e," data source, you must configure it below or in the config file. For detailed instructions,"," ",v.createElement("a",{href:t,target:"_blank",rel:"noreferrer"},"view the documentation"),"."),n&&v.createElement("p",{className:o.text},v.createElement("i",null,"Fields marked with * are required")))},Fe=({config:e,onChange:t,description:n,urlPlaceholder:r,urlTooltip:a,urlLabel:o,className:i})=>{const s=void 0!==e.url&&/^(ftp|http|https):\/\/(\w+:{0,1}\w*@)?(\S+)(:[0-9]+)?(\/|\/([\w#!:.?+=&%@!\-\/]))?$/.test(e.url),l={container:(0,f.css)({maxWidth:578})};return v.createElement(v.Fragment,null,v.createElement(M,{title:"Connection",description:n,className:(0,f.cx)(l.container,i)},v.createElement(b.InlineField,{htmlFor:"connection-url",label:o||"URL",labelWidth:24,tooltip:a||v.createElement(v.Fragment,null,"Specify a complete HTTP URL",v.createElement("br",null),"(for example https://example.com:8080)"),grow:!0,disabled:e.readOnly,required:!0,invalid:!s&&!e.readOnly,error:s?"":"Please enter a valid URL",interactive:!0},v.createElement(b.Input,{id:"connection-url","aria-label":"Data source connection URL",onChange:n=>t({...e,url:n.currentTarget.value}),value:e.url||"",placeholder:r||"URL"}))))},Se=()=>({inlineFieldNoMarginRight:(0,f.css)({marginRight:0}),inlineFieldWithSecret:(0,f.css)({'[class$="layoutChildrenWrapper"]:first-child':{flexGrow:1}})}),Ie=({user:e,passwordConfigured:t,userLabel:n="User",userTooltip:r="The username of the data source account",userPlaceholder:a="User",passwordLabel:o="Password",passwordTooltip:i="The password of the data source account",passwordPlaceholder:s="Password",onUserChange:l,onPasswordChange:c,onPasswordReset:u,readOnly:d})=>{const p=Se(),h={lastInlineField:(0,f.css)({marginBottom:0})};return v.createElement(v.Fragment,null,v.createElement(b.InlineField,{className:p.inlineFieldNoMarginRight,label:n,labelWidth:24,tooltip:r,required:!0,htmlFor:"basic-auth-user-input",interactive:!0,grow:!0,disabled:d},v.createElement(b.Input,{id:"basic-auth-user-input",placeholder:a,value:e,onChange:e=>l(e.currentTarget.value),required:!0})),v.createElement(b.InlineField,{className:(0,f.cx)(p.inlineFieldNoMarginRight,p.inlineFieldWithSecret,h.lastInlineField),label:o,labelWidth:24,tooltip:i,required:!0,htmlFor:"basic-auth-password-input",interactive:!0,grow:!0,disabled:d},v.createElement(b.SecretInput,{id:"basic-auth-password-input",isConfigured:t,onReset:d?()=>{}:u,placeholder:s,onChange:e=>c(e.currentTarget.value),required:!0})))};var Pe=(e=>(e.NoAuth="NoAuth",e.BasicAuth="BasicAuth",e.OAuthForward="OAuthForward",e.CrossSiteCredentials="CrossSiteCredentials",e))(Pe||{});const Ne={[Pe.BasicAuth]:{label:"Basic authentication",value:Pe.BasicAuth,description:"Authenticate with your data source username and password"},[Pe.CrossSiteCredentials]:{label:"Enable cross-site access control requests",value:Pe.CrossSiteCredentials,description:"Allow cross-site Access-Control requests with your existing credentials and cookies. This enables the server to authenticate the user and perform authorized requests on their behalf on other domains."},[Pe.OAuthForward]:{label:"Forward OAuth Identity",value:Pe.OAuthForward,description:"Forward the OAuth access token (and if available: the OIDC ID token) of the user querying to the data source"},[Pe.NoAuth]:{label:"No Authentication",value:Pe.NoAuth,description:"Data source is available without authentication"}},Ee=({selectedMethod:e,mostCommonMethod:t,visibleMethods:n,defaultOptionsOverrides:r,customMethods:a,onAuthMethodSelect:o,basicAuth:i,readOnly:s})=>{var l,c,u,d;const[p,h]=(0,v.useState)(!1),{colors:m,spacing:g}=(0,b.useTheme2)(),y=(0,v.useMemo)((()=>{var e;return null!=n?n:[Pe.BasicAuth,Pe.OAuthForward,Pe.NoAuth,...null!=(e=null==a?void 0:a.map((e=>e.id)))?e:[]]}),[a,n]),O=y.length>1,j=(0,v.useMemo)((()=>{var e;const n=null!=(e=null==a?void 0:a.reduce(((e,t)=>(e[t.id]={label:t.label,value:t.id,description:t.description},e)),{}))?e:{},o={};let i;for(i in Ne)o[i]={...Ne[i],...null==r?void 0:r[i]};const s={...n,...o};return y.filter((e=>Boolean(s[e]))).map((e=>{const n=s[e];return e===t&&O?{...n,label:`${n.label} (most common)`}:n}))}),[y,a,r,t,O]);let w=e;O?e===Pe.NoAuth&&t&&!p&&(w=t):w=y[0];let D=null;w===Pe.BasicAuth&&i?D=v.createElement(Ie,{...i,readOnly:s}):w.startsWith("custom-")&&(D=null!=(c=null==(l=null==a?void 0:a.find((e=>e.id===w)))?void 0:l.component)?c:null);const T=O?"Authentication methods":null!=(u=j[0].label)?u:"",x=O?"Choose an authentication method to access the data source":null!=(d=j[0].description)?d:"",C={authMethods:(0,f.css)({marginTop:g(2.5),...O&&{padding:g(2),border:`1px solid ${m.border.weak}`}}),selectedMethodFields:(0,f.css)({marginTop:g(1.5)})};return v.createElement(de,{title:T,description:x},v.createElement("div",{className:C.authMethods},O&&v.createElement(b.Field,{label:"Authentication method"},v.createElement(b.Select,{inputId:"auth-method-select",options:j,value:w,onChange:e=>{h(!0),o(e.value)},disabled:s})),D&&v.createElement("div",{className:C.selectedMethodFields},D)))},ke=({children:e,enabled:t,label:n,tooltipText:r,onToggle:a,readOnly:o})=>{const{colors:i,spacing:s}=(0,b.useTheme2)(),l={container:(0,f.css)({marginTop:3}),checkboxContainer:(0,f.css)({display:"flex",alignItems:"center"}),infoIcon:(0,f.css)({marginTop:-2,marginLeft:5,color:i.text.secondary}),content:(0,f.css)({margin:s(1,0,2,3)})};return v.createElement("div",{className:l.container},v.createElement("div",{className:l.checkboxContainer},v.createElement(b.Checkbox,{value:t,label:n,onChange:()=>a(!t),disabled:o}),v.createElement(b.Tooltip,{placement:"top",content:r,interactive:!0},v.createElement(b.Icon,{name:"info-circle",className:l.infoIcon,size:"sm"}))),t&&e&&v.createElement("div",{className:l.content},e))},Ae=({enabled:e,certificateConfigured:t,onToggle:n,onCertificateChange:r,onCertificateReset:a,tooltips:o,readOnly:i})=>{var s;const l=Se();return v.createElement(ke,{enabled:e,label:"Add self-signed certificate",tooltipText:"Add your own Certificate Authority (CA) certificate on top of one generated by the certificate authorities for additional security measures",onToggle:e=>n(e),readOnly:i},v.createElement(b.InlineField,{label:"CA Certificate",labelWidth:24,tooltip:null!=(s=null==o?void 0:o.certificateLabel)?s:"Your self-signed certificate",required:!0,htmlFor:"self-signed-certificate-input",interactive:!0,grow:!0,className:(0,f.cx)(l.inlineFieldNoMarginRight,l.inlineFieldWithSecret),disabled:i},v.createElement(b.SecretTextArea,{id:"self-signed-certificate-input",isConfigured:t,onChange:e=>r(e.currentTarget.value),onReset:i?()=>{}:a,placeholder:"Begins with --- BEGIN CERTIFICATE ---",rows:6,required:!0})))},Re=({enabled:e,serverName:t,clientCertificateConfigured:n,clientKeyConfigured:r,onToggle:a,onServerNameChange:o,onClientCertificateChange:i,onClientKeyChange:s,onClientCertificateReset:l,onClientKeyReset:c,tooltips:u,readOnly:d})=>{var p,h,m;const g=Se();return v.createElement(ke,{enabled:e,label:"TLS Client Authentication",tooltipText:"Validate using TLS client authentication, in which the server authenticates the client",onToggle:e=>a(e),readOnly:d},v.createElement(b.InlineField,{label:"ServerName",labelWidth:24,tooltip:null!=(p=null==u?void 0:u.serverNameLabel)?p:"A Servername is used to verify the hostname on the returned certificate",required:!0,htmlFor:"client-auth-servername-input",interactive:!0,grow:!0,className:g.inlineFieldNoMarginRight,disabled:d},v.createElement(b.Input,{id:"client-auth-servername-input",placeholder:"domain.example.com",value:t,onChange:e=>o(e.currentTarget.value),required:!0})),v.createElement(b.InlineField,{label:"Client Certificate",labelWidth:24,tooltip:null!=(h=null==u?void 0:u.certificateLabel)?h:"The client certificate can be generated from a Certificate Authority or be self-signed",required:!0,htmlFor:"client-auth-client-certificate-input",interactive:!0,grow:!0,className:(0,f.cx)(g.inlineFieldNoMarginRight,g.inlineFieldWithSecret),disabled:d},v.createElement(b.SecretTextArea,{id:"client-auth-client-certificate-input",isConfigured:n,onChange:e=>i(e.currentTarget.value),onReset:d?()=>{}:l,placeholder:"Begins with --- BEGIN CERTIFICATE ---",rows:6,required:!0})),v.createElement(b.InlineField,{label:"Client Key",labelWidth:24,tooltip:null!=(m=null==u?void 0:u.keyLabel)?m:"The client key can be generated from a Certificate Authority or be self-signed",required:!0,htmlFor:"client-auth-client-key-input",interactive:!0,grow:!0,className:(0,f.cx)(g.inlineFieldNoMarginRight,g.inlineFieldWithSecret),disabled:d},v.createElement(b.SecretTextArea,{id:"client-auth-client-key-input",isConfigured:r,onChange:e=>s(e.currentTarget.value),onReset:d?()=>{}:c,placeholder:"Begins with --- RSA PRIVATE KEY CERTIFICATE ---",rows:6,required:!0})))},Me=({enabled:e,onToggle:t,readOnly:n})=>v.createElement(ke,{enabled:e,label:"Skip TLS certificate validation",tooltipText:"Skipping TLS certificate validation is not recommended unless absolutely necessary or for testing",onToggle:e=>t(e),readOnly:n}),qe=({selfSignedCertificate:e,TLSClientAuth:t,skipTLSVerification:n,readOnly:r})=>{const{spacing:a}=(0,b.useTheme2)(),o={container:(0,f.css)({marginTop:a(3)})};return v.createElement(de,{className:o.container,title:"TLS settings",description:"Additional security measures that can be applied on top of authentication"},v.createElement(Ae,{...e,readOnly:r}),v.createElement(Re,{...t,readOnly:r}),v.createElement(Me,{...n,readOnly:r}))},Je=({header:e,onChange:t,onBlur:n,onDelete:r,readOnly:a})=>{const{spacing:o}=(0,b.useTheme2)(),i=Se(),s={container:(0,f.css)({alignItems:"center"}),input:(0,f.css)({minWidth:"100%"}),headerNameField:(0,f.css)({width:"40%",marginRight:0,paddingRight:o(1)}),headerValueField:(0,f.css)({width:"45%",marginRight:0}),removeHeaderBtn:(0,f.css)({margin:"0 0 3px 10px"})};return v.createElement(v.Fragment,null,v.createElement(b.InlineFieldRow,{className:s.container},v.createElement(b.InlineField,{label:"Header",labelWidth:9,grow:!0,className:s.headerNameField,htmlFor:`custom-header-${e.id}-name-input`,disabled:a},v.createElement(b.Input,{id:`custom-header-${e.id}-name-input`,placeholder:"X-Custom-Header",value:e.name,width:12,onChange:n=>t({...e,name:n.currentTarget.value}),onBlur:n,className:s.input})),v.createElement(b.InlineField,{label:"Value",labelWidth:9,grow:!0,className:(0,f.cx)(i.inlineFieldWithSecret,s.headerValueField),htmlFor:`custom-header-${e.id}-value-input`,disabled:a},v.createElement(b.SecretInput,{id:`custom-header-${e.id}-value-input`,isConfigured:e.configured,placeholder:"Header value",value:e.value,width:12,onChange:n=>t({...e,value:n.currentTarget.value}),onReset:a?()=>{}:()=>t({...e,configured:!1,value:""}),onBlur:n,className:s.input})),v.createElement(b.IconButton,{name:"trash-alt",tooltip:"Remove header",tooltipPlacement:"top",className:s.removeHeaderBtn,onClick:r,type:"button",disabled:a})))},Be=({headers:e,onChange:t,readOnly:n})=>{const{spacing:r}=(0,b.useTheme2)(),[a,o]=(0,v.useState)(e.map((e=>({...e,id:Le(),value:""}))));(0,v.useEffect)((()=>{o((t=>{let n=!1;const r=t.map((t=>{var r;const a=null==(r=e.find((e=>e.name===t.name)))?void 0:r.configured;return void 0!==a&&t.configured!==a?(n=!0,{...t,configured:a}):t}));return n?r:t}))}),[e]);const i=()=>{t(a.map((({name:e,value:t,configured:n})=>({name:e,value:t,configured:n}))))},s={container:(0,f.css)({marginTop:r(3)}),addHeaderButton:(0,f.css)({marginTop:r(1.5)})};return v.createElement("div",{className:s.container},v.createElement(de,{title:"HTTP headers",description:"Pass along additional context and metadata about the request/response",isCollapsible:!0,isInitiallyOpen:a.length>0},v.createElement("div",null,a.map((e=>v.createElement(Je,{key:e.id,header:e,onChange:e=>((e,t)=>{o(a.map((n=>n.id===e?{...t}:n)))})(e.id,e),onDelete:()=>(e=>{const n=a.findIndex((t=>t.id===e));if(-1===n)return;const r=[...a];r.splice(n,1),o(r),t(r.map((({name:e,value:t,configured:n})=>({name:e,value:t,configured:n}))))})(e.id),onBlur:i,readOnly:n})))),v.createElement("div",{className:s.addHeaderButton},v.createElement(b.Button,{icon:"plus",variant:"secondary",fill:"outline",onClick:()=>{o([...a,{id:Le(),name:"",value:"",configured:!1}])},disabled:n},0===a.length?"Add header":"Add another header"))))};function Le(){return Math.random().toString(16).slice(2)}const We=({selectedMethod:e,mostCommonMethod:t,visibleMethods:n,defaultOptionsOverrides:r,customMethods:a,onAuthMethodSelect:o,basicAuth:i,TLS:s,customHeaders:l,readOnly:c=!1})=>{const u={container:(0,f.css)({maxWidth:578})};return v.createElement("div",{className:u.container},v.createElement(M,{title:"Authentication"},v.createElement(Ee,{selectedMethod:e,mostCommonMethod:t,customMethods:a,visibleMethods:n,defaultOptionsOverrides:r,onAuthMethodSelect:o,basicAuth:i,readOnly:c}),s&&v.createElement(qe,{...s,readOnly:c}),l&&v.createElement(Be,{...l,readOnly:c})))},Ge="httpHeaderName",$e="httpHeaderValue";function _e({config:e,onChange:t}){return{selectedMethod:Ue(e),onAuthMethodSelect:Ve(e,t),basicAuth:He(e,t),TLS:Qe(e,t),customHeaders:Ke(e,t),readOnly:e.readOnly}}function Ue(e){return e.basicAuth?Pe.BasicAuth:e.withCredentials?Pe.CrossSiteCredentials:e.jsonData.oauthPassThru?Pe.OAuthForward:Pe.NoAuth}function Ve(e,t){return n=>{t({...e,basicAuth:n===Pe.BasicAuth,withCredentials:n===Pe.CrossSiteCredentials,jsonData:{...e.jsonData,oauthPassThru:n===Pe.OAuthForward}})}}function He(e,t){return{user:e.basicAuthUser,passwordConfigured:e.secureJsonFields.basicAuthPassword,onUserChange:n=>t({...e,basicAuthUser:n}),onPasswordChange:n=>t({...e,secureJsonData:{...e.secureJsonData,basicAuthPassword:n}}),onPasswordReset:()=>t({...e,secureJsonData:{...e.secureJsonData,basicAuthPassword:""},secureJsonFields:{...e.secureJsonFields,basicAuthPassword:!1}})}}function Qe(e,t){var n,r,a;return{selfSignedCertificate:{enabled:Boolean(e.jsonData.tlsAuthWithCACert),certificateConfigured:!!(null==(n=e.secureJsonFields)?void 0:n.tlsCACert),onToggle:n=>t(n?{...e,jsonData:{...e.jsonData,tlsAuthWithCACert:n}}:{...e,jsonData:{...e.jsonData,tlsAuthWithCACert:n},secureJsonData:{...e.secureJsonData,tlsCACert:""},secureJsonFields:{...e.secureJsonFields,tlsCACert:!1}}),onCertificateChange:n=>t({...e,secureJsonData:{...e.secureJsonData,tlsCACert:n}}),onCertificateReset:()=>t({...e,secureJsonData:{...e.secureJsonData,tlsCACert:""},secureJsonFields:{...e.secureJsonFields,tlsCACert:!1}})},TLSClientAuth:{enabled:e.jsonData.tlsAuth,serverName:e.jsonData.serverName,clientCertificateConfigured:!!(null==(r=e.secureJsonFields)?void 0:r.tlsClientCert),clientKeyConfigured:!!(null==(a=e.secureJsonFields)?void 0:a.tlsClientKey),onToggle:n=>t(n?{...e,jsonData:{...e.jsonData,tlsAuth:n}}:{...e,jsonData:{...e.jsonData,tlsAuth:n,serverName:""},secureJsonData:{...e.secureJsonData,tlsClientCert:"",tlsClientKey:""},secureJsonFields:{...e.secureJsonFields,tlsClientCert:!1,tlsClientKey:!1}}),onServerNameChange:n=>t({...e,jsonData:{...e.jsonData,serverName:n}}),onClientCertificateChange:n=>t({...e,secureJsonData:{...e.secureJsonData,tlsClientCert:n}}),onClientCertificateReset:()=>t({...e,secureJsonData:{...e.secureJsonData,tlsClientCert:""},secureJsonFields:{...e.secureJsonFields,tlsClientCert:!1}}),onClientKeyChange:n=>t({...e,secureJsonData:{...e.secureJsonData,tlsClientKey:n}}),onClientKeyReset:()=>t({...e,secureJsonData:{...e.secureJsonData,tlsClientKey:""},secureJsonFields:{...e.secureJsonFields,tlsClientKey:!1}})},skipTLSVerification:{enabled:e.jsonData.tlsSkipVerify,onToggle:n=>t({...e,jsonData:{...e.jsonData,tlsSkipVerify:n}})}}}function Ke(e,t){return{headers:Object.keys(e.jsonData).filter((e=>e.startsWith(Ge))).sort().map((t=>{var n;const r=t.slice(14);return{name:e.jsonData[t],configured:null!=(n=e.secureJsonFields[`${$e}${r}`])&&n}})),onChange:n=>{const r=Object.fromEntries(Object.entries(e.jsonData).filter((([e])=>!e.startsWith(Ge)))),a=Object.fromEntries(Object.entries(e.secureJsonData||{}).filter((([e])=>!e.startsWith($e)))),o=Object.fromEntries(Object.entries(e.secureJsonFields).filter((([e])=>!e.startsWith($e))));n.forEach(((e,t)=>{r[`${Ge}${t+1}`]=e.name,e.configured?o[`${$e}${t+1}`]=!0:a[`${$e}${t+1}`]=e.value})),t({...e,jsonData:r,secureJsonData:a,secureJsonFields:o})}}}const ze=({config:e,onChange:t,className:n})=>{const r={container:(0,f.css)({maxWidth:578})};return v.createElement(de,{title:"Advanced HTTP settings",className:(0,f.cx)(r.container,n)},v.createElement(b.InlineField,{htmlFor:"advanced-http-cookies",label:"Allowed cookies",labelWidth:24,tooltip:"Grafana proxy deletes forwarded cookies by default. Specify cookies by name that should be forwarded to the data source.",disabled:e.readOnly,grow:!0},v.createElement(b.TagsInput,{id:"advanced-http-cookies",placeholder:"New cookie (hit enter to add)",tags:e.jsonData.keepCookies,onChange:n=>{t({...e,jsonData:{...e.jsonData,keepCookies:n}})}})),v.createElement(b.InlineField,{htmlFor:"advanced-http-timeout",label:"Timeout",labelWidth:24,tooltip:"HTTP request timeout in seconds",disabled:e.readOnly,grow:!0},v.createElement(b.Input,{id:"advanced-http-timeout",type:"number",min:0,placeholder:"Timeout in seconds","aria-label":"Timeout in seconds",value:e.jsonData.timeout,onChange:n=>{t({...e,jsonData:{...e.jsonData,timeout:parseInt(n.currentTarget.value,10)}})}})))};function Ye(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function Xe(e,t){return t=null!=t?t:{},Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(t)):function(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}(Object(t)).forEach((function(n){Object.defineProperty(e,n,Object.getOwnPropertyDescriptor(t,n))})),e}function Ze({options:e,onOptionsChange:t}){var n;return(0,g.jsxs)("div",{className:et.container,children:[(0,g.jsx)("h3",{className:"page-heading",children:"Query Trace by ID with Time Params"}),(0,g.jsx)(b.InlineFieldRow,{className:et.row,children:(0,g.jsx)(b.InlineField,{tooltip:"pass time parameters when querying trace by ID",label:"Enable Time Parameters",labelWidth:26,children:(0,g.jsx)(b.InlineSwitch,{id:"enableTraceIdTimeParams",value:null===(n=e.jsonData.traceIdTimeParams)||void 0===n?void 0:n.enabled,onChange:n=>(0,m.updateDatasourcePluginJsonDataOption)({onOptionsChange:t,options:e},"traceIdTimeParams",Xe(function(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{},r=Object.keys(n);"function"==typeof Object.getOwnPropertySymbols&&(r=r.concat(Object.getOwnPropertySymbols(n).filter((function(e){return Object.getOwnPropertyDescriptor(n,e).enumerable})))),r.forEach((function(t){Ye(e,t,n[t])}))}return e}({},e.jsonData.traceIdTimeParams),{enabled:n.currentTarget.checked}))})})})]})}const et={container:(0,f.css)({label:"container",width:"100%"}),row:(0,f.css)({label:"row",alignItems:"baseline"})};function tt(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function nt(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{},r=Object.keys(n);"function"==typeof Object.getOwnPropertySymbols&&(r=r.concat(Object.getOwnPropertySymbols(n).filter((function(e){return Object.getOwnPropertyDescriptor(n,e).enumerable})))),r.forEach((function(t){tt(e,t,n[t])}))}return e}const rt=e=>({container:(0,f.css)({marginBottom:e.spacing(2),maxWidth:"900px"})});var at=u(269),ot=u(59);function it(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function st(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{},r=Object.keys(n);"function"==typeof Object.getOwnPropertySymbols&&(r=r.concat(Object.getOwnPropertySymbols(n).filter((function(e){return Object.getOwnPropertyDescriptor(n,e).enumerable})))),r.forEach((function(t){it(e,t,n[t])}))}return e}function lt(e){const{nodes:t,edges:n}=function(e){const t=[],n=[],r=new m.DataFrameView(e),a=function(e){let t=0,n=1/0;for(let r=0;r<e.length;r++){const a=e.get(r);a.startTime<n&&(n=a.startTime),a.startTime+a.duration>t&&(t=a.startTime+a.duration)}return t-n}(r),o=ut((t=>{if(t>=e.length)return;const n=r.get(t);return{span:st({},n),id:n.spanID,parentIds:n.parentSpanID?[n.parentSpanID]:[]}}));for(let e=0;e<r.length;e++){const s=r.get(e),l=ct(o[s.spanID].children.map((e=>{const t=o[e].span;return[t.startTime,t.startTime+t.duration]}))),c=s.duration-l,u=dt(s.duration,a,c);var i;t.push({[m.NodeGraphDataFrameFieldNames.id]:s.spanID,[m.NodeGraphDataFrameFieldNames.title]:null!==(i=s.serviceName)&&void 0!==i?i:"",[m.NodeGraphDataFrameFieldNames.subTitle]:s.operationName,[m.NodeGraphDataFrameFieldNames.mainStat]:u.main,[m.NodeGraphDataFrameFieldNames.secondaryStat]:u.secondary,[m.NodeGraphDataFrameFieldNames.color]:c/a}),s.parentSpanID&&o[s.parentSpanID].span&&n.push({[m.NodeGraphDataFrameFieldNames.id]:s.parentSpanID+"--"+s.spanID,[m.NodeGraphDataFrameFieldNames.target]:s.spanID,[m.NodeGraphDataFrameFieldNames.source]:s.parentSpanID})}return{nodes:t,edges:n}}(e),[r,a]=ht();for(const e of t)r.add(e);for(const e of n)a.add(e);return[r,a]}function ct(e){e.sort(((e,t)=>e[0]-t[0]));return e.reduce(((e,t)=>{if(!e.length)return[t];const n=e.slice(-1)[0],[r,a]=n,[o,i]=t;return i<a?e:o>a?[...e,t]:[...e.slice(0,-1),[r,i]]}),[]).reduce(((e,t)=>e+(t[1]-t[0])),0)}function ut(e){const t={};let n;for(let r=0;n=e(r),n;r++){t[n.id]?t[n.id].span=n.span:t[n.id]={span:n.span,children:[]};for(const e of n.parentIds)e&&(t[e]?t[e].children.push(n.id):t[e]={span:void 0,children:[n.id]})}return t}function dt(e,t,n){return{main:`${pt(e)}ms (${pt(e/t*100)}%)`,secondary:`${pt(n)}ms (${pt(n/e*100)}%)`}}function pt(e){return parseFloat(e.toFixed(2))}function ht(){return[new m.MutableDataFrame({fields:[{name:m.NodeGraphDataFrameFieldNames.id,type:m.FieldType.string},{name:m.NodeGraphDataFrameFieldNames.title,type:m.FieldType.string},{name:m.NodeGraphDataFrameFieldNames.subTitle,type:m.FieldType.string},{name:m.NodeGraphDataFrameFieldNames.mainStat,type:m.FieldType.string,config:{displayName:"Total time (% of trace)"}},{name:m.NodeGraphDataFrameFieldNames.secondaryStat,type:m.FieldType.string,config:{displayName:"Self time (% of total)"}},{name:m.NodeGraphDataFrameFieldNames.color,type:m.FieldType.number,config:{color:{mode:"continuous-GrYlRd"},displayName:"Self time / Trace duration"}}],meta:{preferredVisualisationType:"nodeGraph"}}),new m.MutableDataFrame({fields:[{name:m.NodeGraphDataFrameFieldNames.id,type:m.FieldType.string},{name:m.NodeGraphDataFrameFieldNames.target,type:m.FieldType.string},{name:m.NodeGraphDataFrameFieldNames.source,type:m.FieldType.string}],meta:{preferredVisualisationType:"nodeGraph"}})]}function mt(e){const{nodes:t,edges:n}=function(e){const t=[],n=[],r=function(e){let t=0,n=1/0;for(const r of e)r.startTime<n&&(n=r.startTime),r.startTime+r.duration>t&&(t=r.startTime+r.duration);return t-n}(e.spans),a=ut((t=>{var n;if(t>=e.spans.length)return;const r=e.spans[t];return{span:r,id:r.spanID,parentIds:(null===(n=r.references)||void 0===n?void 0:n.filter((e=>"CHILD_OF"===e.refType)).map((e=>e.spanID)))||[]}}));for(const l of e.spans){var o,i;const c=e.processes[l.processID],u=ct(a[l.spanID].children.map((e=>{const t=a[e].span;return[t.startTime,t.startTime+t.duration]}))),d=l.duration-u,p=dt(l.duration/1e3,r/1e3,d/1e3);var s;t.push({[m.NodeGraphDataFrameFieldNames.id]:l.spanID,[m.NodeGraphDataFrameFieldNames.title]:null!==(s=null==c?void 0:c.serviceName)&&void 0!==s?s:"",[m.NodeGraphDataFrameFieldNames.subTitle]:l.operationName,[m.NodeGraphDataFrameFieldNames.mainStat]:p.main,[m.NodeGraphDataFrameFieldNames.secondaryStat]:p.secondary,[m.NodeGraphDataFrameFieldNames.color]:d/r});const h=null===(i=l.references)||void 0===i||null===(o=i.find((e=>"CHILD_OF"===e.refType)))||void 0===o?void 0:o.spanID;h&&a[h].span&&n.push({[m.NodeGraphDataFrameFieldNames.id]:h+"--"+l.spanID,[m.NodeGraphDataFrameFieldNames.target]:l.spanID,[m.NodeGraphDataFrameFieldNames.source]:h})}return{nodes:t,edges:n}}(e),[r,a]=ht();for(const e of t)r.add(e);for(const e of n)a.add(e);return[r,a]}function gt(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function ft(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{},r=Object.keys(n);"function"==typeof Object.getOwnPropertySymbols&&(r=r.concat(Object.getOwnPropertySymbols(n).filter((function(e){return Object.getOwnPropertyDescriptor(n,e).enumerable})))),r.forEach((function(t){gt(e,t,n[t])}))}return e}function bt(e,t){return t=null!=t?t:{},Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(t)):function(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}(Object(t)).forEach((function(n){Object.defineProperty(e,n,Object.getOwnPropertyDescriptor(t,n))})),e}function yt(e){const t=e.spans.map((t=>function(e,t){var n,r,a;const o=null===(r=e.references)||void 0===r||null===(n=r.find((e=>"CHILD_OF"===e.refType)))||void 0===n?void 0:n.spanID;var i,s;return{spanID:e.spanID,traceID:e.traceID,parentSpanID:o,operationName:e.operationName,startTime:e.startTime/1e3,duration:e.duration/1e3,logs:e.logs.map((e=>bt(ft({},e),{timestamp:e.timestamp/1e3}))),tags:e.tags,warnings:null!==(i=e.warnings)&&void 0!==i?i:void 0,stackTraces:e.stackTraces,references:null!==(s=null===(a=e.references)||void 0===a?void 0:a.filter((e=>e.spanID!==o)))&&void 0!==s?s:[],serviceName:t[e.processID].serviceName,serviceTags:t[e.processID].tags}}(t,e.processes))),n=new m.MutableDataFrame({fields:[{name:"traceID",type:m.FieldType.string},{name:"spanID",type:m.FieldType.string},{name:"parentSpanID",type:m.FieldType.string},{name:"operationName",type:m.FieldType.string},{name:"serviceName",type:m.FieldType.string},{name:"serviceTags",type:m.FieldType.other},{name:"startTime",type:m.FieldType.number},{name:"duration",type:m.FieldType.number},{name:"logs",type:m.FieldType.other},{name:"references",type:m.FieldType.other,values:[]},{name:"tags",type:m.FieldType.other},{name:"warnings",type:m.FieldType.other},{name:"stackTraces",type:m.FieldType.other}],meta:{preferredVisualisationType:"trace",custom:{traceFormat:"jaeger"}}});for(const e of t)n.add(e);return n}function vt(e,t,n,r,a,o,i){try{var s=e[o](i),l=s.value}catch(e){return void n(e)}s.done?t(l):Promise.resolve(l).then(r,a)}function Ot(e){return function(){var t=this,n=arguments;return new Promise((function(r,a){var o=e.apply(t,n);function i(e){vt(o,r,a,i,s,"next",e)}function s(e){vt(o,r,a,i,s,"throw",e)}i(void 0)}))}}function jt(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function wt(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{},r=Object.keys(n);"function"==typeof Object.getOwnPropertySymbols&&(r=r.concat(Object.getOwnPropertySymbols(n).filter((function(e){return Object.getOwnPropertyDescriptor(n,e).enumerable})))),r.forEach((function(t){jt(e,t,n[t])}))}return e}function Dt(e,t){return t=null!=t?t:{},Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(t)):function(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}(Object(t)).forEach((function(n){Object.defineProperty(e,n,Object.getOwnPropertyDescriptor(t,n))})),e}class Tt extends w.DataSourceWithBackend{metadataRequest(e,t){return Ot((function*(){return yield this.getResource(e,t)})).call(this)}query(e){const t=e.targets[0];if(!t)return(0,at.of)({data:[xt]});if("upload"===t.queryType){if(!this.uploadedJson)return(0,at.of)({data:[]});try{var n;const e=JSON.parse(this.uploadedJson).data[0];let t=[yt(e)];return(null===(n=this.nodeGraph)||void 0===n?void 0:n.enabled)&&t.push(...mt(e)),(0,at.of)({data:t})}catch(e){return(0,at.of)({error:{message:"The JSON file uploaded is not in a valid Jaeger format"},data:[]})}}return super.query(Dt(wt({},e),{targets:[t]})).pipe((0,ot.map)((e=>{var n;return(null===(n=this.nodeGraph)||void 0===n?void 0:n.enabled)&&!t.queryType?function(e){if(!e.data||0===e.data.length)return e;const t=(0,m.toDataFrame)(e.data[0]),n=e.data.concat(lt(t));return Dt(wt({},e),{data:n})}(e):e})))}interpolateVariablesInQueries(e,t){return e&&0!==e.length?e.map((e=>wt(Dt(wt({},e),{datasource:this.getRef()}),this.applyTemplateVariables(e,t)))):[]}applyTemplateVariables(e,t){let n=wt({},e);var r,a,o,i;return e.tags&&this.templateSrv.containsTemplate(e.tags)&&(n=Dt(wt({},e),{tags:this.templateSrv.replace(e.tags,t)})),Dt(wt({},n),{service:this.templateSrv.replace(null!==(r=e.service)&&void 0!==r?r:"",t),operation:this.templateSrv.replace(null!==(a=e.operation)&&void 0!==a?a:"",t),minDuration:this.templateSrv.replace(null!==(o=e.minDuration)&&void 0!==o?o:"",t),maxDuration:this.templateSrv.replace(null!==(i=e.maxDuration)&&void 0!==i?i:"",t)})}testDatasource(){var e=this,t=()=>super.testDatasource;return Ot((function*(){return yield t().call(e)}))()}getQueryDisplayText(e){return e.query||""}constructor(e,t=(0,w.getTemplateSrv)()){super(e),jt(this,"templateSrv",void 0),jt(this,"uploadedJson",void 0),jt(this,"nodeGraph",void 0),jt(this,"traceIdTimeParams",void 0),jt(this,"spanBar",void 0),this.templateSrv=t,this.uploadedJson=null,this.nodeGraph=e.jsonData.nodeGraph,this.traceIdTimeParams=e.jsonData.traceIdTimeParams}}const xt=new m.MutableDataFrame({fields:[{name:"trace",type:m.FieldType.trace,values:[]}],meta:{preferredVisualisationType:"trace",custom:{traceFormat:"jaeger"}}});const Ct=new m.DataSourcePlugin(Tt).setConfigEditor((({options:e,onOptionsChange:t})=>{const n=(0,b.useStyles2)(rt);return(0,g.jsxs)("div",{className:n.container,children:[(0,g.jsx)(Ce,{dataSourceName:"Jaeger",docsLink:"https://grafana.com/docs/grafana/latest/datasources/jaeger",hasRequiredFields:!1}),(0,g.jsx)(b.Divider,{spacing:4}),(0,g.jsx)(Fe,{config:e,onChange:t,urlPlaceholder:"http://localhost:16686"}),(0,g.jsx)(b.Divider,{spacing:4}),(0,g.jsx)(We,nt({},_e({config:e,onChange:t}))),(0,g.jsx)(b.Divider,{spacing:4}),(0,g.jsx)(ae,{options:e,onOptionsChange:t}),(0,g.jsx)(b.Divider,{spacing:4}),(0,g.jsx)(ce,{options:e,onOptionsChange:t}),(0,g.jsx)(b.Divider,{spacing:4}),(0,g.jsx)(M,{title:"Additional settings",description:"Additional settings are optional settings that can be configured for more control over your data source.",isCollapsible:!0,isInitiallyOpen:!1,children:(0,g.jsxs)(b.Stack,{gap:5,direction:"column",children:[(0,g.jsx)(ze,{config:e,onChange:t}),w.config.secureSocksDSProxyEnabled&&(0,g.jsx)(b.SecureSocksProxySettings,{options:e,onOptionsChange:t}),(0,g.jsx)(ge,{options:e,onOptionsChange:t}),(0,g.jsx)(Te,{options:e,onOptionsChange:t}),(0,g.jsx)(Ze,{options:e,onOptionsChange:t})]})})]})})).setQueryEditor((function({datasource:e,query:t,onChange:n,onRunQuery:r}){const[a,o]=(0,v.useState)(!1),i=(0,b.useTheme2)(),s=(0,b.useStyles2)(A),l=e=>{const r=k(E({},t),{query:e});n(r)};return(0,g.jsxs)(g.Fragment,{children:[(0,g.jsx)(b.Modal,{title:"Upload trace",isOpen:a,onDismiss:()=>o(!1),children:(0,g.jsx)("div",{className:(0,f.css)({padding:i.spacing(2)}),children:(0,g.jsx)(b.FileDropzone,{options:{multiple:!1},onLoad:a=>{e.uploadedJson=a,n(k(E({},t),{queryType:"upload"})),o(!1),r()}})})}),(0,g.jsxs)("div",{className:s.container,children:[(0,g.jsx)(b.InlineFieldRow,{children:(0,g.jsx)(b.InlineField,{label:"Query type",grow:!0,children:(0,g.jsxs)(b.Stack,{gap:1,alignItems:"center",justifyContent:"space-between",children:[(0,g.jsx)(b.RadioButtonGroup,{options:[{value:"search",label:"Search"},{value:void 0,label:"TraceID"},{value:"dependencyGraph",label:"Dependency graph"}],value:t.queryType,onChange:e=>n(k(E({},t),{queryType:e})),size:"md"}),(0,g.jsx)(b.Button,{variant:"secondary",size:"sm",onClick:()=>{o(!0)},children:"Import trace"})]})})}),(()=>{switch(t.queryType){case"search":return(0,g.jsx)(P,{datasource:e,query:t,onChange:n});case"dependencyGraph":return null;default:return(0,g.jsx)(b.InlineFieldRow,{children:(0,g.jsx)(b.InlineField,{label:"Trace ID",labelWidth:14,grow:!0,children:(0,g.jsx)(b.QueryField,{query:t.query,onChange:l,onRunQuery:r,placeholder:"Enter a Trace ID (run with Shift+Enter)",portalOrigin:"jaeger"})})})}})()]})]})})).setQueryEditorHelp((function(){const e=(0,b.useStyles2)(y);return(0,g.jsxs)(g.Fragment,{children:[(0,g.jsx)("h2",{id:"jaeger-cheat-sheet",children:"Jaeger Cheat Sheet"}),(0,g.jsxs)("p",{children:["This cheat sheet provides a quick overview of the query types that are available. For more details about the Jaeger data source, check out"," ",(0,g.jsx)(b.TextLink,{href:"https://grafana.com/docs/grafana/latest/datasources/jaeger",external:!0,children:"the documentation"}),"."]}),(0,g.jsx)("hr",{}),(0,g.jsxs)("ul",{className:e.unorderedList,children:[(0,g.jsx)("li",{children:"Search - filter traces by service name. Addtionally, you can filter by tags or min/max duration, as well as limit the number of traces that are returned."}),(0,g.jsx)("li",{children:"TraceID - if you have a trace ID, simply enter the trace ID to see the trace."}),(0,g.jsxs)("li",{children:["JSON File - you can upload a JSON file that contains a single trace to visualize it. If the file has multiple traces then the first trace is used for visualization. An example of a valid JSON file can be found in"," ",(0,g.jsx)(b.TextLink,{href:"https://grafana.com/docs/grafana/latest/datasources/jaeger/#upload-json-trace-file",external:!0,children:"this section"})," ","of the documentation."]})]})]})}));return d})())); //# sourceMappingURL=module.js.map
.
Edit
..
Edit
CHANGELOG.md
Edit
LICENSE
Edit
README.md
Edit
img
Edit
mockJsonResponse.json
Edit
mockSearchResponse.json
Edit
mockTraceResponse.json
Edit
module.js
Edit
module.js.LICENSE.txt
Edit
module.js.map
Edit
plugin.json
Edit