4546.d4aae37cc28835969d99.js 28 KB

12
  1. "use strict";(self.webpackChunkgrafana=self.webpackChunkgrafana||[]).push([[4546],{19982:(e,t,r)=>{r.d(t,{et:()=>a,fy:()=>i,nO:()=>o,np:()=>u});var n=r(43215);function a(e){e.sort(((e,t)=>e[0]-t[0]));return e.reduce(((e,t)=>{if(!e.length)return[t];const r=e.slice(-1)[0],[n,a]=r,[o,i]=t;return i<a?e:o>a?[...e,t]:[...e.slice(0,-1),[n,i]]}),[]).reduce(((e,t)=>e+(t[1]-t[0])),0)}function o(e){const t={};let r;for(let n=0;r=e(n),r;n++){t[r.id]?t[r.id].span=r.span:t[r.id]={span:r.span,children:[]};for(const e of r.parentIds)e&&(t[e]?t[e].children.push(r.id):t[e]={span:void 0,children:[r.id]})}return t}function i(e,t,r){return{main:`${s(e)}ms (${s(e/t*100)}%)`,secondary:`${s(r)}ms (${s(r/e*100)}%)`}}function s(e){return parseFloat(e.toFixed(2))}function u(){return[new n.MutableDataFrame({fields:[{name:n.NodeGraphDataFrameFieldNames.id,type:n.FieldType.string},{name:n.NodeGraphDataFrameFieldNames.title,type:n.FieldType.string},{name:n.NodeGraphDataFrameFieldNames.subTitle,type:n.FieldType.string},{name:n.NodeGraphDataFrameFieldNames.mainStat,type:n.FieldType.string,config:{displayName:"Total time (% of trace)"}},{name:n.NodeGraphDataFrameFieldNames.secondaryStat,type:n.FieldType.string,config:{displayName:"Self time (% of total)"}},{name:n.NodeGraphDataFrameFieldNames.color,type:n.FieldType.number,config:{color:{mode:"continuous-GrYlRd"},displayName:"Self time / Trace duration"}}],meta:{preferredVisualisationType:"nodeGraph"}}),new n.MutableDataFrame({fields:[{name:n.NodeGraphDataFrameFieldNames.id,type:n.FieldType.string},{name:n.NodeGraphDataFrameFieldNames.target,type:n.FieldType.string},{name:n.NodeGraphDataFrameFieldNames.source,type:n.FieldType.string}],meta:{preferredVisualisationType:"nodeGraph"}})]}},59465:(e,t,r)=>{r.d(t,{BC:()=>p,M7:()=>o,NZ:()=>c,Yt:()=>s,t3:()=>l,yf:()=>u});var n=r(43215),a=r(19982);function o(e){const{nodes:t,edges:r}=function(e){const t=[],r=[],o=new n.DataFrameView(e),i=function(e){let t=0,r=1/0;for(let n=0;n<e.length;n++){const a=e.get(n);a.startTime<r&&(r=a.startTime),a.startTime+a.duration>t&&(t=a.startTime+a.duration)}return t-r}(o),s=(0,a.nO)((t=>{if(t>=e.length)return;const r=o.get(t);return{span:Object.assign({},r),id:r.spanID,parentIds:r.parentSpanID?[r.parentSpanID]:[]}}));for(let e=0;e<o.length;e++){var u;const c=o.get(e),l=s[c.spanID].children.map((e=>{const t=s[e].span;return[t.startTime,t.startTime+t.duration]})),p=(0,a.et)(l),d=c.duration-p,f=(0,a.fy)(c.duration,i,d);t.push({[n.NodeGraphDataFrameFieldNames.id]:c.spanID,[n.NodeGraphDataFrameFieldNames.title]:null!==(u=c.serviceName)&&void 0!==u?u:"",[n.NodeGraphDataFrameFieldNames.subTitle]:c.operationName,[n.NodeGraphDataFrameFieldNames.mainStat]:f.main,[n.NodeGraphDataFrameFieldNames.secondaryStat]:f.secondary,[n.NodeGraphDataFrameFieldNames.color]:d/i}),c.parentSpanID&&s[c.parentSpanID].span&&r.push({[n.NodeGraphDataFrameFieldNames.id]:c.parentSpanID+"--"+c.spanID,[n.NodeGraphDataFrameFieldNames.target]:c.spanID,[n.NodeGraphDataFrameFieldNames.source]:c.parentSpanID})}return{nodes:t,edges:r}}(e),[o,i]=(0,a.np)();for(const e of t)o.add(e);for(const e of r)i.add(e);return[o,i]}const i="traces_service_graph_request_server_seconds_sum",s="traces_service_graph_request_total",u="traces_service_graph_request_failed_total",c="traces_service_graph_request_server_seconds_bucket",l=[i,s,u,c];function p(e,t){const r=function(e){return e[0].data.reduce(((e,t)=>(e[t.refId]=new n.DataFrameView(t),e)),{})}(e),a={},o={};return d(r[s],"total",s,a,o),d(r[i],"seconds",i,a,o),d(r[u],"failed",u,a,o),function(e,t,r){const a=r.to.valueOf()-r.from.valueOf(),[o,i]=function(){function e(e,t){return new n.MutableDataFrame({name:e,fields:t,meta:{preferredVisualisationType:"nodeGraph"}})}const t=e("Nodes",[{name:n.NodeGraphDataFrameFieldNames.id},{name:n.NodeGraphDataFrameFieldNames.title,config:{displayName:"Service name"}},{name:n.NodeGraphDataFrameFieldNames.mainStat,config:{unit:"ms/r",displayName:"Average response time"}},{name:n.NodeGraphDataFrameFieldNames.secondaryStat,config:{unit:"r/sec",displayName:"Requests per second"}},{name:n.NodeGraphDataFrameFieldNames.arc+"success",config:{displayName:"Success",color:{fixedColor:"green",mode:n.FieldColorModeId.Fixed}}},{name:n.NodeGraphDataFrameFieldNames.arc+"failed",config:{displayName:"Failed",color:{fixedColor:"red",mode:n.FieldColorModeId.Fixed}}}]),r=e("Edges",[{name:n.NodeGraphDataFrameFieldNames.id},{name:n.NodeGraphDataFrameFieldNames.source},{name:n.NodeGraphDataFrameFieldNames.target},{name:n.NodeGraphDataFrameFieldNames.mainStat,config:{unit:"r",displayName:"Requests"}},{name:n.NodeGraphDataFrameFieldNames.secondaryStat,config:{unit:"ms/r",displayName:"Average response time"}}]);return[t,r]}();for(const t of Object.keys(e)){const r=e[t];o.add({[n.NodeGraphDataFrameFieldNames.id]:t,[n.NodeGraphDataFrameFieldNames.title]:t,[n.NodeGraphDataFrameFieldNames.mainStat]:r.total?r.seconds/r.total*1e3:Number.NaN,[n.NodeGraphDataFrameFieldNames.secondaryStat]:r.total?Math.round(r.total/(a/1e3)*100)/100:Number.NaN,[n.NodeGraphDataFrameFieldNames.arc+"success"]:r.total?(r.total-Math.min(r.failed||0,r.total))/r.total:1,[n.NodeGraphDataFrameFieldNames.arc+"failed"]:r.total?Math.min(r.failed||0,r.total)/r.total:0})}for(const e of Object.keys(t)){const r=t[e];i.add({[n.NodeGraphDataFrameFieldNames.id]:e,[n.NodeGraphDataFrameFieldNames.source]:r.source,[n.NodeGraphDataFrameFieldNames.target]:r.target,[n.NodeGraphDataFrameFieldNames.mainStat]:r.total,[n.NodeGraphDataFrameFieldNames.secondaryStat]:r.total?r.seconds/r.total*1e3:Number.NaN})}return{nodes:o,edges:i}}(a,o,t)}function d(e,t,r,n,a){if(!e)return;const o=`Value #${r}`;for(let r=0;r<e.length;r++){const i=e.get(r),s=`${i.client}_${i.server}`;a[s]?a[s][t]=(a[s][t]||0)+i[o]:a[s]={target:i.server,source:i.client,[t]:i[o]},n[i.server]?n[i.server][t]=(n[i.server][t]||0)+i[o]:n[i.server]={[t]:i[o]},n[i.client]||(n[i.client]={[t]:0})}}},94546:(e,t,r)=>{r.d(t,{n4:()=>Ae,IM:()=>we,g9:()=>Ie,Jk:()=>Me,RY:()=>ye});var n="object"==typeof globalThis?globalThis:"object"==typeof self?self:"object"==typeof window?window:"object"==typeof r.g?r.g:{},a="1.1.0",o=/^(\d+)\.(\d+)\.(\d+)(-(.+))?$/;var i=function(e){var t=new Set([e]),r=new Set,n=e.match(o);if(!n)return function(){return!1};var a=+n[1],i=+n[2],s=+n[3];if(null!=n[4])return function(t){return t===e};function u(e){return r.add(e),!1}function c(e){return t.add(e),!0}return function(e){if(t.has(e))return!0;if(r.has(e))return!1;var n=e.match(o);if(!n)return u(e);var l=+n[1],p=+n[2],d=+n[3];return null!=n[4]||a!==l?u(e):0===a?i===p&&s<=d?c(e):u(e):i<=p?c(e):u(e)}}(a),s=a.split(".")[0],u=Symbol.for("opentelemetry.js.api."+s),c=n;function l(e,t,r,n){var o;void 0===n&&(n=!1);var i=c[u]=null!==(o=c[u])&&void 0!==o?o:{version:a};if(!n&&i[e]){var s=new Error("@opentelemetry/api: Attempted duplicate registration of API: "+e);return r.error(s.stack||s.message),!1}if(i.version!==a){s=new Error("@opentelemetry/api: All API registration versions must match");return r.error(s.stack||s.message),!1}return i[e]=t,r.debug("@opentelemetry/api: Registered a global for "+e+" v"+"1.1.0."),!0}function p(e){var t,r,n=null===(t=c[u])||void 0===t?void 0:t.version;if(n&&i(n))return null===(r=c[u])||void 0===r?void 0:r[e]}function d(e,t){t.debug("@opentelemetry/api: Unregistering a global for "+e+" v"+"1.1.0.");var r=c[u];r&&delete r[e]}var f,m=function(){function e(e){this._namespace=e.namespace||"DiagComponentLogger"}return e.prototype.debug=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return g("debug",this._namespace,e)},e.prototype.error=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return g("error",this._namespace,e)},e.prototype.info=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return g("info",this._namespace,e)},e.prototype.warn=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return g("warn",this._namespace,e)},e.prototype.verbose=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return g("verbose",this._namespace,e)},e}();function g(e,t,r){var n=p("diag");if(n)return r.unshift(t),n[e].apply(n,r)}!function(e){e[e.NONE=0]="NONE",e[e.ERROR=30]="ERROR",e[e.WARN=50]="WARN",e[e.INFO=60]="INFO",e[e.DEBUG=70]="DEBUG",e[e.VERBOSE=80]="VERBOSE",e[e.ALL=9999]="ALL"}(f||(f={}));var h=function(){function e(){function e(e){return function(){for(var t=[],r=0;r<arguments.length;r++)t[r]=arguments[r];var n=p("diag");if(n)return n[e].apply(n,t)}}var t=this;t.setLogger=function(e,r){var n,a;if(void 0===r&&(r=f.INFO),e===t){var o=new Error("Cannot use diag as the logger for itself. Please use a DiagLogger implementation like ConsoleDiagLogger or a custom implementation");return t.error(null!==(n=o.stack)&&void 0!==n?n:o.message),!1}var i=p("diag"),s=function(e,t){function r(r,n){var a=t[r];return"function"==typeof a&&e>=n?a.bind(t):function(){}}return e<f.NONE?e=f.NONE:e>f.ALL&&(e=f.ALL),t=t||{},{error:r("error",f.ERROR),warn:r("warn",f.WARN),info:r("info",f.INFO),debug:r("debug",f.DEBUG),verbose:r("verbose",f.VERBOSE)}}(r,e);if(i){var u=null!==(a=(new Error).stack)&&void 0!==a?a:"<failed to generate stacktrace>";i.warn("Current logger will be overwritten from "+u),s.warn("Current logger will overwrite one already registered from "+u)}return l("diag",s,t,!0)},t.disable=function(){d("diag",t)},t.createComponentLogger=function(e){return new m(e)},t.verbose=e("verbose"),t.debug=e("debug"),t.info=e("info"),t.warn=e("warn"),t.error=e("error")}return e.instance=function(){return this._instance||(this._instance=new e),this._instance},e}(),v=function(){function e(e){this._entries=e?new Map(e):new Map}return e.prototype.getEntry=function(e){var t=this._entries.get(e);if(t)return Object.assign({},t)},e.prototype.getAllEntries=function(){return Array.from(this._entries.entries()).map((function(e){return[e[0],e[1]]}))},e.prototype.setEntry=function(t,r){var n=new e(this._entries);return n._entries.set(t,r),n},e.prototype.removeEntry=function(t){var r=new e(this._entries);return r._entries.delete(t),r},e.prototype.removeEntries=function(){for(var t=[],r=0;r<arguments.length;r++)t[r]=arguments[r];for(var n=new e(this._entries),a=0,o=t;a<o.length;a++){var i=o[a];n._entries.delete(i)}return n},e.prototype.clear=function(){return new e},e}();Symbol("BaggageEntryMetadata"),h.instance();function y(e){return void 0===e&&(e={}),new v(new Map(Object.entries(e)))}var N={get:function(e,t){if(null!=e)return e[t]},keys:function(e){return null==e?[]:Object.keys(e)}},b={set:function(e,t,r){null!=e&&(e[t]=r)}};function D(e){return Symbol.for(e)}var F,_=function e(t){var r=this;r._currentContext=t?new Map(t):new Map,r.getValue=function(e){return r._currentContext.get(e)},r.setValue=function(t,n){var a=new e(r._currentContext);return a._currentContext.set(t,n),a},r.deleteValue=function(t){var n=new e(r._currentContext);return n._currentContext.delete(t),n}},T=new _,S=function(e,t){for(var r=0,n=t.length,a=e.length;r<n;r++,a++)e[a]=t[r];return e},w=function(){function e(){}return e.prototype.active=function(){return T},e.prototype.with=function(e,t,r){for(var n=[],a=3;a<arguments.length;a++)n[a-3]=arguments[a];return t.call.apply(t,S([r],n))},e.prototype.bind=function(e,t){return t},e.prototype.enable=function(){return this},e.prototype.disable=function(){return this},e}(),I=function(e,t){for(var r=0,n=t.length,a=e.length;r<n;r++,a++)e[a]=t[r];return e},E="context",k=new w,R=function(){function e(){}return e.getInstance=function(){return this._instance||(this._instance=new e),this._instance},e.prototype.setGlobalContextManager=function(e){return l(E,e,h.instance())},e.prototype.active=function(){return this._getContextManager().active()},e.prototype.with=function(e,t,r){for(var n,a=[],o=3;o<arguments.length;o++)a[o-3]=arguments[o];return(n=this._getContextManager()).with.apply(n,I([e,t,r],a))},e.prototype.bind=function(e,t){return this._getContextManager().bind(e,t)},e.prototype._getContextManager=function(){return p(E)||k},e.prototype.disable=function(){this._getContextManager().disable(),d(E,h.instance())},e}();!function(e){e[e.NONE=0]="NONE",e[e.SAMPLED=1]="SAMPLED"}(F||(F={}));var C="0000000000000000",x="00000000000000000000000000000000",O={traceId:x,spanId:C,traceFlags:F.NONE},M=function(){function e(e){void 0===e&&(e=O),this._spanContext=e}return e.prototype.spanContext=function(){return this._spanContext},e.prototype.setAttribute=function(e,t){return this},e.prototype.setAttributes=function(e){return this},e.prototype.addEvent=function(e,t){return this},e.prototype.setStatus=function(e){return this},e.prototype.updateName=function(e){return this},e.prototype.end=function(e){},e.prototype.isRecording=function(){return!1},e.prototype.recordException=function(e,t){},e}(),G=D("OpenTelemetry Context Key SPAN");function A(e){return e.getValue(G)||void 0}function V(e,t){return e.setValue(G,t)}function L(e){return e.deleteValue(G)}function P(e,t){return V(e,new M(t))}function U(e){var t;return null===(t=A(e))||void 0===t?void 0:t.spanContext()}var j=/^([0-9a-f]{32})$/i,B=/^[0-9a-f]{16}$/i;function $(e){return r=e.traceId,j.test(r)&&r!==x&&(t=e.spanId,B.test(t)&&t!==C);var t,r}function Z(e){return new M(e)}var q=R.getInstance(),X=function(){function e(){}return e.prototype.startSpan=function(e,t,r){if(Boolean(null==t?void 0:t.root))return new M;var n,a=r&&U(r);return"object"==typeof(n=a)&&"string"==typeof n.spanId&&"string"==typeof n.traceId&&"number"==typeof n.traceFlags&&$(a)?new M(a):new M},e.prototype.startActiveSpan=function(e,t,r,n){var a,o,i;if(!(arguments.length<2)){2===arguments.length?i=t:3===arguments.length?(a=t,i=r):(a=t,o=r,i=n);var s=null!=o?o:q.active(),u=this.startSpan(e,a,s),c=V(s,u);return q.with(c,i,void 0,u)}},e}();var z,K,Y,J=new X,W=function(){function e(e,t,r,n){this._provider=e,this.name=t,this.version=r,this.options=n}return e.prototype.startSpan=function(e,t,r){return this._getTracer().startSpan(e,t,r)},e.prototype.startActiveSpan=function(e,t,r,n){var a=this._getTracer();return Reflect.apply(a.startActiveSpan,a,arguments)},e.prototype._getTracer=function(){if(this._delegate)return this._delegate;var e=this._provider.getDelegateTracer(this.name,this.version,this.options);return e?(this._delegate=e,this._delegate):J},e}(),H=new(function(){function e(){}return e.prototype.getTracer=function(e,t,r){return new X},e}()),Q=function(){function e(){}return e.prototype.getTracer=function(e,t,r){var n;return null!==(n=this.getDelegateTracer(e,t,r))&&void 0!==n?n:new W(this,e,t,r)},e.prototype.getDelegate=function(){var e;return null!==(e=this._delegate)&&void 0!==e?e:H},e.prototype.setDelegate=function(e){this._delegate=e},e.prototype.getDelegateTracer=function(e,t,r){var n;return null===(n=this._delegate)||void 0===n?void 0:n.getTracer(e,t,r)},e}();!function(e){e[e.NOT_RECORD=0]="NOT_RECORD",e[e.RECORD=1]="RECORD",e[e.RECORD_AND_SAMPLED=2]="RECORD_AND_SAMPLED"}(z||(z={})),function(e){e[e.INTERNAL=0]="INTERNAL",e[e.SERVER=1]="SERVER",e[e.CLIENT=2]="CLIENT",e[e.PRODUCER=3]="PRODUCER",e[e.CONSUMER=4]="CONSUMER"}(K||(K={})),function(e){e[e.UNSET=0]="UNSET",e[e.OK=1]="OK",e[e.ERROR=2]="ERROR"}(Y||(Y={}));var ee=new RegExp("^(?:[a-z][_0-9a-z-*/]{0,255}|[a-z0-9][_0-9a-z-*/]{0,240}@[a-z][_0-9a-z-*/]{0,13})$"),te=/^[ -~]{0,255}[!-~]$/,re=/,|=/;!function(){function e(e){this._internalState=new Map,e&&this._parse(e)}e.prototype.set=function(e,t){var r=this._clone();return r._internalState.has(e)&&r._internalState.delete(e),r._internalState.set(e,t),r},e.prototype.unset=function(e){var t=this._clone();return t._internalState.delete(e),t},e.prototype.get=function(e){return this._internalState.get(e)},e.prototype.serialize=function(){var e=this;return this._keys().reduce((function(t,r){return t.push(r+"="+e.get(r)),t}),[]).join(",")},e.prototype._parse=function(e){e.length>512||(this._internalState=e.split(",").reverse().reduce((function(e,t){var r=t.trim(),n=r.indexOf("=");if(-1!==n){var a=r.slice(0,n),o=r.slice(n+1,t.length);(function(e){return ee.test(e)})(a)&&function(e){return te.test(e)&&!re.test(e)}(o)&&e.set(a,o)}return e}),new Map),this._internalState.size>32&&(this._internalState=new Map(Array.from(this._internalState.entries()).reverse().slice(0,32))))},e.prototype._keys=function(){return Array.from(this._internalState.keys()).reverse()},e.prototype._clone=function(){var t=new e;return t._internalState=new Map(this._internalState),t}}();var ne="trace",ae=function(){function e(){this._proxyTracerProvider=new Q,this.wrapSpanContext=Z,this.isSpanContextValid=$,this.deleteSpan=L,this.getSpan=A,this.getSpanContext=U,this.setSpan=V,this.setSpanContext=P}return e.getInstance=function(){return this._instance||(this._instance=new e),this._instance},e.prototype.setGlobalTracerProvider=function(e){var t=l(ne,this._proxyTracerProvider,h.instance());return t&&this._proxyTracerProvider.setDelegate(e),t},e.prototype.getTracerProvider=function(){return p(ne)||this._proxyTracerProvider},e.prototype.getTracer=function(e,t){return this.getTracerProvider().getTracer(e,t)},e.prototype.disable=function(){d(ne,h.instance()),this._proxyTracerProvider=new Q},e}(),oe=function(){function e(){}return e.prototype.inject=function(e,t){},e.prototype.extract=function(e,t){return e},e.prototype.fields=function(){return[]},e}(),ie=D("OpenTelemetry Baggage Key");function se(e){return e.getValue(ie)||void 0}function ue(e,t){return e.setValue(ie,t)}function ce(e){return e.deleteValue(ie)}var le="propagation",pe=new oe,de=function(){function e(){this.createBaggage=y,this.getBaggage=se,this.setBaggage=ue,this.deleteBaggage=ce}return e.getInstance=function(){return this._instance||(this._instance=new e),this._instance},e.prototype.setGlobalPropagator=function(e){return l(le,e,h.instance())},e.prototype.inject=function(e,t,r){return void 0===r&&(r=b),this._getGlobalPropagator().inject(e,t,r)},e.prototype.extract=function(e,t,r){return void 0===r&&(r=N),this._getGlobalPropagator().extract(e,t,r)},e.prototype.fields=function(){return this._getGlobalPropagator().fields()},e.prototype.disable=function(){d(le,h.instance())},e.prototype._getGlobalPropagator=function(){return p(le)||pe},e}();R.getInstance();ae.getInstance(),de.getInstance(),h.instance();var fe="service.name",me=r(98812),ge=r(31704),he=r(43215),ve=r(59465);function ye(e,t,r,n){return e.data.forEach(((a,o)=>{const i=function(e,t,r,n){const a=new he.MutableDataFrame({fields:[{name:"Time",type:he.FieldType.time,config:{custom:{width:150}}},{name:"traceID",type:he.FieldType.string,config:{displayNameFromDS:"Trace ID",custom:{width:300},links:[{title:"Click to open trace ${__value.raw}",url:"",internal:{datasourceUid:t,datasourceName:r,query:{query:"${__value.raw}"}}}]}},{name:"Message",type:he.FieldType.string}],meta:{preferredVisualisationType:"table"}});if(!e||0===n.length)return a;const o=e.fields.find((e=>e.type===he.FieldType.time));for(let t of e.fields){let e=!1;if(t.type===he.FieldType.string){const r=t.values.toArray();for(let t=0;t<r.length;t++){const i=r[t];if(i)for(let r of n){const n=i.match(r);if(n){const r=n[1],s=o?o.values.get(t):null;a.fields[0].values.add(s),a.fields[1].values.add(r),a.fields[2].values.add(i),e=!0}}}}if(e)break}return a}(a,t,r,n);e.data[o]=i})),e}function Ne(e){const t=atob(e);let r="";for(let e=0;e<t.length;e++){const n=t.charCodeAt(e).toString(16);r+=2===n.length?n:"0"+n}return r.length>16?r.slice(16):r}function be(e){const t=e.match(/\w{2}/g)||[];return btoa(t.map((function(e){return String.fromCharCode(parseInt(e,16))})).join(""))}function De(e){if(e.stringValue)return e.stringValue;if(void 0!==e.boolValue)return Boolean(e.boolValue);if(void 0!==e.intValue)return Number.parseInt(e.intValue,10);if(e.doubleValue)return Number.parseFloat(e.doubleValue);if(e.arrayValue){const t=[];for(const r of e.arrayValue.values)t.push(De(r));return t}return""}function Fe(e){const t=[];let r="OTLPResourceNoServiceName";if(!e)return{serviceName:r,serviceTags:t};for(const n of e.attributes)n.key===fe&&(r=n.value.stringValue||r),t.push({key:n.key,value:De(n.value)});return{serviceName:r,serviceTags:t}}function _e(e,t){const r=[];if(t&&(t.name&&r.push({key:"otel.library.name",value:t.name}),t.version&&r.push({key:"otel.library.version",value:t.version})),e.attributes)for(const t of e.attributes)r.push({key:t.key,value:De(t.value)});if(e.status&&(e.status.code&&e.status.code!==Y.UNSET&&(r.push({key:"otel.status_code",value:Y[e.status.code]}),e.status.message&&r.push({key:"otel.status_description",value:e.status.message})),e.status.code===Y.ERROR&&r.push({key:"error",value:!0})),void 0!==e.kind){const t=e.kind.toString().toLowerCase().split("_");r.push({key:"span.kind",value:t.length?t[t.length-1]:e.kind.toString()})}return r}function Te(e){const t=[];if(e.links)for(const r of e.links){const{traceId:e,spanId:n}=r,a=[];if(r.attributes)for(const e of r.attributes)a.push({key:e.key,value:De(e.value)});t.push({traceID:e,spanID:n,tags:a})}return t}function Se(e){const t=[];if(e.events)for(const r of e.events){const e=[];if(r.attributes)for(const t of r.attributes)e.push({key:t.key,value:De(t.value)});t.push({fields:e,timestamp:r.timeUnixNano/1e6})}return t}function we(e){let t=arguments.length>1&&void 0!==arguments[1]&&arguments[1];const r=new he.MutableDataFrame({fields:[{name:"traceID",type:he.FieldType.string},{name:"spanID",type:he.FieldType.string},{name:"parentSpanID",type:he.FieldType.string},{name:"operationName",type:he.FieldType.string},{name:"serviceName",type:he.FieldType.string},{name:"serviceTags",type:he.FieldType.other},{name:"startTime",type:he.FieldType.number},{name:"duration",type:he.FieldType.number},{name:"logs",type:he.FieldType.other},{name:"references",type:he.FieldType.other},{name:"tags",type:he.FieldType.other}],meta:{preferredVisualisationType:"trace",custom:{traceFormat:"otlp"}}});try{for(const t of e){const{serviceName:e,serviceTags:n}=Fe(t.resource);for(const a of t.instrumentationLibrarySpans)for(const t of a.spans)r.add({traceID:Ne(t.traceId),spanID:Ne(t.spanId),parentSpanID:Ne(t.parentSpanId||""),operationName:t.name||"",serviceName:e,serviceTags:n,startTime:t.startTimeUnixNano/1e6,duration:(t.endTimeUnixNano-t.startTimeUnixNano)/1e6,tags:_e(t,a.instrumentationLibrary),logs:Se(t),references:Te(t)})}}catch(e){return console.error(e),{error:{message:"JSON is not valid OpenTelemetry format: "+e},data:[]}}let n=[r];return t&&n.push(...(0,ve.M7)(r)),{data:n}}function Ie(e){let t={batches:[]},r={};for(let o=0;o<e.length;o++){const i=e.get(o);r[i.serviceName]||(r[i.serviceName]=t.batches.length,t.batches.push({resource:{attributes:[],droppedAttributesCount:0},instrumentationLibrarySpans:[{spans:[]}]}));let s=r[i.serviceName];if(0===t.batches[s].resource.attributes.length&&(t.batches[s].resource.attributes=ke(i.serviceTags)),!t.batches[s].instrumentationLibrarySpans[0].instrumentationLibrary){var n;let e=null===(n=i.tags.find((e=>"otel.library.name"===e.key)))||void 0===n?void 0:n.value;var a;if(e)t.batches[s].instrumentationLibrarySpans[0].instrumentationLibrary={name:e,version:null===(a=i.tags.find((e=>"otel.library.version"===e.key)))||void 0===a?void 0:a.value}}t.batches[s].instrumentationLibrarySpans[0].spans.push({traceId:be(i.traceID.padStart(32,"0")),spanId:be(i.spanID),traceState:"",parentSpanId:be(i.parentSpanID||""),name:i.operationName,kind:Ee(i.tags),startTimeUnixNano:1e6*i.startTime,endTimeUnixNano:1e6*(i.startTime+i.duration),attributes:ke(i.tags),droppedAttributesCount:0,droppedEventsCount:0,droppedLinksCount:0,status:Ce(i.tags),events:xe(i.logs),links:Oe(i.references)})}return t}function Ee(e){var t;let r;switch(null===(t=e.find((e=>"span.kind"===e.key)))||void 0===t?void 0:t.value){case"server":r="SPAN_KIND_SERVER";break;case"client":r="SPAN_KIND_CLIENT";break;case"producer":r="SPAN_KIND_PRODUCER";break;case"consumer":r="SPAN_KIND_CONSUMER"}return r}function ke(e){return e.filter((e=>!["span.kind","otel.library.name","otel.libary.version","otel.status_description","otel.status_code"].includes(e.key))).reduce(((e,t)=>[...e,{key:t.key,value:Re(t)}]),[])}function Re(e){if("string"==typeof e.value)return{stringValue:e.value};if("boolean"==typeof e.value)return{boolValue:e.value};if("number"==typeof e.value)return e.value%1==0?{intValue:e.value}:{doubleValue:e.value};if("object"==typeof e.value&&Array.isArray(e.value)){const t=[];for(const r of e.value)t.push(Re(r));return{arrayValue:{values:t}}}return{stringValue:e.value}}function Ce(e){let t;const r=e.find((e=>"otel.status_code"===e.key));var n;r&&(t={code:r.value,message:null===(n=e.find((e=>"otel_status_description"===e.key)))||void 0===n?void 0:n.value});return t}function xe(e){if(!e||!e.length)return;let t=[];for(const r of e){let e={timeUnixNano:1e6*r.timestamp,attributes:[],droppedAttributesCount:0,name:""};for(const t of r.fields)e.attributes.push({key:t.key,value:Re(t)});t.push(e)}return t}function Oe(e){if(!e||!e.length)return;let t=[];for(const a of e){var r;let e={traceId:a.traceID,spanId:a.spanID,attributes:[],droppedAttributesCount:0};if(null!==(r=a.tags)&&void 0!==r&&r.length)for(const t of a.tags){var n;null===(n=e.attributes)||void 0===n||n.push({key:t.key,value:Re(t)})}t.push(e)}return t}function Me(e){let t=arguments.length>1&&void 0!==arguments[1]&&arguments[1];const r=e.data[0];if(!r)return Le;try{Ge(r)}catch(e){return console.error(e),{error:{message:"Unable to parse trace response: "+e},data:[]}}let n=[...e.data];return t&&n.push(...(0,ve.M7)(r)),Object.assign({},e,{data:n})}function Ge(e){for(const t of["serviceTags","logs","tags","references"]){const r=e.fields.find((e=>e.name===t));if(r){const t=e.fields.indexOf(r),n=new he.ArrayVector,a=Object.assign({},r,{values:n,type:he.FieldType.other});for(let e=0;e<r.values.length;e++){const t=r.values.get(e);n.set(e,""===t?void 0:JSON.parse(t))}e.fields[t]=a}}}function Ae(e,t){const r=new he.MutableDataFrame({fields:[{name:"traceID",type:he.FieldType.string,config:{unit:"string",displayNameFromDS:"Trace ID",links:[{title:"Trace: ${__value.raw}",url:"",internal:{datasourceUid:t.uid,datasourceName:t.name,query:{query:"${__value.raw}",queryType:"traceId"}}}]}},{name:"traceName",type:he.FieldType.string,config:{displayNameFromDS:"Trace name"}},{name:"startTime",type:he.FieldType.string,config:{displayNameFromDS:"Start time"}},{name:"duration",type:he.FieldType.number,config:{displayNameFromDS:"Duration",unit:"ms"}}],meta:{preferredVisualisationType:"table"}});if(null==e||!e.length)return r;const n=e.sort(((e,t)=>parseInt(null==t?void 0:t.startTimeUnixNano,10)/1e6-parseInt(null==e?void 0:e.startTimeUnixNano,10)/1e6)).map(Ve);for(const e of n)r.add(e);return r}function Ve(e){let t="";e.rootServiceName&&(t+=e.rootServiceName+" "),e.rootTraceName&&(t+=e.rootTraceName);const r=parseInt(e.startTimeUnixNano,10)/1e6;let n=(0,he.dateTimeFormat)(r);return Math.abs((0,me.Z)(new Date(r),Date.now()))<=1&&(n=(0,ge.Z)(new Date(r),Date.now(),{addSuffix:!0,includeSeconds:!0})),{traceID:e.traceID,startTime:n,duration:e.durationMs,traceName:t}}const Le={data:[new he.MutableDataFrame({fields:[{name:"trace",type:he.FieldType.trace,values:[]}],meta:{preferredVisualisationType:"trace",custom:{traceFormat:"otlp"}}})]}},31704:(e,t,r)=>{r.d(t,{Z:()=>f});var n=r(32795),a=r(34340),o=r(96186),i=r(17745),s=r(17204);function u(e){return function(e,t){if(null==e)throw new TypeError("assign requires that input parameter not be null or undefined");for(var r in t=t||{})Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r]);return e}({},e)}var c=r(51341),l=r(61514),p=1440,d=43200;function f(e,t){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};(0,l.Z)(2,arguments);var f=r.locale||i.Z;if(!f.formatDistance)throw new RangeError("locale must contain formatDistance property");var m=(0,n.Z)(e,t);if(isNaN(m))throw new RangeError("Invalid time value");var g,h,v=u(r);v.addSuffix=Boolean(r.addSuffix),v.comparison=m,m>0?(g=(0,s.Z)(t),h=(0,s.Z)(e)):(g=(0,s.Z)(e),h=(0,s.Z)(t));var y,N=(0,o.Z)(h,g),b=((0,c.Z)(h)-(0,c.Z)(g))/1e3,D=Math.round((N-b)/60);if(D<2)return r.includeSeconds?N<5?f.formatDistance("lessThanXSeconds",5,v):N<10?f.formatDistance("lessThanXSeconds",10,v):N<20?f.formatDistance("lessThanXSeconds",20,v):N<40?f.formatDistance("halfAMinute",null,v):N<60?f.formatDistance("lessThanXMinutes",1,v):f.formatDistance("xMinutes",1,v):0===D?f.formatDistance("lessThanXMinutes",1,v):f.formatDistance("xMinutes",D,v);if(D<45)return f.formatDistance("xMinutes",D,v);if(D<90)return f.formatDistance("aboutXHours",1,v);if(D<p){var F=Math.round(D/60);return f.formatDistance("aboutXHours",F,v)}if(D<2520)return f.formatDistance("xDays",1,v);if(D<d){var _=Math.round(D/p);return f.formatDistance("xDays",_,v)}if(D<86400)return y=Math.round(D/d),f.formatDistance("aboutXMonths",y,v);if((y=(0,a.Z)(h,g))<12){var T=Math.round(D/d);return f.formatDistance("xMonths",T,v)}var S=y%12,w=Math.floor(y/12);return S<3?f.formatDistance("aboutXYears",w,v):S<9?f.formatDistance("overXYears",w,v):f.formatDistance("almostXYears",w+1,v)}}}]);
  2. //# sourceMappingURL=4546.d4aae37cc28835969d99.js.map