"use strict";(self.webpackChunkgrafana=self.webpackChunkgrafana||[]).push([[6752],{90950:(X,W,i)=>{i.d(W,{n:()=>Q});var S=i(52423),u=i(68404),w=i(5916),n=i(11543),N=i(81764),b=i(8944);function Q({options:A,onOptionsChange:h}){return u.createElement("div",{className:f.container},u.createElement("h3",{className:"page-heading"},"Node Graph"),u.createElement(n.Z,{className:f.row},u.createElement(N._,{tooltip:"Enables the Node Graph visualization in the trace viewer.",label:"Enable Node Graph",labelWidth:26},u.createElement(b.x,{id:"enableNodeGraph",value:A.jsonData.nodeGraph?.enabled,onChange:D=>(0,w.tp)({onOptionsChange:h,options:A},"nodeGraph",{...A.jsonData.nodeGraph,enabled:D.currentTarget.checked})}))))}const f={container:S.css`
    label: container;
    width: 100%;
  `,row:S.css`
    label: row;
    align-items: baseline;
  `}},48288:(X,W,i)=>{i.d(W,{F:()=>D});var S=i(52423),u=i(68404),w=i(5916),n=i(53117),N=i(72648),b=i(11543),Q=i(81764),f=i(31403),A=i(46967),h=i(33045);function D({options:m,onOptionsChange:M}){const L=(0,N.wW)(v);return u.createElement("div",{className:(0,S.css)({width:"100%"})},u.createElement("h3",{className:"page-heading"},"Trace to metrics"),u.createElement("div",{className:L.infoText},"Trace to metrics lets you navigate from a trace span to the selected data source."),u.createElement(b.Z,{className:L.row},u.createElement(Q._,{tooltip:"The data source the trace is going to navigate to",label:"Data source",labelWidth:26},u.createElement(n.q,{inputId:"trace-to-metrics-data-source-picker",pluginId:"prometheus",current:m.jsonData.tracesToMetrics?.datasourceUid,noDefault:!0,width:40,onChange:I=>(0,w.tp)({onOptionsChange:M,options:m},"tracesToMetrics",{...m.jsonData.tracesToMetrics,datasourceUid:I.uid})})),m.jsonData.tracesToMetrics?.datasourceUid?u.createElement(f.zx,{type:"button",variant:"secondary",size:"sm",fill:"text",onClick:()=>{(0,w.tp)({onOptionsChange:M,options:m},"tracesToMetrics",{...m.jsonData.tracesToMetrics,datasourceUid:void 0})}},"Clear"):null),u.createElement(b.Z,null,u.createElement(Q._,{tooltip:"Tags that will be used in the metrics query.",label:"Tags",labelWidth:26},u.createElement(h.a,{values:m.jsonData.tracesToMetrics?.tags??[],onChange:I=>(0,w.tp)({onOptionsChange:M,options:m},"tracesToMetrics",{...m.jsonData.tracesToMetrics,tags:I})}))),u.createElement(b.Z,null,u.createElement(Q._,{label:"Span start time shift",labelWidth:26,grow:!0,tooltip:"Shifts the start time of the span. Default 0 (Time units can be used here, for example: 5s, 1m, 3h)"},u.createElement(A.I,{type:"text",placeholder:"-1h",width:40,onChange:I=>(0,w.tp)({onOptionsChange:M,options:m},"tracesToMetrics",{...m.jsonData.tracesToMetrics,spanStartTimeShift:I.currentTarget.value}),value:m.jsonData.tracesToMetrics?.spanStartTimeShift||""}))),u.createElement(b.Z,null,u.createElement(Q._,{label:"Span end time shift",labelWidth:26,grow:!0,tooltip:"Shifts the end time of the span. Default 0 Time units can be used here, for example: 5s, 1m, 3h"},u.createElement(A.I,{type:"text",placeholder:"1h",width:40,onChange:I=>(0,w.tp)({onOptionsChange:M,options:m},"tracesToMetrics",{...m.jsonData.tracesToMetrics,spanEndTimeShift:I.currentTarget.value}),value:m.jsonData.tracesToMetrics?.spanEndTimeShift||""}))),m.jsonData.tracesToMetrics?.queries?.map((I,x)=>u.createElement("div",{key:x,className:L.queryRow},u.createElement(Q._,{label:"Link Label",labelWidth:10},u.createElement(A.I,{label:"Link Label",type:"text",allowFullScreen:!0,value:I.name,onChange:C=>{let y=m.jsonData.tracesToMetrics?.queries.slice()??[];y[x].name=C.currentTarget.value,(0,w.tp)({onOptionsChange:M,options:m},"tracesToMetrics",{...m.jsonData.tracesToMetrics,queries:y})}})),u.createElement(Q._,{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},u.createElement(A.I,{label:"Query",type:"text",allowFullScreen:!0,value:I.query,onChange:C=>{let y=m.jsonData.tracesToMetrics?.queries.slice()??[];y[x].query=C.currentTarget.value,(0,w.tp)({onOptionsChange:M,options:m},"tracesToMetrics",{...m.jsonData.tracesToMetrics,queries:y})}})),u.createElement(f.zx,{variant:"destructive",title:"Remove query",icon:"times",type:"button",onClick:()=>{let C=m.jsonData.tracesToMetrics?.queries.slice();C?.splice(x,1),(0,w.tp)({onOptionsChange:M,options:m},"tracesToMetrics",{...m.jsonData.tracesToMetrics,queries:C})}}))),u.createElement(f.zx,{variant:"secondary",title:"Add query",icon:"plus",type:"button",onClick:()=>{(0,w.tp)({onOptionsChange:M,options:m},"tracesToMetrics",{...m.jsonData.tracesToMetrics,queries:[...m.jsonData.tracesToMetrics?.queries??[],{query:""}]})}},"Add query"))}const v=m=>({infoText:S.css`
    padding-bottom: ${m.spacing(2)};
    color: ${m.colors.text.secondary};
  `,row:S.css`
    label: row;
    align-items: baseline;
  `,queryRow:S.css`
    display: flex;
  `})},91159:(X,W,i)=>{i.d(W,{n:()=>I});var S=i(57706),u=i(68404),w=i(40400),n=i(35645),N=i(31220),b=i(13193),Q=i(67660),f=i(69659),A=i(59796),h=i(31439);const D=u.lazy(()=>Promise.all([i.e(1899),i.e(4254),i.e(794),i.e(7142)]).then(i.bind(i,47864))),v=x=>u.createElement(u.Suspense,{fallback:null},u.createElement(D,{...x})),m=x=>{const C=(0,u.useRef)(null),{runQueryOnBlur:y,onRunQuery:P,onChange:F,...z}=x,R=V=>{C.current=V,F(V),P()},B=V=>{y?V!==C.current&&R(V):F(V)};return u.createElement(v,{onRunQuery:R,onBlur:B,...z})},M="grafana.datasources.loki.browser.labels";function L(x,{typeaheadContext:C,typeaheadText:y}){switch(C){case"context-labels":{const P=N.getNextCharacter();(!P||P==="}"||P===",")&&(x+="=");break}case"context-label-values":{let P="";y.match(/^(!?=~?"|")/)||(P='"'),P+=(0,h.Hk)(x,y),N.getNextCharacter()!=='"'&&(P+='"'),x=P;break}default:}return x}class I extends u.PureComponent{constructor(C){super(C),this._isMounted=!1,this.onChangeLabelBrowser=y=>{this.onChangeQuery(y,!0),this.setState({labelBrowserVisible:!1})},this.onChangeQuery=(y,P)=>{const{query:F,onChange:z,onRunQuery:R}=this.props;if(z){const B={...F,expr:y};z(B),P&&R&&R()}},this.onTypeahead=async y=>{const{datasource:P}=this.props;if(!P.languageProvider)return{suggestions:[]};const F=P.languageProvider,{history:z}=this.props,{prefix:R,text:B,value:V,wrapperClasses:ce,labelKey:ue}=y;return await F.provideCompletionItems({text:B,value:V,prefix:R,wrapperClasses:ce,labelKey:ue},{history:z})},this.state={labelsLoaded:!1,labelBrowserVisible:!1},this.plugins=[(0,b.h)(),(0,Q.Z)({onlyIn:y=>y.object==="block"&&y.type==="code_block",getSyntax:y=>"logql"},{...S.languages,logql:this.props.datasource.languageProvider.getSyntax()})]}async componentDidMount(){this._isMounted=!0,await this.props.datasource.languageProvider.start(),this._isMounted&&this.setState({labelsLoaded:!0})}componentWillUnmount(){this._isMounted=!1}componentDidUpdate(C){const{range:y,datasource:{languageProvider:P}}=this.props;(0,h.rf)(y,C.range)&&P.fetchLabels()}render(){const{ExtraFieldElement:C,query:y,app:P,datasource:F,placeholder:z="Enter a Loki query (run with Shift+Enter)",history:R,onRunQuery:B,onBlur:V}=this.props;return u.createElement(A.G,{storageKey:M,defaultValue:[]},(ce,ue,de)=>u.createElement(u.Fragment,null,u.createElement("div",{className:"gf-form-inline gf-form-inline--xs-view-flex-column flex-grow-1","data-testid":this.props["data-testid"]},u.createElement("div",{className:"gf-form gf-form--grow flex-shrink-1 min-width-15"},n.v.featureToggles.lokiMonacoEditor?u.createElement(m,{runQueryOnBlur:P!==w.zj.Explore,datasource:F,history:R??[],onChange:this.onChangeQuery,onRunQuery:B,initialValue:y.expr??""}):u.createElement(f.q,{additionalPlugins:this.plugins,cleanText:F.languageProvider.cleanText,query:y.expr,onTypeahead:this.onTypeahead,onWillApplySuggestion:L,onChange:this.onChangeQuery,onBlur:V,onRunQuery:B,placeholder:z,portalOrigin:"loki"}))),C))}}},31439:(X,W,i)=>{i.d(W,{Hk:()=>A,U9:()=>b,_z:()=>h,aC:()=>D,iS:()=>Q,rf:()=>w,tU:()=>f});function S(v){return u(v/1e3)}function u(v){return Math.floor(v/60)}function w(v,m){if(v&&m){const M=S(v.from.valueOf())===S(m.from.valueOf()),L=S(v.to.valueOf())===S(m.to.valueOf());return!(M&&L)}return!1}const n=/[*+?()|\\.\[\]{}^$]/g;function N(v){return v.replace(n,"\\$&")}function b(v){return v.replace(/\\/g,"\\\\").replace(/\n/g,"\\n").replace(/"/g,'\\"')}function Q(v){return v.replace(/\\n/g,`
`).replace(/\\"/g,'"').replace(/\\\\/g,"\\")}function f(v){return b(N(v))}function A(v,m){return h(m)?f(v):b(v)}function h(v){return!!(v&&(v.includes("=~")||v.includes("!~")))}function D(v){const m=["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"],M=new RegExp(`^(?:-?\\d+(?:\\.\\d+)?)(?:${m.join("|")})$`);return!!v.match(M)}},38435:(X,W,i)=>{i.d(W,{d:()=>f});var S=i(52423),u=i(68404),w=i(86253),n=i(20112),N=i(26418),b=i(72648),Q=i(39904);function f({title:h,children:D,collapsedInfo:v,queryStats:m}){const[M,L]=(0,w.Z)(!1),I=(0,b.wW)(A),x=()=>{const{text:C,suffix:y}=(0,n.Cf)("bytes")(m.bytes,1);return C+y};return u.createElement("div",{className:I.wrapper},u.createElement(N.Stack,{gap:0,direction:"column"},u.createElement("div",{className:I.header,onClick:L,title:"Click to edit options"},u.createElement("div",{className:I.toggle},u.createElement(Q.J,{name:M?"angle-down":"angle-right"})),u.createElement("h6",{className:I.title},h),!M&&u.createElement("div",{className:I.description},v.map((C,y)=>u.createElement("span",{key:y},C)))),M&&u.createElement("div",{className:I.body},D)),m&&u.createElement("p",{className:I.stats},"This query will process approximately ",x(),"."))}const A=h=>({wrapper:(0,S.css)({width:"100%",display:"flex",justifyContent:"space-between",alignItems:"baseline"}),switchLabel:(0,S.css)({color:h.colors.text.secondary,cursor:"pointer",fontSize:h.typography.bodySmall.fontSize,"&:hover":{color:h.colors.text.primary}}),header:(0,S.css)({display:"flex",cursor:"pointer",alignItems:"baseline",color:h.colors.text.primary,"&:hover":{background:h.colors.emphasize(h.colors.background.primary,.03)}}),title:(0,S.css)({flexGrow:1,overflow:"hidden",fontSize:h.typography.bodySmall.fontSize,fontWeight:h.typography.fontWeightMedium,margin:0}),description:(0,S.css)({color:h.colors.text.secondary,fontSize:h.typography.bodySmall.fontSize,paddingLeft:h.spacing(2),gap:h.spacing(2),display:"flex"}),body:(0,S.css)({display:"flex",paddingTop:h.spacing(2),gap:h.spacing(2),flexWrap:"wrap"}),toggle:(0,S.css)({color:h.colors.text.secondary,marginRight:`${h.spacing(1)}`}),stats:(0,S.css)({margin:"0px",color:h.colors.text.secondary,fontSize:h.typography.bodySmall.fontSize})})},6752:(X,W,i)=>{i.r(W),i.d(W,{plugin:()=>ca});var S=i(7238),u=i(55294),w=i(82378),n=i(68404),N=i(41818),b=i(35645);function Q(){return(0,N.ff)("grafana_traces_cheatsheet_clicked",{datasourceType:"tempo",grafana_version:b.v.buildInfo.version}),n.createElement("div",null,n.createElement("h2",{id:"tempo-cheat-sheet"},"Tempo Cheat Sheet"),n.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."),n.createElement("p",null,"Here are some"," ",n.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 f=i(52423),A=i(50700),h=i(11543),D=i(81764),v=i(2594),m=i(30784),M=i(77117),L=i(72648),I=i(91159),x=i(82897);const C={};var y=(t=>(t[t.UNSPECIFIED=0]="UNSPECIFIED",t[t.INTERNAL=1]="INTERNAL",t[t.SERVER=2]="SERVER",t[t.CLIENT=3]="CLIENT",t[t.PRODUCER=4]="PRODUCER",t[t.CONSUMER=5]="CONSUMER",t))(y||{}),P=i(26418),F=i(68668),z=i(38435),R=i(53786),B=i(85526),V=i(37537),ce=i(16313),ue=i(4534),de=i(3363),Ne=i(98356),Z=i(2101),Me=i(94514),Ie=i(39409),Se=i(73273),Y=i(49922),Pe=i(33180),ge=i(46519),me=i(37556),Je=i(14582),qe=i(22069),ee=i(40885),he=i(54899),Xe=i(8878),pe=i(91162),O=i(69407);class Le extends S.iL{constructor(e,a){super(),this.request=async(s,r={})=>(await this.datasource.metadataRequest(s,r))?.data,this.start=async()=>(this.startTask||(this.startTask=this.fetchTags().then(()=>[])),this.startTask),this.getTags=()=>this.tags,this.provideCompletionItems=async({text:s,value:r})=>{const o={suggestions:[]};if(!r)return o;const l=r.endText.getText();return l[l.indexOf(s)-1]==="="||s==="="?this.getTagValueCompletionItems(r):this.getTagsCompletionItems()},this.getTagsCompletionItems=()=>{const{tags:s}=this,r=[];return s?.length&&r.push({label:"Tag",items:s.map(o=>({label:o}))}),{suggestions:r}},this.datasource=e,Object.assign(this,a)}async fetchTags(){const e=await this.request("/api/search/tags",[]);this.tags=e.tagNames}async getTagValueCompletionItems(e){const a=e.endText.getText().split(" ");let s=a[a.length-1]??"";s=s.split("=")[0];const r=await this.request(`/api/v2/search/tag/${s}/values`,[]),o=[];return r&&r.tagValues&&o.push({label:"Tag Values",items:r.tagValues.map(l=>({label:l,insertText:`"${l}"`}))}),{suggestions:o}}async getOptionsV1(e){const a=await this.request(`/api/search/tag/${e}/values`);let s=[];return a&&a.tagValues&&(s=a.tagValues.map(r=>({value:r,label:r}))),s}async getOptionsV2(e){const a=await this.request(`/api/v2/search/tag/${e}/values`);let s=[];return a&&a.tagValues&&(s=a.tagValues.map(r=>({type:r.type,value:r.value,label:r.value}))),s}}var te=i(83663);const ae=20;class et extends qe.CK{constructor(e,a=(0,ee.J)()){super(e),this.instanceSettings=e,this.templateSrv=a,this.uploadedJson=null,this.getLokiSearchDS=()=>{const s=this.tracesToLogs?.lokiSearch!==!1&&this.lokiSearch===void 0?this.tracesToLogs?.datasourceUid:void 0;return this.lokiSearch?.datasourceUid??s},this.tracesToLogs=e.jsonData.tracesToLogs,this.serviceMap=e.jsonData.serviceMap,this.search=e.jsonData.search,this.nodeGraph=e.jsonData.nodeGraph,this.lokiSearch=e.jsonData.lokiSearch,this.traceQuery=e.jsonData.traceQuery,this.languageProvider=new Le(this)}query(e){const a=[],s=e.targets.filter(l=>!l.hide),r=(0,x.groupBy)(s,l=>l.queryType||"traceql");if(r.clear)return(0,R.of)({data:[],state:Y.Gu.Done});const o=this.getLokiSearchDS();if(o&&r.search?.length>0){(0,N.ff)("grafana_traces_loki_search_queried",{datasourceType:"tempo",app:e.app??"",grafana_version:b.v.buildInfo.version,hasLinkedQueryExpr:!!(r.search[0].linkedQuery?.expr&&r.search[0].linkedQuery?.expr!=="")});const l=(0,pe.ak)();a.push((0,B.D)(l.get(o)).pipe((0,Ne.z)(c=>{const d={...e,targets:r.search.map(p=>p.linkedQuery)},T=c.instanceSettings.jsonData.derivedFields?.filter(p=>p.datasourceUid===this.uid&&p.matcherRegex).map(p=>p.matcherRegex)||[];return!T||T.length===0?(0,V._)(()=>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.")):c.query(d).pipe((0,Z.U)(p=>p.error?p:(0,te.RY)(p,this.uid,this.name,T)))})))}if(r.nativeSearch?.length)try{(0,N.ff)("grafana_traces_search_queried",{datasourceType:"tempo",app:e.app??"",grafana_version:b.v.buildInfo.version,hasServiceName:!!r.nativeSearch[0].serviceName,hasSpanName:!!r.nativeSearch[0].spanName,resultLimit:r.nativeSearch[0].limit??"",hasSearch:!!r.nativeSearch[0].search,minDuration:r.nativeSearch[0].minDuration??"",maxDuration:r.nativeSearch[0].maxDuration??""});const l={startTime:e.range.from.unix(),endTime:e.range.to.unix()},c=this.applyVariables(r.nativeSearch[0],e.scopedVars),d=this.buildSearchQuery(c,l);a.push(this._request("/api/search",d).pipe((0,Z.U)(g=>({data:[(0,te.n4)(g.data.traces,this.instanceSettings)]})),(0,Me.K)(g=>(0,R.of)({error:{message:g.data.message},data:[]}))))}catch(l){return(0,R.of)({error:{message:l instanceof Error?l.message:"Unknown error occurred"},data:[]})}if(r.traceql?.length)try{const c=this.applyVariables(r.traceql[0],e.scopedVars)?.query||"",d=/^[0-9A-Fa-f]*$/;c.trim().match(d)?((0,N.ff)("grafana_traces_traceID_queried",{datasourceType:"tempo",app:e.app??"",grafana_version:b.v.buildInfo.version,hasQuery:c!==""}),a.push(this.handleTraceIdQuery(e,r.traceql))):((0,N.ff)("grafana_traces_traceql_queried",{datasourceType:"tempo",app:e.app??"",grafana_version:b.v.buildInfo.version,query:c??""}),a.push(this._request("/api/search",{q:c,limit:e.targets[0].limit,start:e.range.from.unix(),end:e.range.to.unix()}).pipe((0,Z.U)(g=>({data:(0,te.xA)(g.data.traces,this.instanceSettings)})),(0,Me.K)(g=>(0,R.of)({error:{message:g.data.message},data:[]})))))}catch(l){return(0,R.of)({error:{message:l instanceof Error?l.message:"Unknown error occurred"},data:[]})}if(r.upload?.length)if(this.uploadedJson){(0,N.ff)("grafana_traces_json_file_uploaded",{datasourceType:"tempo",app:e.app??"",grafana_version:b.v.buildInfo.version});const l=JSON.parse(this.uploadedJson),c=l.batches,d=Array.isArray(l)&&l.some(g=>g?.meta?.preferredVisualisationType==="nodeGraph");c?a.push((0,R.of)((0,te.IM)(l.batches,this.nodeGraph?.enabled))):d?a.push((0,R.of)({data:l,state:Y.Gu.Done})):a.push((0,R.of)({error:{message:"Unable to parse uploaded data."},data:[]}))}else a.push((0,R.of)({data:[],state:Y.Gu.Done}));if(this.serviceMap?.datasourceUid&&r.serviceMap?.length>0){(0,N.ff)("grafana_traces_service_graph_queried",{datasourceType:"tempo",app:e.app??"",grafana_version:b.v.buildInfo.version,hasServiceMapQuery:!!r.serviceMap[0].serviceMapQuery});const l=this.serviceMap.datasourceUid,c=this.uid;a.push(tt(e,l,c).pipe((0,Ie.b)(d=>at(e,d,l).pipe((0,Ie.b)(g=>rt(e,g,l,c))))))}return(0,ce.T)(...a)}applyTemplateVariables(e,a){return this.applyVariables(e,a)}interpolateVariablesInQueries(e,a){return!e||e.length===0?[]:e.map(s=>({...s,datasource:this.getRef(),...this.applyVariables(s,a)}))}applyVariables(e,a){const s={...e};return e.linkedQuery&&(s.linkedQuery={...e.linkedQuery,expr:this.templateSrv.replace(e.linkedQuery?.expr??"",a)}),{...s,query:this.templateSrv.replace(e.query??"",a),serviceName:this.templateSrv.replace(e.serviceName??"",a),spanName:this.templateSrv.replace(e.spanName??"",a),search:this.templateSrv.replace(e.search??"",a),minDuration:this.templateSrv.replace(e.minDuration??"",a),maxDuration:this.templateSrv.replace(e.maxDuration??"",a)}}handleTraceIdQuery(e,a){const s=a.filter(o=>o.query).map(o=>({...o,query:o.query.trim()}));if(!s.length)return ue.E;const r=this.traceIdQueryRequest(e,s);return super.query(r).pipe((0,Z.U)(o=>o.error?o:(0,te.Jk)(o,this.nodeGraph?.enabled)))}traceIdQueryRequest(e,a){const s={...e,targets:a};return this.traceQuery?.timeShiftEnabled?s.range=e.range&&{...e.range,from:e.range.from.subtract(Pe.intervalToMs(this.traceQuery?.spanStartTimeShift||"30m"),"milliseconds"),to:e.range.to.add(Pe.intervalToMs(this.traceQuery?.spanEndTimeShift||"30m"),"milliseconds")}:s.range={from:(0,ge.CQ)(0),to:(0,ge.CQ)(0),raw:{from:(0,ge.CQ)(0),to:(0,ge.CQ)(0)}},s}async metadataRequest(e,a={}){return await(0,de.n)(this._request(e,a,{method:"GET",hideFromInspector:!0}))}_request(e,a,s){const r=a?(0,Xe.tW)(a):"",o=`${this.instanceSettings.url}${e}${r.length?`?${r}`:""}`,l={...s,url:o};return(0,he.i)().fetch(l)}async testDatasource(){const e={headers:{},method:"GET",url:`${this.instanceSettings.url}/api/echo`};if((await(0,de.n)((0,he.i)().fetch(e)))?.ok)return{status:"success",message:"Data source is working"}}getQueryDisplayText(e){if(e.queryType==="nativeSearch"){let a=[];for(const s of["serviceName","spanName","search","minDuration","maxDuration","limit"])e.hasOwnProperty(s)&&e[s]&&a.push(`${(0,x.startCase)(s)}: ${e[s]}`);return a.join(", ")}return e.query}buildSearchQuery(e,a){let s=e.search??"",r=(0,x.pick)(e,["minDuration","maxDuration","limit"]);if(r=(0,x.pickBy)(r,x.identity),e.serviceName&&(s+=` service.name="${e.serviceName}"`),e.spanName&&(s+=` name="${e.spanName}"`),r.limit||(r.limit=ae),r.minDuration){if(r.minDuration=this.templateSrv.replace(r.minDuration??""),!(0,me.IA)(r.minDuration))throw new Error("Please enter a valid min duration.");r.minDuration=r.minDuration.replace(/\s/g,"")}if(r.maxDuration){if(r.maxDuration=this.templateSrv.replace(r.maxDuration??""),!(0,me.IA)(r.maxDuration))throw new Error("Please enter a valid max duration.");r.maxDuration=r.maxDuration.replace(/\s/g,"")}if(!Number.isInteger(r.limit)||r.limit<=0)throw new Error("Please enter a valid limit.");let o={tags:s,...r};return a&&(o.start=a.startTime,o.end=a.endTime),o}}function be(t,e){return(0,B.D)((0,pe.ak)().get(e)).pipe((0,Ne.z)(a=>a.query(t)))}function tt(t,e,a){const s=De(t);return be(s,e).pipe((0,Se.q)(),(0,Z.U)(r=>{const o=r.find(d=>!!d.error);if(o)throw new Error(o.error.message);const{nodes:l,edges:c}=(0,O.BC)(r,t.range);if(l.fields.length>0&&c.fields.length>0){const d=l.fields[0].values.length,g=c.fields[0].values.length;(0,N.ff)("grafana_traces_service_graph_size",{datasourceType:"tempo",grafana_version:b.v.buildInfo.version,nodeLength:d,edgeLength:g})}return l.refId=t.targets[0].refId,c.refId=t.targets[0].refId,l.fields[0].config=we(e,a,"__data.fields.id","__data.fields[0]"),c.fields[0].config=we(e,a,"__data.fields.target","__data.fields.target","__data.fields.source"),{data:[l,c],state:Y.Gu.Done}}))}function at(t,e,a){const s=De(t);return s.targets=Qe([H(O.rB,O.T1,t)]),be(s,a).pipe((0,Se.q)(),(0,Z.U)(r=>{const o=r.find(l=>!!l.error);if(o)throw new Error(o.error.message);return{data:[r[0]?.data??[],e.data[0],e.data[1]],state:Y.Gu.Done}}))}function rt(t,e,a,s){let r=[],o="",l=[];const c=e.data[0][0]?.fields[1]?.values.toArray()??[];c.length>0&&(o=H(O.$C,'span_name=~"'+c.join("|")+'"',t),r.push(o),c.map(g=>{const T=H(O.vO,'span_name=~"'+g+'"',t);l.push(T),r.push(T)}));const d=De(t);return d.targets=Qe(r),be(d,a).pipe((0,Se.q)(),(0,Z.U)(g=>{const T=g.find(k=>!!k.error);if(T)throw new Error(T.error.message);const p=st(t,e,g[0],o,l,a,s);return p.fields.length===0?{data:[e.data[1],e.data[2]],state:Y.Gu.Done}:{data:[p,e.data[1],e.data[2]],state:Y.Gu.Done}}))}function J(t,e,a,s){return{url:"",title:t,internal:{query:{expr:e,range:!s,exemplar:!s,instant:s},datasourceUid:a,datasourceName:(0,pe.ak)().getDataSourceSettingsByUid(a)?.name??""}}}function we(t,e,a,s,r){return r=r?`client="\${${r}}",`:"",{links:[J("Request rate",`sum by (client, server)(rate(${O.Yt}{${r}server="\${${a}}"}[$__rate_interval]))`,t,!1),J("Request histogram",`histogram_quantile(0.9, sum(rate(${O.NZ}{${r}server="\${${a}}"}[$__rate_interval])) by (le, client, server))`,t,!1),J("Failed request rate",`sum by (client, server)(rate(${O.yf}{${r}server="\${${a}}"}[$__rate_interval]))`,t,!1),Re("View traces",`\${${s}}`,"",e)]}}function Re(t,e,a,s){let r={queryType:"nativeSearch"};return e!==""&&(r.serviceName=e),a!==""&&(r.spanName=a),{url:"",title:t,internal:{query:r,datasourceUid:s,datasourceName:(0,pe.ak)().getDataSourceSettingsByUid(s)?.name??""}}}function De(t){return{...t,targets:O.t3.map(e=>({format:"table",refId:e,expr:`rate(${e}${t.targets[0].serviceMapQuery||""}[$__range])`,instant:!0}))}}function st(t,e,a,s,r,o,l){let c={fields:[]};const d=e.data[0]?.filter(p=>p.refId===H(O.rB,O.T1,t)),g=a.data.filter(p=>p.refId===s),T=a.data.filter(p=>r.includes(p.refId));if(d.length>0&&d[0].fields?.length>2&&(c.fields.push({...d[0].fields[1],name:"Name",config:{filterable:!1}}),c.fields.push({...d[0].fields[2],name:"Rate",config:{links:[J("Rate",xe(H(O.rB,'span_name="${__data.fields[0]}"',t)),o,!1)],decimals:2}}),c.fields.push({...d[0].fields[2],name:" ",labels:null,config:{color:{mode:"continuous-BlPu"},custom:{displayMode:"lcd-gauge"},decimals:3}})),g.length>0&&g[0].fields?.length>2){const p=g[0].fields[1]?.values.toArray()??[],k=g[0].fields[2]?.values.toArray()??[];let $={};p.map((ye,Ee)=>{$[ye]={value:k[Ee]}});const j=Ae({...d},$);c.fields.push({...g[0].fields[2],name:"Error Rate",values:j,config:{links:[J("Error Rate",xe(H(O.$C,'span_name="${__data.fields[0]}"',t)),o,!1)],decimals:2}}),c.fields.push({...g[0].fields[2],name:"  ",values:j,labels:null,config:{color:{mode:"continuous-RdYlGr"},custom:{displayMode:"lcd-gauge"},decimals:3}})}if(T.length>0&&T[0].fields?.length>1){let p={};T.map(k=>{const $=k.refId?.includes('span_name=~"')?'span_name=~"':'span_name="',j=k.refId?.split($)[1].split('"}')[0];p[j]={value:k.fields[1].values.toArray()[0]}}),c.fields.push({...T[0].fields[1],name:"Duration (p90)",values:Ae({...d},p),config:{links:[J("Duration",xe(H(O.vO,'span_name="${__data.fields[0]}"',t)),o,!1)],unit:"s"}})}return c.fields.length>0&&c.fields[0].values&&c.fields.push({name:"Links",type:Je.fS.string,values:c.fields[0].values.map(()=>"Tempo"),config:{links:[Re("Tempo","","${__data.fields[0]}",l)]}}),c}function H(t,e,a){let s=a.targets[0]?.serviceMapQuery??"";const r=s.match(/^{(.*)}$/);r?.length&&(s=r[1]),s=s.replace("client","service").replace("server","service");const o=s.includes("span_name")?t.params.concat(s):t.params.concat(s).concat(e).filter(l=>l);return t.expr.replace("{}","{"+o.join(",")+"}")}function xe(t){return t=t.replace("topk(5, ","").replace(" by (span_name))",""),t.replace("__range","__rate_interval")}function Ae(t,e){const a=t[0]?.fields[1]?.values.toArray()??[];let s=[];for(let r=0;r<a.length;r++)Object.keys(e).includes(a[r])?s.push(e[a[r]].value):s.push("0");return s}function Qe(t){return t.map(e=>({refId:e,expr:e,instant:!0}))}const Oe=n.memo(({onChange:t,query:e})=>{e.hasOwnProperty("limit")||(e.limit=ae);const a=s=>{t({...e,limit:parseInt(s.currentTarget.value,10)})};return n.createElement(n.Fragment,null,n.createElement(P.EditorRow,null,n.createElement(z.d,{title:"Options",collapsedInfo:[`Limit: ${e.limit||ae}`]},n.createElement(P.EditorField,{label:"Limit",tooltip:"Maximum number of traces to return."},n.createElement(F.H,{className:"width-4",placeholder:"auto",type:"number",min:1,defaultValue:e.limit||ae,onCommitChange:a,value:e.limit})))))});Oe.displayName="TempoQueryBuilderOptions";var $e=i(9405),fe=i(60499),Ue=i(98864),ve=i(3153);const q=class{constructor(t){this.triggerCharacters=["{",".","[","(","=","~"," ",'"'],this.tags={},this.cachedValues={},this.languageProvider=t.languageProvider,this.registerInteractionCommandId=null}provideCompletionItems(t,e){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:a,offset:s}=it(this.monaco,t,e),r=this.getSituation(t.getValue(),s);return this.getCompletions(r).then(l=>{const c=l.length.toString().length;return{suggestions:l.map((g,T)=>{const p={kind:nt(g.type,this.monaco),label:g.label,insertText:g.insertText,sortText:T.toString().padStart(c,"0"),range:a,command:{id:this.registerInteractionCommandId||"noOp",title:"Report Interaction",arguments:[g.label,g.type]}};return ot(p,g.type,t,s),p})}})}setTags(t){t.forEach(e=>this.tags[e]=new Set)}setRegisterInteractionCommandId(t){this.registerInteractionCommandId=t}async getTagValues(t){let e;return this.cachedValues.hasOwnProperty(t)?e=this.cachedValues[t]:(e=await this.languageProvider.getOptionsV2(t),this.cachedValues[t]=e),e}async getCompletions(t){if(!Object.keys(this.tags).length)return[];switch(t.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_NAME":return this.getScopesCompletions().concat(this.getIntrinsicsCompletions()).concat(this.getTagsCompletions());case"SPANSET_IN_NAME_SCOPE":return this.getTagsCompletions();case"SPANSET_AFTER_NAME":return q.operators.map(r=>({label:r,insertText:r,type:"OPERATOR"}));case"SPANSET_IN_VALUE":const e=await this.getTagValues(t.tagName),a=[],s=r=>t.betweenQuotes?r.label:r.type==="string"?`"${r.label}"`:r.label;return e.forEach(r=>{r?.label&&a.push({label:r.label,insertText:s(r),type:"TAG_VALUE"})}),a;case"SPANSET_AFTER_VALUE":return q.logicalOps.concat("}").map(r=>({label:r,insertText:r,type:"OPERATOR"}));default:throw new Error(`Unexpected situation ${t}`)}}getTagsCompletions(t){return Object.keys(this.tags).sort((e,a)=>e.localeCompare(a,void 0,{sensitivity:"accent"})).map(e=>({label:e,insertText:(t||"")+e,type:"TAG_NAME"}))}getIntrinsicsCompletions(t){return q.intrinsics.map(e=>({label:e,insertText:(t||"")+e,type:"KEYWORD"}))}getScopesCompletions(t){return q.scopes.map(e=>({label:e,insertText:(t||"")+e,type:"SCOPE"}))}getSituationInSpanSet(t){const e=/(?<name>[\w./-]+)?/,a=/(?<op>[!=+\-<>]+)/,s=/(?<value>(?<open_quote>")([^"\n&|]+)?(?<close_quote>")?|([^"\n\s&|]+))?/,r=new RegExp("([\\s{])("+e.source+"(?<space1>\\s*)("+a.source+"(?<space2>\\s*)"+s.source+")?)(?<space3>\\s*)$"),o=t.match(r);if(o){const l=o.groups?.name,c=o.groups?.op;if(!l)return{type:"SPANSET_EMPTY"};if(l===".")return{type:"SPANSET_ONLY_DOT"};const d=l.match(/^(?<pre_dot>\.)?(?<word>\w[\w./-]*\w)(?<post_dot>\.)?$/);return c?o.groups?.space3&&o.groups.open_quote===o.groups.close_quote?{type:"SPANSET_AFTER_VALUE"}:{type:"SPANSET_IN_VALUE",tagName:l,betweenQuotes:!!o.groups?.open_quote}:q.scopes.filter(g=>g===d?.groups?.word)&&d?.groups?.post_dot?{type:"SPANSET_IN_NAME_SCOPE"}:{type:o.groups?.space1?"SPANSET_AFTER_NAME":"SPANSET_IN_NAME"}}return{type:"EMPTY"}}getSituation(t,e){if(t===""||e===0)return{type:"EMPTY"};const a=t.substring(0,e);return a.lastIndexOf("{")>a.lastIndexOf("}")?this.getSituationInSpanSet(a):{type:"UNKNOWN"}}};let re=q;re.intrinsics=["duration","name","status"],re.scopes=["resource","span"],re.operators=["=","-","+","<",">",">=","<=","=~"],re.logicalOps=["&&","||"];function nt(t,e){switch(t){case"TAG_NAME":return e.languages.CompletionItemKind.Enum;case"KEYWORD":return e.languages.CompletionItemKind.Keyword;case"OPERATOR":return e.languages.CompletionItemKind.Operator;case"TAG_VALUE":return e.languages.CompletionItemKind.EnumMember;case"SCOPE":return e.languages.CompletionItemKind.Class;default:throw new Error(`Unexpected CompletionType: ${t}`)}}function it(t,e,a){const s=e.getWordAtPosition(a),r=s!=null?t.Range.lift({startLineNumber:a.lineNumber,endLineNumber:a.lineNumber,startColumn:s.startColumn,endColumn:s.endColumn}):t.Range.fromPositions(a),o={column:a.column,lineNumber:a.lineNumber};return{offset:e.getOffsetAt(o),range:r}}function ot(t,e,a,s){if(e==="TAG_NAME"){const r=a.getValue().substring(0,s).match(/(span\.|resource\.|\.)?([\w./-]*)$/);if(r){const o=r[1],l=r[2];l&&(!o&&t.insertText[0]!=="."&&(t.insertText="."+t.insertText),t.range={...t.range,startColumn:s-l.length+1})}}}const lt={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=["=","!=",">","<",">=","<=","=~","!~"],ut=["duration","name","status","parent"],dt=["resource","span"],gt={ignoreCase:!1,defaultToken:"",tokenPostfix:".traceql",keywords:ut.concat(dt),operators:ct,statusValues:["ok","unset","error","false","true"],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:[[/[a-z_.][\w./_-]*(?=\s*(=|!=|>|<|>=|<=|=~|!~))/,"tag"],[/[a-z_.][\w./_-]*/,"tag"],[/[0-9.]+(s|ms|ns|m)/,"number"],[/^\s*[0-9A-Fa-f]+\s*$/,"tag"],[/[a-zA-Z_.]\w*/,{cases:{"@keywords":"type","@statusValues":"type.identifier","@default":"identifier"}}],[/"([^"\\]|\\.)*$/,"string.invalid"],[/'([^'\\]|\\.)*$/,"string.invalid"],[/"/,"string","@string_double"],[/'/,"string","@string_single"],{include:"@whitespace"},[/[{}()\[\]]/,"@brackets"],[/[<>](?!@symbols)/,"@brackets"],[/@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"]],clauses:[[/[^(,)]/,"tag"],[/\)/,"identifier","@pop"]],whitespace:[[/[ \t\r\n]+/,"white"]]}},mt={id:"traceql",extensions:[".traceql"],aliases:["tempo","traceql"],mimetypes:[],def:{language:gt,languageConfiguration:lt}};function ht(t){const{onChange:e,onRunQuery:a,placeholder:s}=t,r=Et(t.datasource),o=(0,L.l4)(),l=St(o,s);return n.createElement($e.p,{value:t.value,language:se,onBlur:e,onChange:e,containerStyles:l.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:Tt,onEditorDidMount:(c,d)=>{r(c,d,vt(c)),ft(c,d,a),pt(c,d,l),yt(c)}})}function pt(t,e,a){const s=[{range:new e.Range(1,1,1,1),options:{className:a.placeholder,isWholeLine:!0}}];let r=[];const o=()=>{const l=t.getModel();if(!l)return;const c=l.getValueLength()===0?s:[];r=l.deltaDecorations(r,c)};o(),t.onDidChangeModelContent(o)}function ft(t,e,a){t.addAction({id:"run-query",label:"Run Query",keybindings:[e.KeyMod.Shift|e.KeyCode.Enter],contextMenuGroupId:"navigation",contextMenuOrder:1.5,run:function(){a()}})}function vt(t){return t.addCommand(0,function(e,a,s){const r={datasourceType:"tempo",type:s};s!=="TAG_VALUE"&&(r.label=a),(0,N.ff)("grafana_traces_traceql_completion",r)})}function yt(t){const e=t.getDomNode(),a=()=>{if(e){const s=Math.min(1e3,t.getContentHeight()),r=parseInt(e.style.width,10);e.style.width=`${r}px`,e.style.height=`${s}px`,t.layout({width:r,height:s})}};t.onDidContentSizeChange(a),a()}function Et(t){const e=(0,n.useRef)(new re({languageProvider:t.languageProvider}));(0,n.useEffect)(()=>{(async()=>{try{await t.languageProvider.start();const r=t.languageProvider.getTags();r&&(r.find(o=>o==="status")||r.push("status"),e.current.setTags(r))}catch(r){r instanceof Error&&(0,ve.WI)((0,Ue.$l)((0,fe.t_)("Error",r)))}})()},[t]);const a=(0,n.useRef)(null);return(0,n.useEffect)(()=>()=>{a.current?.()},[]),(s,r,o)=>{e.current.editor=s,e.current.monaco=r,e.current.setRegisterInteractionCommandId(o);const{dispose:l}=r.languages.registerCompletionItemProvider(se,e.current);a.current=l}}let We=!1;const se="traceql";function Tt(t){if(!We){We=!0;const{aliases:e,extensions:a,mimetypes:s,def:r}=mt;t.languages.register({id:se,aliases:e,extensions:a,mimetypes:s}),t.languages.setMonarchTokensProvider(se,r.language),t.languages.setLanguageConfiguration(se,r.languageConfiguration)}}const St=(t,e)=>({queryField:f.css`
      border-radius: ${t.shape.borderRadius()};
      border: 1px solid ${t.components.input.borderColor};
      flex: 1;
    `,placeholder:f.css`
      ::after {
        content: '${e}';
        font-family: ${t.typography.fontFamilyMonospace};
        opacity: 0.3;
      }
    `});function bt(t){const e=(0,L.wW)(Dt),a=(0,x.defaults)(t.query,C),s=r=>{t.onChange({...a,query:r})};return n.createElement(n.Fragment,null,n.createElement(M.W,null,"Build complex queries using TraceQL to select a list of traces."," ",n.createElement("a",{rel:"noreferrer",target:"_blank",href:"https://grafana.com/docs/tempo/latest/traceql/"},"Documentation")),n.createElement(ht,{placeholder:"Enter a TraceQL query or trace ID (run with Shift+Enter)",value:a.query,onChange:s,datasource:t.datasource,onRunQuery:t.onRunQuery}),n.createElement("div",{className:e.optionsContainer},n.createElement(Oe,{query:a,onChange:t.onChange})))}const Dt=()=>({optionsContainer:f.css`
    margin-top: 10px;
  `});var Fe=i(63134),xt=i(27303),Ve=i(53217),ne=i(46967),Be=i(45253),ke=i(659);class Ct{constructor(e){this.triggerCharacters=["="," "],this.tags={},this.cachedValues={},this.languageProvider=e.languageProvider}provideCompletionItems(e,a){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:s,offset:r}=Mt(this.monaco,e,a),o=this.getSituation(e.getValue(),r);return this.getCompletions(o).then(c=>{const d=c.length.toString().length;return{suggestions:c.map((T,p)=>({kind:Nt(T.type,this.monaco),label:T.label,insertText:T.insertText,sortText:p.toString().padStart(d,"0"),range:s}))}})}setTags(e){e.forEach(a=>this.tags[a]=new Set)}async getTagValues(e){let a;return this.cachedValues.hasOwnProperty(e)?a=this.cachedValues[e]:(a=await this.languageProvider.getOptionsV1(e),this.cachedValues[e]=a),a}async getCompletions(e){if(!Object.keys(this.tags).length)return[];switch(e.type){case"UNKNOWN":return[];case"EMPTY":return this.getTagsCompletions();case"IN_NAME":return this.getTagsCompletions();case"IN_VALUE":const a=await this.getTagValues(e.tagName),s=[],r=o=>`"${o.label}"`;return a.forEach(o=>{o?.label&&s.push({label:o.label,insertText:r(o),type:"TAG_VALUE"})}),s;default:throw new Error(`Unexpected situation ${e}`)}}getTagsCompletions(){return Object.keys(this.tags).sort((e,a)=>e.localeCompare(a,void 0,{sensitivity:"accent"})).map(e=>({label:e,insertText:e,type:"TAG_NAME"}))}getSituation(e,a){if(e===""||a===0||e[e.length-1]===" ")return{type:"EMPTY"};const s=e.substring(0,a),r=/(?<key>[^= ]+)(?<equals>=)?(?<value>([^ "]+)|"([^"]*)")?/,o=s.match(new RegExp(r,"g"));if(o?.length){const c=o[o.length-1].match(r);if(c){const d=c.groups?.key,g=c.groups?.equals;return d?g?{type:"IN_VALUE",tagName:d}:{type:"IN_NAME"}:{type:"EMPTY"}}}return{type:"EMPTY"}}}function Nt(t,e){switch(t){case"TAG_NAME":return e.languages.CompletionItemKind.Enum;case"KEYWORD":return e.languages.CompletionItemKind.Keyword;case"OPERATOR":return e.languages.CompletionItemKind.Operator;case"TAG_VALUE":return e.languages.CompletionItemKind.EnumMember;case"SCOPE":return e.languages.CompletionItemKind.Class;default:throw new Error(`Unexpected CompletionType: ${t}`)}}function Mt(t,e,a){const s=e.getWordAtPosition(a),r=s!=null?t.Range.lift({startLineNumber:a.lineNumber,endLineNumber:a.lineNumber,startColumn:s.startColumn,endColumn:s.endColumn}):t.Range.fromPositions(a),o={column:a.column,lineNumber:a.lineNumber};return{offset:e.getOffsetAt(o),range:r}}const It={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 Pt(t){const{onChange:e,onBlur:a,placeholder:s}=t,r=Rt(t.datasource),o=(0,L.l4)(),l=Qt(o,s);return n.createElement($e.p,{value:t.value,language:ie,onBlur:a,onChange:e,containerStyles:l.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:At,onEditorDidMount:(c,d)=>{r(c,d),Lt(c,d,l),wt(c)}})}function Lt(t,e,a){const s=[{range:new e.Range(1,1,1,1),options:{className:a.placeholder,isWholeLine:!0}}];let r=[];const o=()=>{const l=t.getModel();if(!l)return;const c=l.getValueLength()===0?s:[];r=l.deltaDecorations(r,c)};o(),t.onDidChangeModelContent(o)}function wt(t){const e=t.getDomNode(),a=()=>{if(e){const s=Math.min(1e3,t.getContentHeight()),r=parseInt(e.style.width,10);e.style.width=`${r}px`,e.style.height=`${s}px`,t.layout({width:r,height:s})}};t.onDidContentSizeChange(a),a()}function Rt(t){const e=(0,n.useRef)(new Ct({languageProvider:t.languageProvider}));(0,n.useEffect)(()=>{(async()=>{try{await t.languageProvider.start();const r=t.languageProvider.getTags();r&&(r.find(o=>o==="status.code")||r.push("status.code"),e.current.setTags(r))}catch(r){r instanceof Error&&(0,ve.WI)((0,Ue.$l)((0,fe.t_)("Error",r)))}})()},[t]);const a=(0,n.useRef)(null);return(0,n.useEffect)(()=>()=>{a.current?.()},[]),(s,r)=>{e.current.editor=s,e.current.monaco=r;const{dispose:o}=r.languages.registerCompletionItemProvider(ie,e.current);a.current=o}}let je=!1;const ie="tagsfield";function At(t){if(!je){je=!0;const{aliases:e,extensions:a,mimetypes:s,def:r}=It;t.languages.register({id:ie,aliases:e,extensions:a,mimetypes:s}),t.languages.setMonarchTokensProvider(ie,r.language),t.languages.setLanguageConfiguration(ie,r.languageConfiguration)}}const Qt=(t,e)=>({queryField:f.css`
      border-radius: ${t.shape.borderRadius()};
      border: 1px solid ${t.components.input.borderColor};
      flex: 1;
    `,placeholder:f.css`
      ::after {
        content: '${e}';
        font-family: ${t.typography.fontFamilyMonospace};
        opacity: 0.3;
      }
    `}),ze="e.g. 1.2s, 100ms",Ot=({datasource:t,query:e,onChange:a,onBlur:s,onRunQuery:r})=>{const o=(0,L.wW)($t),l=(0,n.useMemo)(()=>new Le(t),[t]),[c,d]=(0,n.useState)(),[g,T]=(0,n.useState)(),[p,k]=(0,n.useState)(null),[$,j]=(0,n.useState)({}),[ye,Ee]=(0,n.useState)({serviceName:!1,spanName:!1}),oe=(0,n.useCallback)(async(E,U="")=>{const Te=E==="serviceName"?"service.name":"name";Ee(K=>({...K,[E]:!0}));try{return(await l.getOptionsV1(Te)).filter(He=>He.value?(0,xt.C)(He.value,U).found:!1)}catch(K){return(0,he.kW)(K)&&K?.status===404?k(K):K instanceof Error&&(0,ve.WI)((0,ke.$l)((0,fe.t_)("Error",K))),[]}finally{Ee(K=>({...K,[E]:!1}))}},[l]);(0,n.useEffect)(()=>{(async()=>{try{const[U,Te]=await Promise.all([oe("serviceName"),oe("spanName")]);e.serviceName&&(0,ee.J)().containsTemplate(e.serviceName)&&U.push((0,Fe.E)(e.serviceName)),d(U),e.spanName&&(0,ee.J)().containsTemplate(e.spanName)&&Te.push((0,Fe.E)(e.spanName)),T(Te)}catch(U){(0,he.kW)(U)&&U?.status===404?k(U):U instanceof Error&&(0,ve.WI)((0,ke.$l)((0,fe.t_)("Error",U)))}})()},[l,oe,e.serviceName,e.spanName]);const le=E=>{E.key==="Enter"&&(E.shiftKey||E.ctrlKey)&&r()},ua=(0,n.useCallback)(E=>{a({...e,search:E})},[a,e]),Ye=(0,ee.J)();return n.createElement(n.Fragment,null,n.createElement("div",{className:o.container},n.createElement(h.Z,null,n.createElement(D._,{label:"Service Name",labelWidth:14,grow:!0},n.createElement(Ve.Ph,{inputId:"service",options:c,onOpenMenu:()=>{oe("serviceName")},isLoading:ye.serviceName,value:c?.find(E=>E?.value===e.serviceName)||e.serviceName,onChange:E=>{a({...e,serviceName:E?.value})},placeholder:"Select a service",isClearable:!0,onKeyDown:le,"aria-label":"select-service-name",allowCustomValue:!0}))),n.createElement(h.Z,null,n.createElement(D._,{label:"Span Name",labelWidth:14,grow:!0},n.createElement(Ve.Ph,{inputId:"spanName",options:g,onOpenMenu:()=>{oe("spanName")},isLoading:ye.spanName,value:g?.find(E=>E?.value===e.spanName)||e.spanName,onChange:E=>{a({...e,spanName:E?.value})},placeholder:"Select a span",isClearable:!0,onKeyDown:le,"aria-label":"select-span-name",allowCustomValue:!0}))),n.createElement(h.Z,null,n.createElement(D._,{label:"Tags",labelWidth:14,grow:!0,tooltip:"Values should be in logfmt."},n.createElement(Pt,{placeholder:"http.status_code=200 error=true",value:e.search||"",onChange:ua,onBlur:s,datasource:t}))),n.createElement(h.Z,null,n.createElement(D._,{label:"Min Duration",invalid:!!$.minDuration,labelWidth:14,grow:!0},n.createElement(ne.I,{id:"minDuration",value:e.minDuration||"",placeholder:ze,onBlur:()=>{const E=Ye.replace(e.minDuration??"");e.minDuration&&!(0,me.IA)(E)?j({...$,minDuration:!0}):j({...$,minDuration:!1})},onChange:E=>a({...e,minDuration:E.currentTarget.value}),onKeyDown:le}))),n.createElement(h.Z,null,n.createElement(D._,{label:"Max Duration",invalid:!!$.maxDuration,labelWidth:14,grow:!0},n.createElement(ne.I,{id:"maxDuration",value:e.maxDuration||"",placeholder:ze,onBlur:()=>{const E=Ye.replace(e.maxDuration??"");e.maxDuration&&!(0,me.IA)(E)?j({...$,maxDuration:!0}):j({...$,maxDuration:!1})},onChange:E=>a({...e,maxDuration:E.currentTarget.value}),onKeyDown:le}))),n.createElement(h.Z,null,n.createElement(D._,{label:"Limit",invalid:!!$.limit,labelWidth:14,grow:!0,tooltip:"Maximum number of returned results"},n.createElement(ne.I,{id:"limit",value:e.limit||"",placeholder:`Default: ${ae}`,type:"number",onChange:E=>{let U=E.currentTarget.value?parseInt(E.currentTarget.value,10):void 0;U&&(!Number.isInteger(U)||U<=0)?j({...$,limit:!0}):j({...$,limit:!1}),a({...e,limit:E.currentTarget.value?parseInt(E.currentTarget.value,10):void 0})},onKeyDown:le})))),p?n.createElement(Be.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 ",n.createElement("a",{href:`/datasources/edit/${t.uid}`},"datasource settings"),"."):null)},$t=t=>({container:f.css`
    max-width: 500px;
  `,alert:f.css`
    max-width: 75ch;
    margin-top: ${t.spacing(2)};
  `});var Ut=i(44847),Wt=i(86647);async function Ke(t){if(!t)return;const e=(0,Wt.F)();try{return await e.get(t)}catch(a){console.error("Failed to load data source",a);return}}function Ft({graphDatasourceUid:t,query:e,onChange:a}){const s=(0,L.wW)(Bt),r=(0,A.Z)(()=>Ke(t),[t]),[o,l]=(0,n.useState)(void 0);if((0,n.useEffect)(()=>{async function g(T){const p=await T.getTagKeys({series:["traces_service_graph_request_server_seconds_sum","traces_service_graph_request_total","traces_service_graph_request_failed_total"]});l(Boolean(p.length))}!r.loading&&r.value&&g(r.value)},[r]),r.loading)return null;const c=r.value;if(!t)return n.createElement("div",{className:"text-warning"},"Please set up a service graph datasource in the datasource settings.");if(t&&!c)return n.createElement("div",{className:"text-warning"},"Service graph datasource is configured but the data source no longer exists. Please configure existing data source to use the service graph functionality.");const d=Vt(e.serviceMapQuery||"");return n.createElement("div",null,n.createElement(h.Z,null,n.createElement(D._,{label:"Filter",labelWidth:14,grow:!0},n.createElement(Ut.F,{datasource:{uid:t},filters:d,getTagKeysOptions:{series:["traces_service_graph_request_total","traces_spanmetrics_calls_total"]},addFilter:g=>{a({...e,serviceMapQuery:Ce([...d,g])})},removeFilter:g=>{const T=[...d];T.splice(g,1),a({...e,serviceMapQuery:Ce(T)})},changeFilter:(g,T)=>{const p=[...d];p.splice(g,1,T),a({...e,serviceMapQuery:Ce(p)})}}))),o===!1?n.createElement(Be.b,{title:"No service graph data found",severity:"info",className:s.alert},"Please ensure that service graph metrics are set up correctly according to the"," ",n.createElement("a",{target:"_blank",rel:"noreferrer noopener",href:"https://grafana.com/docs/tempo/next/grafana-agent/service-graphs/"},"Tempo documentation"),"."):null)}function Vt(t){let e,a=[];const s=/([\w_]+)(=|!=|<|>|=~|!~)"(.*?)"/g;for(;(e=s.exec(t))!==null;)a.push({key:e[1],operator:e[2],value:e[3],condition:""});return a}function Ce(t){return`{${t.map(e=>`${e.key}${e.operator}"${e.value}"`).join(",")}}`}const Bt=t=>({alert:f.css`
    max-width: 75ch;
    margin-top: ${t.spacing(2)};
  `}),kt="traceql";class jt extends n.PureComponent{constructor(e){super(e),this.onChangeLinkedQuery=a=>{const{query:s,onChange:r}=this.props;r({...s,linkedQuery:{...a,refId:"linked"}})},this.onRunLinkedQuery=()=>{this.props.onRunQuery()},this.onClearResults=()=>{const{onChange:a,query:s,onRunQuery:r}=this.props;a({...s,queryType:"clear"}),r()}}async componentDidMount(){(!this.props.query.queryType||this.props.query.queryType==="clear")&&this.props.onChange({...this.props.query,queryType:kt})}render(){const{query:e,onChange:a,datasource:s,app:r}=this.props,o=s.getLokiSearchDS(),l=s.serviceMap?.datasourceUid;let c=[{value:"traceql",label:"TraceQL"},{value:"upload",label:"JSON File"},{value:"serviceMap",label:"Service Graph"}];return s?.search?.hide||c.unshift({value:"nativeSearch",label:"Search"}),o&&(s?.search?.hide?c.unshift({value:"search",label:"Search"}):c.push({value:"search",label:"Loki Search"})),n.createElement(n.Fragment,null,n.createElement(h.Z,null,n.createElement(D._,{label:"Query type"},n.createElement(v.S,{options:c,value:e.queryType,onChange:d=>{(0,N.ff)("grafana_traces_query_type_changed",{datasourceType:"tempo",app:r??"",grafana_version:b.v.buildInfo.version,newQueryType:d,previousQueryType:e.queryType??""}),this.onClearResults(),a({...e,queryType:d})},size:"md"}))),e.queryType==="search"&&n.createElement(zt,{logsDatasourceUid:o,query:e,onRunQuery:this.onRunLinkedQuery,onChange:this.onChangeLinkedQuery}),e.queryType==="nativeSearch"&&n.createElement(Ot,{datasource:this.props.datasource,query:e,onChange:a,onBlur:this.props.onBlur,onRunQuery:this.props.onRunQuery}),e.queryType==="upload"&&n.createElement("div",{className:(0,f.css)({padding:this.props.theme.spacing(2)})},n.createElement(m.Yo,{options:{multiple:!1},onLoad:d=>{this.props.datasource.uploadedJson=d,this.props.onRunQuery()}})),e.queryType==="serviceMap"&&n.createElement(Ft,{graphDatasourceUid:l,query:e,onChange:a}),e.queryType==="traceql"&&n.createElement(bt,{datasource:this.props.datasource,query:e,onRunQuery:this.props.onRunQuery,onChange:a}))}}function zt({logsDatasourceUid:t,onChange:e,onRunQuery:a,query:s}){const r=(0,A.Z)(()=>Ke(t),[t]);if(r.loading)return null;const o=r.value;return o?n.createElement(n.Fragment,null,n.createElement(M.W,null,"Tempo uses ",o.name," to find traces."),n.createElement(I.n,{datasource:o,onChange:e,onRunQuery:a,query:s.linkedQuery??{refId:"linked"},history:[]})):t?t&&!o?n.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:n.createElement("div",{className:"text-warning"},"Please set up a Loki search datasource in the datasource settings.")}const Kt=(0,L.HE)(jt);var Gt=i(12006),_t=i(12580),Zt=i(90950),Yt=i(83437),Ht=i(48288),Jt=i(67089),G=i(5916),Ge=i(53117),_e=i(31403);function qt({options:t,onOptionsChange:e}){const a=(0,L.wW)(Xt),s=t.jsonData.tracesToLogs?.lokiSearch!==!1?t.jsonData.tracesToLogs?.datasourceUid:void 0;return s&&t.jsonData.lokiSearch===void 0&&(0,G.tp)({onOptionsChange:e,options:t},"lokiSearch",{datasourceUid:s}),n.createElement("div",{className:(0,f.css)({width:"100%"})},n.createElement("h3",{className:"page-heading"},"Loki Search"),n.createElement("div",{className:a.infoText},"Select a Loki datasource to search for traces. Derived fields must be configured in the Loki data source."),n.createElement(h.Z,{className:a.row},n.createElement(D._,{tooltip:"The Loki data source with the service graph data",label:"Data source",labelWidth:26},n.createElement(Ge.q,{inputId:"loki-search-data-source-picker",pluginId:"loki",current:t.jsonData.lokiSearch?.datasourceUid,noDefault:!0,width:40,onChange:r=>(0,G.tp)({onOptionsChange:e,options:t},"lokiSearch",{datasourceUid:r.uid})})),t.jsonData.lokiSearch?.datasourceUid?n.createElement(_e.zx,{type:"button",variant:"secondary",size:"sm",fill:"text",onClick:()=>{(0,G.tp)({onOptionsChange:e,options:t},"lokiSearch",{datasourceUid:void 0})}},"Clear"):null))}const Xt=t=>({infoText:f.css`
    label: infoText;
    padding-bottom: ${t.spacing(2)};
    color: ${t.colors.text.secondary};
  `,row:f.css`
    label: row;
    align-items: baseline;
  `});var Ze=i(8944);function ea({options:t,onOptionsChange:e}){const a=(0,L.wW)(ta);return n.createElement("div",{className:a.container},n.createElement("h3",{className:"page-heading"},"TraceID Query"),n.createElement(D._,{label:"Use time range in query",tooltip:"The time range is ignored by default when querying by TraceID but can be used when there are performance issues or timeouts since it will narrow down the search to the defined range. Default is disabled.",labelWidth:26},n.createElement(Ze.x,{id:"enable-time-shift",value:t.jsonData.traceQuery?.timeShiftEnabled||!1,onChange:s=>{(0,G.tp)({onOptionsChange:e,options:t},"traceQuery",{...t.jsonData.traceQuery,timeShiftEnabled:s.currentTarget.checked})}})),n.createElement(h.Z,null,n.createElement(D._,{label:"Time shift for start of search",labelWidth:26,disabled:!t.jsonData.traceQuery?.timeShiftEnabled,grow:!0,tooltip:"Shifts the start of the time range when searching by TraceID. This is needed as searching for traces 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)"},n.createElement(ne.I,{type:"text",placeholder:"30m",width:40,onChange:s=>(0,G.tp)({onOptionsChange:e,options:t},"traceQuery",{...t.jsonData.traceQuery,spanStartTimeShift:s.currentTarget.value}),value:t.jsonData.traceQuery?.spanStartTimeShift||""}))),n.createElement(h.Z,null,n.createElement(D._,{label:"Time shift for end of search",labelWidth:26,disabled:!t.jsonData.traceQuery?.timeShiftEnabled,grow:!0,tooltip:"Shifts the end of the time range when searching by TraceID. This is needed as searching for traces 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)"},n.createElement(ne.I,{type:"text",placeholder:"30m",width:40,onChange:s=>(0,G.tp)({onOptionsChange:e,options:t},"traceQuery",{...t.jsonData.traceQuery,spanEndTimeShift:s.currentTarget.value}),value:t.jsonData.traceQuery?.spanEndTimeShift||""}))))}const ta=()=>({container:f.css`
    label: container;
    width: 100%;
  `,row:f.css`
    label: row;
    align-items: baseline;
  `});function aa({options:t,onOptionsChange:e}){const a=(0,L.wW)(ra);return n.createElement("div",{className:a.container},n.createElement("h3",{className:"page-heading"},"Search"),n.createElement(h.Z,{className:a.row},n.createElement(D._,{tooltip:"Removes the Search tab from the Tempo query editor.",label:"Hide search",labelWidth:26},n.createElement(Ze.x,{id:"hideSearch",value:t.jsonData.search?.hide,onChange:s=>(0,G.tp)({onOptionsChange:e,options:t},"search",{...t.jsonData.search,hide:s.currentTarget.checked})}))))}const ra=()=>({container:f.css`
    label: container;
    width: 100%;
  `,row:f.css`
    label: row;
    align-items: baseline;
  `});function sa({options:t,onOptionsChange:e}){const a=(0,L.wW)(na);return n.createElement("div",{className:(0,f.css)({width:"100%"})},n.createElement("h3",{className:"page-heading"},"Service Graph"),n.createElement("div",{className:a.infoText},"To allow querying service graph data you have to select a Prometheus instance where the data is stored."),n.createElement(h.Z,{className:a.row},n.createElement(D._,{tooltip:"The Prometheus data source with the service graph data",label:"Data source",labelWidth:26},n.createElement(Ge.q,{inputId:"service-graph-data-source-picker",pluginId:"prometheus",current:t.jsonData.serviceMap?.datasourceUid,noDefault:!0,width:40,onChange:s=>(0,G.tp)({onOptionsChange:e,options:t},"serviceMap",{datasourceUid:s.uid})})),t.jsonData.serviceMap?.datasourceUid?n.createElement(_e.zx,{type:"button",variant:"secondary",size:"sm",fill:"text",onClick:()=>{(0,G.tp)({onOptionsChange:e,options:t},"serviceMap",{datasourceUid:void 0})}},"Clear"):null))}const na=t=>({infoText:f.css`
    label: infoText;
    padding-bottom: ${t.spacing(2)};
    color: ${t.colors.text.secondary};
  `,row:f.css`
    label: row;
    align-items: baseline;
  `}),ia=({options:t,onOptionsChange:e})=>n.createElement(n.Fragment,null,n.createElement(Gt.E,{defaultUrl:"http://tempo",dataSourceConfig:t,showAccessOptions:!1,onChange:e}),b.v.featureToggles.secureSocksDatasourceProxy&&n.createElement(_t.i,{options:t,onOptionsChange:e}),n.createElement("div",{className:"gf-form-group"},n.createElement(Yt.Z,{options:t,onOptionsChange:e})),b.v.featureToggles.traceToMetrics?n.createElement("div",{className:"gf-form-group"},n.createElement(Ht.F,{options:t,onOptionsChange:e})):null,n.createElement("div",{className:"gf-form-group"},n.createElement(sa,{options:t,onOptionsChange:e})),n.createElement("div",{className:"gf-form-group"},n.createElement(aa,{options:t,onOptionsChange:e})),n.createElement("div",{className:"gf-form-group"},n.createElement(Zt.n,{options:t,onOptionsChange:e})),n.createElement("div",{className:"gf-form-group"},n.createElement(qt,{options:t,onOptionsChange:e})),n.createElement("div",{className:"gf-form-group"},n.createElement(ea,{options:t,onOptionsChange:e})),n.createElement("div",{className:"gf-form-group"},n.createElement(Jt.SpanBarSettings,{options:t,onOptionsChange:e})));var oa=i(35630);const la=({payload:{dashboardId:t,orgId:e,grafanaVersion:a,queries:s}})=>{try{const r=s[oa.id];if(!r?.length)return;let o={grafana_version:a,dashboard_id:t,org_id:e,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 l of r)l.hide||(l.queryType==="nativeSearch"?(o.native_search_query_count++,(l.serviceName&&_(l.serviceName)||l.spanName&&_(l.spanName)||l.search&&_(l.search)||l.minDuration&&_(l.minDuration)||l.maxDuration&&_(l.maxDuration))&&o.native_search_queries_with_template_variables_count++):l.queryType==="search"?(o.search_query_count++,l.linkedQuery&&l.linkedQuery.expr&&_(l.linkedQuery.expr)&&o.search_queries_with_template_variables_count++):l.queryType==="serviceMap"?(o.service_map_query_count++,l.serviceMapQuery&&_(l.serviceMapQuery)&&o.service_map_queries_with_template_variables_count++):l.queryType==="traceql"?(o.traceql_query_count++,_(l.query)&&o.traceql_queries_with_template_variables_count++):l.queryType==="upload"&&o.upload_query_count++);(0,N.ff)("grafana_tempo_dashboard_loaded",o)}catch(r){console.error("error in tempo tracking handler",r)}},_=t=>(0,ee.J)().containsTemplate(t),ca=new S.hf(et).setQueryEditor(Kt).setConfigEditor(ia).setQueryEditorHelp(Q);(0,w.N$)().subscribe(u.Pl,la)}}]);

//# sourceMappingURL=6752.7d73ce68a668b4b1018b.js.map