"use strict";(self.webpackChunkgrafana=self.webpackChunkgrafana||[]).push([[5254],{54522:(ie,F,u)=>{u.d(F,{a:()=>_});var T=u(39953),v=u(41407),A=u(69171),s=u(97250),V=u(38637),y=u(99242),w=Object.defineProperty,S=Object.defineProperties,W=Object.getOwnPropertyDescriptors,$=Object.getOwnPropertySymbols,C=Object.prototype.hasOwnProperty,O=Object.prototype.propertyIsEnumerable,Q=(N,f,M)=>f in N?w(N,f,{enumerable:!0,configurable:!0,writable:!0,value:M}):N[f]=M,D=(N,f)=>{for(var M in f||(f={}))C.call(f,M)&&Q(N,M,f[M]);if($)for(var M of $(f))O.call(f,M)&&Q(N,M,f[M]);return N},P=(N,f)=>S(N,W(f));const _=({config:N,onChange:f,className:M})=>{const re=Y=>{f(P(D({},N),{jsonData:P(D({},N.jsonData),{keepCookies:Y})}))},x=Y=>{f(P(D({},N),{jsonData:P(D({},N.jsonData),{timeout:parseInt(Y.currentTarget.value,10)})}))},ee={container:(0,v.css)({maxWidth:578})};return T.createElement(y._,{title:"Advanced HTTP settings",className:(0,v.cx)(ee.container,M)},T.createElement(A._,{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:N.readOnly,grow:!0},T.createElement(s.B,{id:"advanced-http-cookies",placeholder:"New cookie (hit enter to add)",tags:N.jsonData.keepCookies,onChange:re})),T.createElement(A._,{htmlFor:"advanced-http-timeout",label:"Timeout",labelWidth:24,tooltip:"HTTP request timeout in seconds",disabled:N.readOnly,grow:!0},T.createElement(V.I,{id:"advanced-http-timeout",type:"number",min:0,placeholder:"Timeout in seconds","aria-label":"Timeout in seconds",value:N.jsonData.timeout,onChange:x})))}},25243:(ie,F,u)=>{u.d(F,{i:()=>s});var T=u(41407),v=u(39953),A=u(82803);const s=({hideLine:y=!1})=>{const w=(0,A.wW)(V);return y?v.createElement("hr",{className:w.dividerHideLine}):v.createElement("hr",{className:w.divider})},V=y=>({divider:(0,T.css)`
    margin: ${y.spacing(4,0)};
  `,dividerHideLine:(0,T.css)`
    border: none;
    margin: ${y.spacing(3,0)};
  `})},23846:(ie,F,u)=>{u.d(F,{I:()=>C});var T=u(41407),v=u(39953),A=u(47635),s=u(99242),V=u(82803),y=u(74661),w=u(69171),S=u(26286),W=u(43997);function $({options:Q,onOptionsChange:D}){const P=(0,V.wW)(O);return v.createElement("div",{className:P.container},v.createElement(y.Z,{className:P.row},v.createElement(w._,{tooltip:"Displays the node graph above the trace view. Default: disabled",label:"Enable node graph",labelWidth:26},v.createElement(S.x,{id:"enableNodeGraph",value:Q.jsonData.nodeGraph?.enabled,onChange:_=>(0,A.tp)({onOptionsChange:D,options:Q},"nodeGraph",{...Q.jsonData.nodeGraph,enabled:_.currentTarget.checked})}))))}const C=({options:Q,onOptionsChange:D})=>v.createElement(s._,{title:"Node graph",description:v.createElement(W.W,{description:"Show or hide the node graph visualization.",suffix:`${Q.type}/#node-graph`,feature:"the node graph"})},v.createElement($,{options:Q,onOptionsChange:D})),O=Q=>({infoText:(0,T.css)`
    label: infoText;
    padding-bottom: ${Q.spacing(2)};
    color: ${Q.colors.text.secondary};
  `,container:(0,T.css)`
    label: container;
    width: 100%;
  `,row:(0,T.css)`
    label: row;
    align-items: baseline;
  `})},49605:(ie,F,u)=>{u.d(F,{Y:()=>_});var T=u(41407),v=u(39953),A=u(47635),s=u(27770),V=u(82803),y=u(74661),w=u(69171),S=u(4919),W=u(38637),$=u(92811),C=u(43997),O=u(13273),Q=u(60317),D=u(36516);function P({options:f,onOptionsChange:M}){const re=(0,V.wW)(N);return v.createElement("div",{className:(0,T.css)({width:"100%"})},v.createElement(y.Z,{className:re.row},v.createElement(w._,{tooltip:"The Prometheus data source the trace is going to navigate to",label:"Data source",labelWidth:26},v.createElement($.q,{inputId:"trace-to-metrics-data-source-picker",pluginId:"prometheus",current:f.jsonData.tracesToMetrics?.datasourceUid,noDefault:!0,width:40,onChange:x=>(0,A.tp)({onOptionsChange:M,options:f},"tracesToMetrics",{...f.jsonData.tracesToMetrics,datasourceUid:x.uid})})),f.jsonData.tracesToMetrics?.datasourceUid?v.createElement(S.zx,{type:"button",variant:"secondary",size:"sm",fill:"text",onClick:()=>{(0,A.tp)({onOptionsChange:M,options:f},"tracesToMetrics",{...f.jsonData.tracesToMetrics,datasourceUid:void 0})}},"Clear"):null),v.createElement(y.Z,null,v.createElement(O.w,{label:(0,D.mH)("start"),tooltip:(0,D.rr)("start","-2m"),value:f.jsonData.tracesToMetrics?.spanStartTimeShift||"",onChange:x=>{(0,A.tp)({onOptionsChange:M,options:f},"tracesToMetrics",{...f.jsonData.tracesToMetrics,spanStartTimeShift:x})},placeholder:"-2m",isInvalidError:D.Ny})),v.createElement(y.Z,null,v.createElement(O.w,{label:(0,D.mH)("end"),tooltip:(0,D.rr)("end","2m"),value:f.jsonData.tracesToMetrics?.spanEndTimeShift||"",onChange:x=>{(0,A.tp)({onOptionsChange:M,options:f},"tracesToMetrics",{...f.jsonData.tracesToMetrics,spanEndTimeShift:x})},placeholder:"2m",isInvalidError:D.Ny})),v.createElement(y.Z,null,v.createElement(w._,{tooltip:"Tags that will be used in the metrics query",label:"Tags",labelWidth:26},v.createElement(Q.a,{values:f.jsonData.tracesToMetrics?.tags??[],onChange:x=>(0,A.tp)({onOptionsChange:M,options:f},"tracesToMetrics",{...f.jsonData.tracesToMetrics,tags:x})}))),f.jsonData.tracesToMetrics?.queries?.map((x,ee)=>v.createElement("div",{key:ee,className:re.queryRow},v.createElement(w._,{label:"Link Label",labelWidth:26,tooltip:"Descriptive label for the linked query"},v.createElement(W.I,{label:"Link Label",type:"text",allowFullScreen:!0,value:x.name,width:40,onChange:Y=>{let oe=f.jsonData.tracesToMetrics?.queries.slice()??[];oe[ee].name=Y.currentTarget.value,(0,A.tp)({onOptionsChange:M,options:f},"tracesToMetrics",{...f.jsonData.tracesToMetrics,queries:oe})}})),v.createElement(w._,{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},v.createElement(W.I,{label:"Query",type:"text",allowFullScreen:!0,value:x.query,onChange:Y=>{let oe=f.jsonData.tracesToMetrics?.queries.slice()??[];oe[ee].query=Y.currentTarget.value,(0,A.tp)({onOptionsChange:M,options:f},"tracesToMetrics",{...f.jsonData.tracesToMetrics,queries:oe})}})),v.createElement(S.zx,{variant:"destructive",title:"Remove query",icon:"times",type:"button",onClick:()=>{let Y=f.jsonData.tracesToMetrics?.queries.slice();Y?.splice(ee,1),(0,A.tp)({onOptionsChange:M,options:f},"tracesToMetrics",{...f.jsonData.tracesToMetrics,queries:Y})}}))),v.createElement(S.zx,{variant:"secondary",title:"Add query",icon:"plus",type:"button",onClick:()=>{(0,A.tp)({onOptionsChange:M,options:f},"tracesToMetrics",{...f.jsonData.tracesToMetrics,queries:[...f.jsonData.tracesToMetrics?.queries??[],{query:""}]})}},"Add query"))}const _=({options:f,onOptionsChange:M})=>v.createElement(s.K,{title:"Trace to metrics",description:v.createElement(C.W,{description:"Navigate from a trace span to the selected data source's metrics.",suffix:`${f.type}/#trace-to-metrics`,feature:"trace to metrics"}),isCollapsible:!0,isInitiallyOpen:!0},v.createElement(P,{options:f,onOptionsChange:M})),N=f=>({infoText:(0,T.css)`
    padding-bottom: ${f.spacing(2)};
    color: ${f.colors.text.secondary};
  `,row:(0,T.css)`
    label: row;
    align-items: baseline;
  `,queryRow:(0,T.css)`
    label: queryRow;
    display: flex;
    flex-flow: wrap;
  `})},88132:(ie,F,u)=>{u.d(F,{n:()=>y});var T=u(39953),v=u(38793);const A=T.lazy(()=>Promise.all([u.e(1569),u.e(7142)]).then(u.bind(u,29681))),s=w=>T.createElement(T.Suspense,{fallback:null},T.createElement(A,{...w})),V=w=>{const S=(0,T.useRef)(null),{onRunQuery:W,onChange:$,...C}=w,O=D=>{S.current=D,$(D),W()},Q=D=>{$(D)};return T.createElement(s,{onRunQuery:O,onBlur:Q,onChange:$,...C})};class y extends T.PureComponent{constructor(S){super(S),this._isMounted=!1,this.onChangeQuery=(W,$)=>{const{query:C,onChange:O,onRunQuery:Q}=this.props;if(O){const D={...C,expr:W};O(D),$&&Q&&Q()}},this.state={labelsLoaded:!1}}async componentDidMount(){this._isMounted=!0,await this.props.datasource.languageProvider.start(),this._isMounted&&this.setState({labelsLoaded:!0})}componentWillUnmount(){this._isMounted=!1}componentDidUpdate(S){const{range:W,datasource:{languageProvider:$}}=this.props;(0,v.rf)(W,S.range)&&$.fetchLabels()}render(){const{ExtraFieldElement:S,query:W,datasource:$,history:C,onRunQuery:O}=this.props,Q=this.props.placeholder??"Enter a Loki query (run with Shift+Enter)";return T.createElement(T.Fragment,null,T.createElement("div",{className:"gf-form-inline gf-form-inline--xs-view-flex-column flex-grow-1","data-testid":this.props["data-testid"]},T.createElement("div",{className:"gf-form--grow flex-shrink-1 min-width-15"},T.createElement(V,{datasource:$,history:C??[],onChange:this.onChangeQuery,onRunQuery:O,initialValue:W.expr??"",placeholder:Q}))),S)}}},38793:(ie,F,u)=>{u.d(F,{Hk:()=>W,U9:()=>y,_z:()=>$,aC:()=>C,iS:()=>w,rf:()=>A,tU:()=>S});function T(O){return v(O/1e3)}function v(O){return Math.floor(O/60)}function A(O,Q){if(O&&Q){const D=T(O.from.valueOf())===T(Q.from.valueOf()),P=T(O.to.valueOf())===T(Q.to.valueOf());return!(D&&P)}return!1}const s=/[*+?()|\\.\[\]{}^$]/g;function V(O){return O.replace(s,"\\$&")}function y(O){return O.replace(/\\/g,"\\\\").replace(/\n/g,"\\n").replace(/"/g,'\\"')}function w(O){return O.replace(/\\n/g,`
`).replace(/\\"/g,'"').replace(/\\\\/g,"\\")}function S(O){return y(V(O))}function W(O,Q){return $(Q)?S(O):y(O)}function $(O){return!!(O&&(O.includes("=~")||O.includes("!~")))}function C(O){const Q=["b","kib","Kib","kb","KB","mib","Mib","mb","MB","gib","Gib","gb","GB","tib","Tib","tb","TB","pib","Pib","pb","PB","eib","Eib","eb","EB"],D=new RegExp(`^(?:-?\\d+(?:\\.\\d+)?)(?:${Q.join("|")})$`);return!!O.match(D)}},30736:(ie,F,u)=>{u.d(F,{d:()=>C});var T=u(41407),v=u(39953),A=u(948),s=u(83502),V=u(27366),y=u(32688),w=u(82803),S=u(62818),W=u(69865),$=u(12190);function C({title:P,children:_,collapsedInfo:N,queryStats:f}){const[M,re]=(0,A.Z)(!1),x=(0,w.wW)(O);return v.createElement("div",{className:x.wrapper},v.createElement(S.U,{className:x.collapse,collapsible:!0,isOpen:M,onToggle:re,label:v.createElement(V.K,{gap:0,wrap:!1},v.createElement("h6",{className:x.title},P),!M&&v.createElement("div",{className:x.description},N.map((ee,Y)=>v.createElement("span",{key:Y},ee))))},v.createElement("div",{className:x.body},_)),f&&y.config.featureToggles.lokiQuerySplitting&&v.createElement(W.u,{content:"Note: the query will be split into multiple parts and executed in sequence. Query limits will only apply each individual part."},v.createElement($.J,{tabIndex:0,name:"info-circle",className:x.tooltip,size:"sm"})),f&&v.createElement("p",{className:x.stats},Q(f)))}const O=P=>({collapse:(0,T.css)({backgroundColor:"unset",border:"unset",marginBottom:0,["> button"]:{padding:P.spacing(0,1)}}),wrapper:(0,T.css)({width:"100%",display:"flex",justifyContent:"space-between",alignItems:"baseline"}),title:(0,T.css)({flexGrow:1,overflow:"hidden",fontSize:P.typography.bodySmall.fontSize,fontWeight:P.typography.fontWeightMedium,margin:0}),description:(0,T.css)({color:P.colors.text.secondary,fontSize:P.typography.bodySmall.fontSize,fontWeight:P.typography.bodySmall.fontWeight,paddingLeft:P.spacing(2),gap:P.spacing(2),display:"flex"}),body:(0,T.css)({display:"flex",gap:P.spacing(2),flexWrap:"wrap"}),stats:(0,T.css)({margin:"0px",color:P.colors.text.secondary,fontSize:P.typography.bodySmall.fontSize}),tooltip:(0,T.css)({marginRight:P.spacing(.25)})}),Q=P=>P.message?P.message:`This query will process approximately ${D(P)}.`,D=P=>{const{text:_,suffix:N}=(0,s.Cf)("bytes")(P.bytes,1);return _+N}},5254:(ie,F,u)=>{u.r(F),u.d(F,{plugin:()=>Rn});var T=u(54721),v=u(36316),A=u(77014),s=u(39953),V=u(72639),y=u(32688);function w(){return(0,V.ff)("grafana_traces_cheatsheet_clicked",{datasourceType:"tempo",grafana_version:y.config.buildInfo.version}),s.createElement("div",null,s.createElement("h2",{id:"tempo-cheat-sheet"},"Tempo Cheat Sheet"),s.createElement("p",null,"Tempo is a trace id lookup store. Enter a trace id in the above field and hit \u201CRun Query\u201D to retrieve your trace. Tempo is generally paired with other datasources such as Loki or Prometheus to find traces."),s.createElement("p",null,"Here are some"," ",s.createElement("a",{href:"https://grafana.com/docs/tempo/latest/guides/instrumentation/",target:"blank"},"instrumentation examples")," ","to get you started with trace discovery through logs and metrics (exemplars)."))}var S=u(41407),W=u(73075),$=u(17789),C=u(74661),O=u(69171),Q=u(12223),D=u(20454),P=u(4919),_=u(82803),N=u(99292),f=u(99491),M=u(88132),re=u(26205);const x=(e,t)=>{const a=e?` (${e})`:"";return`${t||"Error"}${a}. Please check the server logs for more details.`};async function ee(e){if(!e)return;const t=(0,re.F)();try{return await t.get(e)}catch(a){console.error("Failed to load data source",a);return}}function Y({logsDatasourceUid:e,onChange:t,onRunQuery:a,query:r}){const n=(0,N.Z)(()=>ee(e),[e]);if(n.loading)return null;const o=n.value;return o?s.createElement(s.Fragment,null,s.createElement(f.W,null,"Tempo uses ",o.name," to find traces."),s.createElement(M.n,{datasource:o,onChange:t,onRunQuery:a,query:r.linkedQuery??{refId:"linked"},history:[]})):e?e&&!o?s.createElement("div",{className:"text-warning"},"Loki search datasource is configured but the data source no longer exists. Please configure existing data source to use the search."):null:s.createElement("div",{className:"text-warning"},"Please set up a Loki search datasource in the datasource settings.")}var oe=u(99456),Me=u(5195),Te=u(4148),pe=u(79059),ua=u(52184),Se=u(33155),te=u(9558),Le=u(38637),Et=u(97316),ue=u(90634),le=u(74600),z=u(86832),qe=u(31312),j=u(63302),Je=u(22605),la=u(8894),Qt=u(3195),Pt=u(51366),Z=u(71476),ye=u(10752),Ae=u(84289),Rt=u(83639),et=u(41311),ca=u(64912),da=u.n(ca),ne=u(10694),bt=u(81626),we=u(92403),ga=u(96083),H=u(89591),pa=u(92743),be=u(34547),ma=u(5365),$e=u(52436),L=u(1838);const ha={wordPattern:/(-?\d*\.\d\w*)|([^`~!#%^&*()\-=+\[{\]}\\|;:'",.<>\/?\s]+)/g,brackets:[["{","}"],["(",")"]],autoClosingPairs:[{open:"{",close:"}"},{open:"(",close:")"},{open:'"',close:'"'},{open:"'",close:"'"}],surroundingPairs:[{open:"{",close:"}"},{open:"(",close:")"},{open:'"',close:'"'},{open:"'",close:"'"}],folding:{}},Ct=["=","!=",">","<",">=","<=","=~","!~"],fa=["=","!=","=~","!~"],Oa=["=","!=",">","<",">=","<="],_e=["duration","kind","name","status"],xt=["resource","span"],va=["avg","min","max","sum","count","by"],Ta={ignoreCase:!1,defaultToken:"",tokenPostfix:".traceql",keywords:_e.concat(xt),operators:Ct,statusValues:["ok","unset","error","false","true"],functions:va,symbols:/[=><!~?:&|+\-*\/^%]+/,escapes:/\\(?:[abfnrtv\\"']|x[0-9A-Fa-f]{1,4}|u[0-9A-Fa-f]{4}|U[0-9A-Fa-f]{8})/,digits:/\d+(_+\d+)*/,octaldigits:/[0-7]+(_+[0-7]+)*/,binarydigits:/[0-1]+(_+[0-1]+)*/,tokenizer:{root:[[/[0-9]+(.[0-9]+)?(us|µs|ns|ms|s|m|h)/,"number"],[/^\s*[0-9A-Fa-f]+\s*$/,"tag"],[/[a-zA-Z_.]\w*/,{cases:{"@functions":"predefined","@keywords":"keyword","@statusValues":"type","@default":"tag"}}],[/"([^"\\]|\\.)*$/,"string.invalid"],[/'([^'\\]|\\.)*$/,"string.invalid"],[/"/,"string","@string_double"],[/'/,"string","@string_single"],[/[{}()\[\]]/,"delimiter.bracket"],[/@symbols/,{cases:{"@operators":"delimiter","@default":""}}],[/(@digits)[eE]([\-+]?(@digits))?[fFdD]?/,"number.float"],[/(@digits)\.(@digits)([eE][\-+]?(@digits))?[fFdD]?/,"number.float"],[/0(@octaldigits)[Ll]?/,"number.octal"],[/0[bB](@binarydigits)[Ll]?/,"number.binary"],[/(@digits)[fFdD]/,"number.float"],[/(@digits)[lL]?/,"number"]],string_double:[[/[^\\"]+/,"string"],[/@escapes/,"string.escape"],[/\\./,"string.escape.invalid"],[/"/,"string","@pop"]],string_single:[[/[^\\']+/,"string"],[/@escapes/,"string.escape"],[/\\./,"string.escape.invalid"],[/'/,"string","@pop"]]}},Sa={id:"traceql",extensions:[".traceql"],aliases:["tempo","traceql"],mimetypes:[],def:{language:Ta,languageConfiguration:ha}},ya={comment:{pattern:/#.*/},"span-set":{pattern:/\{[^}]*}/,inside:{filter:{pattern:/([\w.\/-]+)?(\s*)(([!=+\-<>~]+)\s*("([^"\n&]+)?"?|([^"\n\s&|}]+))?)/g,inside:{comment:{pattern:/#.*/},"label-key":{pattern:/[a-z_.][\w./_-]*(?=\s*(=|!=|>|<|>=|<=|=~|!~))/,alias:"attr-name"},"label-value":{pattern:/("(?:\\.|[^\\"])*")|(\w+)/,alias:"attr-value"}}},punctuation:/[}{&|]/}},number:/\b-?\d+((\.\d*)?([eE][+-]?\d+)?)?\b/,operator:new RegExp("/[-+*/=%^~]|&&?|\\|?\\||!=?|<(?:=>?|<|>)?|>[>=]?|","i"),punctuation:/[{};()`,.]/},tt=e=>`{${e.filter(t=>t.tag&&t.operator&&t.value?.length).map(t=>`${Dt(t)}${t.tag}${t.operator}${Ea(t)}`).join(" && ")}}`,Ea=e=>Array.isArray(e.value)&&e.value.length>1?`"${e.value.join("|")}"`:e.valueType==="string"?`"${e.value}"`:e.value,Dt=e=>_e.find(t=>t===e.tag)?"":(e.scope===L.NM.Resource||e.scope===L.NM.Span?e.scope?.toLowerCase():"")+".",at=e=>Dt(e)+e.tag,Qa=e=>e.tag==="name"?"Span Name":(0,z.startCase)(at(e)),Pa=(e,t)=>[..._e,...e].filter(a=>!t.includes(a)),Ue=e=>(0,z.uniq)(e.map(t=>t.name&&t.name!=="intrinsic"&&t.tags?t.tags:[]).flat()),Ra=e=>(0,z.uniq)(e.map(t=>t.tags?t.tags:[]).flat()),rt=(e,t)=>(0,z.uniq)(e.map(a=>a.name&&a.name===t&&a.tags?a.tags:[]).flat());function nt(e,t,a){const r=e.slice(0);return r[t]=a,r}const It=e=>{const t={label:e,value:e};switch(e){case"=":t.description="Equals";break;case"!=":t.description="Not equals";break;case">":t.description="Greater";break;case">=":t.description="Greater or Equal";break;case"<":t.description="Less";break;case"<=":t.description="Less or Equal";break;case"=~":t.description="Matches regex";break;case"!~":t.description="Does not match regex";break}return t};var st=(e=>(e[e.LabelNames=0]="LabelNames",e[e.LabelValues=1]="LabelValues",e))(st||{});const ba=[{label:"Label names",value:0},{label:"Label values",value:1}],it="TempoDatasourceVariableQueryEditor-VariableQuery",Ca=({onChange:e,query:t,datasource:a})=>{const[r,n]=(0,s.useState)(t.label||""),[o,i]=(0,s.useState)(t.type),[l,d]=(0,s.useState)([]);(0,s.useEffect)(()=>{o===1&&a.labelNamesQuery().then(m=>{d(m.map(({text:h})=>({label:h,value:h})))})},[a,t,o]);const c=m=>{i(m.value),m.value!==void 0&&e({type:m.value,label:r,refId:it})},p=m=>{const h=m.value||"";n(h),o!==void 0&&e({type:o,label:h,refId:it})},g=()=>{o!==void 0&&e({type:o,label:r,refId:it})};return s.createElement(s.Fragment,null,s.createElement(C.Z,null,s.createElement(O._,{label:"Query type",labelWidth:20},s.createElement(te.Ph,{"aria-label":"Query type",onChange:c,onBlur:g,value:o,options:ba,width:32}))),o===1&&s.createElement(C.Z,null,s.createElement(O._,{label:"Label",labelWidth:20},s.createElement(te.Ph,{"aria-label":"Label",onChange:p,onBlur:g,value:{label:r,value:r},options:l,width:32,allowCustomValue:!0}))))};var X=u(1497);class ot extends T.iL{constructor(t,a){super(),this.request=async(r,n={})=>(await this.datasource.metadataRequest(r,n))?.data,this.start=async()=>(this.startTask||(this.startTask=this.fetchTags().then(()=>[])),this.startTask),this.setV1Tags=r=>{this.tagsV1=r},this.setV2Tags=r=>{this.tagsV2=r},this.getTags=r=>this.tagsV2&&r?r===L.NM.Unscoped?Ue(this.tagsV2):rt(this.tagsV2,r):this.tagsV1?(this.tagsV1.find(n=>n==="status")||this.tagsV1.push("status"),this.tagsV1):[],this.getMetricsSummaryTags=r=>this.tagsV2&&r?r===L.NM.Unscoped?Ue(this.tagsV2):rt(this.tagsV2,r):this.tagsV1?this.tagsV1:[],this.getTraceqlAutocompleteTags=r=>{if(this.tagsV2){if(r){if(r===L.NM.Unscoped)return Ue(this.tagsV2)}else return Ue(this.tagsV2);return rt(this.tagsV2,r)}else if(this.tagsV1)return this.tagsV1.find(n=>n==="status")||this.tagsV1.push("status"),this.tagsV1;return[]},this.getAutocompleteTags=()=>this.tagsV2?Ra(this.tagsV2):this.tagsV1?(this.tagsV1.find(r=>r==="status.code")||this.tagsV1.push("status.code"),this.tagsV1):[],this.encodeTag=r=>encodeURIComponent(encodeURIComponent(r)),this.datasource=t,Object.assign(this,a)}async fetchTags(){let t,a;try{a=await this.request("/api/v2/search/tags",[])}catch{t=await this.request("/api/search/tags",[])}a&&a.scopes?this.setV2Tags(a.scopes):t&&this.setV1Tags(t.tagNames)}async getOptionsV1(t){const a=this.encodeTag(t),r=await this.request(`/api/search/tag/${a}/values`);let n=[];return r&&r.tagValues&&(n=r.tagValues.map(o=>({value:o,label:o}))),n}async getOptionsV2(t,a){const r=this.encodeTag(t),n=await this.request(`/api/v2/search/tag/${r}/values`,a?{q:a}:{});let o=[];return n&&n.tagValues&&n.tagValues.forEach(i=>{i.value&&o.push({type:i.type,value:i.value,label:i.value})}),o}}var Nt=u(53305),xa=u(7906);function Da(e,t,a){let r;if(!e.length)return Ce;const n={};e.forEach(i=>{const l=Na(i.series,t);i.series.forEach(d=>{n[d.key]={name:`${d.key}`,type:H.fS.string,config:Va(d,l,a),values:[]}})}),r=(0,Nt.at)({name:"Metrics Summary",refId:"metrics-summary",fields:[...Object.values(n).sort((i,l)=>i.name.localeCompare(l.name)),{name:"kind",type:H.fS.string,config:{displayNameFromDS:"Kind",custom:{width:150}}},{name:"spanCount",type:H.fS.number,config:{displayNameFromDS:"Span count",custom:{width:150}}},{name:"errorPercentage",type:H.fS.number,config:{displayNameFromDS:"Error",unit:"percent",custom:{width:150}}},Fe("p50"),Fe("p90"),Fe("p95"),Fe("p99")],meta:{preferredVisualisationType:"table"}});const o=e.map(Ia);r.length=o.length;for(const i of o)for(const l of r.fields)l.values.push(i[l.name]);return r=(0,Nt.aK)(r,0),[r]}const Ia=e=>{const t=e.errorSpanCount?me(e.errorSpanCount)/me(e.spanCount)*100:"0%",a={kind:"server",spanCount:me(e.spanCount),errorPercentage:t,p50:me(e.p50),p90:me(e.p90),p95:me(e.p95),p99:me(e.p99)};return e.series.forEach(r=>{a[`${r.key}`]=Ma(r)||""}),a},Na=(e,t)=>{const a=e.map(o=>{const i=o.value.type===3||o.value.type===4,l=o.value.type===8||o.value.type===9,d=i||l?"":'"';return`${o.key}=${d}\${__data.fields["`+o.key+`"]}${d}`});let r="";const n=t.indexOf("}");if(n!==-1){const o=t.substring(n+1);r=t.substring(0,n),a.length>0&&(r+=t.replace(/\s/g,"").includes("{}")?"":" && ",r+=`${a.join(" && ")} && kind=server`,r+="}"),r+=`${o}`}else r=`{${a.join(" && ")} && kind=server} | ${t}`;return r},Va=(e,t,a)=>{const r={displayNameFromDS:e.key,noValue:"<no value>",links:[{title:"Query in explore",url:"",internal:{datasourceUid:a.uid,datasourceName:a.name,query:{query:t,queryType:"traceql"}}}]};return e.value.type===7?{...r,unit:"ns"}:{...r}},We="",Ma=e=>{if(!e.value.type)return We;switch(e.value.type){case 3:return e.value.n;case 4:return e.value.f;case 5:return e.value.s;case 6:return e.value.b;case 7:return e.value.d;case 8:return La(e.value.status);case 9:return Aa(e.value.kind);default:return We}},La=e=>{if(!e)return We;switch(e){case 0:return"error";case 1:return"ok";default:return"unset"}},Aa=e=>{if(!e)return We;switch(e){case 1:return"internal";case 2:return"client";case 3:return"server";case 4:return"producer";case 5:return"consumer";default:return"unspecified"}},Fe=e=>({name:e,type:H.fS.number,config:{displayNameFromDS:e,unit:"ns",custom:{width:150}}}),me=e=>{const t=parseInt(e,10);return isNaN(t)?0:t},Ce=new xa.v({name:"Metrics Summary",refId:"metrics-summary",fields:[],meta:{preferredVisualisationType:"table"}});var he=u(94776),wa=u(53072),ut=u(34032),$a=u(48614),_a=u(60695),Ua=u(16843);async function Wa(){return(0,ut.Z)()}function Fa(e,t,a,r){const n=a.range;let o,i=ne.Gu.NotStarted;return(0,wa.P)(()=>Wa()).pipe((0,Ae.z)(l=>{const d=performance.now();return(0,Ua.gj)().getStream({scope:$a.z.DataSource,namespace:t.uid,path:`search/${l}`,data:{...e,SpansPerSpanSet:e.spss??xe,timeRange:{from:n.from.toISOString(),to:n.to.toISOString()}}}).pipe((0,Z.U)(c=>{if("message"in c&&c?.message){const g=performance.now()-d,m=c.message.data.values[0][0],h=c.message.data.values[1][0],R=c.message.data.values[2][0],k=c.message.data.values[3][0];switch(R){case L.sY.Done:i=ne.Gu.Done;break;case L.sY.Streaming:i=ne.Gu.Streaming;break;case L.sY.Error:throw new Error(k)}o=[Ba(h,R,g),...(0,he.KZ)(m,r,e.tableType)]}return{data:o||[],state:i}}))}))}function Ba(e,t,a){const r={steps:[{color:"blue",value:-1/0},{color:"green",value:75}],mode:_a.H.Absolute};return{refId:"streaming-progress",name:"Streaming Progress",length:1,fields:[{name:"state",type:H.fS.string,values:[(0,z.capitalize)(t.toString())],config:{displayNameFromDS:"State"}},{name:"elapsedTime",type:H.fS.number,values:[a],config:{unit:"ms",displayNameFromDS:"Elapsed Time"}},{name:"totalBlocks",type:H.fS.number,values:[e.totalBlocks],config:{displayNameFromDS:"Total Blocks"}},{name:"completedJobs",type:H.fS.number,values:[e.completedJobs],config:{displayNameFromDS:"Completed Jobs"}},{name:"totalJobs",type:H.fS.number,values:[e.totalJobs],config:{displayNameFromDS:"Total Jobs"}},{name:"progress",type:H.fS.number,values:[t===L.sY.Done?100:(e.completedJobs||0)/(e.totalJobs||1)*100],config:{displayNameFromDS:"Progress",unit:"percent",min:0,max:100,custom:{cellOptions:{type:"gauge",mode:"gradient"}},thresholds:r}}],meta:{preferredVisualisationType:"table"}}}var ja=u(95405);class ka extends ja.Mg{constructor(t){super(),this.datasource=t,this.editor=Ca}query(t){if(!this.datasource)throw new Error("Datasource not initialized");const a=this.datasource.executeVariableQuery(t.targets[0]);return(0,Je.D)(a).pipe((0,Z.U)(r=>({data:r})))}}const fe=20,xe=3;var Ga=(e=>(e.streaming="streaming",e))(Ga||{});const Ya={streaming:"2.2.0"},Xa="2.1.0";class Ka extends pa.CK{constructor(t,a=(0,pe.J)()){super(t),this.instanceSettings=t,this.templateSrv=a,this.uploadedJson=null,this.init=async()=>{const r=await(0,qe.n)(this._request("/api/status/buildinfo").pipe((0,Z.U)(n=>n),(0,ye.K)(n=>(console.error("Failure in retrieving build information",n.data.message),(0,j.of)({error:n,data:{version:null}})))));this.tempoVersion=r.data.version},this.handleMetricsSummary=(r,n,o)=>{if((0,V.ff)("grafana_traces_metrics_summary_queried",{datasourceType:"tempo",app:o.app??"",grafana_version:y.config.buildInfo.version,filterCount:r.groupBy?.length??0}),n==="{}")return(0,j.of)({error:{message:"Please ensure you do not have an empty query. This is so filters are applied and the metrics summary is not generated from all spans."},data:Ce});const i=r.groupBy?this.formatGroupBy(r.groupBy):"";return this._request("/api/metrics/summary",{q:n,groupBy:i,start:o.range.from.unix(),end:o.range.to.unix()}).pipe((0,Z.U)(l=>l.data.summaries?l.data.summaries.some(c=>c.series.length>0)?{data:Da(l.data.summaries,n,this.instanceSettings)}:{error:{message:x("No series data. Ensure you are using an up to date version of Tempo")},data:Ce}:{error:{message:x(`No summary data for '${i}'. Note: the metrics summary API only considers spans of kind = server. You can check if the attributes exist by running a TraceQL query like { attr_key = attr_value && kind = server }`)},data:Ce}),(0,ye.K)(l=>(0,j.of)({error:{message:x(l.data.message)},data:Ce})))},this.formatGroupBy=r=>r?.filter(n=>n.tag).map(n=>n.scope===L.NM.Unscoped?`.${n.tag}`:n.scope!==L.NM.Intrinsic?`${n.scope}.${n.tag}`:n.tag).join(", "),this.hasGroupBy=r=>r.groupBy?.find(n=>n.tag),this.getLokiSearchDS=()=>{const r=this.tracesToLogs?.lokiSearch!==!1&&this.lokiSearch===void 0?this.tracesToLogs?.datasourceUid:void 0;return this.lokiSearch?.datasourceUid??r},this.tracesToLogs=t.jsonData.tracesToLogs,this.serviceMap=t.jsonData.serviceMap,this.search=t.jsonData.search,this.nodeGraph=t.jsonData.nodeGraph,this.lokiSearch=t.jsonData.lokiSearch,this.traceQuery=t.jsonData.traceQuery,this.languageProvider=new ot(this),this.search?.filters||(this.search={...this.search,filters:[{id:"service-name",tag:"service.name",operator:"=",scope:L.NM.Resource},{id:"span-name",tag:"name",operator:"=",scope:L.NM.Span}]}),this.variables=new ka(this)}async executeVariableQuery(t){if(t.type===void 0)return new Promise(()=>[]);switch(t.type){case st.LabelNames:return await this.labelNamesQuery();case st.LabelValues:return this.labelValuesQuery(t.label);default:throw Error("Invalid query type",t.type)}}async labelNamesQuery(){return await this.languageProvider.fetchTags(),this.languageProvider.getAutocompleteTags().filter(a=>a!==void 0).map(a=>({text:a}))}async labelValuesQuery(t){if(!t)return[];let a;try{const r=(this.languageProvider.tagsV2||[]).flatMap(o=>o.tags.map(i=>({scope:o.name,name:i}))).find(o=>o.name===t)?.scope;if(!r)throw Error(`Scope for tag ${t} not found`);const n=r==="intrinsic"?t:`${r}.${t}`;a=await this.languageProvider.getOptionsV2(n)}catch{a=await this.languageProvider.getOptionsV1(t)}return a.filter(r=>r.value!==void 0).map(r=>({text:r.value}))}isFeatureAvailable(t){const a=this.tempoVersion??Xa;try{return da().gte(a,Ya[t])}catch{return!0}}query(t){const a=[],r=t.targets.filter(i=>!i.hide),n=(0,z.groupBy)(r,i=>i.queryType||"traceql");if(n.clear)return(0,j.of)({data:[],state:ne.Gu.Done});const o=this.getLokiSearchDS();if(o&&n.search?.length>0){(0,V.ff)("grafana_traces_loki_search_queried",{datasourceType:"tempo",app:t.app??"",grafana_version:y.config.buildInfo.version,hasLinkedQueryExpr:!!(n.search[0].linkedQuery?.expr&&n.search[0].linkedQuery?.expr!=="")});const i=(0,$e.ak)();a.push((0,Je.D)(i.get(o)).pipe((0,Ae.z)(l=>{const d={...t,targets:n.search.map(g=>g.linkedQuery)},p=l.instanceSettings.jsonData.derivedFields?.filter(g=>g.datasourceUid===this.uid&&g.matcherRegex).map(g=>g.matcherRegex)||[];return!p||p.length===0?(0,la._)(()=>new Error("No Loki datasource configured for search. Set up Derived Fields for traces in a Loki datasource settings and link it to this Tempo datasource.")):l.query(d).pipe((0,Z.U)(g=>g.error?g:(0,he.RY)(g,this.uid,this.name,p)))})))}if(n.nativeSearch?.length)try{(0,V.ff)("grafana_traces_search_queried",{datasourceType:"tempo",app:t.app??"",grafana_version:y.config.buildInfo.version,hasServiceName:!!n.nativeSearch[0].serviceName,hasSpanName:!!n.nativeSearch[0].spanName,resultLimit:n.nativeSearch[0].limit??"",hasSearch:!!n.nativeSearch[0].search,minDuration:n.nativeSearch[0].minDuration??"",maxDuration:n.nativeSearch[0].maxDuration??""});const i={startTime:t.range.from.unix(),endTime:t.range.to.unix()},l=this.applyVariables(n.nativeSearch[0],t.scopedVars),d=this.buildSearchQuery(l,i);a.push(this._request("/api/search",d).pipe((0,Z.U)(c=>({data:[(0,he.n4)(c.data.traces,this.instanceSettings)]})),(0,ye.K)(c=>(0,j.of)({error:{message:x(c.data.message)},data:[]}))))}catch(i){return(0,j.of)({error:{message:i instanceof Error?i.message:"Unknown error occurred"},data:[]})}if(n.traceql?.length)try{const l=this.applyVariables(n.traceql[0],t.scopedVars)?.query||"",d=/^[0-9A-Fa-f]*$/;l.trim().match(d)?((0,V.ff)("grafana_traces_traceID_queried",{datasourceType:"tempo",app:t.app??"",grafana_version:y.config.buildInfo.version,hasQuery:l!==""}),a.push(this.handleTraceIdQuery(t,n.traceql))):((0,V.ff)("grafana_traces_traceql_queried",{datasourceType:"tempo",app:t.app??"",grafana_version:y.config.buildInfo.version,query:l??"",streaming:y.config.featureToggles.traceQLStreaming}),y.config.featureToggles.traceQLStreaming&&this.isFeatureAvailable("streaming")?a.push(this.handleStreamingSearch(t,n.traceql,l)):a.push(this._request("/api/search",{q:l,limit:t.targets[0].limit??fe,spss:t.targets[0].spss??xe,start:t.range.from.unix(),end:t.range.to.unix()}).pipe((0,Z.U)(c=>({data:(0,he.KZ)(c.data.traces,this.instanceSettings,n.traceql[0].tableType)})),(0,ye.K)(c=>(0,j.of)({error:{message:x(c.data.message)},data:[]})))))}catch(i){return(0,j.of)({error:{message:i instanceof Error?i.message:"Unknown error occurred"},data:[]})}if(n.traceqlSearch?.length)try{if(y.config.featureToggles.metricsSummary){const l=n.traceqlSearch.find(d=>this.hasGroupBy(d));l&&a.push(this.handleMetricsSummary(l,tt(l.filters),t))}const i=y.config.featureToggles.metricsSummary?n.traceqlSearch.filter(l=>!this.hasGroupBy(l)):n.traceqlSearch;if(i.length>0){const l=tt(i[0].filters),d=this.templateSrv.replace(l,t.scopedVars);(0,V.ff)("grafana_traces_traceql_search_queried",{datasourceType:"tempo",app:t.app??"",grafana_version:y.config.buildInfo.version,query:d??"",streaming:y.config.featureToggles.traceQLStreaming}),y.config.featureToggles.traceQLStreaming&&this.isFeatureAvailable("streaming")?a.push(this.handleStreamingSearch(t,i,d)):a.push(this._request("/api/search",{q:d,limit:t.targets[0].limit??fe,spss:t.targets[0].spss??xe,start:t.range.from.unix(),end:t.range.to.unix()}).pipe((0,Z.U)(c=>({data:(0,he.KZ)(c.data.traces,this.instanceSettings,n.traceqlSearch[0].tableType)})),(0,ye.K)(c=>(0,j.of)({error:{message:x(c.data.message)},data:[]}))))}}catch(i){return(0,j.of)({error:{message:i instanceof Error?i.message:"Unknown error occurred"},data:[]})}if(n.upload?.length)if(this.uploadedJson){(0,V.ff)("grafana_traces_json_file_uploaded",{datasourceType:"tempo",app:t.app??"",grafana_version:y.config.buildInfo.version});const i=JSON.parse(this.uploadedJson),l=i.batches,d=Array.isArray(i)&&i.some(c=>c?.meta?.preferredVisualisationType==="nodeGraph");l?a.push((0,j.of)((0,he.IM)(i.batches,this.nodeGraph?.enabled))):d?a.push((0,j.of)({data:i,state:ne.Gu.Done})):a.push((0,j.of)({error:{message:"Unable to parse uploaded data."},data:[]}))}else a.push((0,j.of)({data:[],state:ne.Gu.Done}));if(this.serviceMap?.datasourceUid&&n.serviceMap?.length>0){(0,V.ff)("grafana_traces_service_graph_queried",{datasourceType:"tempo",app:t.app??"",grafana_version:y.config.buildInfo.version,hasServiceMapQuery:!!n.serviceMap[0].serviceMapQuery});const i=this.serviceMap.datasourceUid,l=this.uid;a.push(za(t,i,l).pipe((0,Rt.b)(d=>Za(t,d,i).pipe((0,Rt.b)(c=>Ha(t,c,i,l))))))}return(0,Qt.T)(...a)}applyTemplateVariables(t,a){return this.applyVariables(t,a)}interpolateVariablesInQueries(t,a){return!t||t.length===0?[]:t.map(r=>({...r,datasource:this.getRef(),...this.applyVariables(r,a)}))}applyVariables(t,a){const r={...t};return t.linkedQuery&&(r.linkedQuery={...t.linkedQuery,expr:this.templateSrv.replace(t.linkedQuery?.expr??"",a)}),{...r,query:this.templateSrv.replace(t.query??"",a,be.b8.Pipe),serviceName:this.templateSrv.replace(t.serviceName??"",a),spanName:this.templateSrv.replace(t.spanName??"",a),search:this.templateSrv.replace(t.search??"",a),minDuration:this.templateSrv.replace(t.minDuration??"",a),maxDuration:this.templateSrv.replace(t.maxDuration??"",a)}}handleTraceIdQuery(t,a){const r=a.filter(o=>o.query).map(o=>({...o,query:o.query?.trim(),queryType:"traceId"}));if(!r.length)return Pt.E;const n=this.traceIdQueryRequest(t,r);return super.query(n).pipe((0,Z.U)(o=>o.error?o:(0,he.Jk)(o,this.nodeGraph?.enabled)))}traceIdQueryRequest(t,a){const r={...t,targets:a};return this.traceQuery?.timeShiftEnabled?r.range=t.range&&{...t.range,from:t.range.from.subtract(bt.intervalToMs(this.traceQuery?.spanStartTimeShift||"30m"),"milliseconds"),to:t.range.to.add(bt.intervalToMs(this.traceQuery?.spanEndTimeShift||"30m"),"milliseconds")}:r.range={from:(0,we.CQ)(0),to:(0,we.CQ)(0),raw:{from:(0,we.CQ)(0),to:(0,we.CQ)(0)}},r}handleStreamingSearch(t,a,r){return r===""?Pt.E:(0,Qt.T)(...a.map(n=>Fa({...n,query:r},this,t,this.instanceSettings)))}async metadataRequest(t,a={}){return await(0,qe.n)(this._request(t,a,{method:"GET",hideFromInspector:!0}))}_request(t,a,r){const n=a?(0,ma.tW)(a):"",o=`${this.instanceSettings.url}${t}${n.length?`?${n}`:""}`,i={...r,url:o};return(0,Te.i)().fetch(i)}async testDatasource(){const t={headers:{},method:"GET",url:`${this.instanceSettings.url}/api/echo`};return await(0,qe.n)((0,Te.i)().fetch(t).pipe((0,Ae.z)(()=>(0,j.of)({status:"success",message:"Data source successfully connected."})),(0,ye.K)(a=>(0,j.of)({status:"error",message:x(a.data.message,"Unable to connect with Tempo")}))))}getQueryDisplayText(t){if(t.queryType==="nativeSearch"){let a=[];for(const r of["serviceName","spanName","search","minDuration","maxDuration","limit"])t.hasOwnProperty(r)&&t[r]&&a.push(`${(0,z.startCase)(r)}: ${t[r]}`);return a.join(", ")}return t.query??""}buildSearchQuery(t,a){let r=t.search??"",n=(0,z.pick)(t,["minDuration","maxDuration","limit"]);if(n=(0,z.pickBy)(n,z.identity),t.serviceName&&(r+=` service.name="${t.serviceName}"`),t.spanName&&(r+=` name="${t.spanName}"`),n.limit||(n.limit=fe),n.minDuration){if(n.minDuration=this.templateSrv.replace(n.minDuration??""),!(0,Me.IA)(n.minDuration))throw new Error("Please enter a valid min duration.");n.minDuration=n.minDuration.replace(/\s/g,"")}if(n.maxDuration){if(n.maxDuration=this.templateSrv.replace(n.maxDuration??""),!(0,Me.IA)(n.maxDuration))throw new Error("Please enter a valid max duration.");n.maxDuration=n.maxDuration.replace(/\s/g,"")}if(!Number.isInteger(n.limit)||n.limit<=0)throw new Error("Please enter a valid limit.");let o={tags:r,...n};return a&&(o.start=a.startTime,o.end=a.endTime),o}}function lt(e,t){return(0,Je.D)((0,$e.ak)().get(t)).pipe((0,Ae.z)(a=>a.query(e)))}function za(e,t,a){const r=ct(e);return lt(r,t).pipe((0,et.q)(),(0,Z.U)(n=>{const o=n.find(p=>!!p.error);if(o)throw new Error(x(o.error?.message));const{nodes:i,edges:l}=(0,X.BC)(n,e.range);if(i.fields.length>0&&l.fields.length>0){const p=i.fields[0].values.length,g=l.fields[0].values.length;(0,V.ff)("grafana_traces_service_graph_size",{datasourceType:"tempo",grafana_version:y.config.buildInfo.version,nodeLength:p,edgeLength:g})}const{serviceMapIncludeNamespace:d,refId:c}=e.targets[0];return i.refId=c,l.refId=c,d?(i.fields[0].config=Be(t,a,"__data.fields.title","__data.fields[0]",void 0,{targetNamespace:"__data.fields.subtitle"}),l.fields[0].config=Be(t,a,"__data.fields.targetName","__data.fields.target","__data.fields.sourceName",{targetNamespace:"__data.fields.targetNamespace",sourceNamespace:"__data.fields.sourceNamespace"})):(i.fields[0].config=Be(t,a,"__data.fields.id","__data.fields[0]"),l.fields[0].config=Be(t,a,"__data.fields.target","__data.fields.target","__data.fields.source")),{nodes:i,edges:l,state:ne.Gu.Done}}))}function Za(e,t,a){const r=ct(e);return r.targets=Lt([Oe(X.rB,X.T1,e)]),lt(r,a).pipe((0,et.q)(),(0,Z.U)(n=>{const o=n.find(i=>!!i.error);if(o)throw new Error(x(o.error?.message));return{rates:n[0]?.data??[],nodes:t.nodes,edges:t.edges}}))}function Ha(e,t,a,r){let n=[],o="",i=[],l=[];if(t.rates[0]&&e.app===ga.zj.Explore){const p=t.rates[0].fields.find(g=>g.name==="span_name");p&&p.values&&(l=p.values)}else t.rates&&t.rates.map(p=>{const g=p.fields.find(m=>m.labels?.span_name);g&&l.push(g.labels?.span_name)});const d=qa(l);d.length>0&&(o=Oe(X.$C,'span_name=~"'+d.join("|")+'"',e),n.push(o),d.map(p=>{const g=Oe(X.vO,'span_name=~"'+p+'"',e);i.push(g),n.push(g)}));const c=ct(e);return c.targets=Lt(n),lt(c,a).pipe((0,et.q)(),(0,Z.U)(p=>{const g=p.find(h=>!!h.error);if(g)throw new Error(x(g.error?.message));const m=Ja(e,t,p[0],o,i,a,r);return m.fields.length===0?{data:[t.nodes,t.edges],state:ne.Gu.Done}:{data:[m,t.nodes,t.edges],state:ne.Gu.Done}}))}function Ee(e,t,a,r){return{url:"",title:e,internal:{query:{expr:t,range:!r,exemplar:!r,instant:r},datasourceUid:a,datasourceName:(0,$e.ak)().getDataSourceSettingsByUid(a)?.name??""}}}function qa(e){return e.map(t=>t.replace(/[.*+?^${}()|[\]\\]/g,"\\\\$&"))}function Be(e,t,a,r,n,o){let i=n?`client="\${${n}}",`:"",l=`server="\${${a}}"`,d="server";if(o!==void 0){const{targetNamespace:c}=o;if(l+=`,server_service_namespace="\${${c}}"`,d+=", server_service_namespace",i){const{sourceNamespace:p}=o;i+=`client_service_namespace="\${${p}}",`,d+=", client_service_namespace"}}return{links:[Ee("Request rate",`sum by (client, ${d})(rate(${X.Yt}{${i}${l}}[$__rate_interval]))`,e,!1),Ee("Request histogram",`histogram_quantile(0.9, sum(rate(${X.NZ}{${i}${l}}[$__rate_interval])) by (le, client, ${d}))`,e,!1),Ee("Failed request rate",`sum by (client, ${d})(rate(${X.yf}{${i}${l}}[$__rate_interval]))`,e,!1),Vt("View traces",`\${${r}}`,"",t)]}}function Vt(e,t,a,r){let n={refId:"A",queryType:"traceqlSearch",filters:[]};return t!==""&&n.filters.push({id:"service-name",scope:L.NM.Resource,tag:"service.name",value:t,operator:"=",valueType:"string"}),a!==""&&n.filters.push({id:"span-name",scope:L.NM.Span,tag:"name",value:a,operator:"=",valueType:"string"}),{url:"",title:e,internal:{query:n,datasourceUid:r,datasourceName:(0,$e.ak)().getDataSourceSettingsByUid(r)?.name??""}}}function ct(e){return{...e,targets:X.t3.map(t=>{const{serviceMapQuery:a,serviceMapIncludeNamespace:r}=e.targets[0];return{format:"table",refId:t,expr:`sum by (client, server${r?", client_service_namespace, server_service_namespace":""}) (rate(${t}${a||""}[$__range]))`,instant:!0}})}}function Ja(e,t,a,r,n,o,i){let l={fields:[]};const d=t.rates.filter(g=>g.refId===Oe(X.rB,X.T1,e)),c=a.data.filter(g=>g.refId===r),p=a.data.filter(g=>n.includes(g.refId??""));if(d.length>0&&d[0].fields?.length>2&&(l.fields.push({...d[0].fields[1],name:"Name",config:{filterable:!1}}),l.fields.push({...d[0].fields[2],name:"Rate",config:{links:[Ee("Rate",dt(Oe(X.rB,'span_name="${__data.fields[0]}"',e)),o,!1)],decimals:2}}),l.fields.push({...d[0].fields[2],name:"  ",labels:null,config:{color:{mode:"continuous-BlPu"},custom:{cellOptions:{mode:be.QH.Lcd,type:be.h2.Gauge}},decimals:3}})),c.length>0&&c[0].fields?.length>2){const g=c[0].fields[1]?.values??[],m=c[0].fields[2]?.values??[];let h={};g.map((k,b)=>{h[k]={value:m[b]}});const R=Mt({...d},h);l.fields.push({...c[0].fields[2],name:"Error Rate",values:R,config:{links:[Ee("Error Rate",dt(Oe(X.$C,'span_name="${__data.fields[0]}"',e)),o,!1)],decimals:2}}),l.fields.push({...c[0].fields[2],name:"   ",values:R,labels:null,config:{color:{mode:"continuous-RdYlGr"},custom:{cellOptions:{mode:be.QH.Lcd,type:be.h2.Gauge}},decimals:3}})}if(p.length>0){let g={};p.forEach(m=>{if(m.fields.length>1){const h=m.refId?.includes('span_name=~"')?'span_name=~"':'span_name="',R=m.refId?.split(h)[1].split('"}')[0];g[R]={value:m.fields[1].values[0]}}}),Object.keys(g).length>0&&l.fields.push({...p[0].fields[1],name:"Duration (p90)",values:Mt({...d},g),config:{links:[Ee("Duration",dt(Oe(X.vO,'span_name="${__data.fields[0]}"',e)),o,!1)],unit:"s"}})}return l.fields.length>0&&l.fields[0].values&&l.fields.push({name:"Links",type:H.fS.string,values:l.fields[0].values.map(()=>"Tempo"),config:{links:[Vt("Tempo","","${__data.fields[0]}",i)]}}),l}function Oe(e,t,a){let r=a.targets[0]?.serviceMapQuery??"";const n=r.match(/^{(.*)}$/);n?.length&&(r=n[1]),r=r.replace("client","service").replace("server","service");const o=r.includes("span_name")?e.params.concat(r):e.params.concat(r).concat(t).filter(i=>i);return e.expr.replace("{}","{"+o.join(",")+"}")}function dt(e){return e=e.replace("topk(5, ","").replace(" by (span_name))",""),e.replace("__range","__rate_interval")}function Mt(e,t){const a=e[0]?.fields[1]?.values??[];let r=[];for(let n=0;n<a.length;n++)Object.keys(t).includes(a[n])?r.push(t[a[n]].value):r.push("0");return r}function Lt(e){return e.map(t=>({refId:t,expr:t,instant:!0}))}var At=u(84541),Qe=u(59138);class er{constructor(t){this.triggerCharacters=["="," "],this.cachedValues={},this.languageProvider=t.languageProvider}provideCompletionItems(t,a){if(!(this.monaco&&this.editor))throw new Error("provideCompletionItems called before CompletionProvider was initialized");if(this.editor.getModel()?.id!==t.id)return{suggestions:[]};const{range:r,offset:n}=ar(this.monaco,t,a),o=this.getSituation(t.getValue(),n);return this.getCompletions(o).then(l=>{const d=l.length.toString().length;return{suggestions:l.map((p,g)=>({kind:tr(p.type,this.monaco),label:p.label,insertText:p.insertText,sortText:g.toString().padStart(d,"0"),range:r}))}})}async getTagValues(t){let a;return this.cachedValues.hasOwnProperty(t)?a=this.cachedValues[t]:(a=await this.languageProvider.getOptionsV1(t),this.cachedValues[t]=a),a}async getCompletions(t){switch(t.type){case"UNKNOWN":return[];case"EMPTY":return this.getTagsCompletions();case"IN_NAME":return this.getTagsCompletions();case"IN_VALUE":const a=await this.getTagValues(t.tagName),r=[],n=o=>`"${o.label}"`;return a.forEach(o=>{o?.label&&r.push({label:o.label,insertText:n(o),type:"TAG_VALUE"})}),r;default:throw new Error(`Unexpected situation ${t}`)}}getTagsCompletions(){return this.languageProvider.getAutocompleteTags().sort((a,r)=>a.localeCompare(r,void 0,{sensitivity:"accent"})).map(a=>({label:a,insertText:a,type:"TAG_NAME"}))}getSituation(t,a){if(t===""||a===0||t[t.length-1]===" ")return{type:"EMPTY"};const r=t.substring(0,a),n=/(?<key>[^= ]+)(?<equals>=)?(?<value>([^ "]+)|"([^"]*)")?/,o=r.match(new RegExp(n,"g"));if(o?.length){const l=o[o.length-1].match(n);if(l){const d=l.groups?.key,c=l.groups?.equals;return d?c?{type:"IN_VALUE",tagName:d}:{type:"IN_NAME"}:{type:"EMPTY"}}}return{type:"EMPTY"}}}function tr(e,t){switch(e){case"TAG_NAME":return t.languages.CompletionItemKind.Enum;case"KEYWORD":return t.languages.CompletionItemKind.Keyword;case"OPERATOR":return t.languages.CompletionItemKind.Operator;case"TAG_VALUE":return t.languages.CompletionItemKind.EnumMember;case"SCOPE":return t.languages.CompletionItemKind.Class;default:throw new Error(`Unexpected CompletionType: ${e}`)}}function ar(e,t,a){const r=t.getWordAtPosition(a),n=r!=null?e.Range.lift({startLineNumber:a.lineNumber,endLineNumber:a.lineNumber,startColumn:r.startColumn,endColumn:r.endColumn}):e.Range.fromPositions(a),o={column:a.column,lineNumber:a.lineNumber};return{offset:t.getOffsetAt(o),range:n}}const rr={id:"tagsfield",extensions:[".tagsfield"],aliases:["tagsfield"],mimetypes:[],def:{language:{ignoreCase:!1,defaultToken:"",tokenPostfix:".tagsfield",operators:["="],symbols:/[=><!~?:&|+\-*\/^%]+/,escapes:/\\(?:[abfnrtv\\"']|x[0-9A-Fa-f]{1,4}|u[0-9A-Fa-f]{4}|U[0-9A-Fa-f]{8})/,digits:/\d+(_+\d+)*/,octaldigits:/[0-7]+(_+[0-7]+)*/,binarydigits:/[0-1]+(_+[0-1]+)*/,hexdigits:/[[0-9a-fA-F]+(_+[0-9a-fA-F]+)*/,integersuffix:/(ll|LL|u|U|l|L)?(ll|LL|u|U|l|L)?/,floatsuffix:/[fFlL]?/,tokenizer:{root:[[/[a-z_.][\w./_-]*(?=\s*(=|!=|>|<|>=|<=|=~|!~))/,"tag"],[/[a-zA-Z_.]\w*/,{cases:{"@default":"identifier"}}],[/"([^"\\]|\\.)*$/,"string.invalid"],[/'([^'\\]|\\.)*$/,"string.invalid"],[/"/,"string","@string_double"],[/'/,"string","@string_single"],{include:"@whitespace"},[/[{}()\[\]]/,"@brackets"],[/[<>](?!@symbols)/,"@brackets"],[/@symbols/,{cases:{"@operators":"delimiter","@default":""}}],[/\d+/,"number"],[/\d*\d+[eE]([\-+]?\d+)?(@floatsuffix)/,"number.float"],[/\d*\.\d+([eE][\-+]?\d+)?(@floatsuffix)/,"number.float"],[/0[xX][0-9a-fA-F']*[0-9a-fA-F](@integersuffix)/,"number.hex"],[/0[0-7']*[0-7](@integersuffix)/,"number.octal"],[/0[bB][0-1']*[0-1](@integersuffix)/,"number.binary"],[/\d[\d']*\d(@integersuffix)/,"number"],[/\d(@integersuffix)/,"number"]],string_double:[[/[^\\"]+/,"string"],[/@escapes/,"string.escape"],[/\\./,"string.escape.invalid"],[/"/,"string","@pop"]],string_single:[[/[^\\']+/,"string"],[/@escapes/,"string.escape"],[/\\./,"string.escape.invalid"],[/'/,"string","@pop"]],clauses:[[/[^(,)]/,"tag"],[/\)/,"identifier","@pop"]],whitespace:[[/[ \t\r\n]+/,"white"]]}},languageConfiguration:{wordPattern:/(-?\d*\.\d\w*)|([^`~!#%^&*()\-=+\[{\]}\\|;:'",.<>\/?\s]+)/g,brackets:[["{","}"],["(",")"]],autoClosingPairs:[{open:"{",close:"}"},{open:"(",close:")"},{open:'"',close:'"'},{open:"'",close:"'"}],surroundingPairs:[{open:"{",close:"}"},{open:"(",close:")"},{open:'"',close:'"'},{open:"'",close:"'"}],folding:{}}}};function nr(e){const{onChange:t,onBlur:a,placeholder:r}=e,n=or(e.datasource),o=(0,_.l4)(),i=lr(o,r);return s.createElement(At.p,{value:e.value,language:De,onBlur:a,onChange:t,containerStyles:i.queryField,monacoOptions:{folding:!1,fontSize:14,lineNumbers:"off",overviewRulerLanes:0,renderLineHighlight:"none",scrollbar:{vertical:"hidden",verticalScrollbarSize:8,horizontal:"hidden",horizontalScrollbarSize:0},scrollBeyondLastLine:!1,wordWrap:"on"},onBeforeEditorMount:ur,onEditorDidMount:(l,d)=>{n(l,d),sr(l,d,i),ir(l)}})}function sr(e,t,a){const r=[{range:new t.Range(1,1,1,1),options:{className:a.placeholder,isWholeLine:!0}}];let n=[];const o=()=>{const i=e.getModel();if(!i)return;const l=i.getValueLength()===0?r:[];n=i.deltaDecorations(n,l)};o(),e.onDidChangeModelContent(o)}function ir(e){const t=e.getDomNode(),a=()=>{if(t){const r=Math.min(1e3,e.getContentHeight()),n=parseInt(t.style.width,10);t.style.width=`${n}px`,t.style.height=`${r}px`,e.layout({width:n,height:r})}};e.onDidContentSizeChange(a),a()}function or(e){const t=(0,s.useRef)(new er({languageProvider:e.languageProvider}));(0,s.useEffect)(()=>{(async()=>{try{await e.languageProvider.start()}catch(n){n instanceof Error&&(0,le.WI)((0,Qe.$l)((0,ue.t_)("Error",n)))}})()},[e]);const a=(0,s.useRef)(null);return(0,s.useEffect)(()=>()=>{a.current?.()},[]),(r,n)=>{t.current.editor=r,t.current.monaco=n;const{dispose:o}=n.languages.registerCompletionItemProvider(De,t.current);a.current=o}}let wt=!1;const De="tagsfield";function ur(e){if(!wt){wt=!0;const{aliases:t,extensions:a,mimetypes:r,def:n}=rr;e.languages.register({id:De,aliases:t,extensions:a,mimetypes:r}),e.languages.setMonarchTokensProvider(De,n.language),e.languages.setLanguageConfiguration(De,n.languageConfiguration)}}const lr=(e,t)=>({queryField:(0,S.css)`
      border-radius: ${e.shape.radius.default};
      border: 1px solid ${e.components.input.borderColor};
      flex: 1;
    `,placeholder:(0,S.css)`
      ::after {
        content: '${t}';
        font-family: ${e.typography.fontFamilyMonospace};
        opacity: 0.3;
      }
    `}),$t="e.g. 1.2s, 100ms",cr=({datasource:e,query:t,onChange:a,onBlur:r,onRunQuery:n})=>{const o=(0,_.wW)(dr),i=(0,s.useMemo)(()=>new ot(e),[e]),[l,d]=(0,s.useState)(),[c,p]=(0,s.useState)(),[g,m]=(0,s.useState)(null),[h,R]=(0,s.useState)({}),[k,b]=(0,s.useState)({serviceName:!1,spanName:!1}),U=(0,s.useCallback)(async(E,G="")=>{const Re=E==="serviceName"?"service.name":"name";b(K=>({...K,[E]:!0}));try{return(await i.getOptionsV1(Re)).filter(ve=>ve.value?(0,ua.C)(ve.value,G).found:!1)}catch(K){return(0,Te.kW)(K)&&K?.status===404?m(K):K instanceof Error&&(0,le.WI)((0,Et.$l)((0,ue.t_)("Error",K))),[]}finally{b(K=>({...K,[E]:!1}))}},[i]);(0,s.useEffect)(()=>{(async()=>{try{const[G,Re]=await Promise.all([U("serviceName"),U("spanName")]);t.serviceName&&(0,pe.J)().containsTemplate(t.serviceName)&&G.push((0,oe.E)(t.serviceName)),d(G),t.spanName&&(0,pe.J)().containsTemplate(t.spanName)&&Re.push((0,oe.E)(t.spanName)),p(Re)}catch(G){(0,Te.kW)(G)&&G?.status===404?m(G):G instanceof Error&&(0,le.WI)((0,Et.$l)((0,ue.t_)("Error",G)))}})()},[i,U,t.serviceName,t.spanName]);const ae=E=>{E.key==="Enter"&&(E.shiftKey||E.ctrlKey)&&n()},Ve=(0,s.useCallback)(E=>{a({...t,search:E})},[a,t]),Ze=(0,pe.J)();return s.createElement(s.Fragment,null,s.createElement("div",{className:o.container},s.createElement(Se.b,{title:"Deprecated query type",severity:"warning"},"This query type has been deprecated and will be removed in Grafana v10.3. Please migrate to another Tempo query type."),s.createElement(C.Z,null,s.createElement(O._,{label:"Service Name",labelWidth:14,grow:!0},s.createElement(te.Ph,{inputId:"service",options:l,onOpenMenu:()=>{U("serviceName")},isLoading:k.serviceName,value:l?.find(E=>E?.value===t.serviceName)||t.serviceName,onChange:E=>{a({...t,serviceName:E?.value})},placeholder:"Select a service",isClearable:!0,onKeyDown:ae,"aria-label":"select-service-name",allowCustomValue:!0}))),s.createElement(C.Z,null,s.createElement(O._,{label:"Span Name",labelWidth:14,grow:!0},s.createElement(te.Ph,{inputId:"spanName",options:c,onOpenMenu:()=>{U("spanName")},isLoading:k.spanName,value:c?.find(E=>E?.value===t.spanName)||t.spanName,onChange:E=>{a({...t,spanName:E?.value})},placeholder:"Select a span",isClearable:!0,onKeyDown:ae,"aria-label":"select-span-name",allowCustomValue:!0}))),s.createElement(C.Z,null,s.createElement(O._,{label:"Tags",labelWidth:14,grow:!0,tooltip:"Values should be in logfmt."},s.createElement(nr,{placeholder:"http.status_code=200 error=true",value:t.search||"",onChange:Ve,onBlur:r,datasource:e}))),s.createElement(C.Z,null,s.createElement(O._,{label:"Min Duration",invalid:!!h.minDuration,labelWidth:14,grow:!0},s.createElement(Le.I,{id:"minDuration",value:t.minDuration||"",placeholder:$t,onBlur:()=>{const E=Ze.replace(t.minDuration??"");t.minDuration&&!(0,Me.IA)(E)?R({...h,minDuration:!0}):R({...h,minDuration:!1})},onChange:E=>a({...t,minDuration:E.currentTarget.value}),onKeyDown:ae}))),s.createElement(C.Z,null,s.createElement(O._,{label:"Max Duration",invalid:!!h.maxDuration,labelWidth:14,grow:!0},s.createElement(Le.I,{id:"maxDuration",value:t.maxDuration||"",placeholder:$t,onBlur:()=>{const E=Ze.replace(t.maxDuration??"");t.maxDuration&&!(0,Me.IA)(E)?R({...h,maxDuration:!0}):R({...h,maxDuration:!1})},onChange:E=>a({...t,maxDuration:E.currentTarget.value}),onKeyDown:ae}))),s.createElement(C.Z,null,s.createElement(O._,{label:"Limit",invalid:!!h.limit,labelWidth:14,grow:!0,tooltip:"Maximum number of returned results"},s.createElement(Le.I,{id:"limit",value:t.limit||"",placeholder:`Default: ${fe}`,type:"number",onChange:E=>{let G=E.currentTarget.value?parseInt(E.currentTarget.value,10):void 0;G&&(!Number.isInteger(G)||G<=0)?R({...h,limit:!0}):R({...h,limit:!1}),a({...t,limit:E.currentTarget.value?parseInt(E.currentTarget.value,10):void 0})},onKeyDown:ae})))),g?s.createElement(Se.b,{title:"Unable to connect to Tempo search",severity:"info",className:o.alert},"Please ensure that Tempo is configured with search enabled. If you would like to hide this tab, you can configure it in the ",s.createElement("a",{href:`/datasources/edit/${e.uid}`},"datasource settings"),"."):null)},dr=e=>({container:(0,S.css)`
    max-width: 500px;
  `,alert:(0,S.css)`
    max-width: 75ch;
    margin-top: ${e.spacing(2)};
  `});var _t=u(87355),gr=u(6155),gt=u(46101),Ut=u(28448),pr=u(30736);const pt=s.memo(({onChange:e,query:t})=>{t.hasOwnProperty("limit")||(t.limit=fe),t.hasOwnProperty("tableType")||(t.tableType=L.Mt.Traces);const a=i=>{e({...t,limit:parseInt(i.currentTarget.value,10)})},r=i=>{e({...t,spss:parseInt(i.currentTarget.value,10)})},n=i=>{e({...t,tableType:i})},o=[`Limit: ${t.limit||fe}`,`Spans Limit: ${t.spss||xe}`,`Table Format: ${t.tableType===L.Mt.Traces?"Traces":"Spans"}`];return s.createElement(s.Fragment,null,s.createElement(_t.p,null,s.createElement(pr.d,{title:"Options",collapsedInfo:o},s.createElement(gt.S,{label:"Limit",tooltip:"Maximum number of traces to return."},s.createElement(Ut.H,{className:"width-4",placeholder:"auto",type:"number",min:1,defaultValue:t.limit||fe,onCommitChange:a,value:t.limit})),s.createElement(gt.S,{label:"Span Limit",tooltip:"Maximum number of spans to return for each span set."},s.createElement(Ut.H,{className:"width-4",placeholder:"auto",type:"number",min:1,defaultValue:t.spss||xe,onCommitChange:r,value:t.spss})),s.createElement(gt.S,{label:"Table Format",tooltip:"How the query data should be displayed in the results table"},s.createElement(D.S,{options:[{label:"Traces",value:L.Mt.Traces},{label:"Spans",value:L.Mt.Spans}],value:t.tableType,onChange:n})))))});pt.displayName="TempoQueryBuilderOptions";const mr=/^(\$\w+)|(\d+(?:\.\d)?\d*(?:us|µs|ns|ms|s|m|h))$/,hr=()=>({noBoxShadow:(0,S.css)`
    box-shadow: none;
    *:focus {
      box-shadow: none;
    }
  `}),Wt=({filter:e,operators:t,updateFilter:a})=>{const r=(0,_.wW)(hr);let n=!1;return typeof e.value=="string"&&(n=e.value?!mr.test(e.value.concat("")):!1),s.createElement(Q.Lh,{spacing:"none"},s.createElement(te.Ph,{className:r.noBoxShadow,inputId:`${e.id}-operator`,options:t.map(It),value:e.operator,onChange:o=>{a({...e,operator:o?.value})},isClearable:!1,"aria-label":`select ${e.id} operator`,allowCustomValue:!0,width:8}),s.createElement(Le.I,{className:r.noBoxShadow,value:e.value,onChange:o=>{a({...e,value:o.currentTarget.value})},placeholder:"e.g. 100ms, 1.2s","aria-label":`select ${e.id} value`,invalid:n,width:18}))};var je=u(81803);const ke=({label:e,tooltip:t,children:a})=>s.createElement(C.Z,null,s.createElement(O._,{label:e,labelWidth:28,grow:!0,tooltip:t},a)),fr=e=>{const{datasource:t,onChange:a,query:r,isTagsLoading:n}=e,o=(0,_.wW)(Or),i=()=>(0,ut.Z)().slice(0,8);(0,s.useEffect)(()=>{(!r.groupBy||r.groupBy.length===0)&&a({...r,groupBy:[{id:i(),scope:L.NM.Span}]})},[a,r]);const l=m=>t.languageProvider.getMetricsSummaryTags(m.scope),d=()=>{p({id:i(),scope:L.NM.Span})},c=m=>{a({...r,groupBy:r.groupBy?.filter(h=>h.id!==m.id)})},p=m=>{const h={...r};h.groupBy||=[];const R=h.groupBy.findIndex(k=>k.id===m.id);R>=0?h.groupBy=nt(h.groupBy,R,m):h.groupBy.push(m),a(h)},g=Object.values(L.NM).map(m=>({label:m,value:m}));return s.createElement(ke,{label:"Aggregate by",tooltip:"Select one or more tags to see the metrics summary. Note: the metrics summary API only considers spans of kind = server."},s.createElement(s.Fragment,null,r.groupBy?.map((m,h)=>s.createElement("div",{key:m.id},s.createElement(Q.Lh,{spacing:"none",width:"auto"},s.createElement(te.Ph,{"aria-label":`Select scope for filter ${h+1}`,onChange:R=>{p({...m,scope:R?.value,tag:""})},options:g,placeholder:"Select scope",value:m.scope}),s.createElement(te.Ph,{"aria-label":`Select tag for filter ${h+1}`,isClearable:!0,isLoading:n,key:m.tag,onChange:R=>{p({...m,tag:R?.value})},options:l(m)?.map(R=>({label:R,value:R})),placeholder:"Select tag",value:m.tag||""}),s.createElement(je._,{"aria-label":`Remove tag for filter ${h+1}`,icon:"times",onClick:()=>c(m),tooltip:"Remove tag",variant:"secondary"}),h===(r.groupBy?.length??0)-1&&s.createElement("span",{className:o.addFilter},s.createElement(je._,{"aria-label":"Add tag",icon:"plus",onClick:()=>d(),tooltip:"Add tag",variant:"secondary"})))))))},Or=e=>({addFilter:(0,S.css)`
    margin-left: ${e.spacing(2)};
  `}),vr=()=>({dropdown:(0,S.css)`
    box-shadow: none;
  `}),Ft=({filter:e,datasource:t,updateFilter:a,deleteFilter:r,isTagsLoading:n,tags:o,setError:i,hideScope:l,hideTag:d,hideValue:c,allowDelete:p,query:g})=>{const m=(0,_.wW)(vr),h=(0,s.useMemo)(()=>new ot(t),[t]),R=(0,s.useMemo)(()=>at(e),[e]),[k,b]=(0,s.useState)(e.operator),[U,ae]=(0,s.useState)(e.value),Ve=async()=>{try{return e.tag?await h.getOptionsV2(R,g):[]}catch(I){(0,Te.kW)(I)&&I?.status===404?i(I):I instanceof Error&&(0,le.WI)((0,Qe.$l)((0,ue.t_)("Error",I)))}return[]},{loading:Ze,value:E}=(0,N.Z)(Ve,[R,h,i,g]);e.value&&!Array.isArray(e.value)&&E&&!E.find(I=>I.value===e.value)&&E.push({label:e.value.toString(),value:e.value.toString(),type:e.valueType}),(0,s.useEffect)(()=>{Array.isArray(e.value)&&e.value.length>1&&e.operator!=="=~"&&(b(e.operator),a({...e,operator:"=~"})),Array.isArray(e.value)&&e.value.length<=1&&(U?.length||0)>1&&a({...e,operator:k,value:e.value[0]})},[U,k,a,e]),(0,s.useEffect)(()=>{ae(e.value)},[e.value]);const G=Object.values(L.NM).filter(I=>I!==L.NM.Intrinsic).map(I=>({label:I,value:I})),Re=E?.filter(I=>I.type===E[0]?.type),K=E?.length===Re?.length?E?.[0]?.type:void 0;let He=Ct;switch(K){case"string":He=fa;break;case"int":case"float":He=Oa}const ve=I=>{const yt=(0,pe.J)().getVariables();return[...I||[],...yt.map(oa=>({label:`$${oa.name}`,value:`$${oa.name}`}))]};return s.createElement(Q.Lh,{spacing:"none",width:"auto"},!l&&s.createElement(te.Ph,{className:m.dropdown,inputId:`${e.id}-scope`,options:ve(G),value:e.scope,onChange:I=>{a({...e,scope:I?.value})},placeholder:"Select scope","aria-label":`select ${e.id} scope`}),!d&&s.createElement(te.Ph,{className:m.dropdown,inputId:`${e.id}-tag`,isLoading:n,options:ve((e.tag!==void 0?(0,z.uniq)([e.tag,...o]):o).map(I=>({label:I,value:I}))),value:e.tag,onChange:I=>{a({...e,tag:I?.value})},placeholder:"Select tag",isClearable:!0,"aria-label":`select ${e.id} tag`,allowCustomValue:!0}),s.createElement(te.Ph,{className:m.dropdown,inputId:`${e.id}-operator`,options:ve(He.map(It)),value:e.operator,onChange:I=>{a({...e,operator:I?.value})},isClearable:!1,"aria-label":`select ${e.id} operator`,allowCustomValue:!0,width:8}),!c&&s.createElement(te.Ph,{className:m.dropdown,inputId:`${e.id}-value`,isLoading:Ze,options:ve(E),value:e.value,onChange:I=>{Array.isArray(I)?a({...e,value:I.map(yt=>yt.value),valueType:I[0]?.type||K}):a({...e,value:I?.value,valueType:I?.type||K})},placeholder:"Select value",isClearable:!1,"aria-label":`select ${e.id} value`,allowCustomValue:!0,isMulti:!0,allowCreateWhileLoading:!0}),p&&s.createElement(je._,{variant:"secondary",icon:"times",onClick:()=>r?.(e),tooltip:"Remove tag","aria-label":`remove tag with ID ${e.id}`}))},Tr=()=>({vertical:(0,S.css)`
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
  `,horizontal:(0,S.css)`
    display: flex;
    flex-direction: row;
    gap: 1rem;
  `}),Bt=({updateFilter:e,deleteFilter:t,filters:a,datasource:r,setError:n,staticTags:o,isTagsLoading:i,hideValues:l,query:d})=>{const c=(0,_.wW)(Tr),p=()=>(0,ut.Z)().slice(0,8),g=(0,s.useCallback)(()=>e({id:p(),operator:"=",scope:L.NM.Span}),[e]);(0,s.useEffect)(()=>{a?.length||g()},[a,g]);const m=h=>{const R=r.languageProvider.getTags(h.scope);return Pa(R,o)};return s.createElement("div",{className:c.vertical},a?.map((h,R)=>s.createElement("div",{className:c.horizontal,key:h.id},s.createElement(Ft,{filter:h,datasource:r,setError:n,updateFilter:e,tags:m(h),isTagsLoading:i,deleteFilter:t,allowDelete:!0,hideValue:l,query:d}),R===a.length-1&&s.createElement(je._,{variant:"secondary",icon:"plus",onClick:g,title:"Add tag"}))))},Sr=({datasource:e,query:t,onChange:a})=>{const r=(0,_.wW)(yr),[n,o]=(0,s.useState)(null),[i,l]=(0,s.useState)(!0),[d,c]=(0,s.useState)(""),p=(0,pe.J)(),g=(0,s.useCallback)(b=>{const U={...t};U.filters||=[];const ae=U.filters.findIndex(Ve=>Ve.id===b.id);ae>=0?U.filters=nt(U.filters,ae,b):U.filters.push(b),a(U)},[a,t]),m=b=>{a({...t,filters:t.filters.filter(U=>U.id!==b.id)})};(0,s.useEffect)(()=>{c(tt(t.filters||[]))},[t]);const h=(0,s.useCallback)(b=>t.filters?.find(U=>U.id===b),[t.filters]);(0,s.useEffect)(()=>{(async()=>{try{await e.languageProvider.start(),l(!1)}catch(U){U instanceof Error&&(0,le.WI)((0,Qe.$l)((0,ue.t_)("Error",U)))}})()},[e]),(0,s.useEffect)(()=>{e.search?.filters?.filter(b=>b.value).forEach(b=>{h(b.id)||g(b)})},[e.search?.filters,h,g]);const R=e.search?.filters?.map(b=>b.tag)||[];R.push("duration");const k=(t.filters||[]).filter(b=>b.tag!=="duration"&&(e.search?.filters?.findIndex(U=>U.id===b.id)||0)===-1);return s.createElement(s.Fragment,null,s.createElement("div",{className:r.container},s.createElement("div",null,e.search?.filters?.map(b=>b.tag&&s.createElement(ke,{key:b.id,label:Qa(b),tooltip:`Filter your search by ${at(b)}. To modify the default filters shown for search visit the Tempo datasource configuration page.`},s.createElement(Ft,{filter:h(b.id)||b,datasource:e,setError:o,updateFilter:g,tags:[],hideScope:!0,hideTag:!0,query:d}))),s.createElement(ke,{label:"Duration",tooltip:"The span duration, i.e.	end - start time of the span. Accepted units are ns, ms, s, m, h"},s.createElement(Q.Lh,{spacing:"sm"},s.createElement(Wt,{filter:h("min-duration")||{id:"min-duration",tag:"duration",operator:">",valueType:"duration"},operators:[">",">="],updateFilter:g}),s.createElement(Wt,{filter:h("max-duration")||{id:"max-duration",tag:"duration",operator:"<",valueType:"duration"},operators:["<","<="],updateFilter:g}))),s.createElement(ke,{label:"Tags"},s.createElement(Bt,{filters:k,datasource:e,setError:o,updateFilter:g,deleteFilter:m,staticTags:R,isTagsLoading:i,query:d})),y.config.featureToggles.metricsSummary&&s.createElement(fr,{datasource:e,onChange:a,query:t,isTagsLoading:i})),s.createElement(_t.p,null,s.createElement(gr.U,{query:p.replace(d),lang:{grammar:ya,name:"traceql"}})),s.createElement(pt,{onChange:a,query:t})),n?s.createElement(Se.b,{title:"Unable to connect to Tempo search",severity:"info",className:r.alert},"Please ensure that Tempo is configured with search enabled. If you would like to hide this tab, you can configure it in the ",s.createElement("a",{href:`/datasources/edit/${e.uid}`},"datasource settings"),"."):null)},yr=e=>({alert:(0,S.css)`
    max-width: 75ch;
    margin-top: ${e.spacing(2)};
  `,container:(0,S.css)`
    display: flex;
    gap: 4px;
    flex-wrap: wrap;
    flex-direction: column;
  `});var Er=u(24524);function Qr({graphDatasourceUid:e,query:t,onChange:a}){const r=(0,_.wW)(Rr),n=(0,N.Z)(()=>ee(e),[e]),[o,i]=(0,s.useState)(void 0);if((0,s.useEffect)(()=>{async function c(p){const g=await p.getTagKeys({filters:[{key:"__name__",operator:"=~",value:"traces_service_graph_request_server_seconds_sum|traces_service_graph_request_total|traces_service_graph_request_failed_total",condition:""}]});i(!!g.length)}!n.loading&&n.value&&c(n.value)},[n]),n.loading)return null;const l=n.value;if(!e)return mt("No service graph datasource selected","Please set up a service graph datasource in the datasource settings",r);if(e&&!l)return mt("No service graph data found","Service graph datasource is configured but the data source no longer exists. Please configure existing data source to use the service graph functionality",r);const d=Pr(t.serviceMapQuery||"");return s.createElement("div",null,s.createElement(C.Z,null,s.createElement(O._,{label:"Filter",labelWidth:14,grow:!0},s.createElement(Er.F,{datasource:{uid:e},filters:d,baseFilters:[{key:"__name__",operator:"=~",value:"traces_service_graph_request_total|traces_spanmetrics_calls_total",condition:""}],addFilter:c=>{a({...t,serviceMapQuery:ht([...d,c])})},removeFilter:c=>{const p=[...d];p.splice(c,1),a({...t,serviceMapQuery:ht(p)})},changeFilter:(c,p)=>{const g=[...d];g.splice(c,1,p),a({...t,serviceMapQuery:ht(g)})}}))),o===!1?mt("No service graph data found","Please ensure that service graph metrics are set up correctly",r):null)}function mt(e,t,a){return s.createElement(Se.b,{title:e,severity:"info",className:a.alert},t," according to the"," ",s.createElement("a",{target:"_blank",rel:"noreferrer noopener",href:"https://grafana.com/docs/grafana/latest/datasources/tempo/service-graph/",className:a.link},"Tempo documentation"),".")}function Pr(e){let t,a=[];const r=/([\w_]+)(=|!=|<|>|=~|!~)"(.*?)"/g;for(;(t=r.exec(e))!==null;)a.push({key:t[1],operator:t[2],value:t[3],condition:""});return a}function ht(e){return`{${e.map(t=>`${t.key}${t.operator}"${t.value}"`).join(",")}}`}const Rr=e=>({alert:(0,S.css)`
    max-width: 75ch;
    margin-top: ${e.spacing(2)};
  `,link:(0,S.css)`
    color: ${e.colors.text.link};
    text-decoration: underline;
  `}),br={};var Cr=(e=>(e[e.UNSPECIFIED=0]="UNSPECIFIED",e[e.INTERNAL=1]="INTERNAL",e[e.SERVER=2]="SERVER",e[e.CLIENT=3]="CLIENT",e[e.PRODUCER=4]="PRODUCER",e[e.CONSUMER=5]="CONSUMER",e))(Cr||{}),xr=u(48355);const jt=xr.WQ.deserialize({version:14,states:",xOVQPOOOVQPO'#CfO!lQPO'#CeO$|QPO'#CgOOQO'#Cz'#CzOOQO'#Cy'#CyO%TQPO'#CyO%YQQO'#CvOOQO'#Cw'#CwO%bQPO'#CwO%mQPO'#C|O%rQPO'#C}O%wQQO'#DPOOQO'#Ce'#CeQ%|QPOOOOQO'#C^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O~Ox!QO~P!WOltOouOx!RO~Ox!SORQXSQXTQXUQXVQXyQX~Ox!TO~P%|Ow!UO~O!d!ZORdXUdX]dX{dXxdX!ldX~Og![O~O!d!]O~OR!`OU!aO]!_O{!bO~O`WOaWObWOcWOw!eO|XO!eTO!fSO!gSO!hSO!iSO~OSeOTfOyhOUYiVYitYixYi~ORYi~P)_OSeORYiUYiVYitYiyYixYi~OTYi~P)}ORdO~P)_OTfO~P)}Og!pOh!qOi!qO~Og!pO~OR!`OU!aO]!_Ox!rO~OR!`OU!aO]!_O{[ax[a!l[a~OR!`OU!aO]!_Ox!uO~OltORjiSjiTjiUjiVjitjiyjixji~OR!`OU!aO]!_Ox!wO~OR!`OU!aO]!_OxrX!lrX~Ox!yO!l!xO~OS{OT|Oy!OOUQiVQitQixQi~ORQi~P-uOS{ORQiUQiVQitQiyQixQi~OTQi~P.eORzO~P-uOT|O~P.eORzOS{OT|OU}Oy!OOVQitQixQi~ORdOSeOTfOUgOx!QOyhO~O!d!zO~O]!_OU[i{[ix[i!l[i~OR[i~P0hOR!`O~P0hOltOx!RO~Og!|O~OR!`OU!aO]!_Oxri!lri~Oab`ehige~",goto:"%otPPuPPPPP!_!i!u#e#oP$_PPPPP$_P$_PPP#e$kP%Q%_P#e#e%l#eQ^OQcPQ!T{Q!jzQ!k|Q!l}Q!m!OR!n!Pa_OPz{|}!O!P^_Oz{|}!O!PRbP^QOz{|}!O!PQ`PQ!QeQ!VdQ!WfQ!XgQ!YhR!o!Ua]OPz{|}!O!PQoRQ!^nQ!cpQ!dsQ!gwQ!hxQ!r!_Q!s!`Q!t!aR!{!xeqRnpswx!_!`!a!x^VOz{|}!O!PQaPQ!RtQ!fuR!v!egWOPtuz{|}!O!P!egUOPtuz{|}!O!P!eR!ix",nodeNames:"\u26A0 TraceQL SpansetPipelineExpression And Gt Desc Or Pipe WrappedSpansetPipeline SpansetPipeline SpansetExpression SpansetFilter FieldExpression FieldOp Static String Integer Float Duration TemplateVariable IntrinsicField Parent AttributeField Identifier Resource Span ScalarFilter ScalarExpression ScalarOp Aggregate AggregateExpression ComparisonOp GroupOperation SelectOperation SelectArgs CoalesceOperation",maxTerm:76,skippedNodes:[0],repeatNodeCount:0,tokenData:"#.Y~R!XX^$npq$nqr%crs%utu&juv)Zvw)bxy)myz)zz{)Z{|)Z|}*P}!O*U!O!P*_!P!Q)Z!Q![+Z!^!_,[!_!`,f!`!a,p!c!}*u#Q#R)Z#R#S*u#T#U-U#U#V.r#V#W/t#W#XAk#X#YE|#Y#ZHp#Z#]*u#]#^Ka#^#_*u#_#`! r#`#a*u#a#b!#z#b#c!&m#c#d!)z#d#e!*|#e#f*u#f#g!2X#g#h!@s#h#i!K|#i#j#&[#j#o*u#o#p#-j#p#q#-o#q#r#-|#r#s#.R#y#z$n$f$g$n#BY#BZ$n$IS$I_$n$I|$JO$n$JT$JU$n$KV$KW$n&FU&FV$n~$sYv~X^$npq$n#y#z$n$f$g$n#BY#BZ$n$IS$I_$n$I|$JO$n$JT$JU$n$KV$KW$n&FU&FV$nV%hQ}P!_!`%n#r#s%nU%uOoQ]S~%xVOY%uZr%urs&_s#O%u#P;'S%u;'S;=`&d<%lO%u~&dO_~~&gP;=`<%l%uR&mT!O!P&|!c!}&|#R#S&|#T#o&|#o#p'bP'RTcP!O!P&|!Q![&|!c!}&|#R#S&|#T#o&|R'eS!O!P'q!c!}'q#R#S'q#T#o'qR'tV!O!P'q!Q!['q![!](Z!c!}'q#R#S'q#T#o'q#q#r)SR(^T!O!P(m!Q![(m!c!}(m#R#S(m#T#o(mR(pU!O!P(m!Q![(m!c!}(m#R#S(m#T#o(m#q#r)SR)ZOcPgQ^)bO]SlY~)ePvw)h~)mOR~R)rPwPyz)uQ)zO!nQ~*POx~~*UO!l~_*_O|P]SlYV*fT!dTgQ!O!P*u!Q![*u!c!}*u#R#S*u#T#o*uQ*zTgQ!O!P*u!Q![*u!c!}*u#R#S*u#T#o*u~+`T`~!O!P+o!Q![+Z#[#]+}#a#b,S#g#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!Q![*u!c!}*u#R#S*u#T#X*u#X#Y#,h#Y#o*uR#,mVgQ!O!P*u!Q![*u!c!}*u#R#S*u#T#W*u#W#X#-S#X#o*uR#-ZT!UPgQ!O!P*u!Q![*u!c!}*u#R#S*u#T#o*u~#-oOz~~#-tPV~#p#q#-w~#-|OU~~#.RO{~]#.YO]SyX",tokenizers:[0,1,2,3],topRules:{TraceQL:[0,1]},tokenPrec:775}),kt=1,Ge=2,Gt=3,$n=4,_n=5,Yt=6,Xt=7,Un=8,Dr=9,Wn=10,ft=11,se=12,Kt=13,Ir=14,Fn=15,Bn=16,jn=17,kn=18,Gn=19,Ot=20,Yn=21,Ie=22,Xn=23,Kn=24,zn=25,zt=26,Nr=27,Zn=28,Ye=29,Hn=30,Zt=31,Vr=32,qn=33,Mr=34,Jn=35;function Ht(e,t){const a=e.cursorAt(t);do if(a.from===t||a.to===t){const{node:r}=a;if(r.type.isError)return r}while(a.next());return null}function Lr(e,t){return e[t]}function Pe(e,t){let a=e;for(const[r,n]of t)if(a=Lr(a,r),a===null||n.find(o=>o===a?.type.id)===void 0)return null;return a}function vt(e,t){return t.slice(e.from===e.to?e.from-1:e.from,e.to)}function Ar(e,t){return e.every((a,r)=>a===t[r])}function wr(e,t){if(e==="")return{query:e,type:"EMPTY"};const a=jt.parse(e);let r=t;for(;r-1>=0&&e[r-1]===" ";)r-=1;let n=Ht(a,r);n||(n=Ht(a,r-1));const o=n!=null?n.cursor():a.cursorAt(r),i=o.node,l=[o.type.id];for(;o.parent();)l.push(o.type.id);let d=null;for(let c of $r)Ar(c.path,l)&&(d=c.fun(i,e,r,t));return{query:e,...d??{type:"UNKNOWN"}}}const ce=0,$r=[{path:[ce,Ie],fun:_r},{path:[ce,se],fun:Ur},{path:[ce,ft],fun:()=>({type:"SPANSET_EXPRESSION_OPERATORS_WITH_MISSING_CLOSED_BRACE"})},{path:[ce,Ye],fun:ta},{path:[ce,Ot],fun:ta},{path:[ce,Ge],fun:Fr},{path:[ce,zt,Dr],fun:Wr},{path:[ce,kt],fun:()=>({type:"UNKNOWN"})},{path:[se],fun:Jt},{path:[ft],fun:Jt},{path:[Ge],fun:ea},{path:[kt],fun:ea}],qt=(e,t,a)=>{const r=Pe(e,[["firstChild",[se]]]);if(r&&t[a-1]!==" "){const n=Pe(r,[["firstChild",[Ie]]]),o=n?vt(n,t):"",i=o.indexOf(".");return{type:"SPANSET_IN_NAME_SCOPE",scope:o.slice(0,i)}}};function Jt(e,t,a,r){const n=qt(e,t,r);if(n)return n;let o=Pe(e,[["firstChild",[se]],["firstChild",[Ie]]]);return o?{type:"SPANSET_EXPRESSION_OPERATORS"}:(o=Pe(e,[["lastChild",[se]],["lastChild",[se]],["lastChild",[Ir]]]),o?{type:"SPANFIELD_COMBINING_OPERATORS"}:(o=Pe(e,[["lastChild",[se]]]),o?{type:"SPANSET_EXPRESSION_OPERATORS"}:{type:"SPANSET_EMPTY"}))}function _r(e,t){const a=Pe(e,[["parent",[Ie]]]),r=a?vt(a,t):"";if(r===".")return{type:"SPANSET_ONLY_DOT"};const n=r.indexOf("."),o=r.slice(0,n);return["span","resource","parent"].find(i=>i===o)?{type:"SPANSET_IN_NAME_SCOPE",scope:o}:{type:"SPANSET_IN_NAME"}}function Ur(e,t,a,r){const n=qt(e,t,r);if(n)return n;if(e.prevSibling?.type.id===Kt){let o=e.prevSibling.prevSibling;if(o)return{type:"SPANSET_IN_VALUE",tagName:vt(o,t),betweenQuotes:!1}}return e.prevSibling?.type.name==="And"||e.prevSibling?.type.name==="Or"?{type:"SPANSET_EMPTY"}:{type:"SPANSET_IN_THE_MIDDLE"}}function Wr(e,t,a){return e.prevSibling?.type.id===Zt?{type:"UNKNOWN"}:{type:"SPANSET_COMPARISON_OPERATORS"}}function ea(e,t,a){let r=e.firstChild;try{for(r=e.firstChild;r.to<a;)r=r.nextSibling}catch(n){console.error("Unexpected error while searching for previous node",n)}return r?.type.id===Gt||r?.type.id===Yt?{type:"NEW_SPANSET"}:{type:"SPANSET_COMBINING_OPERATORS"}}function ta(e,t,a){const r=e?.parent;return r&&[Ot,Ye,Vr,Mr].includes(r.type.id)?{type:"ATTRIBUTE_FOR_FUNCTION"}:{type:"UNKNOWN"}}function Fr(e,t,a){return e.prevSibling?.type.id===Xt?{type:"SPANSET_PIPELINE_AFTER_OPERATOR"}:{type:"NEW_SPANSET"}}const B=class{constructor(e){this.triggerCharacters=["{",".","[","(","=","~"," ",'"'],this.cachedValues={},this.languageProvider=e.languageProvider,this.registerInteractionCommandId=null}provideCompletionItems(e,t){if(!(this.monaco&&this.editor))throw new Error("provideCompletionItems called before CompletionProvider was initialized");if(this.editor.getModel()?.id!==e.id)return{suggestions:[]};const{range:a,offset:r}=jr(this.monaco,e,t),n=wr(e.getValue(),r);return(n!=null?this.getCompletions(n):Promise.resolve([])).then(i=>{const l=i.length.toString().length;return{suggestions:i.map((c,p)=>{const g={kind:Br(c.type,this.monaco),label:c.label,insertText:c.insertText,insertTextRules:c.insertTextRules,detail:c.detail,documentation:c.documentation,sortText:p.toString().padStart(l,"0"),range:a,command:{id:this.registerInteractionCommandId||"noOp",title:"Report Interaction",arguments:[c.label,c.type]}};return kr(g,c.type,e,r),g})}})}setRegisterInteractionCommandId(e){this.registerInteractionCommandId=e}async getTagValues(e,t){let a;return this.cachedValues.hasOwnProperty(e)?a=this.cachedValues[e]:(a=await this.languageProvider.getOptionsV2(e,t),this.cachedValues[e]=a),a}async getCompletions(e){switch(e.type){case"UNKNOWN":return[];case"EMPTY":return this.getScopesCompletions("{ ").concat(this.getIntrinsicsCompletions("{ ")).concat(this.getTagsCompletions("{ ."));case"SPANSET_EMPTY":return this.getScopesCompletions().concat(this.getIntrinsicsCompletions()).concat(this.getTagsCompletions("."));case"SPANSET_ONLY_DOT":return this.getTagsCompletions();case"SPANSET_IN_THE_MIDDLE":return[...B.comparisonOps,...B.logicalOps].map(i=>({...i,type:"OPERATOR"}));case"SPANSET_EXPRESSION_OPERATORS_WITH_MISSING_CLOSED_BRACE":return[...B.comparisonOps,...B.logicalOps].map(i=>({...i,type:"OPERATOR"}));case"SPANSET_IN_NAME":return this.getScopesCompletions().concat(this.getIntrinsicsCompletions()).concat(this.getTagsCompletions());case"SPANSET_IN_NAME_SCOPE":return this.getTagsCompletions(void 0,e.scope);case"SPANSET_EXPRESSION_OPERATORS":return[...B.comparisonOps,...B.logicalOps,...B.arithmeticOps].map(i=>({...i,type:"OPERATOR"}));case"SPANFIELD_COMBINING_OPERATORS":return[...B.logicalOps,...B.arithmeticOps,...B.comparisonOps].map(i=>({...i,type:"OPERATOR"}));case"SPANSET_COMBINING_OPERATORS":return B.spansetOps.map(i=>({...i,type:"OPERATOR"}));case"SPANSET_PIPELINE_AFTER_OPERATOR":const t=B.functions.map(i=>({...i,insertTextRules:this.monaco?.languages.CompletionItemInsertTextRule?.InsertAsSnippet,type:"FUNCTION"})),a=this.getScopesCompletions().concat(this.getIntrinsicsCompletions()).concat(this.getTagsCompletions("."));return[...t,...a];case"SPANSET_COMPARISON_OPERATORS":return B.comparisonOps.map(i=>({...i,type:"OPERATOR"}));case"SPANSET_IN_VALUE":let r;try{r=await this.getTagValues(e.tagName,e.query)}catch(i){(0,Te.kW)(i)?(0,le.WI)((0,Qe.$l)((0,ue.t_)(i.data.error,new Error(i.data.message)))):i instanceof Error&&(0,le.WI)((0,Qe.$l)((0,ue.t_)("Error",i)))}const n=[],o=i=>e.betweenQuotes?i.label:i.type==="string"?`"${i.label}"`:i.label;return r?.forEach(i=>{i?.label&&n.push({label:i.label,insertText:o(i),type:"TAG_VALUE"})}),n;case"SPANSET_AFTER_VALUE":return B.logicalOps.map(i=>({label:i.label,insertText:i.insertText+"}",type:"OPERATOR"}));case"NEW_SPANSET":return this.getScopesCompletions("{ ","$0 }").concat(this.getIntrinsicsCompletions("{ ","$0 }")).concat(this.getTagsCompletions("."));case"ATTRIBUTE_FOR_FUNCTION":return this.getScopesCompletions().concat(this.getIntrinsicsCompletions()).concat(this.getTagsCompletions("."));default:throw new Error(`Unexpected situation ${e}`)}}getTagsCompletions(e,t){return this.languageProvider.getTraceqlAutocompleteTags(t).sort((r,n)=>r.localeCompare(n,void 0,{sensitivity:"accent"})).map(r=>({label:r,insertText:(e||"")+r,type:"TAG_NAME"}))}getIntrinsicsCompletions(e,t){return _e.map(a=>({label:a,insertText:(e||"")+a+(t||""),type:"KEYWORD",insertTextRules:this.monaco?.languages.CompletionItemInsertTextRule?.InsertAsSnippet}))}getScopesCompletions(e,t){return xt.map(a=>({label:a,insertText:(e||"")+a+(t||""),type:"SCOPE",insertTextRules:this.monaco?.languages.CompletionItemInsertTextRule?.InsertAsSnippet}))}};let de=B;de.arithmeticOps=[{label:"+",insertText:"+",detail:"Plus"},{label:"-",insertText:"-",detail:"Minus"},{label:"*",insertText:"*",detail:"Times"},{label:"/",insertText:"/",detail:"Over"}],de.logicalOps=[{label:"&&",insertText:"&&",detail:"And",documentation:"And (intersection) operator. Checks that both conditions found matches."},{label:"||",insertText:"||",detail:"Or",documentation:"Or (union) operator. Checks that either condition found matches."}],de.comparisonOps=[{label:"=",insertText:"=",detail:"Equality"},{label:"!=",insertText:"!=",detail:"Inequality"},{label:">",insertText:">",detail:"Greater than"},{label:">=",insertText:">=",detail:"Greater than or equal to"},{label:"<",insertText:"<",detail:"Less than"},{label:"<=",insertText:"<=",detail:"Less than or equal to"},{label:"=~",insertText:"=~",detail:"Regular expression"},{label:"!~",insertText:"!~",detail:"Negated regular expression"}],de.structuralOps=[{label:">>",insertText:">>",detail:"Descendant",documentation:"Descendant operator. Looks for spans matching {condB} that are descendants of a span matching {condA}"},{label:">",insertText:">",detail:"Child",documentation:"Child operator. Looks for spans matching {condB} that are direct child spans of a parent matching {condA}"},{label:"~",insertText:"~",detail:"Sibling",documentation:"Sibling operator. Checks that spans matching {condA} and {condB} are siblings of the same parent span."}],de.spansetOps=[{label:"|",insertText:"|",detail:"Pipe"},...B.logicalOps,...B.structuralOps],de.spansetAggregatorOps=[{label:"count",insertText:"count()$0",detail:"Number of spans",documentation:"Counts the number of spans in a spanset"},{label:"avg",insertText:"avg($0)",detail:"Average of attribute",documentation:"Computes the average of a given numeric attribute or intrinsic for a spanset."},{label:"max",insertText:"max($0)",detail:"Max value of attribute",documentation:"Computes the maximum value of a given numeric attribute or intrinsic for a spanset."},{label:"min",insertText:"min($0)",detail:"Min value of attribute",documentation:"Computes the minimum value of a given numeric attribute or intrinsic for a spanset."},{label:"sum",insertText:"sum($0)",detail:"Sum value of attribute",documentation:"Computes the sum value of a given numeric attribute or intrinsic for a spanset."}],de.functions=[...B.spansetAggregatorOps,{label:"by",insertText:"by($0)",detail:"Grouping of attributes",documentation:"Groups by arbitrary attributes."},{label:"select",insertText:"select($0)",detail:"Selection of fields",documentation:"Selects arbitrary fields from spans."}];function Br(e,t){switch(e){case"TAG_NAME":return t.languages.CompletionItemKind.Enum;case"KEYWORD":return t.languages.CompletionItemKind.Keyword;case"OPERATOR":return t.languages.CompletionItemKind.Operator;case"TAG_VALUE":return t.languages.CompletionItemKind.EnumMember;case"SCOPE":return t.languages.CompletionItemKind.Class;case"FUNCTION":return t.languages.CompletionItemKind.Function;default:throw new Error(`Unexpected CompletionType: ${e}`)}}function jr(e,t,a){const r=t.getWordAtPosition(a),n=r!=null?e.Range.lift({startLineNumber:a.lineNumber,endLineNumber:a.lineNumber,startColumn:r.startColumn,endColumn:r.endColumn}):e.Range.fromPositions(a),o={column:a.column,lineNumber:a.lineNumber};return{offset:t.getOffsetAt(o),range:n}}function kr(e,t,a,r){if(t==="TAG_NAME"){const n=a.getValue().substring(0,r).match(/(span\.|resource\.|\.)?([\w./-]*)$/);if(n){const o=n[1],i=n[2];i&&(!o&&e.insertText[0]!=="."&&(e.insertText="."+e.insertText),e.range={...e.range,startColumn:r-i.length+1})}}}const Gr=e=>{switch(e.parent?.type.id){case se:switch(e.prevSibling?.type.id){case Gt:case Yt:return"Invalid value after logical operator.";case Kt:return"Invalid value after comparison or aritmetic operator.";default:return"Invalid operator after field expression."}case ft:return e.prevSibling?.type.id===se?"Invalid comparison operator after field expression.":"Invalid expression for spanset.";case Ge:switch(e.prevSibling?.type.id){case Ge:return"Invalid spanset combining operator after spanset expression.";case Xt:return"Invalid aggregation operator after pipepile operator.";default:return"Invalid spanset expression after spanset combining operator."}case Ot:case Ye:return"Invalid expression for aggregator operator.";case Ie:return"Invalid expression for spanset.";case zt:switch(e.prevSibling?.type.id){case Zt:return"Invalid value after comparison operator.";case Nr:if(e.prevSibling?.firstChild?.type.id===Ye)return"Invalid comparison operator after aggregator operator.";default:return"Invalid value after comparison operator."}default:return"Invalid query."}},aa=e=>{if(e.trim()==="")return[];const t=/^[0-9A-Fa-f]*$/;if(e.trim().match(t))return[];const a=jt.parse(e),r=[];return a.iterate({enter:n=>{n.type.id===0&&r.push(n.node)}}),r},Tt=(e,t,a)=>{e.editor.setModelMarkers(t,"owner",a.map(r=>{let n=0,o=0,i=r.from,l=r.to;for(;i>0;)n++,i-=t.getLineLength(n)+1;for(;l>0;)o++,l-=t.getLineLength(o)+1;return{message:Gr(r),severity:e.MarkerSeverity.Error,startLineNumber:n,endLineNumber:o,startColumn:i+t.getLineLength(n)+2,endColumn:l+t.getLineLength(o)+2}}))};function Yr(e){const{onChange:t,onRunQuery:a,placeholder:r}=e,n=Hr(e.datasource),o=(0,_.l4)(),i=Jr(o,r),l=(0,s.useRef)(a);l.current=a;const d=(0,s.useRef)();return s.createElement(At.p,{value:e.value,language:Ne,onBlur:t,onChange:t,containerStyles:i.queryField,readOnly:e.readOnly,monacoOptions:{folding:!1,fontSize:14,lineNumbers:"off",overviewRulerLanes:0,renderLineHighlight:"none",scrollbar:{vertical:"hidden",verticalScrollbarSize:8,horizontal:"hidden",horizontalScrollbarSize:0},scrollBeyondLastLine:!1,wordWrap:"on"},onBeforeEditorMount:qr,onEditorDidMount:(c,p)=>{e.readOnly||(n(c,p,zr(c)),Kr(c,p,()=>l.current()),Xr(c,p,i)),Zr(c);const g=c.getModel();if(g){const m=aa(g.getValue());Tt(p,g,m)}c.onDidChangeModelContent(m=>{const h=c.getModel();if(!h)return;window.clearTimeout(d.current);const R=aa(h.getValue()),k=m.changes[0].rangeOffset;Tt(p,h,R.filter(b=>!(b.from<=k&&k<=b.to))),d.current=window.setTimeout(()=>{Tt(p,h,R)},500)})}})}function Xr(e,t,a){const r=[{range:new t.Range(1,1,1,1),options:{className:a.placeholder,isWholeLine:!0}}];let n=[];const o=()=>{const i=e.getModel();if(!i)return;const l=i.getValueLength()===0?r:[];n=i.deltaDecorations(n,l)};o(),e.onDidChangeModelContent(o)}function Kr(e,t,a){e.addAction({id:"run-query",label:"Run Query",keybindings:[t.KeyMod.Shift|t.KeyCode.Enter],contextMenuGroupId:"navigation",contextMenuOrder:1.5,run:function(){a()}})}function zr(e){return e.addCommand(0,function(t,a,r){const n={datasourceType:"tempo",type:r};r!=="TAG_VALUE"&&(n.label=a),(0,V.ff)("grafana_traces_traceql_completion",n)})}function Zr(e){const t=e.getDomNode(),a=()=>{if(t){const r=Math.min(1e3,e.getContentHeight()),n=parseInt(t.style.width,10);t.style.width=`${n}px`,t.style.height=`${r}px`,e.layout({width:n,height:r})}};e.onDidContentSizeChange(a),a()}function Hr(e){const t=(0,s.useRef)(new de({languageProvider:e.languageProvider}));(0,s.useEffect)(()=>{(async()=>{try{await e.languageProvider.start()}catch(n){n instanceof Error&&(0,le.WI)((0,Qe.$l)((0,ue.t_)("Error",n)))}})()},[e]);const a=(0,s.useRef)(null);return(0,s.useEffect)(()=>()=>{a.current?.()},[]),(r,n,o)=>{t.current.editor=r,t.current.monaco=n,t.current.setRegisterInteractionCommandId(o);const{dispose:i}=n.languages.registerCompletionItemProvider(Ne,t.current);a.current=i}}let ra=!1;const Ne="traceql";function qr(e){if(!ra){ra=!0;const{aliases:t,extensions:a,mimetypes:r,def:n}=Sa;e.languages.register({id:Ne,aliases:t,extensions:a,mimetypes:r}),e.languages.setMonarchTokensProvider(Ne,n.language),e.languages.setLanguageConfiguration(Ne,n.languageConfiguration)}}const Jr=(e,t)=>({queryField:(0,S.css)`
      border-radius: ${e.shape.radius.default};
      border: 1px solid ${e.components.input.borderColor};
      flex: 1;
    `,placeholder:(0,S.css)`
      ::after {
        content: '${t}';
        font-family: ${e.typography.fontFamilyMonospace};
        opacity: 0.3;
      }
    `});function en(e){const t=(0,_.wW)(tn),a=(0,z.defaults)(e.query,br),r=n=>{e.onChange({...a,query:n})};return s.createElement(s.Fragment,null,s.createElement(f.W,null,"Build complex queries using TraceQL to select a list of traces."," ",s.createElement("a",{rel:"noreferrer",target:"_blank",href:"https://grafana.com/docs/tempo/latest/traceql/"},"Documentation")),s.createElement(Yr,{placeholder:"Enter a TraceQL query or trace ID (run with Shift+Enter)",value:a.query||"",onChange:r,datasource:e.datasource,onRunQuery:e.onRunQuery}),s.createElement("div",{className:t.optionsContainer},s.createElement(pt,{query:a,onChange:e.onChange})))}const tn=()=>({optionsContainer:(0,S.css)`
    margin-top: 10px;
  `}),an="traceql";class rn extends s.PureComponent{constructor(t){super(t),this.onChangeLinkedQuery=a=>{const{query:r,onChange:n}=this.props;n({...r,linkedQuery:{...a,refId:"linked"}})},this.onRunLinkedQuery=()=>{this.props.onRunQuery()},this.onClearResults=()=>{const{onChange:a,query:r,onRunQuery:n}=this.props;a({...r,queryType:"clear"}),n()},this.state={uploadModalOpen:!1}}async componentDidMount(){(!this.props.query.queryType||this.props.query.queryType==="clear")&&this.props.onChange({...this.props.query,queryType:an})}render(){const{query:t,onChange:a,datasource:r,app:n}=this.props,o=r.getLokiSearchDS(),i=r.serviceMap?.datasourceUid;let l=[{value:"traceqlSearch",label:"Search"},{value:"traceql",label:"TraceQL"},{value:"serviceMap",label:"Service Graph"}];return o&&(r?.search?.hide?l.unshift({value:"search",label:"Search"}):l.push({value:"search",label:"Loki Search"})),(t.spanName||t.serviceName||t.search||t.maxDuration||t.minDuration||t.queryType==="nativeSearch")&&l.unshift({value:"nativeSearch",label:"[Deprecated] Search"}),s.createElement(s.Fragment,null,s.createElement(W.u,{title:"Upload trace",isOpen:this.state.uploadModalOpen,onDismiss:()=>this.setState({uploadModalOpen:!1})},s.createElement("div",{className:(0,S.css)({padding:this.props.theme.spacing(2)})},s.createElement($.Yo,{options:{multiple:!1},onLoad:d=>{this.props.datasource.uploadedJson=d,a({...t,queryType:"upload"}),this.setState({uploadModalOpen:!1}),this.props.onRunQuery()}}))),s.createElement(C.Z,null,s.createElement(O._,{label:"Query type",grow:!0},s.createElement(Q.Lh,{spacing:"sm",align:"center",justify:"space-between"},s.createElement(D.S,{options:l,value:t.queryType,onChange:d=>{(0,V.ff)("grafana_traces_query_type_changed",{datasourceType:"tempo",app:n??"",grafana_version:y.config.buildInfo.version,newQueryType:d,previousQueryType:t.queryType??""}),this.onClearResults(),a({...t,queryType:d})},size:"md"}),s.createElement(P.zx,{variant:"secondary",size:"sm",onClick:()=>{this.setState({uploadModalOpen:!0})}},"Import trace")))),t.queryType==="search"&&s.createElement(Y,{logsDatasourceUid:o,query:t,onRunQuery:this.onRunLinkedQuery,onChange:this.onChangeLinkedQuery}),t.queryType==="nativeSearch"&&s.createElement(cr,{datasource:this.props.datasource,query:t,onChange:a,onBlur:this.props.onBlur,onRunQuery:this.props.onRunQuery}),t.queryType==="traceqlSearch"&&s.createElement(Sr,{datasource:this.props.datasource,query:t,onChange:a,onBlur:this.props.onBlur}),t.queryType==="serviceMap"&&s.createElement(Qr,{graphDatasourceUid:i,query:t,onChange:a}),t.queryType==="traceql"&&s.createElement(en,{datasource:this.props.datasource,query:t,onRunQuery:this.props.onRunQuery,onChange:a}))}}const nn=(0,_.HE)(rn);var sn=u(17613),on=u(66211),un=u(84461),ln=u(28789),cn=u(27770),dn=u(54522),Xe=u(99242),gn=u(47169),Ke=u(43997),q=u(25243),pn=u(23846),St=u(36516),mn=u(49605),hn=u(95577),J=u(47635),na=u(92811),sa=u(26286),ia=u(13273);function fn({options:e,onOptionsChange:t}){const a=(0,_.wW)(ze),r=o=>`Time shift for ${o} of search`,n=o=>`Shifts the ${o} of the time range when searching by TraceID. Searching can return traces that do not fully fall into the search time range, so we recommend using higher time shifts for longer traces. Default: 30m (Time units can be used here, for example: 5s, 1m, 3h`;return s.createElement("div",{className:a.container},s.createElement(O._,{label:"Use time range in query",tooltip:"The time range can be used when there are performance issues or timeouts since it will narrow down the search to the defined range. Default: disabled",labelWidth:26},s.createElement(sa.x,{id:"enable-time-shift",value:e.jsonData.traceQuery?.timeShiftEnabled||!1,onChange:o=>{(0,J.tp)({onOptionsChange:t,options:e},"traceQuery",{...e.jsonData.traceQuery,timeShiftEnabled:o.currentTarget.checked})}})),s.createElement(ia.w,{label:r("start"),tooltip:n("start"),value:e.jsonData.traceQuery?.spanStartTimeShift||"",disabled:!e.jsonData.traceQuery?.timeShiftEnabled,onChange:o=>{(0,J.tp)({onOptionsChange:t,options:e},"traceQuery",{...e.jsonData.traceQuery,spanStartTimeShift:o})},isInvalidError:St.Ny}),s.createElement(ia.w,{label:r("end"),tooltip:n("end"),value:e.jsonData.traceQuery?.spanEndTimeShift||"",disabled:!e.jsonData.traceQuery?.timeShiftEnabled,onChange:o=>{(0,J.tp)({onOptionsChange:t,options:e},"traceQuery",{...e.jsonData.traceQuery,spanEndTimeShift:o})},isInvalidError:St.Ny}))}const ze=e=>({infoText:(0,S.css)`
    padding-bottom: ${e.spacing(2)};
    color: ${e.colors.text.secondary};
  `,container:(0,S.css)`
    width: 100%;
  `,row:(0,S.css)`
    align-items: baseline;
  `});function On({options:e,onOptionsChange:t}){const a=(0,_.wW)(ze),r=e.jsonData.tracesToLogs?.lokiSearch!==!1?e.jsonData.tracesToLogs?.datasourceUid:void 0;return r&&e.jsonData.lokiSearch===void 0&&(0,J.tp)({onOptionsChange:t,options:e},"lokiSearch",{datasourceUid:r}),s.createElement("div",{className:a.container},s.createElement(C.Z,{className:a.row},s.createElement(O._,{tooltip:"The Loki data source with the service graph data",label:"Data source",labelWidth:26},s.createElement(na.q,{inputId:"loki-search-data-source-picker",pluginId:"loki",current:e.jsonData.lokiSearch?.datasourceUid,noDefault:!0,width:40,onChange:n=>(0,J.tp)({onOptionsChange:t,options:e},"lokiSearch",{datasourceUid:n.uid})})),e.jsonData.lokiSearch?.datasourceUid?s.createElement(P.zx,{type:"button",variant:"secondary",size:"sm",fill:"text",onClick:()=>{(0,J.tp)({onOptionsChange:t,options:e},"lokiSearch",{datasourceUid:void 0})}},"Clear"):null))}function vn({options:e,onOptionsChange:t}){const a=(0,_.wW)(ze);return s.createElement("div",{className:a.container},s.createElement(C.Z,{className:a.row},s.createElement(O._,{tooltip:"The Prometheus data source with the service graph data",label:"Data source",labelWidth:26},s.createElement(na.q,{inputId:"service-graph-data-source-picker",pluginId:"prometheus",current:e.jsonData.serviceMap?.datasourceUid,noDefault:!0,width:40,onChange:r=>(0,J.tp)({onOptionsChange:t,options:e},"serviceMap",{datasourceUid:r.uid})})),e.jsonData.serviceMap?.datasourceUid?s.createElement(P.zx,{type:"button",variant:"secondary",size:"sm",fill:"text",onClick:()=>{(0,J.tp)({onOptionsChange:t,options:e},"serviceMap",{datasourceUid:void 0})}},"Clear"):null))}function Tn({options:e,onOptionsChange:t,datasource:a}){const r=async()=>{if(!a)throw new Error("Unable to retrieve datasource");try{await a.languageProvider.start()}catch(p){throw new Error(x(p.data.message,"Unable to query Tempo"))}},{error:n,loading:o}=(0,N.Z)(r,[a,e]),i=(0,s.useCallback)(p=>{let g=e.jsonData.search?.filters;g||=[];const m=g.findIndex(h=>h.id===p.id);m>=0?g=nt(g,m,p):g.push(p),(0,J.tp)({onOptionsChange:t,options:e},"search",{...e.jsonData.search,filters:g})},[t,e]),l=p=>{(0,J.tp)({onOptionsChange:t,options:e},"search",{...e.jsonData.search,filters:e.jsonData.search?.filters?.filter(g=>g.id!==p.id)})};(0,s.useEffect)(()=>{e.jsonData.search?.filters||(0,J.tp)({onOptionsChange:t,options:e},"search",{...e.jsonData.search,filters:[{id:"service-name",tag:"service.name",operator:"=",scope:L.NM.Resource},{id:"span-name",tag:"name",operator:"=",scope:L.NM.Span}]})},[t,e]);const d=["duration"],c=e.jsonData.search?.filters?.find(p=>!p.tag);return s.createElement(s.Fragment,null,a?s.createElement(Bt,{updateFilter:i,deleteFilter:l,filters:e.jsonData.search?.filters||[],datasource:a,setError:()=>{},staticTags:d,isTagsLoading:o,hideValues:!0,query:"{}"}):s.createElement("div",null,"Invalid data source, please create a valid data source and try again"),n&&s.createElement(Se.b,{title:"Unable to fetch TraceQL tags",severity:"error",topSpacing:1},n.message),c&&s.createElement(Se.b,{title:"Please ensure each filter has a selected tag",severity:"warning",topSpacing:1}))}function Sn({options:e,onOptionsChange:t}){const a=(0,_.wW)(ze),r=(0,re.F)(),n=async()=>await r.get({type:e.type,uid:e.uid}),{value:o}=(0,N.Z)(n,[r,e]);return s.createElement("div",{className:a.container},s.createElement(C.Z,{className:a.row},s.createElement(O._,{tooltip:"Removes the search tab from the query editor",label:"Hide search",labelWidth:26},s.createElement(sa.x,{id:"hideSearch",value:e.jsonData.search?.hide,onChange:i=>(0,J.tp)({onOptionsChange:t,options:e},"search",{...e.jsonData.search,hide:i.currentTarget.checked})}))),s.createElement(C.Z,{className:a.row},s.createElement(O._,{tooltip:"Configures which fields are available in the UI",label:"Static filters",labelWidth:26},s.createElement(Tn,{datasource:o,options:e,onOptionsChange:t}))))}const yn=({options:e,onOptionsChange:t})=>{const a=(0,_.wW)(En);return s.createElement("div",{className:a.container},s.createElement(sn.j,{dataSourceName:"Tempo",docsLink:"https://grafana.com/docs/grafana/latest/datasources/tempo",hasRequiredFields:!1}),s.createElement(q.i,null),s.createElement(on.f,{config:e,onChange:t,urlPlaceholder:"http://localhost:3200"}),s.createElement(q.i,null),s.createElement(un.g,{...(0,ln.T2)({config:e,onChange:t})}),s.createElement(q.i,null),s.createElement(St.dw,{options:e,onOptionsChange:t}),s.createElement(q.i,null),y.config.featureToggles.traceToMetrics?s.createElement(s.Fragment,null,s.createElement(mn.Y,{options:e,onOptionsChange:t}),s.createElement(q.i,null)):null,s.createElement(cn.K,{title:"Additional settings",description:"Additional settings are optional settings that can be configured for more control over your data source.",isCollapsible:!0,isInitiallyOpen:!1},s.createElement(dn.a,{config:e,onChange:t}),y.config.secureSocksDSProxyEnabled&&s.createElement(s.Fragment,null,s.createElement(q.i,{hideLine:!0}),s.createElement(gn.i,{options:e,onOptionsChange:t})),s.createElement(q.i,{hideLine:!0}),s.createElement(Xe._,{title:"Service graph",description:s.createElement(Ke.W,{description:"Select a Prometheus data source that contains the service graph data.",suffix:"tempo/#service-graph",feature:"the service graph"})},s.createElement(vn,{options:e,onOptionsChange:t})),s.createElement(q.i,{hideLine:!0}),s.createElement(pn.I,{options:e,onOptionsChange:t}),s.createElement(q.i,{hideLine:!0}),s.createElement(Xe._,{title:"Tempo search",description:s.createElement(Ke.W,{description:"Modify how traces are searched.",suffix:"tempo/#tempo-search",feature:"Tempo search"})},s.createElement(Sn,{options:e,onOptionsChange:t})),s.createElement(q.i,{hideLine:!0}),s.createElement(Xe._,{title:"Loki search",description:s.createElement(Ke.W,{description:"Select a Loki data source to search for traces. Derived fields must be configured in the Loki data source.",suffix:"tempo/#loki-search",feature:"Loki search"})},s.createElement(On,{options:e,onOptionsChange:t})),s.createElement(q.i,{hideLine:!0}),s.createElement(Xe._,{title:"TraceID query",description:s.createElement(Ke.W,{description:"Modify how TraceID queries are run.",suffix:"tempo/#traceid-query",feature:"the TraceID query"})},s.createElement(fn,{options:e,onOptionsChange:t})),s.createElement(q.i,{hideLine:!0}),s.createElement(hn.vc,{options:e,onOptionsChange:t})))},En=e=>({container:(0,S.css)`
    label: container;
    margin-bottom: ${e.spacing(2)};
    max-width: 900px;
  `});var Qn=u(35630);const Pn=({payload:{dashboardId:e,orgId:t,grafanaVersion:a,queries:r}})=>{try{const n=r[Qn.id];if(!n?.length)return;let o={grafana_version:a,dashboard_id:e,org_id:t,native_search_query_count:0,search_query_count:0,service_map_query_count:0,traceql_query_count:0,upload_query_count:0,native_search_queries_with_template_variables_count:0,search_queries_with_template_variables_count:0,service_map_queries_with_template_variables_count:0,traceql_queries_with_template_variables_count:0};for(const i of n)i.hide||(i.queryType==="nativeSearch"?(o.native_search_query_count++,(i.serviceName&&ge(i.serviceName)||i.spanName&&ge(i.spanName)||i.search&&ge(i.search)||i.minDuration&&ge(i.minDuration)||i.maxDuration&&ge(i.maxDuration))&&o.native_search_queries_with_template_variables_count++):i.queryType==="search"?(o.search_query_count++,i.linkedQuery&&i.linkedQuery.expr&&ge(i.linkedQuery.expr)&&o.search_queries_with_template_variables_count++):i.queryType==="serviceMap"?(o.service_map_query_count++,i.serviceMapQuery&&ge(i.serviceMapQuery)&&o.service_map_queries_with_template_variables_count++):i.queryType==="traceql"?(o.traceql_query_count++,ge(i.query)&&o.traceql_queries_with_template_variables_count++):i.queryType==="upload"&&o.upload_query_count++);(0,V.ff)("grafana_tempo_dashboard_loaded",o)}catch(n){console.error("error in tempo tracking handler",n)}},ge=e=>(0,pe.J)().containsTemplate(e),Rn=new T.hf(Ka).setQueryEditor(nn).setConfigEditor(yn).setQueryEditorHelp(w);(0,A.N$)().subscribe(v.Pl,Pn)},99292:(ie,F,u)=>{var T;T={value:!0};var v=u(52732),A=u(39953),s=v.__importDefault(u(95681));function V(y,w){w===void 0&&(w=[]);var S=s.default(y,w,{loading:!0}),W=S[0],$=S[1];return A.useEffect(function(){$()},[$]),W}F.Z=V}}]);

//# sourceMappingURL=5254.dbe848ddf1630fcf6f6e.js.map