@grafana/faro-core 1.12.1 → 1.12.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/bundle/faro-core.iife.js +1 -1
- package/dist/bundle/types/api/traces/types.d.ts +1 -1
- package/dist/bundle/types/testUtils/mockTransport.d.ts +1 -1
- package/dist/bundle/types/transports/utils.d.ts +1 -1
- package/dist/bundle/types/version.d.ts +1 -1
- package/dist/cjs/api/traces/types.js.map +1 -1
- package/dist/cjs/globalObject/globalObject.js.map +1 -1
- package/dist/cjs/transports/utils.js.map +1 -1
- package/dist/cjs/version.js +1 -1
- package/dist/cjs/version.js.map +1 -1
- package/dist/esm/api/traces/types.js.map +1 -1
- package/dist/esm/globalObject/globalObject.js.map +1 -1
- package/dist/esm/transports/utils.js.map +1 -1
- package/dist/esm/version.js +1 -1
- package/dist/esm/version.js.map +1 -1
- package/dist/spec/core/src/api/traces/types.js.map +1 -1
- package/dist/spec/core/src/globalObject/globalObject.js.map +1 -1
- package/dist/spec/core/src/transports/utils.js.map +1 -1
- package/dist/spec/core/src/transports/utils.test.js.map +1 -1
- package/dist/spec/core/src/version.js +1 -1
- package/dist/spec/core/src/version.js.map +1 -1
- package/dist/types/api/traces/types.d.ts +1 -1
- package/dist/types/core/src/api/traces/types.d.ts +1 -1
- package/dist/types/core/src/testUtils/mockTransport.d.ts +1 -1
- package/dist/types/core/src/transports/utils.d.ts +1 -1
- package/dist/types/core/src/version.d.ts +1 -1
- package/dist/types/testUtils/mockTransport.d.ts +1 -1
- package/dist/types/transports/utils.d.ts +1 -1
- package/dist/types/version.d.ts +1 -1
- package/package.json +6 -3
|
@@ -1 +1 @@
|
|
|
1
|
-
var GrafanaFaroCore=function(e){"use strict";function n(e,n){return typeof e===n}function t(e,n){return Object.prototype.toString.call(e)===`[object ${n}]`}function r(e,n){try{return e instanceof n}catch(e){return!1}}const a=e=>n(e,"null"),i=e=>n(e,"string"),o=e=>n(e,"number")&&!isNaN(e)||n(e,"bigint"),s=e=>!a(e)&&n(e,"object"),u=e=>n(e,"function"),l=e=>t(e,"Array"),c="undefined"!=typeof Event,d="undefined"!=typeof Error,g=e=>d&&r(e,Error),p="undefined"!=typeof Element,f="undefined"!=typeof Map;function m(e,t){if(e===t)return!0;if(n(e,"number")&&isNaN(e))return n(t,"number")&&isNaN(t);const r=l(e),a=l(t);if(r!==a)return!1;if(r&&a){const n=e.length;if(n!==t.length)return!1;for(let r=n;0!=r--;)if(!m(e[r],t[r]))return!1;return!0}const i=s(e),o=s(t);if(i!==o)return!1;if(e&&t&&i&&o){const n=Object.keys(e),r=Object.keys(t);if(n.length!==r.length)return!1;for(let e of n)if(!r.includes(e))return!1;for(let r of n)if(!m(e[r],t[r]))return!1;return!0}return!1}function v(){return(new Date).toISOString()}function b(e){return new Date(e).toISOString()}var h;e.LogLevel=void 0,(h=e.LogLevel||(e.LogLevel={})).TRACE="trace",h.DEBUG="debug",h.INFO="info",h.LOG="log",h.WARN="warn",h.ERROR="error";const E=e.LogLevel.LOG,y=[e.LogLevel.TRACE,e.LogLevel.DEBUG,e.LogLevel.INFO,e.LogLevel.LOG,e.LogLevel.WARN,e.LogLevel.ERROR];function I(){}const T="abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ0123456789";const O="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof global?global:"undefined"!=typeof self?self:void 0;class L{constructor(e,n){var t,r;this.signalBuffer=[],this.itemLimit=null!==(t=null==n?void 0:n.itemLimit)&&void 0!==t?t:50,this.sendTimeout=null!==(r=null==n?void 0:n.sendTimeout)&&void 0!==r?r:250,this.paused=(null==n?void 0:n.paused)||!1,this.sendFn=e,this.flushInterval=-1,this.paused||this.start(),document.addEventListener("visibilitychange",(()=>{"hidden"===document.visibilityState&&this.flush()}))}addItem(e){this.paused||(this.signalBuffer.push(e),this.signalBuffer.length>=this.itemLimit&&this.flush())}start(){this.paused=!1,this.sendTimeout>0&&(this.flushInterval=window.setInterval((()=>this.flush()),this.sendTimeout))}pause(){this.paused=!0,clearInterval(this.flushInterval)}groupItems(e){const n=new Map;return e.forEach((e=>{const t=JSON.stringify(e.meta);let r=n.get(t);r=void 0===r?[e]:[...r,e],n.set(t,r)})),Array.from(n.values())}flush(){if(this.paused||0===this.signalBuffer.length)return;this.groupItems(this.signalBuffer).forEach(this.sendFn),this.signalBuffer=[]}}var S;e.TransportItemType=void 0,(S=e.TransportItemType||(e.TransportItemType={})).EXCEPTION="exception",S.LOG="log",S.MEASUREMENT="measurement",S.TRACE="trace",S.EVENT="event";const N={[e.TransportItemType.EXCEPTION]:"exceptions",[e.TransportItemType.LOG]:"logs",[e.TransportItemType.MEASUREMENT]:"measurements",[e.TransportItemType.TRACE]:"traces",[e.TransportItemType.EVENT]:"events"};function x(n){return t=>{if(t.type===e.TransportItemType.EXCEPTION&&t.payload){const e=t.payload,r=`${e.type}: ${e.value}`;if(function(e,n){return e.some((e=>i(e)?n.includes(e):!!n.match(e)))}(n,r))return null}return t}}function R(e,n,t,r){var a;n.debug("Initializing transports");const i=[];let o=t.paused,s=[];const u=e=>{let n=e;for(const e of s){const t=n.map(e).filter(Boolean);if(0===t.length)return[];n=t}return n},l=e=>{const t=u(e);if(0!==t.length)for(const e of i)n.debug(`Transporting item using ${e.name}\n`,t),e.isBatched()&&e.send(t)};let c;(null===(a=t.batching)||void 0===a?void 0:a.enabled)&&(c=new L(l,{sendTimeout:t.batching.sendTimeout,itemLimit:t.batching.itemLimit,paused:o}));return{add:(...a)=>{n.debug("Adding transports"),a.forEach((a=>{n.debug(`Adding "${a.name}" transport`);i.some((e=>e===a))?n.warn(`Transport ${a.name} is already added`):(a.unpatchedConsole=e,a.internalLogger=n,a.config=t,a.metas=r,i.push(a))}))},addBeforeSendHooks:(...e)=>{n.debug("Adding beforeSendHooks\n",s),e.forEach((e=>{e&&s.push(e)}))},addIgnoreErrorsPatterns:(...e)=>{n.debug("Adding ignoreErrorsPatterns\n",e),e.forEach((e=>{e&&s.push(x(e))}))},getBeforeSendHooks:()=>[...s],execute:e=>{var r;o||((null===(r=t.batching)||void 0===r?void 0:r.enabled)&&(null==c||c.addItem(e)),(e=>{var r,a;if((null===(r=t.batching)||void 0===r?void 0:r.enabled)&&i.every((e=>e.isBatched())))return;const[o]=u([e]);if(void 0!==o)for(const e of i)n.debug(`Transporting item using ${e.name}\n`,o),e.isBatched()?(null===(a=t.batching)||void 0===a?void 0:a.enabled)||e.send([o]):e.send(o)})(e))},isPaused:()=>o,pause:()=>{n.debug("Pausing transports"),null==c||c.pause(),o=!0},remove:(...e)=>{n.debug("Removing transports"),e.forEach((e=>{n.debug(`Removing "${e.name}" transport`);const t=i.indexOf(e);-1!==t?i.splice(t,1):n.warn(`Transport "${e.name}" is not added`)}))},removeBeforeSendHooks:(...e)=>{s.filter((n=>!e.includes(n)))},get transports(){return[...i]},unpause:()=>{n.debug("Unpausing transports"),null==c||c.start(),o=!1}}}var j;e.InternalLoggerLevel=void 0,(j=e.InternalLoggerLevel||(e.InternalLoggerLevel={}))[j.OFF=0]="OFF",j[j.ERROR=1]="ERROR",j[j.WARN=2]="WARN",j[j.INFO=3]="INFO",j[j.VERBOSE=4]="VERBOSE";const A={debug:I,error:I,info:I,prefix:"Faro",warn:I},w=e.InternalLoggerLevel.ERROR,C=Object.assign({},console);let k=C;function _(e){var n;return k=null!==(n=e.unpatchedConsole)&&void 0!==n?n:k,k}function P(n=C,t=w){const r=A;return t>e.InternalLoggerLevel.OFF&&(r.error=t>=e.InternalLoggerLevel.ERROR?function(...e){n.error(`${r.prefix}\n`,...e)}:I,r.warn=t>=e.InternalLoggerLevel.WARN?function(...e){n.warn(`${r.prefix}\n`,...e)}:I,r.info=t>=e.InternalLoggerLevel.INFO?function(...e){n.info(`${r.prefix}\n`,...e)}:I,r.debug=t>=e.InternalLoggerLevel.VERBOSE?function(...e){n.debug(`${r.prefix}\n`,...e)}:I),r}let B=A;function F(e,n){return B=P(e,n.internalLoggerLevel),B}class D{constructor(){this.unpatchedConsole=C,this.internalLogger=A,this.config={},this.metas={}}logDebug(...e){this.internalLogger.debug(`${this.name}\n`,...e)}logInfo(...e){this.internalLogger.info(`${this.name}\n`,...e)}logWarn(...e){this.internalLogger.warn(`${this.name}\n`,...e)}logError(...e){this.internalLogger.error(`${this.name}\n`,...e)}}function M(e,n){var t,r;if(void 0===n)return e;if(void 0===e)return{resourceSpans:n};const a=null===(t=e.resourceSpans)||void 0===t?void 0:t[0];if(void 0===a)return e;const i=(null==a?void 0:a.scopeSpans)||[],o=(null===(r=null==n?void 0:n[0])||void 0===r?void 0:r.scopeSpans)||[];return Object.assign(Object.assign({},e),{resourceSpans:[Object.assign(Object.assign({},a),{scopeSpans:[...i,...o]})]})}const $="Error";let G;function V(e){let n=e.cause;return g(n)?n=e.cause.toString():null!==n&&(s(e.cause)||l(e.cause))?n=JSON.stringify(e.cause):null!=n&&(n=e.cause.toString()),null==n?{}:{cause:n}}const z=e=>e.map((e=>{try{return String(e)}catch(e){return""}})).join(" ");function U(n,t,r,i,o){t.debug("Initializing API");const s=function(n,t,r,a,i){let o;return t.debug("Initializing traces API"),{getOTEL:()=>o,getTraceContext:()=>{const e=null==o?void 0:o.trace.getSpanContext(o.context.active());return e?{trace_id:e.traceId,span_id:e.spanId}:void 0},initOTEL:(e,n)=>{t.debug("Initializing OpenTelemetry"),o={trace:e,context:n}},isOTELInitialized:()=>!!o,pushTraces:n=>{try{const r={type:e.TransportItemType.TRACE,payload:n,meta:a.value};t.debug("Pushing trace\n",r),i.execute(r)}catch(e){t.error("Error pushing trace\n",e)}}}}(0,t,0,i,o);return Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({},s),function(n,t,r,i,o,s){var u;t.debug("Initializing exceptions API");let l=null;G=null!==(u=r.parseStacktrace)&&void 0!==u?u:G;const c=e=>{t.debug("Changing stacktrace parser"),G=null!=e?e:G};return c(r.parseStacktrace),{changeStacktraceParser:c,getStacktraceParser:()=>G,pushError:(n,{skipDedupe:u,stackFrames:c,type:d,context:g,spanContext:p,timestampOverwriteMs:f}={})=>{d=d||n.name||$;const h={meta:i.value,payload:{type:d,value:n.message,timestamp:f?b(f):v(),trace:p?{trace_id:p.traceId,span_id:p.spanId}:s.getTraceContext(),context:Object.assign(Object.assign({},V(n)),null!=g?g:{})},type:e.TransportItemType.EXCEPTION};(null==(c=null!=c?c:n.stack?null==G?void 0:G(n).frames:void 0)?void 0:c.length)&&(h.payload.stacktrace={frames:c});const E={type:h.payload.type,value:h.payload.value,stackTrace:h.payload.stacktrace,context:h.payload.context};u||!r.dedupe||a(l)||!m(E,l)?(l=E,t.debug("Pushing exception\n",h),o.execute(h)):t.debug("Skipping error push because it is the same as the last one\n",h.payload)}}}(0,t,r,i,o,s)),function(e,n,t,r){let a,i,o;n.debug("Initializing meta API");const s=e=>{i&&r.remove(i),i={user:e},r.add(i)},u=e=>{a&&r.remove(a),a={session:e},r.add(a)};return{setUser:s,resetUser:s,setSession:u,resetSession:u,getSession:()=>r.value.session,setView:e=>{var n;if((null===(n=null==o?void 0:o.view)||void 0===n?void 0:n.name)===(null==e?void 0:e.name))return;const t=o;o={view:e},r.add(o),t&&r.remove(t)},getView:()=>r.value.view}}(0,t,0,i)),function(n,t,r,i,o,s){var u;t.debug("Initializing logs API");let l=null;const c=null!==(u=r.logArgsSerializer)&&void 0!==u?u:z;return{pushLog:(n,{context:u,level:d,skipDedupe:g,spanContext:p,timestampOverwriteMs:f}={})=>{try{const h={type:e.TransportItemType.LOG,payload:{message:c(n),level:null!=d?d:E,context:null!=u?u:{},timestamp:f?b(f):v(),trace:p?{trace_id:p.traceId,span_id:p.spanId}:s.getTraceContext()},meta:i.value},y={message:h.payload.message,level:h.payload.level,context:h.payload.context};if(!g&&r.dedupe&&!a(l)&&m(y,l))return void t.debug("Skipping log push because it is the same as the last one\n",h.payload);l=y,t.debug("Pushing log\n",h),o.execute(h)}catch(e){t.error("Error pushing log\n",e)}}}}(0,t,r,i,o,s)),function(n,t,r,i,o,s){t.debug("Initializing measurements API");let u=null;return{pushMeasurement:(n,{skipDedupe:l,context:c,spanContext:d,timestampOverwriteMs:g}={})=>{try{const p={type:e.TransportItemType.MEASUREMENT,payload:Object.assign(Object.assign({},n),{trace:d?{trace_id:d.traceId,span_id:d.spanId}:s.getTraceContext(),timestamp:g?b(g):v(),context:null!=c?c:{}}),meta:i.value},f={type:p.payload.type,values:p.payload.values,context:p.payload.context};if(!l&&r.dedupe&&!a(u)&&m(f,u))return void t.debug("Skipping measurement push because it is the same as the last one\n",p.payload);u=f,t.debug("Pushing measurement\n",p),o.execute(p)}catch(e){t.error("Error pushing measurement\n",e)}}}}(0,t,r,i,o,s)),function(n,t,r,i,o,s){let u=null;return{pushEvent:(n,l,c,{skipDedupe:d,spanContext:g,timestampOverwriteMs:p}={})=>{try{const f={meta:i.value,payload:{name:n,domain:null!=c?c:r.eventDomain,attributes:l,timestamp:p?b(p):v(),trace:g?{trace_id:g.traceId,span_id:g.spanId}:s.getTraceContext()},type:e.TransportItemType.EVENT},h={name:f.payload.name,attributes:f.payload.attributes,domain:f.payload.domain};if(!d&&r.dedupe&&!a(u)&&m(h,u))return void t.debug("Skipping event push because it is the same as the last one\n",f.payload);u=h,t.debug("Pushing event\n",f),o.execute(f)}catch(e){t.error("Error pushing event",e)}}}}(0,t,r,i,o,s))}const K="1.12.1";const H="_faroInternal";function W(e){e.config.isolate?e.internalLogger.debug("Skipping registering internal Faro instance on global object"):(e.internalLogger.debug("Registering internal Faro instance on global object"),Object.defineProperty(O,H,{configurable:!1,enumerable:!1,writable:!1,value:e}))}function X(){return H in O}function J(n,t,r,a,i,o,s){return t.debug("Initializing Faro"),e.faro={api:o,config:r,instrumentations:s,internalLogger:t,metas:a,pause:i.pause,transports:i,unpatchedConsole:n,unpause:i.unpause},W(e.faro),function(e){if(e.config.preventGlobalExposure)e.internalLogger.debug("Skipping registering public Faro instance in the global scope");else{if(e.internalLogger.debug(`Registering public faro reference in the global scope using "${e.config.globalObjectKey}" key`),e.config.globalObjectKey in O)return void e.internalLogger.warn(`Skipping global registration due to key "${e.config.globalObjectKey}" being used already. Please set "globalObjectKey" to something else or set "preventGlobalExposure" to "true"`);Object.defineProperty(O,e.config.globalObjectKey,{configurable:!1,writable:!1,value:e})}}(e.faro),e.faro}e.faro={};return e.BaseExtension=D,e.BaseInstrumentation=class extends D{constructor(){super(...arguments),this.api={},this.transports={}}},e.BaseTransport=class extends D{isBatched(){return!1}getIgnoreUrls(){return[]}},e.Conventions={EventNames:{CLICK:"click",NAVIGATION:"navigation",SESSION_START:"session_start",VIEW_CHANGED:"view_changed"}},e.EVENT_CLICK="click",e.EVENT_NAVIGATION="navigation",e.EVENT_ROUTE_CHANGE="route_change",e.EVENT_SESSION_EXTEND="session_extend",e.EVENT_SESSION_RESUME="session_resume",e.EVENT_SESSION_START="session_start",e.EVENT_VIEW_CHANGED="view_changed",e.VERSION=K,e.allLogLevels=y,e.createInternalLogger=P,e.createPromiseBuffer=function(e){const{size:n,concurrency:t}=e,r=[];let a=0;const i=()=>{if(a<t&&r.length){const{producer:e,resolve:n,reject:t}=r.shift();a++,e().then((e=>{a--,i(),n(e)}),(e=>{a--,i(),t(e)}))}};return{add:e=>{if(r.length+a>=n)throw new Error("Task buffer full");return new Promise(((n,t)=>{r.push({producer:e,resolve:n,reject:t}),i()}))}}},e.dateNow=function(){return Date.now()},e.deepEqual=m,e.defaultBatchingConfig={enabled:!0,sendTimeout:250,itemLimit:50},e.defaultExceptionType=$,e.defaultGlobalObjectKey="faro",e.defaultInternalLoggerLevel=w,e.defaultLogArgsSerializer=z,e.defaultLogLevel=E,e.defaultUnpatchedConsole=C,e.genShortID=function(e=10){return Array.from(Array(e)).map((()=>T[Math.floor(59*Math.random())])).join("")},e.getCurrentTimestamp=v,e.getInternalFaroFromGlobalObject=function(){return O[H]},e.getTransportBody=function(n){let t={meta:{}};return void 0!==n[0]&&(t.meta=n[0].meta),n.forEach((n=>{switch(n.type){case e.TransportItemType.LOG:case e.TransportItemType.EVENT:case e.TransportItemType.EXCEPTION:case e.TransportItemType.MEASUREMENT:const r=N[n.type],a=t[r];t=Object.assign(Object.assign({},t),{[r]:void 0===a?[n.payload]:[...a,n.payload]});break;case e.TransportItemType.TRACE:t=Object.assign(Object.assign({},t),{traces:M(t.traces,n.payload.resourceSpans)})}})),t},e.globalObject=O,e.initializeFaro=function(e){const n=_(e),t=F(n,e);if(X()&&!e.isolate)return void t.error('Faro is already registered. Either add instrumentations, transports etc. to the global faro instance or use the "isolate" property');t.debug("Initializing");const r=function(e,n){let t=[],r=[];const a=()=>t.reduce(((e,n)=>Object.assign(e,u(n)?n():n)),{}),i=()=>{if(r.length){const e=a();r.forEach((n=>n(e)))}};return{add:(...e)=>{n.debug("Adding metas\n",e),t.push(...e),i()},remove:(...e)=>{n.debug("Removing metas\n",e),t=t.filter((n=>!e.includes(n))),i()},addListener:e=>{n.debug("Adding metas listener\n",e),r.push(e)},removeListener:e=>{n.debug("Removing metas listener\n",e),r=r.filter((n=>n!==e))},get value(){return a()}}}(0,t),a=R(n,t,e,r),i=U(0,t,e,r,a),o=function(e,n,t,r,a,i){n.debug("Initializing instrumentations");const o=[];return{add:(...s)=>{n.debug("Adding instrumentations"),s.forEach((s=>{n.debug(`Adding "${s.name}" instrumentation`),o.some((e=>e.name===s.name))?n.warn(`Instrumentation ${s.name} is already added`):(s.unpatchedConsole=e,s.internalLogger=n,s.config=t,s.metas=r,s.transports=a,s.api=i,o.push(s),s.initialize())}))},get instrumentations(){return[...o]},remove:(...e)=>{n.debug("Removing instrumentations"),e.forEach((e=>{var t,r;n.debug(`Removing "${e.name}" instrumentation`);const a=o.reduce(((n,t,r)=>null===n&&t.name===e.name?r:null),null);a?(null===(r=(t=o[a]).destroy)||void 0===r||r.call(t),o.splice(a,1)):n.warn(`Instrumentation "${e.name}" is not added`)}))}}}(n,t,e,r,a,i),s=J(n,t,e,r,a,i,o);return function(e){var n,t;const r={sdk:{version:K},app:{bundleId:e.config.app.name&&(a=e.config.app.name,null==O?void 0:O[`__faroBundleId_${a}`])}};var a;const i=null===(n=e.config.sessionTracking)||void 0===n?void 0:n.session;i&&e.api.setSession(i),e.config.app&&(r.app=Object.assign(Object.assign({},e.config.app),r.app)),e.config.user&&(r.user=e.config.user),e.config.view&&(r.view=e.config.view),e.metas.add(r,...null!==(t=e.config.metas)&&void 0!==t?t:[])}(s),function(e){e.transports.add(...e.config.transports),e.transports.addBeforeSendHooks(e.config.beforeSend),e.transports.addIgnoreErrorsPatterns(e.config.ignoreErrors)}(s),function(e){e.instrumentations.add(...e.config.instrumentations)}(s),s},e.internalGlobalObjectKey=H,e.isArray=l,e.isBoolean=e=>n(e,"boolean"),e.isDomError=e=>t(e,"DOMError"),e.isDomException=e=>t(e,"DOMException"),e.isElement=e=>p&&r(e,Element),e.isElementDefined=p,e.isError=g,e.isErrorDefined=d,e.isErrorEvent=e=>t(e,"ErrorEvent"),e.isEvent=e=>c&&r(e,Event),e.isEventDefined=c,e.isFunction=u,e.isInstanceOf=r,e.isInt=e=>o(e)&&Number.isInteger(e),e.isInternalFaroOnGlobalObject=X,e.isMap=e=>f&&r(e,Map),e.isMapDefined=f,e.isNull=a,e.isNumber=o,e.isObject=s,e.isPrimitive=e=>!s(e)&&!u(e),e.isRegExp=e=>t(e,"RegExp"),e.isString=i,e.isSymbol=e=>n(e,"symbol"),e.isSyntheticEvent=e=>s(e)&&"nativeEvent"in e&&"preventDefault"in e&&"stopPropagation"in e,e.isThenable=e=>u(null==e?void 0:e.then),e.isToString=t,e.isTypeof=n,e.isUndefined=e=>n(e,"undefined"),e.noop=I,e.setInternalFaroOnGlobalObject=W,e.transportItemTypeToBodyKey=N,e.unknownString="unknown",e}({});
|
|
1
|
+
var GrafanaFaroCore=function(e){"use strict";function n(e,n){return typeof e===n}function t(e,n){return Object.prototype.toString.call(e)===`[object ${n}]`}function r(e,n){try{return e instanceof n}catch(e){return!1}}const a=e=>n(e,"null"),i=e=>n(e,"string"),o=e=>n(e,"number")&&!isNaN(e)||n(e,"bigint"),s=e=>!a(e)&&n(e,"object"),u=e=>n(e,"function"),l=e=>t(e,"Array"),c="undefined"!=typeof Event,d="undefined"!=typeof Error,g=e=>d&&r(e,Error),p="undefined"!=typeof Element,f="undefined"!=typeof Map;function m(e,t){if(e===t)return!0;if(n(e,"number")&&isNaN(e))return n(t,"number")&&isNaN(t);const r=l(e),a=l(t);if(r!==a)return!1;if(r&&a){const n=e.length;if(n!==t.length)return!1;for(let r=n;0!=r--;)if(!m(e[r],t[r]))return!1;return!0}const i=s(e),o=s(t);if(i!==o)return!1;if(e&&t&&i&&o){const n=Object.keys(e),r=Object.keys(t);if(n.length!==r.length)return!1;for(let e of n)if(!r.includes(e))return!1;for(let r of n)if(!m(e[r],t[r]))return!1;return!0}return!1}function v(){return(new Date).toISOString()}function b(e){return new Date(e).toISOString()}var h;e.LogLevel=void 0,(h=e.LogLevel||(e.LogLevel={})).TRACE="trace",h.DEBUG="debug",h.INFO="info",h.LOG="log",h.WARN="warn",h.ERROR="error";const E=e.LogLevel.LOG,y=[e.LogLevel.TRACE,e.LogLevel.DEBUG,e.LogLevel.INFO,e.LogLevel.LOG,e.LogLevel.WARN,e.LogLevel.ERROR];function I(){}const T="abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ0123456789";const O="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof global?global:"undefined"!=typeof self?self:void 0;class L{constructor(e,n){var t,r;this.signalBuffer=[],this.itemLimit=null!==(t=null==n?void 0:n.itemLimit)&&void 0!==t?t:50,this.sendTimeout=null!==(r=null==n?void 0:n.sendTimeout)&&void 0!==r?r:250,this.paused=(null==n?void 0:n.paused)||!1,this.sendFn=e,this.flushInterval=-1,this.paused||this.start(),document.addEventListener("visibilitychange",(()=>{"hidden"===document.visibilityState&&this.flush()}))}addItem(e){this.paused||(this.signalBuffer.push(e),this.signalBuffer.length>=this.itemLimit&&this.flush())}start(){this.paused=!1,this.sendTimeout>0&&(this.flushInterval=window.setInterval((()=>this.flush()),this.sendTimeout))}pause(){this.paused=!0,clearInterval(this.flushInterval)}groupItems(e){const n=new Map;return e.forEach((e=>{const t=JSON.stringify(e.meta);let r=n.get(t);r=void 0===r?[e]:[...r,e],n.set(t,r)})),Array.from(n.values())}flush(){if(this.paused||0===this.signalBuffer.length)return;this.groupItems(this.signalBuffer).forEach(this.sendFn),this.signalBuffer=[]}}var S;e.TransportItemType=void 0,(S=e.TransportItemType||(e.TransportItemType={})).EXCEPTION="exception",S.LOG="log",S.MEASUREMENT="measurement",S.TRACE="trace",S.EVENT="event";const N={[e.TransportItemType.EXCEPTION]:"exceptions",[e.TransportItemType.LOG]:"logs",[e.TransportItemType.MEASUREMENT]:"measurements",[e.TransportItemType.TRACE]:"traces",[e.TransportItemType.EVENT]:"events"};function x(n){return t=>{if(t.type===e.TransportItemType.EXCEPTION&&t.payload){const e=t.payload,r=`${e.type}: ${e.value}`;if(function(e,n){return e.some((e=>i(e)?n.includes(e):!!n.match(e)))}(n,r))return null}return t}}function R(e,n,t,r){var a;n.debug("Initializing transports");const i=[];let o=t.paused,s=[];const u=e=>{let n=e;for(const e of s){const t=n.map(e).filter(Boolean);if(0===t.length)return[];n=t}return n},l=e=>{const t=u(e);if(0!==t.length)for(const e of i)n.debug(`Transporting item using ${e.name}\n`,t),e.isBatched()&&e.send(t)};let c;(null===(a=t.batching)||void 0===a?void 0:a.enabled)&&(c=new L(l,{sendTimeout:t.batching.sendTimeout,itemLimit:t.batching.itemLimit,paused:o}));return{add:(...a)=>{n.debug("Adding transports"),a.forEach((a=>{n.debug(`Adding "${a.name}" transport`);i.some((e=>e===a))?n.warn(`Transport ${a.name} is already added`):(a.unpatchedConsole=e,a.internalLogger=n,a.config=t,a.metas=r,i.push(a))}))},addBeforeSendHooks:(...e)=>{n.debug("Adding beforeSendHooks\n",s),e.forEach((e=>{e&&s.push(e)}))},addIgnoreErrorsPatterns:(...e)=>{n.debug("Adding ignoreErrorsPatterns\n",e),e.forEach((e=>{e&&s.push(x(e))}))},getBeforeSendHooks:()=>[...s],execute:e=>{var r;o||((null===(r=t.batching)||void 0===r?void 0:r.enabled)&&(null==c||c.addItem(e)),(e=>{var r,a;if((null===(r=t.batching)||void 0===r?void 0:r.enabled)&&i.every((e=>e.isBatched())))return;const[o]=u([e]);if(void 0!==o)for(const e of i)n.debug(`Transporting item using ${e.name}\n`,o),e.isBatched()?(null===(a=t.batching)||void 0===a?void 0:a.enabled)||e.send([o]):e.send(o)})(e))},isPaused:()=>o,pause:()=>{n.debug("Pausing transports"),null==c||c.pause(),o=!0},remove:(...e)=>{n.debug("Removing transports"),e.forEach((e=>{n.debug(`Removing "${e.name}" transport`);const t=i.indexOf(e);-1!==t?i.splice(t,1):n.warn(`Transport "${e.name}" is not added`)}))},removeBeforeSendHooks:(...e)=>{s.filter((n=>!e.includes(n)))},get transports(){return[...i]},unpause:()=>{n.debug("Unpausing transports"),null==c||c.start(),o=!1}}}var j;e.InternalLoggerLevel=void 0,(j=e.InternalLoggerLevel||(e.InternalLoggerLevel={}))[j.OFF=0]="OFF",j[j.ERROR=1]="ERROR",j[j.WARN=2]="WARN",j[j.INFO=3]="INFO",j[j.VERBOSE=4]="VERBOSE";const A={debug:I,error:I,info:I,prefix:"Faro",warn:I},w=e.InternalLoggerLevel.ERROR,C=Object.assign({},console);let k=C;function _(e){var n;return k=null!==(n=e.unpatchedConsole)&&void 0!==n?n:k,k}function P(n=C,t=w){const r=A;return t>e.InternalLoggerLevel.OFF&&(r.error=t>=e.InternalLoggerLevel.ERROR?function(...e){n.error(`${r.prefix}\n`,...e)}:I,r.warn=t>=e.InternalLoggerLevel.WARN?function(...e){n.warn(`${r.prefix}\n`,...e)}:I,r.info=t>=e.InternalLoggerLevel.INFO?function(...e){n.info(`${r.prefix}\n`,...e)}:I,r.debug=t>=e.InternalLoggerLevel.VERBOSE?function(...e){n.debug(`${r.prefix}\n`,...e)}:I),r}let B=A;function F(e,n){return B=P(e,n.internalLoggerLevel),B}class D{constructor(){this.unpatchedConsole=C,this.internalLogger=A,this.config={},this.metas={}}logDebug(...e){this.internalLogger.debug(`${this.name}\n`,...e)}logInfo(...e){this.internalLogger.info(`${this.name}\n`,...e)}logWarn(...e){this.internalLogger.warn(`${this.name}\n`,...e)}logError(...e){this.internalLogger.error(`${this.name}\n`,...e)}}function M(e,n){var t,r;if(void 0===n)return e;if(void 0===e)return{resourceSpans:n};const a=null===(t=e.resourceSpans)||void 0===t?void 0:t[0];if(void 0===a)return e;const i=(null==a?void 0:a.scopeSpans)||[],o=(null===(r=null==n?void 0:n[0])||void 0===r?void 0:r.scopeSpans)||[];return Object.assign(Object.assign({},e),{resourceSpans:[Object.assign(Object.assign({},a),{scopeSpans:[...i,...o]})]})}const $="Error";let G;function V(e){let n=e.cause;return g(n)?n=e.cause.toString():null!==n&&(s(e.cause)||l(e.cause))?n=JSON.stringify(e.cause):null!=n&&(n=e.cause.toString()),null==n?{}:{cause:n}}const z=e=>e.map((e=>{try{return String(e)}catch(e){return""}})).join(" ");function U(n,t,r,i,o){t.debug("Initializing API");const s=function(n,t,r,a,i){let o;return t.debug("Initializing traces API"),{getOTEL:()=>o,getTraceContext:()=>{const e=null==o?void 0:o.trace.getSpanContext(o.context.active());return e?{trace_id:e.traceId,span_id:e.spanId}:void 0},initOTEL:(e,n)=>{t.debug("Initializing OpenTelemetry"),o={trace:e,context:n}},isOTELInitialized:()=>!!o,pushTraces:n=>{try{const r={type:e.TransportItemType.TRACE,payload:n,meta:a.value};t.debug("Pushing trace\n",r),i.execute(r)}catch(e){t.error("Error pushing trace\n",e)}}}}(0,t,0,i,o);return Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({},s),function(n,t,r,i,o,s){var u;t.debug("Initializing exceptions API");let l=null;G=null!==(u=r.parseStacktrace)&&void 0!==u?u:G;const c=e=>{t.debug("Changing stacktrace parser"),G=null!=e?e:G};return c(r.parseStacktrace),{changeStacktraceParser:c,getStacktraceParser:()=>G,pushError:(n,{skipDedupe:u,stackFrames:c,type:d,context:g,spanContext:p,timestampOverwriteMs:f}={})=>{d=d||n.name||$;const h={meta:i.value,payload:{type:d,value:n.message,timestamp:f?b(f):v(),trace:p?{trace_id:p.traceId,span_id:p.spanId}:s.getTraceContext(),context:Object.assign(Object.assign({},V(n)),null!=g?g:{})},type:e.TransportItemType.EXCEPTION};(null==(c=null!=c?c:n.stack?null==G?void 0:G(n).frames:void 0)?void 0:c.length)&&(h.payload.stacktrace={frames:c});const E={type:h.payload.type,value:h.payload.value,stackTrace:h.payload.stacktrace,context:h.payload.context};u||!r.dedupe||a(l)||!m(E,l)?(l=E,t.debug("Pushing exception\n",h),o.execute(h)):t.debug("Skipping error push because it is the same as the last one\n",h.payload)}}}(0,t,r,i,o,s)),function(e,n,t,r){let a,i,o;n.debug("Initializing meta API");const s=e=>{i&&r.remove(i),i={user:e},r.add(i)},u=e=>{a&&r.remove(a),a={session:e},r.add(a)};return{setUser:s,resetUser:s,setSession:u,resetSession:u,getSession:()=>r.value.session,setView:e=>{var n;if((null===(n=null==o?void 0:o.view)||void 0===n?void 0:n.name)===(null==e?void 0:e.name))return;const t=o;o={view:e},r.add(o),t&&r.remove(t)},getView:()=>r.value.view}}(0,t,0,i)),function(n,t,r,i,o,s){var u;t.debug("Initializing logs API");let l=null;const c=null!==(u=r.logArgsSerializer)&&void 0!==u?u:z;return{pushLog:(n,{context:u,level:d,skipDedupe:g,spanContext:p,timestampOverwriteMs:f}={})=>{try{const h={type:e.TransportItemType.LOG,payload:{message:c(n),level:null!=d?d:E,context:null!=u?u:{},timestamp:f?b(f):v(),trace:p?{trace_id:p.traceId,span_id:p.spanId}:s.getTraceContext()},meta:i.value},y={message:h.payload.message,level:h.payload.level,context:h.payload.context};if(!g&&r.dedupe&&!a(l)&&m(y,l))return void t.debug("Skipping log push because it is the same as the last one\n",h.payload);l=y,t.debug("Pushing log\n",h),o.execute(h)}catch(e){t.error("Error pushing log\n",e)}}}}(0,t,r,i,o,s)),function(n,t,r,i,o,s){t.debug("Initializing measurements API");let u=null;return{pushMeasurement:(n,{skipDedupe:l,context:c,spanContext:d,timestampOverwriteMs:g}={})=>{try{const p={type:e.TransportItemType.MEASUREMENT,payload:Object.assign(Object.assign({},n),{trace:d?{trace_id:d.traceId,span_id:d.spanId}:s.getTraceContext(),timestamp:g?b(g):v(),context:null!=c?c:{}}),meta:i.value},f={type:p.payload.type,values:p.payload.values,context:p.payload.context};if(!l&&r.dedupe&&!a(u)&&m(f,u))return void t.debug("Skipping measurement push because it is the same as the last one\n",p.payload);u=f,t.debug("Pushing measurement\n",p),o.execute(p)}catch(e){t.error("Error pushing measurement\n",e)}}}}(0,t,r,i,o,s)),function(n,t,r,i,o,s){let u=null;return{pushEvent:(n,l,c,{skipDedupe:d,spanContext:g,timestampOverwriteMs:p}={})=>{try{const f={meta:i.value,payload:{name:n,domain:null!=c?c:r.eventDomain,attributes:l,timestamp:p?b(p):v(),trace:g?{trace_id:g.traceId,span_id:g.spanId}:s.getTraceContext()},type:e.TransportItemType.EVENT},h={name:f.payload.name,attributes:f.payload.attributes,domain:f.payload.domain};if(!d&&r.dedupe&&!a(u)&&m(h,u))return void t.debug("Skipping event push because it is the same as the last one\n",f.payload);u=h,t.debug("Pushing event\n",f),o.execute(f)}catch(e){t.error("Error pushing event",e)}}}}(0,t,r,i,o,s))}const K="1.12.3";const H="_faroInternal";function W(e){e.config.isolate?e.internalLogger.debug("Skipping registering internal Faro instance on global object"):(e.internalLogger.debug("Registering internal Faro instance on global object"),Object.defineProperty(O,H,{configurable:!1,enumerable:!1,writable:!1,value:e}))}function X(){return H in O}function J(n,t,r,a,i,o,s){return t.debug("Initializing Faro"),e.faro={api:o,config:r,instrumentations:s,internalLogger:t,metas:a,pause:i.pause,transports:i,unpatchedConsole:n,unpause:i.unpause},W(e.faro),function(e){if(e.config.preventGlobalExposure)e.internalLogger.debug("Skipping registering public Faro instance in the global scope");else{if(e.internalLogger.debug(`Registering public faro reference in the global scope using "${e.config.globalObjectKey}" key`),e.config.globalObjectKey in O)return void e.internalLogger.warn(`Skipping global registration due to key "${e.config.globalObjectKey}" being used already. Please set "globalObjectKey" to something else or set "preventGlobalExposure" to "true"`);Object.defineProperty(O,e.config.globalObjectKey,{configurable:!1,writable:!1,value:e})}}(e.faro),e.faro}e.faro={};return e.BaseExtension=D,e.BaseInstrumentation=class extends D{constructor(){super(...arguments),this.api={},this.transports={}}},e.BaseTransport=class extends D{isBatched(){return!1}getIgnoreUrls(){return[]}},e.Conventions={EventNames:{CLICK:"click",NAVIGATION:"navigation",SESSION_START:"session_start",VIEW_CHANGED:"view_changed"}},e.EVENT_CLICK="click",e.EVENT_NAVIGATION="navigation",e.EVENT_ROUTE_CHANGE="route_change",e.EVENT_SESSION_EXTEND="session_extend",e.EVENT_SESSION_RESUME="session_resume",e.EVENT_SESSION_START="session_start",e.EVENT_VIEW_CHANGED="view_changed",e.VERSION=K,e.allLogLevels=y,e.createInternalLogger=P,e.createPromiseBuffer=function(e){const{size:n,concurrency:t}=e,r=[];let a=0;const i=()=>{if(a<t&&r.length){const{producer:e,resolve:n,reject:t}=r.shift();a++,e().then((e=>{a--,i(),n(e)}),(e=>{a--,i(),t(e)}))}};return{add:e=>{if(r.length+a>=n)throw new Error("Task buffer full");return new Promise(((n,t)=>{r.push({producer:e,resolve:n,reject:t}),i()}))}}},e.dateNow=function(){return Date.now()},e.deepEqual=m,e.defaultBatchingConfig={enabled:!0,sendTimeout:250,itemLimit:50},e.defaultExceptionType=$,e.defaultGlobalObjectKey="faro",e.defaultInternalLoggerLevel=w,e.defaultLogArgsSerializer=z,e.defaultLogLevel=E,e.defaultUnpatchedConsole=C,e.genShortID=function(e=10){return Array.from(Array(e)).map((()=>T[Math.floor(59*Math.random())])).join("")},e.getCurrentTimestamp=v,e.getInternalFaroFromGlobalObject=function(){return O[H]},e.getTransportBody=function(n){let t={meta:{}};return void 0!==n[0]&&(t.meta=n[0].meta),n.forEach((n=>{switch(n.type){case e.TransportItemType.LOG:case e.TransportItemType.EVENT:case e.TransportItemType.EXCEPTION:case e.TransportItemType.MEASUREMENT:const r=N[n.type],a=t[r];t=Object.assign(Object.assign({},t),{[r]:void 0===a?[n.payload]:[...a,n.payload]});break;case e.TransportItemType.TRACE:t=Object.assign(Object.assign({},t),{traces:M(t.traces,n.payload.resourceSpans)})}})),t},e.globalObject=O,e.initializeFaro=function(e){const n=_(e),t=F(n,e);if(X()&&!e.isolate)return void t.error('Faro is already registered. Either add instrumentations, transports etc. to the global faro instance or use the "isolate" property');t.debug("Initializing");const r=function(e,n){let t=[],r=[];const a=()=>t.reduce(((e,n)=>Object.assign(e,u(n)?n():n)),{}),i=()=>{if(r.length){const e=a();r.forEach((n=>n(e)))}};return{add:(...e)=>{n.debug("Adding metas\n",e),t.push(...e),i()},remove:(...e)=>{n.debug("Removing metas\n",e),t=t.filter((n=>!e.includes(n))),i()},addListener:e=>{n.debug("Adding metas listener\n",e),r.push(e)},removeListener:e=>{n.debug("Removing metas listener\n",e),r=r.filter((n=>n!==e))},get value(){return a()}}}(0,t),a=R(n,t,e,r),i=U(0,t,e,r,a),o=function(e,n,t,r,a,i){n.debug("Initializing instrumentations");const o=[];return{add:(...s)=>{n.debug("Adding instrumentations"),s.forEach((s=>{n.debug(`Adding "${s.name}" instrumentation`),o.some((e=>e.name===s.name))?n.warn(`Instrumentation ${s.name} is already added`):(s.unpatchedConsole=e,s.internalLogger=n,s.config=t,s.metas=r,s.transports=a,s.api=i,o.push(s),s.initialize())}))},get instrumentations(){return[...o]},remove:(...e)=>{n.debug("Removing instrumentations"),e.forEach((e=>{var t,r;n.debug(`Removing "${e.name}" instrumentation`);const a=o.reduce(((n,t,r)=>null===n&&t.name===e.name?r:null),null);a?(null===(r=(t=o[a]).destroy)||void 0===r||r.call(t),o.splice(a,1)):n.warn(`Instrumentation "${e.name}" is not added`)}))}}}(n,t,e,r,a,i),s=J(n,t,e,r,a,i,o);return function(e){var n,t;const r={sdk:{version:K},app:{bundleId:e.config.app.name&&(a=e.config.app.name,null==O?void 0:O[`__faroBundleId_${a}`])}};var a;const i=null===(n=e.config.sessionTracking)||void 0===n?void 0:n.session;i&&e.api.setSession(i),e.config.app&&(r.app=Object.assign(Object.assign({},e.config.app),r.app)),e.config.user&&(r.user=e.config.user),e.config.view&&(r.view=e.config.view),e.metas.add(r,...null!==(t=e.config.metas)&&void 0!==t?t:[])}(s),function(e){e.transports.add(...e.config.transports),e.transports.addBeforeSendHooks(e.config.beforeSend),e.transports.addIgnoreErrorsPatterns(e.config.ignoreErrors)}(s),function(e){e.instrumentations.add(...e.config.instrumentations)}(s),s},e.internalGlobalObjectKey=H,e.isArray=l,e.isBoolean=e=>n(e,"boolean"),e.isDomError=e=>t(e,"DOMError"),e.isDomException=e=>t(e,"DOMException"),e.isElement=e=>p&&r(e,Element),e.isElementDefined=p,e.isError=g,e.isErrorDefined=d,e.isErrorEvent=e=>t(e,"ErrorEvent"),e.isEvent=e=>c&&r(e,Event),e.isEventDefined=c,e.isFunction=u,e.isInstanceOf=r,e.isInt=e=>o(e)&&Number.isInteger(e),e.isInternalFaroOnGlobalObject=X,e.isMap=e=>f&&r(e,Map),e.isMapDefined=f,e.isNull=a,e.isNumber=o,e.isObject=s,e.isPrimitive=e=>!s(e)&&!u(e),e.isRegExp=e=>t(e,"RegExp"),e.isString=i,e.isSymbol=e=>n(e,"symbol"),e.isSyntheticEvent=e=>s(e)&&"nativeEvent"in e&&"preventDefault"in e&&"stopPropagation"in e,e.isThenable=e=>u(null==e?void 0:e.then),e.isToString=t,e.isTypeof=n,e.isUndefined=e=>n(e,"undefined"),e.noop=I,e.setInternalFaroOnGlobalObject=W,e.transportItemTypeToBodyKey=N,e.unknownString="unknown",e}({});
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { ContextAPI as OTELContextAPI, TraceAPI as OTELTraceAPI } from '@opentelemetry/api';
|
|
2
|
-
import type { IResourceSpans } from '@opentelemetry/otlp-transformer';
|
|
2
|
+
import type { IResourceSpans } from '@opentelemetry/otlp-transformer/build/src/trace/internal-types';
|
|
3
3
|
export interface TraceEvent {
|
|
4
4
|
resourceSpans?: IResourceSpans[];
|
|
5
5
|
}
|
|
@@ -4,7 +4,7 @@ import type { Transport, TransportItem } from '../transports';
|
|
|
4
4
|
export declare class MockTransport extends BaseTransport implements Transport {
|
|
5
5
|
private ignoreURLs;
|
|
6
6
|
readonly name = "@grafana/transport-mock";
|
|
7
|
-
readonly version = "1.12.
|
|
7
|
+
readonly version = "1.12.3";
|
|
8
8
|
items: TransportItem[];
|
|
9
9
|
constructor(ignoreURLs?: Patterns);
|
|
10
10
|
send(items: TransportItem[]): void | Promise<void>;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { IResourceSpans } from '@opentelemetry/otlp-transformer';
|
|
1
|
+
import type { IResourceSpans } from '@opentelemetry/otlp-transformer/build/src/trace/internal-types';
|
|
2
2
|
import type { TraceEvent } from '..';
|
|
3
3
|
import type { TransportBody, TransportItem } from './types';
|
|
4
4
|
export declare function mergeResourceSpans(traces?: TraceEvent, resourceSpans?: IResourceSpans[]): TraceEvent | undefined;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const VERSION = "1.12.
|
|
1
|
+
export declare const VERSION = "1.12.3";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../../src/api/traces/types.ts"],"names":[],"mappings":"","sourcesContent":["import type { ContextAPI as OTELContextAPI, TraceAPI as OTELTraceAPI } from '@opentelemetry/api';\nimport type { IResourceSpans } from '@opentelemetry/otlp-transformer';\n\n// TODO: Revert temporary patching\n// in latest OpenTelemetry packages protobuf type \"instrumentationLibrary\" has been renamed to \"scope\"\n// however on the Grafana Agent we use older OTel collector that doesn't have this change\n// temporarily patching types to the old shape until Grafana Agent catches up to otel-collector >= 0.52\nexport interface TraceEvent {\n resourceSpans?: IResourceSpans[];\n}\n\nexport interface OTELApi {\n trace: OTELTraceAPI;\n context: OTELContextAPI;\n}\n\nexport interface TracesAPI {\n getOTEL: () => OTELApi | undefined;\n getTraceContext: () => TraceContext | undefined;\n initOTEL: (trace: OTELTraceAPI, context: OTELContextAPI) => void;\n isOTELInitialized: () => boolean;\n pushTraces: (traces: TraceEvent) => void;\n}\n\n// trace context for logs, exceptions, measurements\nexport interface TraceContext {\n trace_id: string;\n span_id: string;\n}\n"]}
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../../src/api/traces/types.ts"],"names":[],"mappings":"","sourcesContent":["import type { ContextAPI as OTELContextAPI, TraceAPI as OTELTraceAPI } from '@opentelemetry/api';\nimport type { IResourceSpans } from '@opentelemetry/otlp-transformer/build/src/trace/internal-types';\n\n// TODO: Revert temporary patching\n// in latest OpenTelemetry packages protobuf type \"instrumentationLibrary\" has been renamed to \"scope\"\n// however on the Grafana Agent we use older OTel collector that doesn't have this change\n// temporarily patching types to the old shape until Grafana Agent catches up to otel-collector >= 0.52\nexport interface TraceEvent {\n resourceSpans?: IResourceSpans[];\n}\n\nexport interface OTELApi {\n trace: OTELTraceAPI;\n context: OTELContextAPI;\n}\n\nexport interface TracesAPI {\n getOTEL: () => OTELApi | undefined;\n getTraceContext: () => TraceContext | undefined;\n initOTEL: (trace: OTELTraceAPI, context: OTELContextAPI) => void;\n isOTELInitialized: () => boolean;\n pushTraces: (traces: TraceEvent) => void;\n}\n\n// trace context for logs, exceptions, measurements\nexport interface TraceContext {\n trace_id: string;\n span_id: string;\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"globalObject.js","sourceRoot":"","sources":["../../../src/globalObject/globalObject.ts"],"names":[],"mappings":";;;AAQA,mGAAmG;AACtF,QAAA,YAAY,GAAG,CAAC,OAAO,UAAU,KAAK,WAAW;IAC5D,CAAC,CAAC,UAAU;IACZ,CAAC,CAAC,OAAO,MAAM,KAAK,WAAW;
|
|
1
|
+
{"version":3,"file":"globalObject.js","sourceRoot":"","sources":["../../../src/globalObject/globalObject.ts"],"names":[],"mappings":";;;AAQA,mGAAmG;AACtF,QAAA,YAAY,GAAG,CAAC,OAAO,UAAU,KAAK,WAAW;IAC5D,CAAC,CAAC,UAAU;IACZ,CAAC,CAAC,OAAO,MAAM,KAAK,WAAW;QAC7B,CAAC,CAAC,MAAM;QACR,CAAC,CAAC,OAAO,IAAI,KAAK,WAAW;YAC3B,CAAC,CAAC,IAAI;YACN,CAAC,CAAC,SAAS,CAA4B,CAAC","sourcesContent":["import type { Faro, internalGlobalObjectKey } from '../sdk';\n\nexport type GlobalObject<T = typeof globalThis | typeof global | typeof self> = T & {\n [label: string]: Faro;\n\n [internalGlobalObjectKey]: Faro;\n};\n\n// This does not uses isUndefined method because it will throw an error in non-browser environments\nexport const globalObject = (typeof globalThis !== 'undefined'\n ? globalThis\n : typeof global !== 'undefined'\n ? global\n : typeof self !== 'undefined'\n ? self\n : undefined) as unknown as GlobalObject;\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../../../src/transports/utils.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AAIA,iCAAwE;AAGxE,SAAgB,kBAAkB,CAAC,MAAmB,EAAE,aAAgC;;IACtF,IAAI,aAAa,KAAK,SAAS,EAAE;QAC/B,OAAO,MAAM,CAAC;KACf;IAED,IAAI,MAAM,KAAK,SAAS,EAAE;QACxB,OAAO;YACL,aAAa,eAAA;SACd,CAAC;KACH;IAED,IAAM,eAAe,GAAG,MAAA,MAAM,CAAC,aAAa,0CAAG,CAAC,CAAC,CAAC;IAClD,IAAI,eAAe,KAAK,SAAS,EAAE;QACjC,OAAO,MAAM,CAAC;KACf;IAED,IAAM,YAAY,GAAG,CAAA,eAAe,aAAf,eAAe,uBAAf,eAAe,CAAE,UAAU,KAAI,EAAE,CAAC;IACvD,IAAM,QAAQ,GAAG,CAAA,MAAA,aAAa,aAAb,aAAa,uBAAb,aAAa,CAAG,CAAC,CAAC,0CAAE,UAAU,KAAI,EAAE,CAAC;IAEtD,6BACK,MAAM,KACT,aAAa,EAAE;kCAER,eAAe,KAClB,UAAU,kCAAM,YAAY,SAAK,QAAQ;SAE5C,IACD;AACJ,CAAC;AA5BD,gDA4BC;AAED,SAAgB,gBAAgB,CAAC,IAAqB;IACpD,IAAI,IAAI,GAAkB;QACxB,IAAI,EAAE,EAAE;KACT,CAAC;IAEF,IAAI,IAAI,CAAC,CAAC,CAAC,KAAK,SAAS,EAAE;QACzB,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC;KAC1B;IAED,IAAI,CAAC,OAAO,CAAC,UAAC,WAA0B;;QACtC,QAAQ,WAAW,CAAC,IAAI,EAAE;YACxB,KAAK,yBAAiB,CAAC,GAAG,CAAC;YAC3B,KAAK,yBAAiB,CAAC,KAAK,CAAC;YAC7B,KAAK,yBAAiB,CAAC,SAAS,CAAC;YACjC,KAAK,yBAAiB,CAAC,WAAW;gBAChC,IAAM,EAAE,GAAG,kCAA0B,CAAC,WAAW,CAAC,IAAI,CAAC,CAAC;gBACxD,IAAM,OAAO,GAAG,IAAI,CAAC,EAAE,CAAsE,CAAC;gBAE9F,IAAI,yBACC,IAAI,gBACN,EAAE,IAAG,OAAO,KAAK,SAAS,CAAC,CAAC,CAAC,CAAC,WAAW,CAAC,OAAO,CAAC,CAAC,CAAC,iCAAK,OAAO,UAAE,WAAW,CAAC,OAAO,SAAC,MACxF,CAAC;gBACF,MAAM;YACR,KAAK,yBAAiB,CAAC,KAAK;gBAC1B,IAAI,yBACC,IAAI,KACP,MAAM,EAAE,kBAAkB,CAAC,IAAI,CAAC,MAAM,EAAG,WAAW,CAAC,OAAsB,CAAC,aAAa,CAAC,GAC3F,CAAC;gBACF,MAAM;SACT;IACH,CAAC,CAAC,CAAC;IAEH,OAAO,IAAI,CAAC;AACd,CAAC;AAjCD,4CAiCC","sourcesContent":["import type { IResourceSpans } from '@opentelemetry/otlp-transformer';\n\nimport type { EventEvent, ExceptionEvent, LogEvent, MeasurementEvent, TraceEvent } from '..';\n\nimport { TransportItemType, transportItemTypeToBodyKey } from './const';\nimport type { TransportBody, TransportItem } from './types';\n\nexport function mergeResourceSpans(traces?: TraceEvent, resourceSpans?: IResourceSpans[]): TraceEvent | undefined {\n if (resourceSpans === undefined) {\n return traces;\n }\n\n if (traces === undefined) {\n return {\n resourceSpans,\n };\n }\n\n const currentResource = traces.resourceSpans?.[0];\n if (currentResource === undefined) {\n return traces;\n }\n\n const currentSpans = currentResource?.scopeSpans || [];\n const newSpans = resourceSpans?.[0]?.scopeSpans || [];\n\n return {\n ...traces,\n resourceSpans: [\n {\n ...currentResource,\n scopeSpans: [...currentSpans, ...newSpans],\n },\n ],\n };\n}\n\nexport function getTransportBody(item: TransportItem[]): TransportBody {\n let body: TransportBody = {\n meta: {},\n };\n\n if (item[0] !== undefined) {\n body.meta = item[0].meta;\n }\n\n item.forEach((currentItem: TransportItem) => {\n switch (currentItem.type) {\n case TransportItemType.LOG:\n case TransportItemType.EVENT:\n case TransportItemType.EXCEPTION:\n case TransportItemType.MEASUREMENT:\n const bk = transportItemTypeToBodyKey[currentItem.type];\n const signals = body[bk] as LogEvent[] | EventEvent[] | ExceptionEvent[] | MeasurementEvent[];\n\n body = {\n ...body,\n [bk]: signals === undefined ? [currentItem.payload] : [...signals, currentItem.payload],\n };\n break;\n case TransportItemType.TRACE:\n body = {\n ...body,\n traces: mergeResourceSpans(body.traces, (currentItem.payload as TraceEvent).resourceSpans),\n };\n break;\n }\n });\n\n return body;\n}\n"]}
|
|
1
|
+
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../../../src/transports/utils.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AAIA,iCAAwE;AAGxE,SAAgB,kBAAkB,CAAC,MAAmB,EAAE,aAAgC;;IACtF,IAAI,aAAa,KAAK,SAAS,EAAE;QAC/B,OAAO,MAAM,CAAC;KACf;IAED,IAAI,MAAM,KAAK,SAAS,EAAE;QACxB,OAAO;YACL,aAAa,eAAA;SAC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AC,MACxF,CAAC;gBACF,MAAM;YACR,KAAK,yBAAiB,CAAC,KAAK;gBAC1B,IAAI,yBACC,IAAI,KACP,MAAM,EAAE,kBAAkB,CAAC,IAAI,CAAC,MAAM,EAAG,WAAW,CAAC,OAAsB,CAAC,aAAa,CAAC,GAC3F,CAAC;gBACF,MAAM;SACT;IACH,CAAC,CAAC,CAAC;IAEH,OAAO,IAAI,CAAC;AACd,CAAC;AAjCD,4CAiCC","sourcesContent":["import type { IResourceSpans } from '@opentelemetry/otlp-transformer/build/src/trace/internal-types';\n\nimport type { EventEvent, ExceptionEvent, LogEvent, MeasurementEvent, TraceEvent } from '..';\n\nimport { TransportItemType, transportItemTypeToBodyKey } from './const';\nimport type { TransportBody, TransportItem } from './types';\n\nexport function mergeResourceSpans(traces?: TraceEvent, resourceSpans?: IResourceSpans[]): TraceEvent | undefined {\n if (resourceSpans === undefined) {\n return traces;\n }\n\n if (traces === undefined) {\n return {\n resourceSpans,\n };\n }\n\n const currentResource = traces.resourceSpans?.[0];\n if (currentResource === undefined) {\n return traces;\n }\n\n const currentSpans = currentResource?.scopeSpans || [];\n const newSpans = resourceSpans?.[0]?.scopeSpans || [];\n\n return {\n ...traces,\n resourceSpans: [\n {\n ...currentResource,\n scopeSpans: [...currentSpans, ...newSpans],\n },\n ],\n };\n}\n\nexport function getTransportBody(item: TransportItem[]): TransportBody {\n let body: TransportBody = {\n meta: {},\n };\n\n if (item[0] !== undefined) {\n body.meta = item[0].meta;\n }\n\n item.forEach((currentItem: TransportItem) => {\n switch (currentItem.type) {\n case TransportItemType.LOG:\n case TransportItemType.EVENT:\n case TransportItemType.EXCEPTION:\n case TransportItemType.MEASUREMENT:\n const bk = transportItemTypeToBodyKey[currentItem.type];\n const signals = body[bk] as LogEvent[] | EventEvent[] | ExceptionEvent[] | MeasurementEvent[];\n\n body = {\n ...body,\n [bk]: signals === undefined ? [currentItem.payload] : [...signals, currentItem.payload],\n };\n break;\n case TransportItemType.TRACE:\n body = {\n ...body,\n traces: mergeResourceSpans(body.traces, (currentItem.payload as TraceEvent).resourceSpans),\n };\n break;\n }\n });\n\n return body;\n}\n"]}
|
package/dist/cjs/version.js
CHANGED
package/dist/cjs/version.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"version.js","sourceRoot":"","sources":["../../src/version.ts"],"names":[],"mappings":";;;AAAA,sCAAsC;AACzB,QAAA,OAAO,GAAG,QAAQ,CAAC","sourcesContent":["// auto-generated by bin/genVersion.ts\nexport const VERSION = '1.12.
|
|
1
|
+
{"version":3,"file":"version.js","sourceRoot":"","sources":["../../src/version.ts"],"names":[],"mappings":";;;AAAA,sCAAsC;AACzB,QAAA,OAAO,GAAG,QAAQ,CAAC","sourcesContent":["// auto-generated by bin/genVersion.ts\nexport const VERSION = '1.12.3';\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../../src/api/traces/types.ts"],"names":[],"mappings":"","sourcesContent":["import type { ContextAPI as OTELContextAPI, TraceAPI as OTELTraceAPI } from '@opentelemetry/api';\nimport type { IResourceSpans } from '@opentelemetry/otlp-transformer';\n\n// TODO: Revert temporary patching\n// in latest OpenTelemetry packages protobuf type \"instrumentationLibrary\" has been renamed to \"scope\"\n// however on the Grafana Agent we use older OTel collector that doesn't have this change\n// temporarily patching types to the old shape until Grafana Agent catches up to otel-collector >= 0.52\nexport interface TraceEvent {\n resourceSpans?: IResourceSpans[];\n}\n\nexport interface OTELApi {\n trace: OTELTraceAPI;\n context: OTELContextAPI;\n}\n\nexport interface TracesAPI {\n getOTEL: () => OTELApi | undefined;\n getTraceContext: () => TraceContext | undefined;\n initOTEL: (trace: OTELTraceAPI, context: OTELContextAPI) => void;\n isOTELInitialized: () => boolean;\n pushTraces: (traces: TraceEvent) => void;\n}\n\n// trace context for logs, exceptions, measurements\nexport interface TraceContext {\n trace_id: string;\n span_id: string;\n}\n"]}
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../../src/api/traces/types.ts"],"names":[],"mappings":"","sourcesContent":["import type { ContextAPI as OTELContextAPI, TraceAPI as OTELTraceAPI } from '@opentelemetry/api';\nimport type { IResourceSpans } from '@opentelemetry/otlp-transformer/build/src/trace/internal-types';\n\n// TODO: Revert temporary patching\n// in latest OpenTelemetry packages protobuf type \"instrumentationLibrary\" has been renamed to \"scope\"\n// however on the Grafana Agent we use older OTel collector that doesn't have this change\n// temporarily patching types to the old shape until Grafana Agent catches up to otel-collector >= 0.52\nexport interface TraceEvent {\n resourceSpans?: IResourceSpans[];\n}\n\nexport interface OTELApi {\n trace: OTELTraceAPI;\n context: OTELContextAPI;\n}\n\nexport interface TracesAPI {\n getOTEL: () => OTELApi | undefined;\n getTraceContext: () => TraceContext | undefined;\n initOTEL: (trace: OTELTraceAPI, context: OTELContextAPI) => void;\n isOTELInitialized: () => boolean;\n pushTraces: (traces: TraceEvent) => void;\n}\n\n// trace context for logs, exceptions, measurements\nexport interface TraceContext {\n trace_id: string;\n span_id: string;\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"globalObject.js","sourceRoot":"","sources":["../../../src/globalObject/globalObject.ts"],"names":[],"mappings":"AAQA,mGAAmG;AACnG,MAAM,CAAC,MAAM,YAAY,GAAG,CAAC,OAAO,UAAU,KAAK,WAAW;IAC5D,CAAC,CAAC,UAAU;IACZ,CAAC,CAAC,OAAO,MAAM,KAAK,WAAW;
|
|
1
|
+
{"version":3,"file":"globalObject.js","sourceRoot":"","sources":["../../../src/globalObject/globalObject.ts"],"names":[],"mappings":"AAQA,mGAAmG;AACnG,MAAM,CAAC,MAAM,YAAY,GAAG,CAAC,OAAO,UAAU,KAAK,WAAW;IAC5D,CAAC,CAAC,UAAU;IACZ,CAAC,CAAC,OAAO,MAAM,KAAK,WAAW;QAC7B,CAAC,CAAC,MAAM;QACR,CAAC,CAAC,OAAO,IAAI,KAAK,WAAW;YAC3B,CAAC,CAAC,IAAI;YACN,CAAC,CAAC,SAAS,CAA4B,CAAC","sourcesContent":["import type { Faro, internalGlobalObjectKey } from '../sdk';\n\nexport type GlobalObject<T = typeof globalThis | typeof global | typeof self> = T & {\n [label: string]: Faro;\n\n [internalGlobalObjectKey]: Faro;\n};\n\n// This does not uses isUndefined method because it will throw an error in non-browser environments\nexport const globalObject = (typeof globalThis !== 'undefined'\n ? globalThis\n : typeof global !== 'undefined'\n ? global\n : typeof self !== 'undefined'\n ? self\n : undefined) as unknown as GlobalObject;\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../../../src/transports/utils.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,iBAAiB,EAAE,0BAA0B,EAAE,MAAM,SAAS,CAAC;AAGxE,MAAM,UAAU,kBAAkB,CAAC,MAAmB,EAAE,aAAgC;;IACtF,IAAI,aAAa,KAAK,SAAS,EAAE;QAC/B,OAAO,MAAM,CAAC;KACf;IAED,IAAI,MAAM,KAAK,SAAS,EAAE;QACxB,OAAO;YACL,aAAa;SACd,CAAC;KACH;IAED,MAAM,eAAe,GAAG,MAAA,MAAM,CAAC,aAAa,0CAAG,CAAC,CAAC,CAAC;IAClD,IAAI,eAAe,KAAK,SAAS,EAAE;QACjC,OAAO,MAAM,CAAC;KACf;IAED,MAAM,YAAY,GAAG,CAAA,eAAe,aAAf,eAAe,uBAAf,eAAe,CAAE,UAAU,KAAI,EAAE,CAAC;IACvD,MAAM,QAAQ,GAAG,CAAA,MAAA,aAAa,aAAb,aAAa,uBAAb,aAAa,CAAG,CAAC,CAAC,0CAAE,UAAU,KAAI,EAAE,CAAC;IAEtD,uCACK,MAAM,KACT,aAAa,EAAE;4CAER,eAAe,KAClB,UAAU,EAAE,CAAC,GAAG,YAAY,EAAE,GAAG,QAAQ,CAAC;SAE7C,IACD;AACJ,CAAC;AAED,MAAM,UAAU,gBAAgB,CAAC,IAAqB;IACpD,IAAI,IAAI,GAAkB;QACxB,IAAI,EAAE,EAAE;KACT,CAAC;IAEF,IAAI,IAAI,CAAC,CAAC,CAAC,KAAK,SAAS,EAAE;QACzB,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC;KAC1B;IAED,IAAI,CAAC,OAAO,CAAC,CAAC,WAA0B,EAAE,EAAE;QAC1C,QAAQ,WAAW,CAAC,IAAI,EAAE;YACxB,KAAK,iBAAiB,CAAC,GAAG,CAAC;YAC3B,KAAK,iBAAiB,CAAC,KAAK,CAAC;YAC7B,KAAK,iBAAiB,CAAC,SAAS,CAAC;YACjC,KAAK,iBAAiB,CAAC,WAAW;gBAChC,MAAM,EAAE,GAAG,0BAA0B,CAAC,WAAW,CAAC,IAAI,CAAC,CAAC;gBACxD,MAAM,OAAO,GAAG,IAAI,CAAC,EAAE,CAAsE,CAAC;gBAE9F,IAAI,mCACC,IAAI,KACP,CAAC,EAAE,CAAC,EAAE,OAAO,KAAK,SAAS,CAAC,CAAC,CAAC,CAAC,WAAW,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,OAAO,EAAE,WAAW,CAAC,OAAO,CAAC,GACxF,CAAC;gBACF,MAAM;YACR,KAAK,iBAAiB,CAAC,KAAK;gBAC1B,IAAI,mCACC,IAAI,KACP,MAAM,EAAE,kBAAkB,CAAC,IAAI,CAAC,MAAM,EAAG,WAAW,CAAC,OAAsB,CAAC,aAAa,CAAC,GAC3F,CAAC;gBACF,MAAM;SACT;IACH,CAAC,CAAC,CAAC;IAEH,OAAO,IAAI,CAAC;AACd,CAAC","sourcesContent":["import type { IResourceSpans } from '@opentelemetry/otlp-transformer';\n\nimport type { EventEvent, ExceptionEvent, LogEvent, MeasurementEvent, TraceEvent } from '..';\n\nimport { TransportItemType, transportItemTypeToBodyKey } from './const';\nimport type { TransportBody, TransportItem } from './types';\n\nexport function mergeResourceSpans(traces?: TraceEvent, resourceSpans?: IResourceSpans[]): TraceEvent | undefined {\n if (resourceSpans === undefined) {\n return traces;\n }\n\n if (traces === undefined) {\n return {\n resourceSpans,\n };\n }\n\n const currentResource = traces.resourceSpans?.[0];\n if (currentResource === undefined) {\n return traces;\n }\n\n const currentSpans = currentResource?.scopeSpans || [];\n const newSpans = resourceSpans?.[0]?.scopeSpans || [];\n\n return {\n ...traces,\n resourceSpans: [\n {\n ...currentResource,\n scopeSpans: [...currentSpans, ...newSpans],\n },\n ],\n };\n}\n\nexport function getTransportBody(item: TransportItem[]): TransportBody {\n let body: TransportBody = {\n meta: {},\n };\n\n if (item[0] !== undefined) {\n body.meta = item[0].meta;\n }\n\n item.forEach((currentItem: TransportItem) => {\n switch (currentItem.type) {\n case TransportItemType.LOG:\n case TransportItemType.EVENT:\n case TransportItemType.EXCEPTION:\n case TransportItemType.MEASUREMENT:\n const bk = transportItemTypeToBodyKey[currentItem.type];\n const signals = body[bk] as LogEvent[] | EventEvent[] | ExceptionEvent[] | MeasurementEvent[];\n\n body = {\n ...body,\n [bk]: signals === undefined ? [currentItem.payload] : [...signals, currentItem.payload],\n };\n break;\n case TransportItemType.TRACE:\n body = {\n ...body,\n traces: mergeResourceSpans(body.traces, (currentItem.payload as TraceEvent).resourceSpans),\n };\n break;\n }\n });\n\n return body;\n}\n"]}
|
|
1
|
+
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../../../src/transports/utils.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,iBAAiB,EAAE,0BAA0B,EAAE,MAAM,SAAS,CAAC;AAGxE,MAAM,UAAU,kBAAkB,CAAC,MAAmB,EAAE,aAAgC;;IACtF,IAAI,aAAa,KAAK,SAAS,EAAE;QAC/B,OAAO,MAAM,CAAC;KACf;IAED,IAAI,MAAM,KAAK,SAAS,EAAE;QACxB,OAAO;YACL,aAAa;SACd,CAAC;KACH;IAED,MAAM,eAAe,GAAG,MAAA,MAAM,CAAC,aAAa,0CAAG,CAAC,CAAC,CAAC;IAClD,IAAI,eAAe,KAAK,SAAS,EAAE;QACjC,OAAO,MAAM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AM,EAAE,kBAAkB,CAAC,IAAI,CAAC,MAAM,EAAG,WAAW,CAAC,OAAsB,CAAC,aAAa,CAAC,GAC3F,CAAC;gBACF,MAAM;SACT;IACH,CAAC,CAAC,CAAC;IAEH,OAAO,IAAI,CAAC;AACd,CAAC","sourcesContent":["import type { IResourceSpans } from '@opentelemetry/otlp-transformer/build/src/trace/internal-types';\n\nimport type { EventEvent, ExceptionEvent, LogEvent, MeasurementEvent, TraceEvent } from '..';\n\nimport { TransportItemType, transportItemTypeToBodyKey } from './const';\nimport type { TransportBody, TransportItem } from './types';\n\nexport function mergeResourceSpans(traces?: TraceEvent, resourceSpans?: IResourceSpans[]): TraceEvent | undefined {\n if (resourceSpans === undefined) {\n return traces;\n }\n\n if (traces === undefined) {\n return {\n resourceSpans,\n };\n }\n\n const currentResource = traces.resourceSpans?.[0];\n if (currentResource === undefined) {\n return traces;\n }\n\n const currentSpans = currentResource?.scopeSpans || [];\n const newSpans = resourceSpans?.[0]?.scopeSpans || [];\n\n return {\n ...traces,\n resourceSpans: [\n {\n ...currentResource,\n scopeSpans: [...currentSpans, ...newSpans],\n },\n ],\n };\n}\n\nexport function getTransportBody(item: TransportItem[]): TransportBody {\n let body: TransportBody = {\n meta: {},\n };\n\n if (item[0] !== undefined) {\n body.meta = item[0].meta;\n }\n\n item.forEach((currentItem: TransportItem) => {\n switch (currentItem.type) {\n case TransportItemType.LOG:\n case TransportItemType.EVENT:\n case TransportItemType.EXCEPTION:\n case TransportItemType.MEASUREMENT:\n const bk = transportItemTypeToBodyKey[currentItem.type];\n const signals = body[bk] as LogEvent[] | EventEvent[] | ExceptionEvent[] | MeasurementEvent[];\n\n body = {\n ...body,\n [bk]: signals === undefined ? [currentItem.payload] : [...signals, currentItem.payload],\n };\n break;\n case TransportItemType.TRACE:\n body = {\n ...body,\n traces: mergeResourceSpans(body.traces, (currentItem.payload as TraceEvent).resourceSpans),\n };\n break;\n }\n });\n\n return body;\n}\n"]}
|
package/dist/esm/version.js
CHANGED
package/dist/esm/version.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"version.js","sourceRoot":"","sources":["../../src/version.ts"],"names":[],"mappings":"AAAA,sCAAsC;AACtC,MAAM,CAAC,MAAM,OAAO,GAAG,QAAQ,CAAC","sourcesContent":["// auto-generated by bin/genVersion.ts\nexport const VERSION = '1.12.
|
|
1
|
+
{"version":3,"file":"version.js","sourceRoot":"","sources":["../../src/version.ts"],"names":[],"mappings":"AAAA,sCAAsC;AACtC,MAAM,CAAC,MAAM,OAAO,GAAG,QAAQ,CAAC","sourcesContent":["// auto-generated by bin/genVersion.ts\nexport const VERSION = '1.12.3';\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../../../../src/api/traces/types.ts"],"names":[],"mappings":"","sourcesContent":["import type { ContextAPI as OTELContextAPI, TraceAPI as OTELTraceAPI } from '@opentelemetry/api';\nimport type { IResourceSpans } from '@opentelemetry/otlp-transformer';\n\n// TODO: Revert temporary patching\n// in latest OpenTelemetry packages protobuf type \"instrumentationLibrary\" has been renamed to \"scope\"\n// however on the Grafana Agent we use older OTel collector that doesn't have this change\n// temporarily patching types to the old shape until Grafana Agent catches up to otel-collector >= 0.52\nexport interface TraceEvent {\n resourceSpans?: IResourceSpans[];\n}\n\nexport interface OTELApi {\n trace: OTELTraceAPI;\n context: OTELContextAPI;\n}\n\nexport interface TracesAPI {\n getOTEL: () => OTELApi | undefined;\n getTraceContext: () => TraceContext | undefined;\n initOTEL: (trace: OTELTraceAPI, context: OTELContextAPI) => void;\n isOTELInitialized: () => boolean;\n pushTraces: (traces: TraceEvent) => void;\n}\n\n// trace context for logs, exceptions, measurements\nexport interface TraceContext {\n trace_id: string;\n span_id: string;\n}\n"]}
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../../../../src/api/traces/types.ts"],"names":[],"mappings":"","sourcesContent":["import type { ContextAPI as OTELContextAPI, TraceAPI as OTELTraceAPI } from '@opentelemetry/api';\nimport type { IResourceSpans } from '@opentelemetry/otlp-transformer/build/src/trace/internal-types';\n\n// TODO: Revert temporary patching\n// in latest OpenTelemetry packages protobuf type \"instrumentationLibrary\" has been renamed to \"scope\"\n// however on the Grafana Agent we use older OTel collector that doesn't have this change\n// temporarily patching types to the old shape until Grafana Agent catches up to otel-collector >= 0.52\nexport interface TraceEvent {\n resourceSpans?: IResourceSpans[];\n}\n\nexport interface OTELApi {\n trace: OTELTraceAPI;\n context: OTELContextAPI;\n}\n\nexport interface TracesAPI {\n getOTEL: () => OTELApi | undefined;\n getTraceContext: () => TraceContext | undefined;\n initOTEL: (trace: OTELTraceAPI, context: OTELContextAPI) => void;\n isOTELInitialized: () => boolean;\n pushTraces: (traces: TraceEvent) => void;\n}\n\n// trace context for logs, exceptions, measurements\nexport interface TraceContext {\n trace_id: string;\n span_id: string;\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"globalObject.js","sourceRoot":"","sources":["../../../../../src/globalObject/globalObject.ts"],"names":[],"mappings":";;;AAQA,mGAAmG;AACtF,QAAA,YAAY,GAAG,CAAC,OAAO,UAAU,KAAK,WAAW;IAC5D,CAAC,CAAC,UAAU;IACZ,CAAC,CAAC,OAAO,MAAM,KAAK,WAAW;
|
|
1
|
+
{"version":3,"file":"globalObject.js","sourceRoot":"","sources":["../../../../../src/globalObject/globalObject.ts"],"names":[],"mappings":";;;AAQA,mGAAmG;AACtF,QAAA,YAAY,GAAG,CAAC,OAAO,UAAU,KAAK,WAAW;IAC5D,CAAC,CAAC,UAAU;IACZ,CAAC,CAAC,OAAO,MAAM,KAAK,WAAW;QAC7B,CAAC,CAAC,MAAM;QACR,CAAC,CAAC,OAAO,IAAI,KAAK,WAAW;YAC3B,CAAC,CAAC,IAAI;YACN,CAAC,CAAC,SAAS,CAA4B,CAAC","sourcesContent":["import type { Faro, internalGlobalObjectKey } from '../sdk';\n\nexport type GlobalObject<T = typeof globalThis | typeof global | typeof self> = T & {\n [label: string]: Faro;\n\n [internalGlobalObjectKey]: Faro;\n};\n\n// This does not uses isUndefined method because it will throw an error in non-browser environments\nexport const globalObject = (typeof globalThis !== 'undefined'\n ? globalThis\n : typeof global !== 'undefined'\n ? global\n : typeof self !== 'undefined'\n ? self\n : undefined) as unknown as GlobalObject;\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../../../../../src/transports/utils.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AAIA,iCAAwE;AAGxE,SAAgB,kBAAkB,CAAC,MAAmB,EAAE,aAAgC;;IACtF,IAAI,aAAa,KAAK,SAAS,EAAE;QAC/B,OAAO,MAAM,CAAC;KACf;IAED,IAAI,MAAM,KAAK,SAAS,EAAE;QACxB,OAAO;YACL,aAAa,eAAA;SACd,CAAC;KACH;IAED,IAAM,eAAe,GAAG,MAAA,MAAM,CAAC,aAAa,0CAAG,CAAC,CAAC,CAAC;IAClD,IAAI,eAAe,KAAK,SAAS,EAAE;QACjC,OAAO,MAAM,CAAC;KACf;IAED,IAAM,YAAY,GAAG,CAAA,eAAe,aAAf,eAAe,uBAAf,eAAe,CAAE,UAAU,KAAI,EAAE,CAAC;IACvD,IAAM,QAAQ,GAAG,CAAA,MAAA,aAAa,aAAb,aAAa,uBAAb,aAAa,CAAG,CAAC,CAAC,0CAAE,UAAU,KAAI,EAAE,CAAC;IAEtD,6BACK,MAAM,KACT,aAAa,EAAE;kCAER,eAAe,KAClB,UAAU,kCAAM,YAAY,SAAK,QAAQ;SAE5C,IACD;AACJ,CAAC;AA5BD,gDA4BC;AAED,SAAgB,gBAAgB,CAAC,IAAqB;IACpD,IAAI,IAAI,GAAkB;QACxB,IAAI,EAAE,EAAE;KACT,CAAC;IAEF,IAAI,IAAI,CAAC,CAAC,CAAC,KAAK,SAAS,EAAE;QACzB,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC;KAC1B;IAED,IAAI,CAAC,OAAO,CAAC,UAAC,WAA0B;;QACtC,QAAQ,WAAW,CAAC,IAAI,EAAE;YACxB,KAAK,yBAAiB,CAAC,GAAG,CAAC;YAC3B,KAAK,yBAAiB,CAAC,KAAK,CAAC;YAC7B,KAAK,yBAAiB,CAAC,SAAS,CAAC;YACjC,KAAK,yBAAiB,CAAC,WAAW;gBAChC,IAAM,EAAE,GAAG,kCAA0B,CAAC,WAAW,CAAC,IAAI,CAAC,CAAC;gBACxD,IAAM,OAAO,GAAG,IAAI,CAAC,EAAE,CAAsE,CAAC;gBAE9F,IAAI,yBACC,IAAI,gBACN,EAAE,IAAG,OAAO,KAAK,SAAS,CAAC,CAAC,CAAC,CAAC,WAAW,CAAC,OAAO,CAAC,CAAC,CAAC,iCAAK,OAAO,UAAE,WAAW,CAAC,OAAO,SAAC,MACxF,CAAC;gBACF,MAAM;YACR,KAAK,yBAAiB,CAAC,KAAK;gBAC1B,IAAI,yBACC,IAAI,KACP,MAAM,EAAE,kBAAkB,CAAC,IAAI,CAAC,MAAM,EAAG,WAAW,CAAC,OAAsB,CAAC,aAAa,CAAC,GAC3F,CAAC;gBACF,MAAM;SACT;IACH,CAAC,CAAC,CAAC;IAEH,OAAO,IAAI,CAAC;AACd,CAAC;AAjCD,4CAiCC","sourcesContent":["import type { IResourceSpans } from '@opentelemetry/otlp-transformer';\n\nimport type { EventEvent, ExceptionEvent, LogEvent, MeasurementEvent, TraceEvent } from '..';\n\nimport { TransportItemType, transportItemTypeToBodyKey } from './const';\nimport type { TransportBody, TransportItem } from './types';\n\nexport function mergeResourceSpans(traces?: TraceEvent, resourceSpans?: IResourceSpans[]): TraceEvent | undefined {\n if (resourceSpans === undefined) {\n return traces;\n }\n\n if (traces === undefined) {\n return {\n resourceSpans,\n };\n }\n\n const currentResource = traces.resourceSpans?.[0];\n if (currentResource === undefined) {\n return traces;\n }\n\n const currentSpans = currentResource?.scopeSpans || [];\n const newSpans = resourceSpans?.[0]?.scopeSpans || [];\n\n return {\n ...traces,\n resourceSpans: [\n {\n ...currentResource,\n scopeSpans: [...currentSpans, ...newSpans],\n },\n ],\n };\n}\n\nexport function getTransportBody(item: TransportItem[]): TransportBody {\n let body: TransportBody = {\n meta: {},\n };\n\n if (item[0] !== undefined) {\n body.meta = item[0].meta;\n }\n\n item.forEach((currentItem: TransportItem) => {\n switch (currentItem.type) {\n case TransportItemType.LOG:\n case TransportItemType.EVENT:\n case TransportItemType.EXCEPTION:\n case TransportItemType.MEASUREMENT:\n const bk = transportItemTypeToBodyKey[currentItem.type];\n const signals = body[bk] as LogEvent[] | EventEvent[] | ExceptionEvent[] | MeasurementEvent[];\n\n body = {\n ...body,\n [bk]: signals === undefined ? [currentItem.payload] : [...signals, currentItem.payload],\n };\n break;\n case TransportItemType.TRACE:\n body = {\n ...body,\n traces: mergeResourceSpans(body.traces, (currentItem.payload as TraceEvent).resourceSpans),\n };\n break;\n }\n });\n\n return body;\n}\n"]}
|
|
1
|
+
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../../../../../src/transports/utils.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AAIA,iCAAwE;AAGxE,SAAgB,kBAAkB,CAAC,MAAmB,EAAE,aAAgC;;IACtF,IAAI,aAAa,KAAK,SAAS,EAAE;QAC/B,OAAO,MAAM,CAAC;KACf;IAED,IAAI,MAAM,KAAK,SAAS,EAAE;QACxB,OAAO;YACL,aAAa,eAAA;SACd,CAAC;KACH;IAED,IAAM,eAAe,GAAG,MAAA,MAAM,CAAC,aAAa,0CAAG,CAAC,CAAC,CAAC;IAClD,IAAI,eAAe,KAAK,SAAS,EAAE;QACjC,OAAO,MAAM,CAAC;KACf;IAED,IAAM,YAAY,GAAG,CAAA,eAAe,aAAf,eAAe,uBAAf,eAAe,CAAE,UAAU,KAAI,EAAE,CAAC;IACvD,IAAM,QAAQ,GAAG,CAAA,MAAA,aAAa,aAAb,aAAa,uBAAb,aAAa,C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elemetry/otlp-transformer/build/src/trace/internal-types';\n\nimport type { EventEvent, ExceptionEvent, LogEvent, MeasurementEvent, TraceEvent } from '..';\n\nimport { TransportItemType, transportItemTypeToBodyKey } from './const';\nimport type { TransportBody, TransportItem } from './types';\n\nexport function mergeResourceSpans(traces?: TraceEvent, resourceSpans?: IResourceSpans[]): TraceEvent | undefined {\n if (resourceSpans === undefined) {\n return traces;\n }\n\n if (traces === undefined) {\n return {\n resourceSpans,\n };\n }\n\n const currentResource = traces.resourceSpans?.[0];\n if (currentResource === undefined) {\n return traces;\n }\n\n const currentSpans = currentResource?.scopeSpans || [];\n const newSpans = resourceSpans?.[0]?.scopeSpans || [];\n\n return {\n ...traces,\n resourceSpans: [\n {\n ...currentResource,\n scopeSpans: [...currentSpans, ...newSpans],\n },\n ],\n };\n}\n\nexport function getTransportBody(item: TransportItem[]): TransportBody {\n let body: TransportBody = {\n meta: {},\n };\n\n if (item[0] !== undefined) {\n body.meta = item[0].meta;\n }\n\n item.forEach((currentItem: TransportItem) => {\n switch (currentItem.type) {\n case TransportItemType.LOG:\n case TransportItemType.EVENT:\n case TransportItemType.EXCEPTION:\n case TransportItemType.MEASUREMENT:\n const bk = transportItemTypeToBodyKey[currentItem.type];\n const signals = body[bk] as LogEvent[] | EventEvent[] | ExceptionEvent[] | MeasurementEvent[];\n\n body = {\n ...body,\n [bk]: signals === undefined ? [currentItem.payload] : [...signals, currentItem.payload],\n };\n break;\n case TransportItemType.TRACE:\n body = {\n ...body,\n traces: mergeResourceSpans(body.traces, (currentItem.payload as TraceEvent).resourceSpans),\n };\n break;\n }\n });\n\n return body;\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.test.js","sourceRoot":"","sources":["../../../../../src/transports/utils.test.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAEA,wBASY;AACZ,kCAAyD;AAEzD,iCAA6C;AAE7C,QAAQ,CAAC,OAAO,EAAE;IAChB,QAAQ,CAAC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AAe;wBACrB,IAAI,EAAE,CAAC;wBACP,iBAAiB,EAAE,mBAAmB;wBACtC,eAAe,EAAE,mBAAmB;wBACpC,UAAU,EAAE;4BACV;gCACE,GAAG,EAAE,YAAY;gCACjB,KAAK,EAAE;oCACL,WAAW,EAAE,YAAY;iCAC1B;6BACF;4BACD;gCACE,GAAG,EAAE,WAAW;gCAChB,KAAK,EAAE;oCACL,WAAW,EAAE,eAAe;iCAC7B;6BACF;4BACD;gCACE,GAAG,EAAE,UAAU;gCACf,KAAK,EAAE;oCACL,WAAW,EACT,oIAAoI;iCACvI;6BACF;4BACD;gCACE,GAAG,EAAE,8BAA8B;gCACnC,KAAK,EAAE;oCACL,QAAQ,EAAE,GAAG;iCACd;6BACF;yBACF;wBACD,sBAAsB,EAAE,CAAC;wBACzB,MAAM,EAAE;4BACN;gCACE,UAAU,EAAE,EAAE;gCACd,IAAI,MAAA;gCACJ,YAAY,EAAE,mBAAmB;gCACjC,sBAAsB,EAAE,CAAC;6BAC1B;yBACF;wBACD,kBAAkB,EAAE,CAAC;wBACrB,MAAM,EAAE;4BACN,IAAI,EAAE,CAAC;yBACR;wBACD,KAAK,EAAE,EAAE;wBACT,iBAAiB,EAAE,CAAC;qBACrB;iBACF;aACF;SACF;KACF,CAAC;AACJ,CAAC;AAED,SAAS,kBAAkB,CAAC,IAAY,EAAE,IAAe;IAAf,qBAAA,EAAA,SAAe;IACvD,OAAO;QACL,IAAI,EAAE,qBAAiB,CAAC,KAAK;QAC7B,OAAO,EAAE;YACP,aAAa,EAAE,CAAC,oBAAoB,CAAC,IAAI,CAAC,CAAC;SAC5C;QACD,IAAI,MAAA;KACL,CAAC;AACJ,CAAC","sourcesContent":["import type { IResourceSpans } from '@opentelemetry/otlp-transformer';\n\nimport {\n EventEvent,\n ExceptionEvent,\n getTransportBody,\n LogEvent,\n Meta,\n TraceEvent,\n TransportItem,\n TransportItemType,\n} from '..';\nimport { getCurrentTimestamp, LogLevel } from '../utils';\n\nimport { mergeResourceSpans } from './utils';\n\ndescribe('utils', () => {\n describe('mergeResourceSpans', () => {\n it('tests merging with empty traces or resourceSpans', () => {\n expect(mergeResourceSpans()).toEqual(undefined);\n });\n\n it('tests merging with empty traces and some resourceSpans', () => {\n const rs = [generateResourceSpan('thisspan')];\n expect(mergeResourceSpans(undefined, rs)).toEqual({ resourceSpans: rs });\n });\n\n it('tests merging with traces that do not have a resource and resourceSpans', () => {\n let traces = generateTraceEvent('trace');\n traces.payload.resourceSpans = [];\n const rs = [generateResourceSpan('thisspan')];\n expect(mergeResourceSpans(traces.payload, rs)).toEqual({ resourceSpans: [] });\n });\n\n it('tests merging with traces and resourceSpans', () => {\n let traces = generateTraceEvent('trace');\n const rs = [generateResourceSpan('thisspan')];\n expect(mergeResourceSpans(traces.payload, rs)).toEqual({\n ...traces.payload,\n resourceSpans: [\n {\n ...(traces.payload.resourceSpans?.[0] || []),\n scopeSpans: [...(traces.payload.resourceSpans?.[0]?.scopeSpans || []), ...(rs[0]?.scopeSpans || [])],\n },\n ],\n });\n });\n });\n\n describe('getTransportBody', () => {\n it('test creating a body with a single item', () => {\n const log = generateLog('This is a log');\n const body = getTransportBody([log]);\n expect(body).toEqual({\n logs: [log.payload],\n meta: {},\n });\n });\n\n it('test creating a body with a two items of the same type', () => {\n const log1 = generateLog('This is a log');\n const log2 = generateLog('This is also a log');\n const body = getTransportBody([log1, log2]);\n expect(body).toEqual({\n logs: [log1.payload, log2.payload],\n meta: {},\n });\n });\n\n it('test creating a body with a items different type (no trace)', () => {\n const log = generateLog('This is a log');\n const event = generateEvent('session_start');\n const exception = generateException('TypeError');\n\n const body = getTransportBody([log, event, exception]);\n expect(body).toEqual({\n logs: [log.payload],\n events: [event.payload],\n exceptions: [exception.payload],\n meta: {},\n });\n });\n\n it('test creating a body with a items different type (with traces)', () => {\n const log1 = generateLog('This is a log');\n const log2 = generateLog('This is also a log');\n const trace1 = generateTraceEvent('session_start');\n const trace2 = generateTraceEvent('session_end');\n\n const body = getTransportBody([log1, log2, trace1, trace2]);\n expect(body).toEqual({\n logs: [log1.payload, log2.payload],\n traces: {\n resourceSpans: [\n {\n resource: trace1.payload.resourceSpans?.[0]?.resource,\n scopeSpans: [\n ...(trace1.payload.resourceSpans?.[0]?.scopeSpans || []),\n ...(trace2.payload.resourceSpans?.[0]?.scopeSpans || []),\n ],\n },\n ],\n },\n meta: {},\n });\n });\n });\n});\n\nfunction generateLog(message: string, meta: Meta = {}): TransportItem<LogEvent> {\n return {\n type: TransportItemType.LOG,\n payload: {\n context: {},\n level: LogLevel.LOG,\n message,\n timestamp: getCurrentTimestamp(),\n },\n meta,\n };\n}\n\nfunction generateException(value: string, meta: Meta = {}): TransportItem<ExceptionEvent> {\n return {\n type: TransportItemType.EXCEPTION,\n payload: {\n value,\n type: 'exception',\n timestamp: getCurrentTimestamp(),\n },\n meta,\n };\n}\n\nfunction generateEvent(name: string, meta: Meta = {}): TransportItem<EventEvent> {\n return {\n type: TransportItemType.EVENT,\n payload: {\n name,\n timestamp: getCurrentTimestamp(),\n },\n meta,\n };\n}\n\nfunction generateResourceSpan(name: string): IResourceSpans {\n return {\n resource: {\n attributes: [],\n droppedAttributesCount: 0,\n },\n scopeSpans: [\n {\n scope: {\n name: '@opentelemetry/instrumentation-document-load',\n version: '0.31.0',\n },\n spans: [\n {\n traceId: 'd6bba34860089d3a4ee58df0811b2f5f',\n spanId: '22c85dd7b7c674e8',\n parentSpanId: '16cff06b28240ca6',\n name: 'resourceFetch',\n kind: 1,\n startTimeUnixNano: 1679329154423000000,\n endTimeUnixNano: 1679329154449000000,\n attributes: [\n {\n key: 'session_id',\n value: {\n stringValue: 'KBw5UzUuvF',\n },\n },\n {\n key: 'component',\n value: {\n stringValue: 'document-load',\n },\n },\n {\n key: 'http.url',\n value: {\n stringValue:\n 'http://localhost:5173/@fs/Users/marcoschaefer/Code/faro-web-sdk/packages/web-sdk/dist/esm/transports/otlp/index.js?t=1679329135042',\n },\n },\n {\n key: 'http.response_content_length',\n value: {\n intValue: 671,\n },\n },\n ],\n droppedAttributesCount: 0,\n events: [\n {\n attributes: [],\n name,\n timeUnixNano: 1679329154423000000,\n droppedAttributesCount: 0,\n },\n ],\n droppedEventsCount: 0,\n status: {\n code: 0,\n },\n links: [],\n droppedLinksCount: 0,\n },\n ],\n },\n ],\n };\n}\n\nfunction generateTraceEvent(name: string, meta: Meta = {}): TransportItem<TraceEvent> {\n return {\n type: TransportItemType.TRACE,\n payload: {\n resourceSpans: [generateResourceSpan(name)],\n },\n meta,\n };\n}\n"]}
|
|
1
|
+
{"version":3,"file":"utils.test.js","sourceRoot":"","sources":["../../../../../src/transports/utils.test.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAEA,wBASY;AACZ,kCAAyD;AAEzD,iCAA6C;AAE7C,QAAQ,CAAC,OAAO,EAAE;IAChB,QAAQ,CAAC,oBAAoB,EAAE;QAC7B,EAAE,CAAC,kDAAkD,EAAE;YACrD,MAAM,CAAC,IAAA,0BAAkB,GAAE,CAAC,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC;QAClD,CAAC,CAAC,CAAC;QAEH,EAAE,CAAC,wDAAwD,EAAE;YAC3D,IAAM,EAAE,GAAG,CAAC,oBAAoB,CAAC,UAAU,CAAC,CAAC,CAAC;YAC9C,MAAM,CAAC,IAAA,0BAAkB,EAAC,SAAS,EAAE,EAAE,CAAC,CAAC,CAAC,OAAO,CAAC,EAAE,aAAa,EAAE,EAAE,EAAE,CAAC,CAAC;QAC3E,CAAC,CAAC,CAAC;QAEH,EAAE,CAAC,yEAAyE,EAAE;YAC5E,IAAI,MAAM,GAAG,kBAAkB,CAAC,OAAO,CAAC,CAAC;YACzC,MAAM,CAAC,OAAO,CAAC,aAAa,GAAG,EAAE,CAAC;YAClC,IAAM,EAAE,GAAG,CAAC,oBAAoB,CAAC,UAAU,CAAC,CAAC,CAAC;YAC9C,MAAM,CAAC,IAAA,0BAAkB,EAAC,MAAM,CAAC,OAAO,EAAE,EAAE,CAAC,CAAC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ACD,KAAK,EAAE,EAAE;wBACT,iBAAiB,EAAE,CAAC;qBACrB;iBACF;aACF;SACF;KACF,CAAC;AACJ,CAAC;AAED,SAAS,kBAAkB,CAAC,IAAY,EAAE,IAAe;IAAf,qBAAA,EAAA,SAAe;IACvD,OAAO;QACL,IAAI,EAAE,qBAAiB,CAAC,KAAK;QAC7B,OAAO,EAAE;YACP,aAAa,EAAE,CAAC,oBAAoB,CAAC,IAAI,CAAC,CAAC;SAC5C;QACD,IAAI,MAAA;KACL,CAAC;AACJ,CAAC","sourcesContent":["import type { IResourceSpans } from '@opentelemetry/otlp-transformer/build/src/trace/internal-types';\n\nimport {\n EventEvent,\n ExceptionEvent,\n getTransportBody,\n LogEvent,\n Meta,\n TraceEvent,\n TransportItem,\n TransportItemType,\n} from '..';\nimport { getCurrentTimestamp, LogLevel } from '../utils';\n\nimport { mergeResourceSpans } from './utils';\n\ndescribe('utils', () => {\n describe('mergeResourceSpans', () => {\n it('tests merging with empty traces or resourceSpans', () => {\n expect(mergeResourceSpans()).toEqual(undefined);\n });\n\n it('tests merging with empty traces and some resourceSpans', () => {\n const rs = [generateResourceSpan('thisspan')];\n expect(mergeResourceSpans(undefined, rs)).toEqual({ resourceSpans: rs });\n });\n\n it('tests merging with traces that do not have a resource and resourceSpans', () => {\n let traces = generateTraceEvent('trace');\n traces.payload.resourceSpans = [];\n const rs = [generateResourceSpan('thisspan')];\n expect(mergeResourceSpans(traces.payload, rs)).toEqual({ resourceSpans: [] });\n });\n\n it('tests merging with traces and resourceSpans', () => {\n let traces = generateTraceEvent('trace');\n const rs = [generateResourceSpan('thisspan')];\n expect(mergeResourceSpans(traces.payload, rs)).toEqual({\n ...traces.payload,\n resourceSpans: [\n {\n ...(traces.payload.resourceSpans?.[0] || []),\n scopeSpans: [...(traces.payload.resourceSpans?.[0]?.scopeSpans || []), ...(rs[0]?.scopeSpans || [])],\n },\n ],\n });\n });\n });\n\n describe('getTransportBody', () => {\n it('test creating a body with a single item', () => {\n const log = generateLog('This is a log');\n const body = getTransportBody([log]);\n expect(body).toEqual({\n logs: [log.payload],\n meta: {},\n });\n });\n\n it('test creating a body with a two items of the same type', () => {\n const log1 = generateLog('This is a log');\n const log2 = generateLog('This is also a log');\n const body = getTransportBody([log1, log2]);\n expect(body).toEqual({\n logs: [log1.payload, log2.payload],\n meta: {},\n });\n });\n\n it('test creating a body with a items different type (no trace)', () => {\n const log = generateLog('This is a log');\n const event = generateEvent('session_start');\n const exception = generateException('TypeError');\n\n const body = getTransportBody([log, event, exception]);\n expect(body).toEqual({\n logs: [log.payload],\n events: [event.payload],\n exceptions: [exception.payload],\n meta: {},\n });\n });\n\n it('test creating a body with a items different type (with traces)', () => {\n const log1 = generateLog('This is a log');\n const log2 = generateLog('This is also a log');\n const trace1 = generateTraceEvent('session_start');\n const trace2 = generateTraceEvent('session_end');\n\n const body = getTransportBody([log1, log2, trace1, trace2]);\n expect(body).toEqual({\n logs: [log1.payload, log2.payload],\n traces: {\n resourceSpans: [\n {\n resource: trace1.payload.resourceSpans?.[0]?.resource,\n scopeSpans: [\n ...(trace1.payload.resourceSpans?.[0]?.scopeSpans || []),\n ...(trace2.payload.resourceSpans?.[0]?.scopeSpans || []),\n ],\n },\n ],\n },\n meta: {},\n });\n });\n });\n});\n\nfunction generateLog(message: string, meta: Meta = {}): TransportItem<LogEvent> {\n return {\n type: TransportItemType.LOG,\n payload: {\n context: {},\n level: LogLevel.LOG,\n message,\n timestamp: getCurrentTimestamp(),\n },\n meta,\n };\n}\n\nfunction generateException(value: string, meta: Meta = {}): TransportItem<ExceptionEvent> {\n return {\n type: TransportItemType.EXCEPTION,\n payload: {\n value,\n type: 'exception',\n timestamp: getCurrentTimestamp(),\n },\n meta,\n };\n}\n\nfunction generateEvent(name: string, meta: Meta = {}): TransportItem<EventEvent> {\n return {\n type: TransportItemType.EVENT,\n payload: {\n name,\n timestamp: getCurrentTimestamp(),\n },\n meta,\n };\n}\n\nfunction generateResourceSpan(name: string): IResourceSpans {\n return {\n resource: {\n attributes: [],\n droppedAttributesCount: 0,\n },\n scopeSpans: [\n {\n scope: {\n name: '@opentelemetry/instrumentation-document-load',\n version: '0.31.0',\n },\n spans: [\n {\n traceId: 'd6bba34860089d3a4ee58df0811b2f5f',\n spanId: '22c85dd7b7c674e8',\n parentSpanId: '16cff06b28240ca6',\n name: 'resourceFetch',\n kind: 1,\n startTimeUnixNano: 1679329154423000000,\n endTimeUnixNano: 1679329154449000000,\n attributes: [\n {\n key: 'session_id',\n value: {\n stringValue: 'KBw5UzUuvF',\n },\n },\n {\n key: 'component',\n value: {\n stringValue: 'document-load',\n },\n },\n {\n key: 'http.url',\n value: {\n stringValue:\n 'http://localhost:5173/@fs/Users/marcoschaefer/Code/faro-web-sdk/packages/web-sdk/dist/esm/transports/otlp/index.js?t=1679329135042',\n },\n },\n {\n key: 'http.response_content_length',\n value: {\n intValue: 671,\n },\n },\n ],\n droppedAttributesCount: 0,\n events: [\n {\n attributes: [],\n name,\n timeUnixNano: 1679329154423000000,\n droppedAttributesCount: 0,\n },\n ],\n droppedEventsCount: 0,\n status: {\n code: 0,\n },\n links: [],\n droppedLinksCount: 0,\n },\n ],\n },\n ],\n };\n}\n\nfunction generateTraceEvent(name: string, meta: Meta = {}): TransportItem<TraceEvent> {\n return {\n type: TransportItemType.TRACE,\n payload: {\n resourceSpans: [generateResourceSpan(name)],\n },\n meta,\n };\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"version.js","sourceRoot":"","sources":["../../../../src/version.ts"],"names":[],"mappings":";;;AAAA,sCAAsC;AACzB,QAAA,OAAO,GAAG,QAAQ,CAAC","sourcesContent":["// auto-generated by bin/genVersion.ts\nexport const VERSION = '1.12.
|
|
1
|
+
{"version":3,"file":"version.js","sourceRoot":"","sources":["../../../../src/version.ts"],"names":[],"mappings":";;;AAAA,sCAAsC;AACzB,QAAA,OAAO,GAAG,QAAQ,CAAC","sourcesContent":["// auto-generated by bin/genVersion.ts\nexport const VERSION = '1.12.3';\n"]}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { ContextAPI as OTELContextAPI, TraceAPI as OTELTraceAPI } from '@opentelemetry/api';
|
|
2
|
-
import type { IResourceSpans } from '@opentelemetry/otlp-transformer';
|
|
2
|
+
import type { IResourceSpans } from '@opentelemetry/otlp-transformer/build/src/trace/internal-types';
|
|
3
3
|
export interface TraceEvent {
|
|
4
4
|
resourceSpans?: IResourceSpans[];
|
|
5
5
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { ContextAPI as OTELContextAPI, TraceAPI as OTELTraceAPI } from '@opentelemetry/api';
|
|
2
|
-
import type { IResourceSpans } from '@opentelemetry/otlp-transformer';
|
|
2
|
+
import type { IResourceSpans } from '@opentelemetry/otlp-transformer/build/src/trace/internal-types';
|
|
3
3
|
export interface TraceEvent {
|
|
4
4
|
resourceSpans?: IResourceSpans[];
|
|
5
5
|
}
|
|
@@ -4,7 +4,7 @@ import type { Transport, TransportItem } from '../transports';
|
|
|
4
4
|
export declare class MockTransport extends BaseTransport implements Transport {
|
|
5
5
|
private ignoreURLs;
|
|
6
6
|
readonly name = "@grafana/transport-mock";
|
|
7
|
-
readonly version = "1.12.
|
|
7
|
+
readonly version = "1.12.3";
|
|
8
8
|
items: TransportItem[];
|
|
9
9
|
constructor(ignoreURLs?: Patterns);
|
|
10
10
|
send(items: TransportItem[]): void | Promise<void>;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { IResourceSpans } from '@opentelemetry/otlp-transformer';
|
|
1
|
+
import type { IResourceSpans } from '@opentelemetry/otlp-transformer/build/src/trace/internal-types';
|
|
2
2
|
import type { TraceEvent } from '..';
|
|
3
3
|
import type { TransportBody, TransportItem } from './types';
|
|
4
4
|
export declare function mergeResourceSpans(traces?: TraceEvent, resourceSpans?: IResourceSpans[]): TraceEvent | undefined;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const VERSION = "1.12.
|
|
1
|
+
export declare const VERSION = "1.12.3";
|
|
@@ -4,7 +4,7 @@ import type { Transport, TransportItem } from '../transports';
|
|
|
4
4
|
export declare class MockTransport extends BaseTransport implements Transport {
|
|
5
5
|
private ignoreURLs;
|
|
6
6
|
readonly name = "@grafana/transport-mock";
|
|
7
|
-
readonly version = "1.12.
|
|
7
|
+
readonly version = "1.12.3";
|
|
8
8
|
items: TransportItem[];
|
|
9
9
|
constructor(ignoreURLs?: Patterns);
|
|
10
10
|
send(items: TransportItem[]): void | Promise<void>;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { IResourceSpans } from '@opentelemetry/otlp-transformer';
|
|
1
|
+
import type { IResourceSpans } from '@opentelemetry/otlp-transformer/build/src/trace/internal-types';
|
|
2
2
|
import type { TraceEvent } from '..';
|
|
3
3
|
import type { TransportBody, TransportItem } from './types';
|
|
4
4
|
export declare function mergeResourceSpans(traces?: TraceEvent, resourceSpans?: IResourceSpans[]): TraceEvent | undefined;
|
package/dist/types/version.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const VERSION = "1.12.
|
|
1
|
+
export declare const VERSION = "1.12.3";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@grafana/faro-core",
|
|
3
|
-
"version": "1.12.
|
|
3
|
+
"version": "1.12.3",
|
|
4
4
|
"description": "Core package of Faro.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"observability",
|
|
@@ -52,10 +52,13 @@
|
|
|
52
52
|
},
|
|
53
53
|
"dependencies": {
|
|
54
54
|
"@opentelemetry/api": "^1.9.0",
|
|
55
|
-
"@opentelemetry/otlp-transformer": "^0.
|
|
55
|
+
"@opentelemetry/otlp-transformer": "^0.57.1"
|
|
56
|
+
},
|
|
57
|
+
"devDependencies": {
|
|
58
|
+
"@types/node": "^22.10.2"
|
|
56
59
|
},
|
|
57
60
|
"publishConfig": {
|
|
58
61
|
"access": "public"
|
|
59
62
|
},
|
|
60
|
-
"gitHead": "
|
|
63
|
+
"gitHead": "a0caa5a8c08398394e3a140465d6f9007754be2e"
|
|
61
64
|
}
|