@vercel/otel 1.11.0 → 1.12.0
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/edge/index.js +1 -1
- package/dist/edge/index.js.map +2 -2
- package/dist/node/index.js +1 -1
- package/dist/node/index.js.map +2 -2
- package/package.json +1 -1
package/dist/edge/index.js
CHANGED
|
@@ -13,5 +13,5 @@ var Ou=Object.create;var Dr=Object.defineProperty;var Ru=Object.getOwnPropertyDe
|
|
|
13
13
|
To resolve the conflict:`,bn(a,e))),i=c):l.diag.warn("A view or instrument with the name ",e.name,` has already been registered and is incompatible with another registered view.
|
|
14
14
|
`,`Details:
|
|
15
15
|
`,Rn(a,e),`To resolve the conflict:
|
|
16
|
-
`,bn(a,e))}}catch(f){n={error:f}}finally{try{u&&!u.done&&(o=s.return)&&o.call(s)}finally{if(n)throw n.error}}return i},t}();var Aa=function(){function t(e){this._backingStorages=e}return t.prototype.record=function(e,r,n,o){this._backingStorages.forEach(function(i){i.record(e,r,n,o)})},t}();E();E();var Oa=function(){function t(e,r){this._instrumentName=e,this._valueType=r,this._buffer=new Z}return t.prototype.observe=function(e,r){if(r===void 0&&(r={}),typeof e!="number"){l.diag.warn("non-number value provided to metric "+this._instrumentName+": "+e);return}this._valueType===l.ValueType.INT&&!Number.isInteger(e)&&(l.diag.warn("INT value type cannot accept a floating-point value for "+this._instrumentName+", ignoring the fractional digits."),e=Math.trunc(e),!Number.isInteger(e))||this._buffer.set(r,e)},t}();var Ra=function(){function t(){this._buffer=new Map}return t.prototype.observe=function(e,r,n){if(n===void 0&&(n={}),!!ft(e)){var o=this._buffer.get(e);if(o==null&&(o=new Z,this._buffer.set(e,o)),typeof r!="number"){l.diag.warn("non-number value provided to metric "+e._descriptor.name+": "+r);return}e._descriptor.valueType===l.ValueType.INT&&!Number.isInteger(r)&&(l.diag.warn("INT value type cannot accept a floating-point value for "+e._descriptor.name+", ignoring the fractional digits."),r=Math.trunc(r),!Number.isInteger(r))||o.set(n,r)}},t}();var Pn=function(t,e,r,n){function o(i){return i instanceof r?i:new r(function(s){s(i)})}return new(r||(r=Promise))(function(i,s){function u(f){try{a(n.next(f))}catch(p){s(p)}}function c(f){try{a(n.throw(f))}catch(p){s(p)}}function a(f){f.done?i(f.value):o(f.value).then(u,c)}a((n=n.apply(t,e||[])).next())})},In=function(t,e){var r={label:0,sent:function(){if(i[0]&1)throw i[1];return i[1]},trys:[],ops:[]},n,o,i,s;return s={next:u(0),throw:u(1),return:u(2)},typeof Symbol=="function"&&(s[Symbol.iterator]=function(){return this}),s;function u(a){return function(f){return c([a,f])}}function c(a){if(n)throw new TypeError("Generator is already executing.");for(;r;)try{if(n=1,o&&(i=a[0]&2?o.return:a[0]?o.throw||((i=o.return)&&i.call(o),0):o.next)&&!(i=i.call(o,a[1])).done)return i;switch(o=0,i&&(a=[a[0]&2,i.value]),a[0]){case 0:case 1:i=a;break;case 4:return r.label++,{value:a[1],done:!1};case 5:r.label++,o=a[1],a=[0];continue;case 7:a=r.ops.pop(),r.trys.pop();continue;default:if(i=r.trys,!(i=i.length>0&&i[i.length-1])&&(a[0]===6||a[0]===2)){r=0;continue}if(a[0]===3&&(!i||a[1]>i[0]&&a[1]<i[3])){r.label=a[1];break}if(a[0]===6&&r.label<i[1]){r.label=i[1],i=a;break}if(i&&r.label<i[2]){r.label=i[2],r.ops.push(a);break}i[2]&&r.ops.pop(),r.trys.pop();continue}a=e.call(t,r)}catch(f){a=[6,f],o=0}finally{n=i=0}if(a[0]&5)throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}},ba=function(t,e){var r=typeof Symbol=="function"&&t[Symbol.iterator];if(!r)return t;var n=r.call(t),o,i=[],s;try{for(;(e===void 0||e-- >0)&&!(o=n.next()).done;)i.push(o.value)}catch(u){s={error:u}}finally{try{o&&!o.done&&(r=n.return)&&r.call(n)}finally{if(s)throw s.error}}return i},La=function(t,e,r){if(r||arguments.length===2)for(var n=0,o=e.length,i;n<o;n++)(i||!(n in e))&&(i||(i=Array.prototype.slice.call(e,0,n)),i[n]=e[n]);return t.concat(i||Array.prototype.slice.call(e))},Pa=function(){function t(){this._callbacks=[],this._batchCallbacks=[]}return t.prototype.addCallback=function(e,r){var n=this._findCallback(e,r);n>=0||this._callbacks.push({callback:e,instrument:r})},t.prototype.removeCallback=function(e,r){var n=this._findCallback(e,r);n<0||this._callbacks.splice(n,1)},t.prototype.addBatchCallback=function(e,r){var n=new Set(r.filter(ft));if(n.size===0){l.diag.error("BatchObservableCallback is not associated with valid instruments",r);return}var o=this._findBatchCallback(e,n);o>=0||this._batchCallbacks.push({callback:e,instruments:n})},t.prototype.removeBatchCallback=function(e,r){var n=new Set(r.filter(ft)),o=this._findBatchCallback(e,n);o<0||this._batchCallbacks.splice(o,1)},t.prototype.observe=function(e,r){return Pn(this,void 0,void 0,function(){var n,o,i,s;return In(this,function(u){switch(u.label){case 0:return n=this._observeCallbacks(e,r),o=this._observeBatchCallbacks(e,r),[4,ia(La(La([],ba(n),!1),ba(o),!1))];case 1:return i=u.sent(),s=i.filter(oa).map(function(c){return c.reason}),[2,s]}})})},t.prototype._observeCallbacks=function(e,r){var n=this;return this._callbacks.map(function(o){var i=o.callback,s=o.instrument;return Pn(n,void 0,void 0,function(){var u,c;return In(this,function(a){switch(a.label){case 0:return u=new Oa(s._descriptor.name,s._descriptor.valueType),c=Promise.resolve(i(u)),r!=null&&(c=vn(c,r)),[4,c];case 1:return a.sent(),s._metricStorages.forEach(function(f){f.record(u._buffer,e)}),[2]}})})})},t.prototype._observeBatchCallbacks=function(e,r){var n=this;return this._batchCallbacks.map(function(o){var i=o.callback,s=o.instruments;return Pn(n,void 0,void 0,function(){var u,c;return In(this,function(a){switch(a.label){case 0:return u=new Ra,c=Promise.resolve(i(u)),r!=null&&(c=vn(c,r)),[4,c];case 1:return a.sent(),s.forEach(function(f){var p=u._buffer.get(f);p!=null&&f._metricStorages.forEach(function(_){_.record(p,e)})}),[2]}})})})},t.prototype._findCallback=function(e,r){return this._callbacks.findIndex(function(n){return n.callback===e&&n.instrument===r})},t.prototype._findBatchCallback=function(e,r){return this._batchCallbacks.findIndex(function(n){return n.callback===e&&aa(n.instruments,r)})},t}();var cf=function(){var t=function(e,r){return t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(n,o){n.__proto__=o}||function(n,o){for(var i in o)Object.prototype.hasOwnProperty.call(o,i)&&(n[i]=o[i])},t(e,r)};return function(e,r){if(typeof r!="function"&&r!==null)throw new TypeError("Class extends value "+String(r)+" is not a constructor or null");t(e,r);function n(){this.constructor=e}e.prototype=r===null?Object.create(r):(n.prototype=r.prototype,new n)}}(),Ia=function(t){cf(e,t);function e(r,n,o,i){var s=t.call(this,r)||this;return s._attributesProcessor=o,s._deltaMetricStorage=new fr(n),s._temporalMetricStorage=new pr(n,i),s}return e.prototype.record=function(r,n,o,i){n=this._attributesProcessor.process(n,o),this._deltaMetricStorage.record(r,n,o,i)},e.prototype.collect=function(r,n){var o=this._deltaMetricStorage.collect();return this._temporalMetricStorage.buildMetrics(r,this._instrumentDescriptor,o,n)},e}(lr);var Ca=function(){var t=function(e,r){return t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(n,o){n.__proto__=o}||function(n,o){for(var i in o)Object.prototype.hasOwnProperty.call(o,i)&&(n[i]=o[i])},t(e,r)};return function(e,r){if(typeof r!="function"&&r!==null)throw new TypeError("Class extends value "+String(r)+" is not a constructor or null");t(e,r);function n(){this.constructor=e}e.prototype=r===null?Object.create(r):(n.prototype=r.prototype,new n)}}(),dr=function(){function t(){}return t.Noop=function(){return ff},t}();var lf=function(t){Ca(e,t);function e(){return t!==null&&t.apply(this,arguments)||this}return e.prototype.process=function(r,n){return r},e}(dr);var Jh=function(t){Ca(e,t);function e(r){var n=t.call(this)||this;return n._allowedAttributeNames=r,n}return e.prototype.process=function(r,n){var o=this,i={};return Object.keys(r).filter(function(s){return o._allowedAttributeNames.includes(s)}).forEach(function(s){return i[s]=r[s]}),i},e}(dr);var ff=new lf;var pf=function(t,e,r,n){function o(i){return i instanceof r?i:new r(function(s){s(i)})}return new(r||(r=Promise))(function(i,s){function u(f){try{a(n.next(f))}catch(p){s(p)}}function c(f){try{a(n.throw(f))}catch(p){s(p)}}function a(f){f.done?i(f.value):o(f.value).then(u,c)}a((n=n.apply(t,e||[])).next())})},df=function(t,e){var r={label:0,sent:function(){if(i[0]&1)throw i[1];return i[1]},trys:[],ops:[]},n,o,i,s;return s={next:u(0),throw:u(1),return:u(2)},typeof Symbol=="function"&&(s[Symbol.iterator]=function(){return this}),s;function u(a){return function(f){return c([a,f])}}function c(a){if(n)throw new TypeError("Generator is already executing.");for(;r;)try{if(n=1,o&&(i=a[0]&2?o.return:a[0]?o.throw||((i=o.return)&&i.call(o),0):o.next)&&!(i=i.call(o,a[1])).done)return i;switch(o=0,i&&(a=[a[0]&2,i.value]),a[0]){case 0:case 1:i=a;break;case 4:return r.label++,{value:a[1],done:!1};case 5:r.label++,o=a[1],a=[0];continue;case 7:a=r.ops.pop(),r.trys.pop();continue;default:if(i=r.trys,!(i=i.length>0&&i[i.length-1])&&(a[0]===6||a[0]===2)){r=0;continue}if(a[0]===3&&(!i||a[1]>i[0]&&a[1]<i[3])){r.label=a[1];break}if(a[0]===6&&r.label<i[1]){r.label=i[1],i=a;break}if(i&&r.label<i[2]){r.label=i[2],r.ops.push(a);break}i[2]&&r.ops.pop(),r.trys.pop();continue}a=e.call(t,r)}catch(f){a=[6,f],o=0}finally{n=i=0}if(a[0]&5)throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}},_f=function(t,e){var r=typeof Symbol=="function"&&t[Symbol.iterator];if(!r)return t;var n=r.call(t),o,i=[],s;try{for(;(e===void 0||e-- >0)&&!(o=n.next()).done;)i.push(o.value)}catch(u){s={error:u}}finally{try{o&&!o.done&&(r=n.return)&&r.call(n)}finally{if(s)throw s.error}}return i},Na=function(){function t(e,r){this._meterProviderSharedState=e,this._instrumentationScope=r,this.metricStorageRegistry=new va,this.observableRegistry=new Pa,this.meter=new Ta(this)}return t.prototype.registerMetricStorage=function(e){var r=this._registerMetricStorage(e,Ia);return r.length===1?r[0]:new Aa(r)},t.prototype.registerAsyncMetricStorage=function(e){var r=this._registerMetricStorage(e,ya);return r},t.prototype.collect=function(e,r,n){return pf(this,void 0,void 0,function(){var o,i,s;return df(this,function(u){switch(u.label){case 0:return[4,this.observableRegistry.observe(r,n?.timeoutMillis)];case 1:return o=u.sent(),i=this.metricStorageRegistry.getStorages(e),i.length===0?[2,null]:(s=i.map(function(c){return c.collect(e,r)}).filter(ta),s.length===0?[2,{errors:o}]:[2,{scopeMetrics:{scope:this._instrumentationScope,metrics:s},errors:o}])}})})},t.prototype._registerMetricStorage=function(e,r){var n=this,o=this._meterProviderSharedState.viewRegistry.findViews(e,this._instrumentationScope),i=o.map(function(c){var a=ua(c,e),f=n.metricStorageRegistry.findOrUpdateCompatibleStorage(a);if(f!=null)return f;var p=c.aggregation.createAggregator(a),_=new r(a,p,c.attributesProcessor,n._meterProviderSharedState.metricCollectors);return n.metricStorageRegistry.register(_),_});if(i.length===0){var s=this._meterProviderSharedState.selectAggregations(e.type),u=s.map(function(c){var a=_f(c,2),f=a[0],p=a[1],_=n.metricStorageRegistry.findOrUpdateCompatibleCollectorStorage(f,e);if(_!=null)return _;var S=p.createAggregator(e),x=new r(e,S,dr.Noop(),[f]);return n.metricStorageRegistry.registerForCollector(f,x),x});i=i.concat(u)}return i},t}();var hf=function(t){var e=typeof Symbol=="function"&&Symbol.iterator,r=e&&t[e],n=0;if(r)return r.call(t);if(t&&typeof t.length=="number")return{next:function(){return t&&n>=t.length&&(t=void 0),{value:t&&t[n++],done:!t}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")},wa=function(){function t(e){this.resource=e,this.viewRegistry=new la,this.metricCollectors=[],this.meterSharedStates=new Map}return t.prototype.getMeterSharedState=function(e){var r=na(e),n=this.meterSharedStates.get(r);return n==null&&(n=new Na(this,e),this.meterSharedStates.set(r,n)),n},t.prototype.selectAggregations=function(e){var r,n,o=[];try{for(var i=hf(this.metricCollectors),s=i.next();!s.done;s=i.next()){var u=s.value;o.push([u,u.selectAggregation(e)])}}catch(c){r={error:c}}finally{try{s&&!s.done&&(n=i.return)&&n.call(i)}finally{if(r)throw r.error}}return o},t}();var Ma=g(I()),_r=function(t,e,r,n){function o(i){return i instanceof r?i:new r(function(s){s(i)})}return new(r||(r=Promise))(function(i,s){function u(f){try{a(n.next(f))}catch(p){s(p)}}function c(f){try{a(n.throw(f))}catch(p){s(p)}}function a(f){f.done?i(f.value):o(f.value).then(u,c)}a((n=n.apply(t,e||[])).next())})},hr=function(t,e){var r={label:0,sent:function(){if(i[0]&1)throw i[1];return i[1]},trys:[],ops:[]},n,o,i,s;return s={next:u(0),throw:u(1),return:u(2)},typeof Symbol=="function"&&(s[Symbol.iterator]=function(){return this}),s;function u(a){return function(f){return c([a,f])}}function c(a){if(n)throw new TypeError("Generator is already executing.");for(;r;)try{if(n=1,o&&(i=a[0]&2?o.return:a[0]?o.throw||((i=o.return)&&i.call(o),0):o.next)&&!(i=i.call(o,a[1])).done)return i;switch(o=0,i&&(a=[a[0]&2,i.value]),a[0]){case 0:case 1:i=a;break;case 4:return r.label++,{value:a[1],done:!1};case 5:r.label++,o=a[1],a=[0];continue;case 7:a=r.ops.pop(),r.trys.pop();continue;default:if(i=r.trys,!(i=i.length>0&&i[i.length-1])&&(a[0]===6||a[0]===2)){r=0;continue}if(a[0]===3&&(!i||a[1]>i[0]&&a[1]<i[3])){r.label=a[1];break}if(a[0]===6&&r.label<i[1]){r.label=i[1],i=a;break}if(i&&r.label<i[2]){r.label=i[2],r.ops.push(a);break}i[2]&&r.ops.pop(),r.trys.pop();continue}a=e.call(t,r)}catch(f){a=[6,f],o=0}finally{n=i=0}if(a[0]&5)throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}},Ef=function(t,e){var r=typeof Symbol=="function"&&t[Symbol.iterator];if(!r)return t;var n=r.call(t),o,i=[],s;try{for(;(e===void 0||e-- >0)&&!(o=n.next()).done;)i.push(o.value)}catch(u){s={error:u}}finally{try{o&&!o.done&&(r=n.return)&&r.call(n)}finally{if(s)throw s.error}}return i},mf=function(t,e,r){if(r||arguments.length===2)for(var n=0,o=e.length,i;n<o;n++)(i||!(n in e))&&(i||(i=Array.prototype.slice.call(e,0,n)),i[n]=e[n]);return t.concat(i||Array.prototype.slice.call(e))},xa=function(){function t(e,r){this._sharedState=e,this._metricReader=r}return t.prototype.collect=function(e){return _r(this,void 0,void 0,function(){var r,n,o,i,s=this;return hr(this,function(u){switch(u.label){case 0:return r=(0,Ma.millisToHrTime)(Date.now()),n=[],o=[],i=Array.from(this._sharedState.meterSharedStates.values()).map(function(c){return _r(s,void 0,void 0,function(){var a;return hr(this,function(f){switch(f.label){case 0:return[4,c.collect(this,r,e)];case 1:return a=f.sent(),a?.scopeMetrics!=null&&n.push(a.scopeMetrics),a?.errors!=null&&o.push.apply(o,mf([],Ef(a.errors),!1)),[2]}})})}),[4,Promise.all(i)];case 1:return u.sent(),[2,{resourceMetrics:{resource:this._sharedState.resource,scopeMetrics:n},errors:o}]}})})},t.prototype.forceFlush=function(e){return _r(this,void 0,void 0,function(){return hr(this,function(r){switch(r.label){case 0:return[4,this._metricReader.forceFlush(e)];case 1:return r.sent(),[2]}})})},t.prototype.shutdown=function(e){return _r(this,void 0,void 0,function(){return hr(this,function(r){switch(r.label){case 0:return[4,this._metricReader.shutdown(e)];case 1:return r.sent(),[2]}})})},t.prototype.selectAggregationTemporality=function(e){return this._metricReader.selectAggregationTemporality(e)},t.prototype.selectAggregation=function(e){return this._metricReader.selectAggregation(e)},t}();var Da=function(t,e,r,n){function o(i){return i instanceof r?i:new r(function(s){s(i)})}return new(r||(r=Promise))(function(i,s){function u(f){try{a(n.next(f))}catch(p){s(p)}}function c(f){try{a(n.throw(f))}catch(p){s(p)}}function a(f){f.done?i(f.value):o(f.value).then(u,c)}a((n=n.apply(t,e||[])).next())})},Ua=function(t,e){var r={label:0,sent:function(){if(i[0]&1)throw i[1];return i[1]},trys:[],ops:[]},n,o,i,s;return s={next:u(0),throw:u(1),return:u(2)},typeof Symbol=="function"&&(s[Symbol.iterator]=function(){return this}),s;function u(a){return function(f){return c([a,f])}}function c(a){if(n)throw new TypeError("Generator is already executing.");for(;r;)try{if(n=1,o&&(i=a[0]&2?o.return:a[0]?o.throw||((i=o.return)&&i.call(o),0):o.next)&&!(i=i.call(o,a[1])).done)return i;switch(o=0,i&&(a=[a[0]&2,i.value]),a[0]){case 0:case 1:i=a;break;case 4:return r.label++,{value:a[1],done:!1};case 5:r.label++,o=a[1],a=[0];continue;case 7:a=r.ops.pop(),r.trys.pop();continue;default:if(i=r.trys,!(i=i.length>0&&i[i.length-1])&&(a[0]===6||a[0]===2)){r=0;continue}if(a[0]===3&&(!i||a[1]>i[0]&&a[1]<i[3])){r.label=a[1];break}if(a[0]===6&&r.label<i[1]){r.label=i[1],i=a;break}if(i&&r.label<i[2]){r.label=i[2],r.ops.push(a);break}i[2]&&r.ops.pop(),r.trys.pop();continue}a=e.call(t,r)}catch(f){a=[6,f],o=0}finally{n=i=0}if(a[0]&5)throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}},Tf=function(t){var e=typeof Symbol=="function"&&Symbol.iterator,r=e&&t[e],n=0;if(r)return r.call(t);if(t&&typeof t.length=="number")return{next:function(){return t&&n>=t.length&&(t=void 0),{value:t&&t[n++],done:!t}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")},Cn=function(){function t(e){var r,n,o;this._shutdown=!1;var i=F.default().merge((o=e?.resource)!==null&&o!==void 0?o:F.empty());if(this._sharedState=new wa(i),e?.views!=null&&e.views.length>0)try{for(var s=Tf(e.views),u=s.next();!u.done;u=s.next()){var c=u.value;this._sharedState.viewRegistry.addView(c)}}catch(a){r={error:a}}finally{try{u&&!u.done&&(n=s.return)&&n.call(s)}finally{if(r)throw r.error}}}return t.prototype.getMeter=function(e,r,n){return r===void 0&&(r=""),n===void 0&&(n={}),this._shutdown?(l.diag.warn("A shutdown MeterProvider cannot provide a Meter"),(0,l.createNoopMeter)()):this._sharedState.getMeterSharedState({name:e,version:r,schemaUrl:n.schemaUrl}).meter},t.prototype.addMetricReader=function(e){var r=new xa(this._sharedState,e);e.setMetricProducer(r),this._sharedState.metricCollectors.push(r)},t.prototype.shutdown=function(e){return Da(this,void 0,void 0,function(){return Ua(this,function(r){switch(r.label){case 0:return this._shutdown?(l.diag.warn("shutdown may only be called once per MeterProvider"),[2]):(this._shutdown=!0,[4,Promise.all(this._sharedState.metricCollectors.map(function(n){return n.shutdown(e)}))]);case 1:return r.sent(),[2]}})})},t.prototype.forceFlush=function(e){return Da(this,void 0,void 0,function(){return Ua(this,function(r){switch(r.label){case 0:return this._shutdown?(l.diag.warn("invalid attempt to force flush after MeterProvider shutdown"),[2]):[4,Promise.all(this._sharedState.metricCollectors.map(function(n){return n.forceFlush(e)}))];case 1:return r.sent(),[2]}})})},t}();var ci=g(me(),1),wr=g(Pt(),1),yu=g(Ha(),1),Pe=g(I(),1);E();var Of=Symbol.for("@vercel/request-context");function ne(){return globalThis[Of]?.get()}var Mn=g(me(),1);function Tr(t){return Object.fromEntries(Object.entries(t).filter(([e,r])=>r!==void 0))}function Fa(t){return t?t.split("::").at(-1):void 0}function ja(t=ne(),e){if(!t)return;let r=e?bf(e,t.headers):void 0;return Tr({[Mn.SemanticAttributes.HTTP_HOST]:t.headers.host,[Mn.SemanticAttributes.HTTP_USER_AGENT]:t.headers["user-agent"],"http.referer":t.headers.referer,"vercel.request_id":Fa(t.headers["x-vercel-id"]),"vercel.matched_path":t.headers["x-matched-path"],"vercel.edge_region":process.env.VERCEL_REGION,...r})}var Rf={keys(t){return[]},get(t,e){return t[e.toLocaleLowerCase()]}};function bf(t,e){if(typeof t=="function")return t(e,Rf);let r={};for(let[n,o]of Object.entries(t)){let i=e[o.toLocaleLowerCase()];i!==void 0&&(r[n]=i)}return r}E();function _t(t){return(t&l.TraceFlags.SAMPLED)!==0}var Sr=class{constructor(e,r){this.processors=e;this.attributesFromHeaders=r;this.rootSpanIds=new Map;this.waitSpanEnd=new Map}forceFlush(){return Promise.all(this.processors.map(e=>e.forceFlush().catch(r=>{l.diag.error("@vercel/otel: forceFlush failed:",r)}))).then(()=>{})}shutdown(){return Promise.all(this.processors.map(e=>e.shutdown().catch(()=>{}))).then(()=>{})}onStart(e,r){let{traceId:n,spanId:o,traceFlags:i}=e.spanContext(),s=!e.parentSpanId||!this.rootSpanIds.has(n);if(s?this.rootSpanIds.set(n,{rootSpanId:o,open:[]}):this.rootSpanIds.get(n)?.open.push(e),s&&_t(i)){let u=ne(),c=ja(u,this.attributesFromHeaders);c&&e.setAttributes(c),u&&u.waitUntil(async()=>{if(this.rootSpanIds.has(n)){let a=new Promise(p=>{this.waitSpanEnd.set(n,p)}),f;await Promise.race([a,new Promise(p=>{f=setTimeout(()=>{this.waitSpanEnd.delete(n),p(void 0)},50)})]),f&&clearTimeout(f)}return this.forceFlush()})}for(let u of this.processors)u.onStart(e,r)}onEnd(e){let{traceId:r,spanId:n,traceFlags:o}=e.spanContext(),i=_t(o),s=this.rootSpanIds.get(r),u=s?.rootSpanId===n;if(i){let c=Pf(e);c&&Object.assign(e.attributes,c)}if(u){if(this.rootSpanIds.delete(r),s.open.length>0){for(let c of s.open)if(!c.ended&&c.spanContext().spanId!==n)try{c.end()}catch(a){l.diag.error("@vercel/otel: onEnd failed:",a)}}}else if(s)for(let c=0;c<s.open.length;c++)s.open[c]?.spanContext().spanId===n&&s.open.splice(c,1);for(let c of this.processors)c.onEnd(e);if(u){let c=this.waitSpanEnd.get(r);c&&(this.waitSpanEnd.delete(r),c())}}},Lf={[l.SpanKind.INTERNAL]:"internal",[l.SpanKind.SERVER]:"server",[l.SpanKind.CLIENT]:"client",[l.SpanKind.PRODUCER]:"producer",[l.SpanKind.CONSUMER]:"consumer"};function Pf(t){let{kind:e,attributes:r}=t,{"operation.name":n,"resource.name":o,"span.type":i,"next.span_type":s,"http.method":u,"http.route":c}=r;if(n)return;let a=o??(u&&typeof u=="string"&&c&&typeof c=="string"?`${u} ${c}`:c);if(t.kind===l.SpanKind.SERVER&&u&&c&&typeof u=="string"&&typeof c=="string")return{"operation.name":"web.request","resource.name":a};let f=t.instrumentationLibrary.name,p=s??i;if(p&&typeof p=="string"){let _=ka(f,p);return c?{"operation.name":_,"resource.name":a}:{"operation.name":_}}return{"operation.name":ka(f,e===l.SpanKind.INTERNAL?"":Lf[e])}}function ka(t,e){if(!t)return e;let r=t.replace(/[ @./]/g,"_");return r.startsWith("_")&&(r=r.slice(1)),e?`${r}.${e}`:r}var is=g(Hn(),1);var ns=g(rs(),1);E();var Qe=class extends ns.OTLPExporterBase{constructor(e={}){super(e),e.headers&&(this._headers=e.headers)}onShutdown(){l.diag.debug("@vercel/otel/otlp: onShutdown")}onInit(){l.diag.debug("@vercel/otel/otlp: onInit")}send(e,r,n){if(this._shutdownOnce.isCalled){l.diag.debug("@vercel/otel/otlp: Shutdown already started. Cannot send objects");return}let o=this.convert(e),i,s,u;try{({body:i,contentType:s,headers:u}=this.toMessage(o))}catch(a){l.diag.warn("@vercel/otel/otlp: no proto",a);return}let c=fetch(this.url,{method:"POST",body:i,headers:{...this._headers,...u,"Content-Type":s,"User-Agent":"OTel-OTLP-Exporter-JavaScript/0.46.0"},next:{internal:!0}}).then(a=>{l.diag.debug("@vercel/otel/otlp: onSuccess",a.status,a.statusText),r(),a.arrayBuffer().catch(()=>{})}).catch(a=>{l.diag.error("@vercel/otel/otlp: onError",a),n(a)}).finally(()=>{let a=this._sendingPromises.indexOf(c);this._sendingPromises.splice(a,1)});this._sendingPromises.push(c)}getDefaultUrl(e){throw new Error("Method not implemented.")}};var zf="v1/traces",$f=`http://localhost:4318/${zf}`;function Ar(t){return typeof t.url=="string"?t.url:$f}var Ze=class{constructor(e={}){this.impl=new qn(e)}export(e,r){this.impl.export(e,r)}shutdown(){return this.impl.shutdown()}forceFlush(){return this.impl.forceFlush()}},qn=class extends Qe{convert(e){return(0,is.createExportTraceServiceRequest)(e,{useHex:!0,useLongBits:!1})}toMessage(e){return{body:JSON.stringify(e),contentType:"application/json"}}getDefaultUrl(e){return Ar(e)}};var au=g(Hn(),1);var nu=g(ru(),1);function iu(t){let e=new nu.Writer;return sp(t,e),e.finish()}function sp(t,e){if(t.resourceSpans!=null&&t.resourceSpans.length)for(let r=0;r<t.resourceSpans.length;++r)up(t.resourceSpans[r],e.uint32(10).fork()).ldelim();return e}function up(t,e){if(t.resource!=null&&cp(t.resource,e.uint32(10).fork()).ldelim(),t.scopeSpans!=null&&t.scopeSpans.length)for(let r=0;r<t.scopeSpans.length;++r)lp(t.scopeSpans[r],e.uint32(18).fork()).ldelim();return t.schemaUrl!=null&&e.uint32(26).string(t.schemaUrl),e}function cp(t,e){if(t.attributes!=null&&t.attributes.length)for(let r=0;r<t.attributes.length;++r)et(t.attributes[r],e.uint32(10).fork()).ldelim();return t.droppedAttributesCount!=null&&e.uint32(16).uint32(t.droppedAttributesCount),e}function lp(t,e){if(t.scope!=null&&dp(t.scope,e.uint32(10).fork()).ldelim(),t.spans!=null&&t.spans.length)for(let r=0;r<t.spans.length;++r)_p(t.spans[r],e.uint32(18).fork()).ldelim();return t.schemaUrl!=null&&e.uint32(26).string(t.schemaUrl),e}function et(t,e){return t.key!=null&&e.uint32(10).string(t.key),t.value!=null&&ou(t.value,e.uint32(18).fork()).ldelim(),e}function ou(t,e){return t.stringValue!=null&&e.uint32(10).string(t.stringValue),t.boolValue!=null&&e.uint32(16).bool(t.boolValue),t.intValue!=null&&e.uint32(24).int64(t.intValue),t.doubleValue!=null&&e.uint32(33).double(t.doubleValue),t.arrayValue!=null&&fp(t.arrayValue,e.uint32(42).fork()).ldelim(),t.kvlistValue!=null&&pp(t.kvlistValue,e.uint32(50).fork()).ldelim(),t.bytesValue!=null&&e.uint32(58).bytes(t.bytesValue),e}function fp(t,e){if(t.values!=null&&t.values.length)for(let r=0;r<t.values.length;++r)ou(t.values[r],e.uint32(10).fork()).ldelim();return e}function pp(t,e){if(t.values!=null&&t.values.length)for(let r=0;r<t.values.length;++r)et(t.values[r],e.uint32(10).fork()).ldelim();return e}function dp(t,e){if(t.name!=null&&e.uint32(10).string(t.name),t.version!=null&&e.uint32(18).string(t.version),t.attributes!=null&&t.attributes.length)for(let r=0;r<t.attributes.length;++r)et(t.attributes[r],e.uint32(26).fork()).ldelim();return t.droppedAttributesCount!=null&&e.uint32(32).uint32(t.droppedAttributesCount),e}function _p(t,e){if(t.traceId!=null&&e.uint32(10).bytes(t.traceId),t.spanId!=null&&e.uint32(18).bytes(t.spanId),t.traceState!=null&&e.uint32(26).string(t.traceState),t.parentSpanId!=null&&e.uint32(34).bytes(t.parentSpanId),t.name!=null&&e.uint32(42).string(t.name),t.kind!=null&&e.uint32(48).int32(t.kind),t.startTimeUnixNano!=null&&e.uint32(57).fixed64(t.startTimeUnixNano),t.endTimeUnixNano!=null&&e.uint32(65).fixed64(t.endTimeUnixNano),t.attributes!=null&&t.attributes.length)for(let r=0;r<t.attributes.length;++r)et(t.attributes[r],e.uint32(74).fork()).ldelim();if(t.droppedAttributesCount!=null&&e.uint32(80).uint32(t.droppedAttributesCount),t.events!=null&&t.events.length)for(let r=0;r<t.events.length;++r)Ep(t.events[r],e.uint32(90).fork()).ldelim();if(t.droppedEventsCount!=null&&e.uint32(96).uint32(t.droppedEventsCount),t.links!=null&&t.links.length)for(let r=0;r<t.links.length;++r)mp(t.links[r],e.uint32(106).fork()).ldelim();return t.droppedLinksCount!=null&&e.uint32(112).uint32(t.droppedLinksCount),t.status!=null&&hp(t.status,e.uint32(122).fork()).ldelim(),e}function hp(t,e){return t.message!=null&&e.uint32(18).string(t.message),t.code!=null&&e.uint32(24).int32(t.code),e}function Ep(t,e){if(t.timeUnixNano!=null&&e.uint32(9).fixed64(t.timeUnixNano),t.name!=null&&e.uint32(18).string(t.name),t.attributes!=null&&t.attributes.length)for(let r=0;r<t.attributes.length;++r)et(t.attributes[r],e.uint32(26).fork()).ldelim();return t.droppedAttributesCount!=null&&e.uint32(32).uint32(t.droppedAttributesCount),e}function mp(t,e){if(t.traceId!=null&&e.uint32(10).bytes(t.traceId),t.spanId!=null&&e.uint32(18).bytes(t.spanId),t.traceState!=null&&e.uint32(26).string(t.traceState),t.attributes!=null&&t.attributes.length)for(let r=0;r<t.attributes.length;++r)et(t.attributes[r],e.uint32(34).fork()).ldelim();return t.droppedAttributesCount!=null&&e.uint32(40).uint32(t.droppedAttributesCount),e}var Ve=class{constructor(e={}){this.impl=new ii(e)}export(e,r){this.impl.export(e,r)}shutdown(){return this.impl.shutdown()}forceFlush(){return this.impl.forceFlush()}},ii=class extends Qe{convert(e){return(0,au.createExportTraceServiceRequest)(e,void 0)}toMessage(e){return{body:iu(e),contentType:"application/x-protobuf",headers:{accept:"application/x-protobuf"}}}getDefaultUrl(e){return Ar(e)}};E();var fe=g(me(),1);function su(t,e){return t.replace(/\{(?<temp1>[^{}]+)\}/g,(r,n)=>{let o=e[n];return o!==void 0?String(o):r})}var tt=class{constructor(e={}){this.instrumentationName="@vercel/otel/fetch";this.instrumentationVersion="1.0.0";this.config=e}getConfig(){return this.config}setConfig(){}setTracerProvider(e){this.tracerProvider=e}setMeterProvider(){}enable(){this.disable();let{tracerProvider:e}=this;if(!e)return;let r=e.getTracer(this.instrumentationName,this.instrumentationVersion),n=this.config.ignoreUrls??[],o=(O,B)=>{if(B?.opentelemetry?.ignore!==void 0)return B.opentelemetry.ignore;if(n.length===0)return!1;let m=O.toString();return n.some(v=>typeof v=="string"?v==="*"?!0:m.startsWith(v):v.test(m))},i=process.env.VERCEL_URL||process.env.NEXT_PUBLIC_VERCEL_URL||null,s=process.env.VERCEL_BRANCH_URL||process.env.NEXT_PUBLIC_VERCEL_BRANCH_URL||null,u=this.config.propagateContextUrls??[],c=this.config.dontPropagateContextUrls??[],a=this.config.resourceNameTemplate,{attributesFromRequestHeaders:f,attributesFromResponseHeaders:p}=this.config,_=(O,B)=>{if(B?.opentelemetry?.propagateContext)return B.opentelemetry.propagateContext;let m=O.toString();return c.length>0&&c.some(v=>typeof v=="string"?v==="*"?!0:m.startsWith(v):v.test(m))?!1:i&&O.protocol==="https:"&&(O.host===i||O.host===s||O.host===ne()?.headers.host)||!i&&O.protocol==="http:"&&O.hostname==="localhost"?!0:u.some(v=>typeof v=="string"?v==="*"?!0:m.startsWith(v):v.test(m))};process.env.NEXT_OTEL_FETCH_DISABLED="1";let S=globalThis.fetch;this.originalFetch=S;let x=async(O,B)=>{let m=B;if(m?.next?.internal)return S(O,m);let v=new Request(O instanceof Request?O.clone():O,m),Y=new URL(v.url);if(o(Y,m))return S(O,m);let gt={[fe.SemanticAttributes.HTTP_METHOD]:v.method,[fe.SemanticAttributes.HTTP_URL]:v.url,[fe.SemanticAttributes.HTTP_HOST]:Y.host,[fe.SemanticAttributes.HTTP_SCHEME]:Y.protocol.replace(":",""),[fe.SemanticAttributes.NET_PEER_NAME]:Y.hostname,[fe.SemanticAttributes.NET_PEER_PORT]:Y.port},Mr=a?su(a,gt):Sp(v.url),yt=m?.opentelemetry?.spanName??`fetch ${v.method} ${v.url}`,li=l.context.active(),D=r.startSpan(yt,{kind:l.SpanKind.CLIENT,attributes:{...gt,"operation.name":`fetch.${v.method}`,"resource.name":Mr,...m?.opentelemetry?.attributes}},li);if(!D.isRecording()||!_t(D.spanContext().traceFlags))return D.end(),S(O,m);if(_(Y,m)){let He=l.trace.setSpan(li,D);l.propagation.inject(He,v.headers,Tp)}f&&uu(D,f,v.headers);try{let He=Date.now();m?.body&&m.body instanceof FormData&&v.headers.delete("content-type");let pe=await S(O,{...m,headers:v.headers}),Au=Date.now()-He;return D.setAttribute(fe.SemanticAttributes.HTTP_STATUS_CODE,pe.status),D.setAttribute("http.response_time",Au),p&&uu(D,p,pe.headers),pe.status>=500&&oi(D,`Status: ${pe.status} (${pe.statusText})`),pe.body?gp(pe).then(xr=>{D.isRecording()&&(D.setAttribute(fe.SemanticAttributes.HTTP_RESPONSE_CONTENT_LENGTH_UNCOMPRESSED,xr),D.end())},xr=>{D.isRecording()&&(oi(D,xr),D.end())}):D.end(),pe}catch(He){throw oi(D,He),D.end(),He}};globalThis.fetch=x}disable(){this.originalFetch&&(globalThis.fetch=this.originalFetch)}},Tp={set(t,e,r){t.set(e,r)}};function Sp(t){let e=t.indexOf("?");return e===-1?t:t.substring(0,e)}function gp(t){let e=0,n=t.clone().body?.getReader();if(!n)return Promise.resolve(0);let o=()=>n.read().then(({done:i,value:s})=>{if(!i)return e+=s.byteLength,o()});return o().then(()=>e)}function oi(t,e){if(e instanceof Error)t.recordException(e),t.setStatus({code:l.SpanStatusCode.ERROR,message:e.message});else{let r=String(e);t.setStatus({code:l.SpanStatusCode.ERROR,message:r})}}function uu(t,e,r){for(let[n,o]of Object.entries(e)){let i=r.get(o);i!==null&&t.setAttribute(n,i)}}E();var cu=g(I(),1),yp="00",ai="traceparent",si="tracestate",St=class{fields(){return[ai,si]}inject(e,r,n){let o=l.trace.getSpanContext(e);if(!o||(0,cu.isTracingSuppressed)(e)||!(0,l.isSpanContextValid)(o))return;let i=`${yp}-${o.traceId}-${o.spanId}-0${Number(o.traceFlags||0).toString(16)}`;n.set(r,ai,i),o.traceState&&n.set(r,si,o.traceState.serialize())}extract(e,r,n){let o=n.get(r,ai);if(!o)return e;let i=Array.isArray(o)?o[0]:o;if(typeof i!="string")return e;let s=vp(i);if(!s)return e;s.isRemote=!0;let u=n.get(r,si);if(u){let c=Array.isArray(u)?u.join(","):u;s.traceState=(0,l.createTraceState)(typeof c=="string"?c:void 0)}return l.trace.setSpanContext(e,s)}};function vp(t){let[e,r,n,o,i]=t.split("-");return!e||!r||!n||!o||e.length!==2||r.length!==32||n.length!==16||o.length!==2||e==="00"&&i?null:{traceId:r,spanId:n,traceFlags:parseInt(o,16)}}E();var Pr=class{fields(){return[]}inject(){}extract(e){let r=ne();if(!r?.telemetry)return l.diag.warn("@vercel/otel: Vercel telemetry extension not found."),e;let{rootSpanContext:n}=r.telemetry;return n?(l.diag.debug("@vercel/otel: Extracted root SpanContext from Vercel request context.",n),l.trace.setSpanContext(e,{...n,isRemote:!0,traceFlags:n.traceFlags||l.TraceFlags.SAMPLED})):e}};E();var Ir=g(I(),1);var rt=g(I()),Ap=BigInt(1e9);function fu(t){return BigInt(t[0])*Ap+BigInt(t[1])}function Op(t){var e=Number(BigInt.asUintN(32,t)),r=Number(BigInt.asUintN(32,t>>BigInt(32)));return{low:e,high:r}}function pu(t){var e=fu(t);return Op(e)}function Rp(t){var e=fu(t);return e.toString()}var bp=typeof BigInt<"u"?Rp:rt.hrTimeToNanoseconds;function lu(t){return t}function du(t){if(t!==void 0)return(0,rt.hexToBase64)(t)}var Lp={encodeHrTime:pu,encodeSpanContext:rt.hexToBase64,encodeOptionalSpanContext:du};function _u(t){var e,r;if(t===void 0)return Lp;var n=(e=t.useLongBits)!==null&&e!==void 0?e:!0,o=(r=t.useHex)!==null&&r!==void 0?r:!1;return{encodeHrTime:n?pu:bp,encodeSpanContext:o?lu:rt.hexToBase64,encodeOptionalSpanContext:o?lu:du}}var Pp=function(t,e){var r=typeof Symbol=="function"&&t[Symbol.iterator];if(!r)return t;var n=r.call(t),o,i=[],s;try{for(;(e===void 0||e-- >0)&&!(o=n.next()).done;)i.push(o.value)}catch(u){s={error:u}}finally{try{o&&!o.done&&(r=n.return)&&r.call(n)}finally{if(s)throw s.error}}return i};function nt(t){return Object.keys(t).map(function(e){return hu(e,t[e])})}function hu(t,e){return{key:t,value:Eu(e)}}function Eu(t){var e=typeof t;return e==="string"?{stringValue:t}:e==="number"?Number.isInteger(t)?{intValue:t}:{doubleValue:t}:e==="boolean"?{boolValue:t}:t instanceof Uint8Array?{bytesValue:t}:Array.isArray(t)?{arrayValue:{values:t.map(Eu)}}:e==="object"&&t!=null?{kvlistValue:{values:Object.entries(t).map(function(r){var n=Pp(r,2),o=n[0],i=n[1];return hu(o,i)})}}:{}}function mu(t,e){var r,n=t.spanContext(),o=t.status;return{traceId:e.encodeSpanContext(n.traceId),spanId:e.encodeSpanContext(n.spanId),parentSpanId:e.encodeOptionalSpanContext(t.parentSpanId),traceState:(r=n.traceState)===null||r===void 0?void 0:r.serialize(),name:t.name,kind:t.kind==null?0:t.kind+1,startTimeUnixNano:e.encodeHrTime(t.startTime),endTimeUnixNano:e.encodeHrTime(t.endTime),attributes:nt(t.attributes),droppedAttributesCount:t.droppedAttributesCount,events:t.events.map(function(i){return Cp(i,e)}),droppedEventsCount:t.droppedEventsCount,status:{code:o.code,message:o.message},links:t.links.map(function(i){return Ip(i,e)}),droppedLinksCount:t.droppedLinksCount}}function Ip(t,e){var r;return{attributes:t.attributes?nt(t.attributes):[],spanId:e.encodeSpanContext(t.context.spanId),traceId:e.encodeSpanContext(t.context.traceId),traceState:(r=t.context.traceState)===null||r===void 0?void 0:r.serialize(),droppedAttributesCount:t.droppedAttributesCount||0}}function Cp(t,e){return{attributes:t.attributes?nt(t.attributes):[],name:t.name,timeUnixNano:e.encodeHrTime(t.time),droppedAttributesCount:t.droppedAttributesCount||0}}var Np=function(t){var e=typeof Symbol=="function"&&Symbol.iterator,r=e&&t[e],n=0;if(r)return r.call(t);if(t&&typeof t.length=="number")return{next:function(){return t&&n>=t.length&&(t=void 0),{value:t&&t[n++],done:!t}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")},wp=function(t,e){var r=typeof Symbol=="function"&&t[Symbol.iterator];if(!r)return t;var n=r.call(t),o,i=[],s;try{for(;(e===void 0||e-- >0)&&!(o=n.next()).done;)i.push(o.value)}catch(u){s={error:u}}finally{try{o&&!o.done&&(r=n.return)&&r.call(n)}finally{if(s)throw s.error}}return i};function ui(t,e){var r=_u(e);return{resourceSpans:xp(t,r)}}function Mp(t){var e,r,n=new Map;try{for(var o=Np(t),i=o.next();!i.done;i=o.next()){var s=i.value,u=n.get(s.resource);u||(u=new Map,n.set(s.resource,u));var c=s.instrumentationLibrary.name+"@"+(s.instrumentationLibrary.version||"")+":"+(s.instrumentationLibrary.schemaUrl||""),a=u.get(c);a||(a=[],u.set(c,a)),a.push(s)}}catch(f){e={error:f}}finally{try{i&&!i.done&&(r=o.return)&&r.call(o)}finally{if(e)throw e.error}}return n}function xp(t,e){for(var r=Mp(t),n=[],o=r.entries(),i=o.next();!i.done;){for(var s=wp(i.value,2),u=s[0],c=s[1],a=[],f=c.values(),p=f.next();!p.done;){var _=p.value;if(_.length>0){var S=_[0].instrumentationLibrary,x=S.name,O=S.version,B=S.schemaUrl,m=_.map(function(Y){return mu(Y,e)});a.push({scope:{name:x,version:O},spans:m,schemaUrl:B})}p=f.next()}var v={resource:{attributes:nt(u.attributes),droppedAttributesCount:0},scopeSpans:a,schemaUrl:void 0};n.push(v),i=o.next()}return n}var Cr=class{export(e,r){let n=ne();if(!n?.telemetry){l.diag.warn("@vercel/otel: no telemetry context found"),r({code:Ir.ExportResultCode.SUCCESS,error:void 0});return}try{let o=ui(e,{useHex:!0,useLongBits:!1});n.telemetry.reportSpans(o),r({code:Ir.ExportResultCode.SUCCESS,error:void 0})}catch(o){r({code:Ir.ExportResultCode.FAILED,error:o instanceof Error?o:new Error(String(o))})}}shutdown(){return Promise.resolve()}forceFlush(){return Promise.resolve()}};var Dp={ALL:l.DiagLogLevel.ALL,VERBOSE:l.DiagLogLevel.VERBOSE,DEBUG:l.DiagLogLevel.DEBUG,INFO:l.DiagLogLevel.INFO,WARN:l.DiagLogLevel.WARN,ERROR:l.DiagLogLevel.ERROR,NONE:l.DiagLogLevel.NONE},Nr=class{constructor(e={}){this.configuration=e}start(){let e=Up(),r=this.configuration,n=process.env.NEXT_RUNTIME||"nodejs",o=!!e.OTEL_SDK_DISABLED;if(process.env.OTEL_LOG_LEVEL&&l.diag.setLogger(new l.DiagConsoleLogger,{logLevel:Dp[process.env.OTEL_LOG_LEVEL.toUpperCase()]}),o)return;let i=r.idGenerator??new nr,s=r.contextManager??new yu.AsyncLocalStorageContextManager;s.enable(),this.contextManager=s;let u=e.OTEL_SERVICE_NAME||r.serviceName||"app",c=new F(Tr({[ci.SemanticResourceAttributes.SERVICE_NAME]:u,"node.ci":process.env.CI?!0:void 0,"node.env":"production",env:process.env.VERCEL_ENV||process.env.NEXT_PUBLIC_VERCEL_ENV,"vercel.region":process.env.VERCEL_REGION,"vercel.runtime":n,"vercel.sha":process.env.VERCEL_GIT_COMMIT_SHA||process.env.NEXT_PUBLIC_VERCEL_GIT_COMMIT_SHA,"vercel.host":process.env.VERCEL_URL||process.env.NEXT_PUBLIC_VERCEL_URL||void 0,"vercel.branch_host":process.env.VERCEL_BRANCH_URL||process.env.NEXT_PUBLIC_VERCEL_BRANCH_URL||void 0,"vercel.deployment_id":process.env.VERCEL_DEPLOYMENT_ID||void 0,[ci.SemanticResourceAttributes.SERVICE_VERSION]:process.env.VERCEL_DEPLOYMENT_ID,...r.attributes})),a=r.resourceDetectors??[wo];if(r.autoDetectResources??!0){let m={detectors:a};c=c.merge(xo(m))}let p=Gp(r.propagators,r,e),_=Vp(r.traceSampler,e),S=Hp(r.spanProcessors,r,e);S.length===0&&l.diag.warn("@vercel/otel: No span processors configured. No spans will be exported.");let x=r.spanLimits,O=new Go({resource:c,idGenerator:i,sampler:_,spanLimits:x});if(O.addSpanProcessor(new Sr(S,r.attributesFromHeaders)),O.register({contextManager:s,propagator:new Pe.CompositePropagator({propagators:p})}),this.tracerProvider=O,r.logRecordProcessor){let m=new yn({resource:c});this.loggerProvider=m,m.addLogRecordProcessor(r.logRecordProcessor),se.logs.setGlobalLoggerProvider(m)}if(r.metricReader||r.views){let m=new Cn({resource:c,views:r.views??[]});r.metricReader&&m.addMetricReader(r.metricReader),l.metrics.setGlobalMeterProvider(m),this.meterProvider=m}let B=Bp(r.instrumentations,r.instrumentationConfig);this.disableInstrumentations=(0,gu.registerInstrumentations)({instrumentations:B}),l.diag.info("@vercel/otel: started",u,n)}async shutdown(){let e=[];this.tracerProvider&&e.push(this.tracerProvider.shutdown()),this.loggerProvider&&e.push(this.loggerProvider.shutdown()),this.meterProvider&&e.push(this.meterProvider.shutdown()),l.diag.info("@vercel/otel: shutting down",e.length,process.env.NEXT_RUNTIME),await Promise.all(e),this.contextManager&&this.contextManager.disable();let{disableInstrumentations:r}=this;r&&r()}};function Up(){let t=(0,wr.parseEnvironment)(process.env);return{...wr.DEFAULT_ENVIRONMENT,...t}}function Bp(t,e){return(t??["auto"]).map(r=>r==="auto"?(l.diag.debug("@vercel/otel: Configure instrumentations: fetch",e?.fetch),[new tt(e?.fetch)]):r==="fetch"?(l.diag.debug("@vercel/otel: Configure instrumentations: fetch",e?.fetch),new tt(e?.fetch)):r).flat()}function Gp(t,e,r){let n=process.env.OTEL_PROPAGATORS&&r.OTEL_PROPAGATORS&&r.OTEL_PROPAGATORS.length>0?r.OTEL_PROPAGATORS:void 0;return(t??n??["auto"]).map(o=>{if(o==="none")return[];if(o==="auto"){let i=[];return i.push({name:"tracecontext",propagator:new St}),i.push({name:"baggage",propagator:new Pe.W3CBaggagePropagator}),i.push({name:"vercel-runtime",propagator:new Pr}),l.diag.debug(`@vercel/otel: Configure propagators: ${i.map(s=>s.name).join(", ")}`),i.map(s=>s.propagator)}if(o==="tracecontext")return l.diag.debug("@vercel/otel: Configure propagator: tracecontext"),new St;if(o==="baggage")return l.diag.debug("@vercel/otel: Configure propagator: baggage"),new Pe.W3CBaggagePropagator;if(typeof o=="string")throw new Error(`Unknown propagator: "${o}"`);return o}).flat()}var Tu="always_on",it=1;function Vp(t,e){if(t&&typeof t!="string")return t;let r=t&&t!=="auto"?t:e.OTEL_TRACES_SAMPLER||Tu;switch(l.diag.debug("@vercel/otel: Configure sampler: ",r),r){case"always_on":return new X;case"always_off":return new ae;case"parentbased_always_on":return new Se({root:new X});case"parentbased_always_off":return new Se({root:new ae});case"traceidratio":return new Xe(Su(e));case"parentbased_traceidratio":return new Se({root:new Xe(Su(e))});default:return l.diag.error(`@vercel/otel: OTEL_TRACES_SAMPLER value "${String(e.OTEL_TRACES_SAMPLER)} invalid, defaulting to ${Tu}".`),new X}}function Su(t){if(t.OTEL_TRACES_SAMPLER_ARG===void 0||t.OTEL_TRACES_SAMPLER_ARG==="")return l.diag.error(`@vercel/otel: OTEL_TRACES_SAMPLER_ARG is blank, defaulting to ${it}.`),it;l.diag.debug("@vercel/otel: Configure sampler probability: ",t.OTEL_TRACES_SAMPLER_ARG);let e=Number(t.OTEL_TRACES_SAMPLER_ARG);return isNaN(e)?(l.diag.error(`@vercel/otel: OTEL_TRACES_SAMPLER_ARG=${t.OTEL_TRACES_SAMPLER_ARG} was given, but it is invalid, defaulting to ${it}.`),it):e<0||e>1?(l.diag.error(`@vercel/otel: OTEL_TRACES_SAMPLER_ARG=${t.OTEL_TRACES_SAMPLER_ARG} was given, but it is out of range ([0..1]), defaulting to ${it}.`),it):e}function Hp(t,e,r){return[...(t??["auto"]).flatMap(n=>{if(n==="auto"){let o=[new De(new Cr)];if(process.env.VERCEL_OTEL_ENDPOINTS){let i=process.env.VERCEL_OTEL_ENDPOINTS_PORT||"4318",s=process.env.VERCEL_OTEL_ENDPOINTS_PROTOCOL||"http/protobuf";l.diag.debug("@vercel/otel: Configure vercel otel collector on port: ",i,s);let u={url:`http://localhost:${i}/v1/traces`,headers:{}},c=s==="http/protobuf"?new Ve(u):new Ze(u);o.push(new De(c))}else if(!e.traceExporter||e.traceExporter==="auto"||r.OTEL_EXPORTER_OTLP_TRACES_ENDPOINT||r.OTEL_EXPORTER_OTLP_ENDPOINT)return new De(Fp(r));return o}return n}).filter(qp),...e.traceExporter&&e.traceExporter!=="auto"?[new De(e.traceExporter)]:[]]}function Fp(t){let e=process.env.OTEL_EXPORTER_OTLP_TRACES_PROTOCOL??process.env.OTEL_EXPORTER_OTLP_PROTOCOL??"http/protobuf",r=kp(t),n={...Pe.baggageUtils.parseKeyPairsIntoRecord(t.OTEL_EXPORTER_OTLP_HEADERS),...Pe.baggageUtils.parseKeyPairsIntoRecord(t.OTEL_EXPORTER_OTLP_TRACES_HEADERS)};switch(l.diag.debug("@vercel/otel: Configure trace exporter: ",e,r,`headers: ${Object.keys(n).join(",")||"<none>"}`),e){case"http/json":return new Ze({url:r,headers:n});case"http/protobuf":return new Ve({url:r,headers:n});default:return l.diag.warn(`@vercel/otel: Unsupported OTLP traces protocol: ${e}. Using http/protobuf.`),new Ve}}var vu="v1/traces",jp=`http://localhost:4318/${vu}`;function kp(t){let e=t.OTEL_EXPORTER_OTLP_TRACES_ENDPOINT;if(e&&typeof e=="string")return e;let r=t.OTEL_EXPORTER_OTLP_ENDPOINT;return r&&typeof r=="string"?`${r}/${vu}`:jp}function qp(t){return t!=null}function hT(t){let e;t?typeof t=="string"?e={serviceName:t}:e=t:e={},new Nr(e).start()}export{tt as FetchInstrumentation,Ze as OTLPHttpJsonTraceExporter,Ve as OTLPHttpProtoTraceExporter,hT as registerOTel};
|
|
16
|
+
`,bn(a,e))}}catch(f){n={error:f}}finally{try{u&&!u.done&&(o=s.return)&&o.call(s)}finally{if(n)throw n.error}}return i},t}();var Aa=function(){function t(e){this._backingStorages=e}return t.prototype.record=function(e,r,n,o){this._backingStorages.forEach(function(i){i.record(e,r,n,o)})},t}();E();E();var Oa=function(){function t(e,r){this._instrumentName=e,this._valueType=r,this._buffer=new Z}return t.prototype.observe=function(e,r){if(r===void 0&&(r={}),typeof e!="number"){l.diag.warn("non-number value provided to metric "+this._instrumentName+": "+e);return}this._valueType===l.ValueType.INT&&!Number.isInteger(e)&&(l.diag.warn("INT value type cannot accept a floating-point value for "+this._instrumentName+", ignoring the fractional digits."),e=Math.trunc(e),!Number.isInteger(e))||this._buffer.set(r,e)},t}();var Ra=function(){function t(){this._buffer=new Map}return t.prototype.observe=function(e,r,n){if(n===void 0&&(n={}),!!ft(e)){var o=this._buffer.get(e);if(o==null&&(o=new Z,this._buffer.set(e,o)),typeof r!="number"){l.diag.warn("non-number value provided to metric "+e._descriptor.name+": "+r);return}e._descriptor.valueType===l.ValueType.INT&&!Number.isInteger(r)&&(l.diag.warn("INT value type cannot accept a floating-point value for "+e._descriptor.name+", ignoring the fractional digits."),r=Math.trunc(r),!Number.isInteger(r))||o.set(n,r)}},t}();var Pn=function(t,e,r,n){function o(i){return i instanceof r?i:new r(function(s){s(i)})}return new(r||(r=Promise))(function(i,s){function u(f){try{a(n.next(f))}catch(p){s(p)}}function c(f){try{a(n.throw(f))}catch(p){s(p)}}function a(f){f.done?i(f.value):o(f.value).then(u,c)}a((n=n.apply(t,e||[])).next())})},In=function(t,e){var r={label:0,sent:function(){if(i[0]&1)throw i[1];return i[1]},trys:[],ops:[]},n,o,i,s;return s={next:u(0),throw:u(1),return:u(2)},typeof Symbol=="function"&&(s[Symbol.iterator]=function(){return this}),s;function u(a){return function(f){return c([a,f])}}function c(a){if(n)throw new TypeError("Generator is already executing.");for(;r;)try{if(n=1,o&&(i=a[0]&2?o.return:a[0]?o.throw||((i=o.return)&&i.call(o),0):o.next)&&!(i=i.call(o,a[1])).done)return i;switch(o=0,i&&(a=[a[0]&2,i.value]),a[0]){case 0:case 1:i=a;break;case 4:return r.label++,{value:a[1],done:!1};case 5:r.label++,o=a[1],a=[0];continue;case 7:a=r.ops.pop(),r.trys.pop();continue;default:if(i=r.trys,!(i=i.length>0&&i[i.length-1])&&(a[0]===6||a[0]===2)){r=0;continue}if(a[0]===3&&(!i||a[1]>i[0]&&a[1]<i[3])){r.label=a[1];break}if(a[0]===6&&r.label<i[1]){r.label=i[1],i=a;break}if(i&&r.label<i[2]){r.label=i[2],r.ops.push(a);break}i[2]&&r.ops.pop(),r.trys.pop();continue}a=e.call(t,r)}catch(f){a=[6,f],o=0}finally{n=i=0}if(a[0]&5)throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}},ba=function(t,e){var r=typeof Symbol=="function"&&t[Symbol.iterator];if(!r)return t;var n=r.call(t),o,i=[],s;try{for(;(e===void 0||e-- >0)&&!(o=n.next()).done;)i.push(o.value)}catch(u){s={error:u}}finally{try{o&&!o.done&&(r=n.return)&&r.call(n)}finally{if(s)throw s.error}}return i},La=function(t,e,r){if(r||arguments.length===2)for(var n=0,o=e.length,i;n<o;n++)(i||!(n in e))&&(i||(i=Array.prototype.slice.call(e,0,n)),i[n]=e[n]);return t.concat(i||Array.prototype.slice.call(e))},Pa=function(){function t(){this._callbacks=[],this._batchCallbacks=[]}return t.prototype.addCallback=function(e,r){var n=this._findCallback(e,r);n>=0||this._callbacks.push({callback:e,instrument:r})},t.prototype.removeCallback=function(e,r){var n=this._findCallback(e,r);n<0||this._callbacks.splice(n,1)},t.prototype.addBatchCallback=function(e,r){var n=new Set(r.filter(ft));if(n.size===0){l.diag.error("BatchObservableCallback is not associated with valid instruments",r);return}var o=this._findBatchCallback(e,n);o>=0||this._batchCallbacks.push({callback:e,instruments:n})},t.prototype.removeBatchCallback=function(e,r){var n=new Set(r.filter(ft)),o=this._findBatchCallback(e,n);o<0||this._batchCallbacks.splice(o,1)},t.prototype.observe=function(e,r){return Pn(this,void 0,void 0,function(){var n,o,i,s;return In(this,function(u){switch(u.label){case 0:return n=this._observeCallbacks(e,r),o=this._observeBatchCallbacks(e,r),[4,ia(La(La([],ba(n),!1),ba(o),!1))];case 1:return i=u.sent(),s=i.filter(oa).map(function(c){return c.reason}),[2,s]}})})},t.prototype._observeCallbacks=function(e,r){var n=this;return this._callbacks.map(function(o){var i=o.callback,s=o.instrument;return Pn(n,void 0,void 0,function(){var u,c;return In(this,function(a){switch(a.label){case 0:return u=new Oa(s._descriptor.name,s._descriptor.valueType),c=Promise.resolve(i(u)),r!=null&&(c=vn(c,r)),[4,c];case 1:return a.sent(),s._metricStorages.forEach(function(f){f.record(u._buffer,e)}),[2]}})})})},t.prototype._observeBatchCallbacks=function(e,r){var n=this;return this._batchCallbacks.map(function(o){var i=o.callback,s=o.instruments;return Pn(n,void 0,void 0,function(){var u,c;return In(this,function(a){switch(a.label){case 0:return u=new Ra,c=Promise.resolve(i(u)),r!=null&&(c=vn(c,r)),[4,c];case 1:return a.sent(),s.forEach(function(f){var p=u._buffer.get(f);p!=null&&f._metricStorages.forEach(function(_){_.record(p,e)})}),[2]}})})})},t.prototype._findCallback=function(e,r){return this._callbacks.findIndex(function(n){return n.callback===e&&n.instrument===r})},t.prototype._findBatchCallback=function(e,r){return this._batchCallbacks.findIndex(function(n){return n.callback===e&&aa(n.instruments,r)})},t}();var cf=function(){var t=function(e,r){return t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(n,o){n.__proto__=o}||function(n,o){for(var i in o)Object.prototype.hasOwnProperty.call(o,i)&&(n[i]=o[i])},t(e,r)};return function(e,r){if(typeof r!="function"&&r!==null)throw new TypeError("Class extends value "+String(r)+" is not a constructor or null");t(e,r);function n(){this.constructor=e}e.prototype=r===null?Object.create(r):(n.prototype=r.prototype,new n)}}(),Ia=function(t){cf(e,t);function e(r,n,o,i){var s=t.call(this,r)||this;return s._attributesProcessor=o,s._deltaMetricStorage=new fr(n),s._temporalMetricStorage=new pr(n,i),s}return e.prototype.record=function(r,n,o,i){n=this._attributesProcessor.process(n,o),this._deltaMetricStorage.record(r,n,o,i)},e.prototype.collect=function(r,n){var o=this._deltaMetricStorage.collect();return this._temporalMetricStorage.buildMetrics(r,this._instrumentDescriptor,o,n)},e}(lr);var Ca=function(){var t=function(e,r){return t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(n,o){n.__proto__=o}||function(n,o){for(var i in o)Object.prototype.hasOwnProperty.call(o,i)&&(n[i]=o[i])},t(e,r)};return function(e,r){if(typeof r!="function"&&r!==null)throw new TypeError("Class extends value "+String(r)+" is not a constructor or null");t(e,r);function n(){this.constructor=e}e.prototype=r===null?Object.create(r):(n.prototype=r.prototype,new n)}}(),dr=function(){function t(){}return t.Noop=function(){return ff},t}();var lf=function(t){Ca(e,t);function e(){return t!==null&&t.apply(this,arguments)||this}return e.prototype.process=function(r,n){return r},e}(dr);var Jh=function(t){Ca(e,t);function e(r){var n=t.call(this)||this;return n._allowedAttributeNames=r,n}return e.prototype.process=function(r,n){var o=this,i={};return Object.keys(r).filter(function(s){return o._allowedAttributeNames.includes(s)}).forEach(function(s){return i[s]=r[s]}),i},e}(dr);var ff=new lf;var pf=function(t,e,r,n){function o(i){return i instanceof r?i:new r(function(s){s(i)})}return new(r||(r=Promise))(function(i,s){function u(f){try{a(n.next(f))}catch(p){s(p)}}function c(f){try{a(n.throw(f))}catch(p){s(p)}}function a(f){f.done?i(f.value):o(f.value).then(u,c)}a((n=n.apply(t,e||[])).next())})},df=function(t,e){var r={label:0,sent:function(){if(i[0]&1)throw i[1];return i[1]},trys:[],ops:[]},n,o,i,s;return s={next:u(0),throw:u(1),return:u(2)},typeof Symbol=="function"&&(s[Symbol.iterator]=function(){return this}),s;function u(a){return function(f){return c([a,f])}}function c(a){if(n)throw new TypeError("Generator is already executing.");for(;r;)try{if(n=1,o&&(i=a[0]&2?o.return:a[0]?o.throw||((i=o.return)&&i.call(o),0):o.next)&&!(i=i.call(o,a[1])).done)return i;switch(o=0,i&&(a=[a[0]&2,i.value]),a[0]){case 0:case 1:i=a;break;case 4:return r.label++,{value:a[1],done:!1};case 5:r.label++,o=a[1],a=[0];continue;case 7:a=r.ops.pop(),r.trys.pop();continue;default:if(i=r.trys,!(i=i.length>0&&i[i.length-1])&&(a[0]===6||a[0]===2)){r=0;continue}if(a[0]===3&&(!i||a[1]>i[0]&&a[1]<i[3])){r.label=a[1];break}if(a[0]===6&&r.label<i[1]){r.label=i[1],i=a;break}if(i&&r.label<i[2]){r.label=i[2],r.ops.push(a);break}i[2]&&r.ops.pop(),r.trys.pop();continue}a=e.call(t,r)}catch(f){a=[6,f],o=0}finally{n=i=0}if(a[0]&5)throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}},_f=function(t,e){var r=typeof Symbol=="function"&&t[Symbol.iterator];if(!r)return t;var n=r.call(t),o,i=[],s;try{for(;(e===void 0||e-- >0)&&!(o=n.next()).done;)i.push(o.value)}catch(u){s={error:u}}finally{try{o&&!o.done&&(r=n.return)&&r.call(n)}finally{if(s)throw s.error}}return i},Na=function(){function t(e,r){this._meterProviderSharedState=e,this._instrumentationScope=r,this.metricStorageRegistry=new va,this.observableRegistry=new Pa,this.meter=new Ta(this)}return t.prototype.registerMetricStorage=function(e){var r=this._registerMetricStorage(e,Ia);return r.length===1?r[0]:new Aa(r)},t.prototype.registerAsyncMetricStorage=function(e){var r=this._registerMetricStorage(e,ya);return r},t.prototype.collect=function(e,r,n){return pf(this,void 0,void 0,function(){var o,i,s;return df(this,function(u){switch(u.label){case 0:return[4,this.observableRegistry.observe(r,n?.timeoutMillis)];case 1:return o=u.sent(),i=this.metricStorageRegistry.getStorages(e),i.length===0?[2,null]:(s=i.map(function(c){return c.collect(e,r)}).filter(ta),s.length===0?[2,{errors:o}]:[2,{scopeMetrics:{scope:this._instrumentationScope,metrics:s},errors:o}])}})})},t.prototype._registerMetricStorage=function(e,r){var n=this,o=this._meterProviderSharedState.viewRegistry.findViews(e,this._instrumentationScope),i=o.map(function(c){var a=ua(c,e),f=n.metricStorageRegistry.findOrUpdateCompatibleStorage(a);if(f!=null)return f;var p=c.aggregation.createAggregator(a),_=new r(a,p,c.attributesProcessor,n._meterProviderSharedState.metricCollectors);return n.metricStorageRegistry.register(_),_});if(i.length===0){var s=this._meterProviderSharedState.selectAggregations(e.type),u=s.map(function(c){var a=_f(c,2),f=a[0],p=a[1],_=n.metricStorageRegistry.findOrUpdateCompatibleCollectorStorage(f,e);if(_!=null)return _;var S=p.createAggregator(e),x=new r(e,S,dr.Noop(),[f]);return n.metricStorageRegistry.registerForCollector(f,x),x});i=i.concat(u)}return i},t}();var hf=function(t){var e=typeof Symbol=="function"&&Symbol.iterator,r=e&&t[e],n=0;if(r)return r.call(t);if(t&&typeof t.length=="number")return{next:function(){return t&&n>=t.length&&(t=void 0),{value:t&&t[n++],done:!t}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")},wa=function(){function t(e){this.resource=e,this.viewRegistry=new la,this.metricCollectors=[],this.meterSharedStates=new Map}return t.prototype.getMeterSharedState=function(e){var r=na(e),n=this.meterSharedStates.get(r);return n==null&&(n=new Na(this,e),this.meterSharedStates.set(r,n)),n},t.prototype.selectAggregations=function(e){var r,n,o=[];try{for(var i=hf(this.metricCollectors),s=i.next();!s.done;s=i.next()){var u=s.value;o.push([u,u.selectAggregation(e)])}}catch(c){r={error:c}}finally{try{s&&!s.done&&(n=i.return)&&n.call(i)}finally{if(r)throw r.error}}return o},t}();var Ma=g(I()),_r=function(t,e,r,n){function o(i){return i instanceof r?i:new r(function(s){s(i)})}return new(r||(r=Promise))(function(i,s){function u(f){try{a(n.next(f))}catch(p){s(p)}}function c(f){try{a(n.throw(f))}catch(p){s(p)}}function a(f){f.done?i(f.value):o(f.value).then(u,c)}a((n=n.apply(t,e||[])).next())})},hr=function(t,e){var r={label:0,sent:function(){if(i[0]&1)throw i[1];return i[1]},trys:[],ops:[]},n,o,i,s;return s={next:u(0),throw:u(1),return:u(2)},typeof Symbol=="function"&&(s[Symbol.iterator]=function(){return this}),s;function u(a){return function(f){return c([a,f])}}function c(a){if(n)throw new TypeError("Generator is already executing.");for(;r;)try{if(n=1,o&&(i=a[0]&2?o.return:a[0]?o.throw||((i=o.return)&&i.call(o),0):o.next)&&!(i=i.call(o,a[1])).done)return i;switch(o=0,i&&(a=[a[0]&2,i.value]),a[0]){case 0:case 1:i=a;break;case 4:return r.label++,{value:a[1],done:!1};case 5:r.label++,o=a[1],a=[0];continue;case 7:a=r.ops.pop(),r.trys.pop();continue;default:if(i=r.trys,!(i=i.length>0&&i[i.length-1])&&(a[0]===6||a[0]===2)){r=0;continue}if(a[0]===3&&(!i||a[1]>i[0]&&a[1]<i[3])){r.label=a[1];break}if(a[0]===6&&r.label<i[1]){r.label=i[1],i=a;break}if(i&&r.label<i[2]){r.label=i[2],r.ops.push(a);break}i[2]&&r.ops.pop(),r.trys.pop();continue}a=e.call(t,r)}catch(f){a=[6,f],o=0}finally{n=i=0}if(a[0]&5)throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}},Ef=function(t,e){var r=typeof Symbol=="function"&&t[Symbol.iterator];if(!r)return t;var n=r.call(t),o,i=[],s;try{for(;(e===void 0||e-- >0)&&!(o=n.next()).done;)i.push(o.value)}catch(u){s={error:u}}finally{try{o&&!o.done&&(r=n.return)&&r.call(n)}finally{if(s)throw s.error}}return i},mf=function(t,e,r){if(r||arguments.length===2)for(var n=0,o=e.length,i;n<o;n++)(i||!(n in e))&&(i||(i=Array.prototype.slice.call(e,0,n)),i[n]=e[n]);return t.concat(i||Array.prototype.slice.call(e))},xa=function(){function t(e,r){this._sharedState=e,this._metricReader=r}return t.prototype.collect=function(e){return _r(this,void 0,void 0,function(){var r,n,o,i,s=this;return hr(this,function(u){switch(u.label){case 0:return r=(0,Ma.millisToHrTime)(Date.now()),n=[],o=[],i=Array.from(this._sharedState.meterSharedStates.values()).map(function(c){return _r(s,void 0,void 0,function(){var a;return hr(this,function(f){switch(f.label){case 0:return[4,c.collect(this,r,e)];case 1:return a=f.sent(),a?.scopeMetrics!=null&&n.push(a.scopeMetrics),a?.errors!=null&&o.push.apply(o,mf([],Ef(a.errors),!1)),[2]}})})}),[4,Promise.all(i)];case 1:return u.sent(),[2,{resourceMetrics:{resource:this._sharedState.resource,scopeMetrics:n},errors:o}]}})})},t.prototype.forceFlush=function(e){return _r(this,void 0,void 0,function(){return hr(this,function(r){switch(r.label){case 0:return[4,this._metricReader.forceFlush(e)];case 1:return r.sent(),[2]}})})},t.prototype.shutdown=function(e){return _r(this,void 0,void 0,function(){return hr(this,function(r){switch(r.label){case 0:return[4,this._metricReader.shutdown(e)];case 1:return r.sent(),[2]}})})},t.prototype.selectAggregationTemporality=function(e){return this._metricReader.selectAggregationTemporality(e)},t.prototype.selectAggregation=function(e){return this._metricReader.selectAggregation(e)},t}();var Da=function(t,e,r,n){function o(i){return i instanceof r?i:new r(function(s){s(i)})}return new(r||(r=Promise))(function(i,s){function u(f){try{a(n.next(f))}catch(p){s(p)}}function c(f){try{a(n.throw(f))}catch(p){s(p)}}function a(f){f.done?i(f.value):o(f.value).then(u,c)}a((n=n.apply(t,e||[])).next())})},Ua=function(t,e){var r={label:0,sent:function(){if(i[0]&1)throw i[1];return i[1]},trys:[],ops:[]},n,o,i,s;return s={next:u(0),throw:u(1),return:u(2)},typeof Symbol=="function"&&(s[Symbol.iterator]=function(){return this}),s;function u(a){return function(f){return c([a,f])}}function c(a){if(n)throw new TypeError("Generator is already executing.");for(;r;)try{if(n=1,o&&(i=a[0]&2?o.return:a[0]?o.throw||((i=o.return)&&i.call(o),0):o.next)&&!(i=i.call(o,a[1])).done)return i;switch(o=0,i&&(a=[a[0]&2,i.value]),a[0]){case 0:case 1:i=a;break;case 4:return r.label++,{value:a[1],done:!1};case 5:r.label++,o=a[1],a=[0];continue;case 7:a=r.ops.pop(),r.trys.pop();continue;default:if(i=r.trys,!(i=i.length>0&&i[i.length-1])&&(a[0]===6||a[0]===2)){r=0;continue}if(a[0]===3&&(!i||a[1]>i[0]&&a[1]<i[3])){r.label=a[1];break}if(a[0]===6&&r.label<i[1]){r.label=i[1],i=a;break}if(i&&r.label<i[2]){r.label=i[2],r.ops.push(a);break}i[2]&&r.ops.pop(),r.trys.pop();continue}a=e.call(t,r)}catch(f){a=[6,f],o=0}finally{n=i=0}if(a[0]&5)throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}},Tf=function(t){var e=typeof Symbol=="function"&&Symbol.iterator,r=e&&t[e],n=0;if(r)return r.call(t);if(t&&typeof t.length=="number")return{next:function(){return t&&n>=t.length&&(t=void 0),{value:t&&t[n++],done:!t}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")},Cn=function(){function t(e){var r,n,o;this._shutdown=!1;var i=F.default().merge((o=e?.resource)!==null&&o!==void 0?o:F.empty());if(this._sharedState=new wa(i),e?.views!=null&&e.views.length>0)try{for(var s=Tf(e.views),u=s.next();!u.done;u=s.next()){var c=u.value;this._sharedState.viewRegistry.addView(c)}}catch(a){r={error:a}}finally{try{u&&!u.done&&(n=s.return)&&n.call(s)}finally{if(r)throw r.error}}}return t.prototype.getMeter=function(e,r,n){return r===void 0&&(r=""),n===void 0&&(n={}),this._shutdown?(l.diag.warn("A shutdown MeterProvider cannot provide a Meter"),(0,l.createNoopMeter)()):this._sharedState.getMeterSharedState({name:e,version:r,schemaUrl:n.schemaUrl}).meter},t.prototype.addMetricReader=function(e){var r=new xa(this._sharedState,e);e.setMetricProducer(r),this._sharedState.metricCollectors.push(r)},t.prototype.shutdown=function(e){return Da(this,void 0,void 0,function(){return Ua(this,function(r){switch(r.label){case 0:return this._shutdown?(l.diag.warn("shutdown may only be called once per MeterProvider"),[2]):(this._shutdown=!0,[4,Promise.all(this._sharedState.metricCollectors.map(function(n){return n.shutdown(e)}))]);case 1:return r.sent(),[2]}})})},t.prototype.forceFlush=function(e){return Da(this,void 0,void 0,function(){return Ua(this,function(r){switch(r.label){case 0:return this._shutdown?(l.diag.warn("invalid attempt to force flush after MeterProvider shutdown"),[2]):[4,Promise.all(this._sharedState.metricCollectors.map(function(n){return n.forceFlush(e)}))];case 1:return r.sent(),[2]}})})},t}();var ci=g(me(),1),wr=g(Pt(),1),yu=g(Ha(),1),Pe=g(I(),1);E();var Of=Symbol.for("@vercel/request-context");function ne(){return globalThis[Of]?.get()}var Mn=g(me(),1);function Tr(t){return Object.fromEntries(Object.entries(t).filter(([e,r])=>r!==void 0))}function Fa(t){return t?t.split("::").at(-1):void 0}function ja(t=ne(),e){if(!t)return;let r=e?bf(e,t.headers):void 0;return Tr({[Mn.SemanticAttributes.HTTP_HOST]:t.headers.host,[Mn.SemanticAttributes.HTTP_USER_AGENT]:t.headers["user-agent"],"http.referer":t.headers.referer,"vercel.request_id":Fa(t.headers["x-vercel-id"]),"vercel.matched_path":t.headers["x-matched-path"],"vercel.edge_region":process.env.VERCEL_REGION,...r})}var Rf={keys(t){return[]},get(t,e){return t[e.toLocaleLowerCase()]}};function bf(t,e){if(typeof t=="function")return t(e,Rf);let r={};for(let[n,o]of Object.entries(t)){let i=e[o.toLocaleLowerCase()];i!==void 0&&(r[n]=i)}return r}E();function _t(t){return(t&l.TraceFlags.SAMPLED)!==0}var Sr=class{constructor(e,r){this.processors=e;this.attributesFromHeaders=r;this.rootSpanIds=new Map;this.waitSpanEnd=new Map}forceFlush(){return Promise.all(this.processors.map(e=>e.forceFlush().catch(r=>{l.diag.error("@vercel/otel: forceFlush failed:",r)}))).then(()=>{})}shutdown(){return Promise.all(this.processors.map(e=>e.shutdown().catch(()=>{}))).then(()=>{})}onStart(e,r){let{traceId:n,spanId:o,traceFlags:i}=e.spanContext(),s=!e.parentSpanId||!this.rootSpanIds.has(n);if(s?this.rootSpanIds.set(n,{rootSpanId:o,open:[]}):this.rootSpanIds.get(n)?.open.push(e),s&&_t(i)){let u=ne(),c=ja(u,this.attributesFromHeaders);c&&e.setAttributes(c),u&&u.waitUntil(async()=>{if(this.rootSpanIds.has(n)){let a=new Promise(p=>{this.waitSpanEnd.set(n,p)}),f;await Promise.race([a,new Promise(p=>{f=setTimeout(()=>{this.waitSpanEnd.delete(n),p(void 0)},50)})]),f&&clearTimeout(f)}return this.forceFlush()})}for(let u of this.processors)u.onStart(e,r)}onEnd(e){let{traceId:r,spanId:n,traceFlags:o}=e.spanContext(),i=_t(o),s=this.rootSpanIds.get(r),u=s?.rootSpanId===n;if(i){let c=Pf(e);c&&Object.assign(e.attributes,c)}if(u){if(this.rootSpanIds.delete(r),s.open.length>0){for(let c of s.open)if(!c.ended&&c.spanContext().spanId!==n)try{c.end()}catch(a){l.diag.error("@vercel/otel: onEnd failed:",a)}}}else if(s)for(let c=0;c<s.open.length;c++)s.open[c]?.spanContext().spanId===n&&s.open.splice(c,1);for(let c of this.processors)c.onEnd(e);if(u){let c=this.waitSpanEnd.get(r);c&&(this.waitSpanEnd.delete(r),c())}}},Lf={[l.SpanKind.INTERNAL]:"internal",[l.SpanKind.SERVER]:"server",[l.SpanKind.CLIENT]:"client",[l.SpanKind.PRODUCER]:"producer",[l.SpanKind.CONSUMER]:"consumer"};function Pf(t){let{kind:e,attributes:r}=t,{"operation.name":n,"resource.name":o,"span.type":i,"next.span_type":s,"http.method":u,"http.route":c}=r;if(n)return;let a=o??(u&&typeof u=="string"&&c&&typeof c=="string"?`${u} ${c}`:c);if(t.kind===l.SpanKind.SERVER&&u&&c&&typeof u=="string"&&typeof c=="string")return{"operation.name":"web.request","resource.name":a};let f=t.instrumentationLibrary.name,p=s??i;if(p&&typeof p=="string"){let _=ka(f,p);return c?{"operation.name":_,"resource.name":a}:{"operation.name":_}}return{"operation.name":ka(f,e===l.SpanKind.INTERNAL?"":Lf[e])}}function ka(t,e){if(!t)return e;let r=t.replace(/[ @./]/g,"_");return r.startsWith("_")&&(r=r.slice(1)),e?`${r}.${e}`:r}var is=g(Hn(),1);var ns=g(rs(),1);E();var Qe=class extends ns.OTLPExporterBase{constructor(e={}){super(e),e.headers&&(this._headers=e.headers)}onShutdown(){l.diag.debug("@vercel/otel/otlp: onShutdown")}onInit(){l.diag.debug("@vercel/otel/otlp: onInit")}send(e,r,n){if(this._shutdownOnce.isCalled){l.diag.debug("@vercel/otel/otlp: Shutdown already started. Cannot send objects");return}let o=this.convert(e),i,s,u;try{({body:i,contentType:s,headers:u}=this.toMessage(o))}catch(a){l.diag.warn("@vercel/otel/otlp: no proto",a);return}let c=fetch(this.url,{method:"POST",body:i,headers:{...this._headers,...u,"Content-Type":s,"User-Agent":"OTel-OTLP-Exporter-JavaScript/0.46.0"},next:{internal:!0}}).then(a=>{l.diag.debug("@vercel/otel/otlp: onSuccess",a.status,a.statusText),r(),a.arrayBuffer().catch(()=>{})}).catch(a=>{l.diag.error("@vercel/otel/otlp: onError",a),n(a)}).finally(()=>{let a=this._sendingPromises.indexOf(c);this._sendingPromises.splice(a,1)});this._sendingPromises.push(c)}getDefaultUrl(e){throw new Error("Method not implemented.")}};var zf="v1/traces",$f=`http://localhost:4318/${zf}`;function Ar(t){return typeof t.url=="string"?t.url:$f}var Ze=class{constructor(e={}){this.impl=new qn(e)}export(e,r){this.impl.export(e,r)}shutdown(){return this.impl.shutdown()}forceFlush(){return this.impl.forceFlush()}},qn=class extends Qe{convert(e){return(0,is.createExportTraceServiceRequest)(e,{useHex:!0,useLongBits:!1})}toMessage(e){return{body:JSON.stringify(e),contentType:"application/json"}}getDefaultUrl(e){return Ar(e)}};var au=g(Hn(),1);var nu=g(ru(),1);function iu(t){let e=new nu.Writer;return sp(t,e),e.finish()}function sp(t,e){if(t.resourceSpans!=null&&t.resourceSpans.length)for(let r=0;r<t.resourceSpans.length;++r)up(t.resourceSpans[r],e.uint32(10).fork()).ldelim();return e}function up(t,e){if(t.resource!=null&&cp(t.resource,e.uint32(10).fork()).ldelim(),t.scopeSpans!=null&&t.scopeSpans.length)for(let r=0;r<t.scopeSpans.length;++r)lp(t.scopeSpans[r],e.uint32(18).fork()).ldelim();return t.schemaUrl!=null&&e.uint32(26).string(t.schemaUrl),e}function cp(t,e){if(t.attributes!=null&&t.attributes.length)for(let r=0;r<t.attributes.length;++r)et(t.attributes[r],e.uint32(10).fork()).ldelim();return t.droppedAttributesCount!=null&&e.uint32(16).uint32(t.droppedAttributesCount),e}function lp(t,e){if(t.scope!=null&&dp(t.scope,e.uint32(10).fork()).ldelim(),t.spans!=null&&t.spans.length)for(let r=0;r<t.spans.length;++r)_p(t.spans[r],e.uint32(18).fork()).ldelim();return t.schemaUrl!=null&&e.uint32(26).string(t.schemaUrl),e}function et(t,e){return t.key!=null&&e.uint32(10).string(t.key),t.value!=null&&ou(t.value,e.uint32(18).fork()).ldelim(),e}function ou(t,e){return t.stringValue!=null&&e.uint32(10).string(t.stringValue),t.boolValue!=null&&e.uint32(16).bool(t.boolValue),t.intValue!=null&&e.uint32(24).int64(t.intValue),t.doubleValue!=null&&e.uint32(33).double(t.doubleValue),t.arrayValue!=null&&fp(t.arrayValue,e.uint32(42).fork()).ldelim(),t.kvlistValue!=null&&pp(t.kvlistValue,e.uint32(50).fork()).ldelim(),t.bytesValue!=null&&e.uint32(58).bytes(t.bytesValue),e}function fp(t,e){if(t.values!=null&&t.values.length)for(let r=0;r<t.values.length;++r)ou(t.values[r],e.uint32(10).fork()).ldelim();return e}function pp(t,e){if(t.values!=null&&t.values.length)for(let r=0;r<t.values.length;++r)et(t.values[r],e.uint32(10).fork()).ldelim();return e}function dp(t,e){if(t.name!=null&&e.uint32(10).string(t.name),t.version!=null&&e.uint32(18).string(t.version),t.attributes!=null&&t.attributes.length)for(let r=0;r<t.attributes.length;++r)et(t.attributes[r],e.uint32(26).fork()).ldelim();return t.droppedAttributesCount!=null&&e.uint32(32).uint32(t.droppedAttributesCount),e}function _p(t,e){if(t.traceId!=null&&e.uint32(10).bytes(t.traceId),t.spanId!=null&&e.uint32(18).bytes(t.spanId),t.traceState!=null&&e.uint32(26).string(t.traceState),t.parentSpanId!=null&&e.uint32(34).bytes(t.parentSpanId),t.name!=null&&e.uint32(42).string(t.name),t.kind!=null&&e.uint32(48).int32(t.kind),t.startTimeUnixNano!=null&&e.uint32(57).fixed64(t.startTimeUnixNano),t.endTimeUnixNano!=null&&e.uint32(65).fixed64(t.endTimeUnixNano),t.attributes!=null&&t.attributes.length)for(let r=0;r<t.attributes.length;++r)et(t.attributes[r],e.uint32(74).fork()).ldelim();if(t.droppedAttributesCount!=null&&e.uint32(80).uint32(t.droppedAttributesCount),t.events!=null&&t.events.length)for(let r=0;r<t.events.length;++r)Ep(t.events[r],e.uint32(90).fork()).ldelim();if(t.droppedEventsCount!=null&&e.uint32(96).uint32(t.droppedEventsCount),t.links!=null&&t.links.length)for(let r=0;r<t.links.length;++r)mp(t.links[r],e.uint32(106).fork()).ldelim();return t.droppedLinksCount!=null&&e.uint32(112).uint32(t.droppedLinksCount),t.status!=null&&hp(t.status,e.uint32(122).fork()).ldelim(),e}function hp(t,e){return t.message!=null&&e.uint32(18).string(t.message),t.code!=null&&e.uint32(24).int32(t.code),e}function Ep(t,e){if(t.timeUnixNano!=null&&e.uint32(9).fixed64(t.timeUnixNano),t.name!=null&&e.uint32(18).string(t.name),t.attributes!=null&&t.attributes.length)for(let r=0;r<t.attributes.length;++r)et(t.attributes[r],e.uint32(26).fork()).ldelim();return t.droppedAttributesCount!=null&&e.uint32(32).uint32(t.droppedAttributesCount),e}function mp(t,e){if(t.traceId!=null&&e.uint32(10).bytes(t.traceId),t.spanId!=null&&e.uint32(18).bytes(t.spanId),t.traceState!=null&&e.uint32(26).string(t.traceState),t.attributes!=null&&t.attributes.length)for(let r=0;r<t.attributes.length;++r)et(t.attributes[r],e.uint32(34).fork()).ldelim();return t.droppedAttributesCount!=null&&e.uint32(40).uint32(t.droppedAttributesCount),e}var Ve=class{constructor(e={}){this.impl=new ii(e)}export(e,r){this.impl.export(e,r)}shutdown(){return this.impl.shutdown()}forceFlush(){return this.impl.forceFlush()}},ii=class extends Qe{convert(e){return(0,au.createExportTraceServiceRequest)(e,void 0)}toMessage(e){return{body:iu(e),contentType:"application/x-protobuf",headers:{accept:"application/x-protobuf"}}}getDefaultUrl(e){return Ar(e)}};E();var fe=g(me(),1);function su(t,e){return t.replace(/\{(?<temp1>[^{}]+)\}/g,(r,n)=>{let o=e[n];return o!==void 0?String(o):r})}var tt=class{constructor(e={}){this.instrumentationName="@vercel/otel/fetch";this.instrumentationVersion="1.0.0";this.config=e}getConfig(){return this.config}setConfig(){}setTracerProvider(e){this.tracerProvider=e}setMeterProvider(){}enable(){this.disable();let{tracerProvider:e}=this;if(!e)return;let r=e.getTracer(this.instrumentationName,this.instrumentationVersion),n=this.config.ignoreUrls??[],o=(O,B)=>{if(B?.opentelemetry?.ignore!==void 0)return B.opentelemetry.ignore;if(n.length===0)return!1;let m=O.toString();return n.some(v=>typeof v=="string"?v==="*"?!0:m.startsWith(v):v.test(m))},i=process.env.VERCEL_URL||process.env.NEXT_PUBLIC_VERCEL_URL||null,s=process.env.VERCEL_BRANCH_URL||process.env.NEXT_PUBLIC_VERCEL_BRANCH_URL||null,u=this.config.propagateContextUrls??[],c=this.config.dontPropagateContextUrls??[],a=this.config.resourceNameTemplate,{attributesFromRequestHeaders:f,attributesFromResponseHeaders:p}=this.config,_=(O,B)=>{if(B?.opentelemetry?.propagateContext)return B.opentelemetry.propagateContext;let m=O.toString();return c.length>0&&c.some(v=>typeof v=="string"?v==="*"?!0:m.startsWith(v):v.test(m))?!1:i&&O.protocol==="https:"&&(O.host===i||O.host===s||O.host===ne()?.headers.host)||!i&&O.protocol==="http:"&&O.hostname==="localhost"?!0:u.some(v=>typeof v=="string"?v==="*"?!0:m.startsWith(v):v.test(m))};process.env.NEXT_OTEL_FETCH_DISABLED="1";let S=globalThis.fetch;this.originalFetch=S;let x=async(O,B)=>{let m=B;if(m?.next?.internal)return S(O,m);let v=new Request(O instanceof Request?O.clone():O,m),Y=new URL(v.url);if(o(Y,m))return S(O,m);let gt={[fe.SemanticAttributes.HTTP_METHOD]:v.method,[fe.SemanticAttributes.HTTP_URL]:v.url,[fe.SemanticAttributes.HTTP_HOST]:Y.host,[fe.SemanticAttributes.HTTP_SCHEME]:Y.protocol.replace(":",""),[fe.SemanticAttributes.NET_PEER_NAME]:Y.hostname,[fe.SemanticAttributes.NET_PEER_PORT]:Y.port},Mr=a?su(a,gt):Sp(v.url),yt=m?.opentelemetry?.spanName??`fetch ${v.method} ${v.url}`,li=l.context.active(),D=r.startSpan(yt,{kind:l.SpanKind.CLIENT,attributes:{...gt,"operation.name":`fetch.${v.method}`,"resource.name":Mr,...m?.opentelemetry?.attributes}},li);if(!D.isRecording()||!_t(D.spanContext().traceFlags))return D.end(),S(O,m);if(_(Y,m)){let He=l.trace.setSpan(li,D);l.propagation.inject(He,v.headers,Tp)}f&&uu(D,f,v.headers);try{let He=Date.now();m?.body&&m.body instanceof FormData&&v.headers.delete("content-type");let pe=await S(O,{...m,headers:v.headers}),Au=Date.now()-He;return D.setAttribute(fe.SemanticAttributes.HTTP_STATUS_CODE,pe.status),D.setAttribute("http.response_time",Au),p&&uu(D,p,pe.headers),pe.status>=500&&oi(D,`Status: ${pe.status} (${pe.statusText})`),pe.body?gp(pe).then(xr=>{D.isRecording()&&(D.setAttribute(fe.SemanticAttributes.HTTP_RESPONSE_CONTENT_LENGTH_UNCOMPRESSED,xr),D.end())},xr=>{D.isRecording()&&(oi(D,xr),D.end())}):D.end(),pe}catch(He){throw oi(D,He),D.end(),He}};globalThis.fetch=x}disable(){this.originalFetch&&(globalThis.fetch=this.originalFetch)}},Tp={set(t,e,r){t.set(e,r)}};function Sp(t){let e=t.indexOf("?");return e===-1?t:t.substring(0,e)}function gp(t){let e=0,n=t.clone().body?.getReader();if(!n)return Promise.resolve(0);let o=()=>n.read().then(({done:i,value:s})=>{if(!i)return e+=s.byteLength,o()});return o().then(()=>e)}function oi(t,e){if(e instanceof Error)t.recordException(e),t.setStatus({code:l.SpanStatusCode.ERROR,message:e.message});else{let r=String(e);t.setStatus({code:l.SpanStatusCode.ERROR,message:r})}}function uu(t,e,r){for(let[n,o]of Object.entries(e)){let i=r.get(o);i!==null&&t.setAttribute(n,i)}}E();var cu=g(I(),1),yp="00",ai="traceparent",si="tracestate",St=class{fields(){return[ai,si]}inject(e,r,n){let o=l.trace.getSpanContext(e);if(!o||(0,cu.isTracingSuppressed)(e)||!(0,l.isSpanContextValid)(o))return;let i=`${yp}-${o.traceId}-${o.spanId}-0${Number(o.traceFlags||0).toString(16)}`;n.set(r,ai,i),o.traceState&&n.set(r,si,o.traceState.serialize())}extract(e,r,n){let o=n.get(r,ai);if(!o)return e;let i=Array.isArray(o)?o[0]:o;if(typeof i!="string")return e;let s=vp(i);if(!s)return e;s.isRemote=!0;let u=n.get(r,si);if(u){let c=Array.isArray(u)?u.join(","):u;s.traceState=(0,l.createTraceState)(typeof c=="string"?c:void 0)}return l.trace.setSpanContext(e,s)}};function vp(t){let[e,r,n,o,i]=t.split("-");return!e||!r||!n||!o||e.length!==2||r.length!==32||n.length!==16||o.length!==2||e==="00"&&i?null:{traceId:r,spanId:n,traceFlags:parseInt(o,16)}}E();var Pr=class{fields(){return[]}inject(){}extract(e){let r=ne();if(!r?.telemetry)return l.diag.warn("@vercel/otel: Vercel telemetry extension not found."),e;let{rootSpanContext:n}=r.telemetry;return n?(l.diag.debug("@vercel/otel: Extracted root SpanContext from Vercel request context.",n),l.trace.setSpanContext(e,{...n,isRemote:!0,traceFlags:n.traceFlags||l.TraceFlags.SAMPLED})):e}};E();var Ir=g(I(),1);var rt=g(I()),Ap=BigInt(1e9);function fu(t){return BigInt(t[0])*Ap+BigInt(t[1])}function Op(t){var e=Number(BigInt.asUintN(32,t)),r=Number(BigInt.asUintN(32,t>>BigInt(32)));return{low:e,high:r}}function pu(t){var e=fu(t);return Op(e)}function Rp(t){var e=fu(t);return e.toString()}var bp=typeof BigInt<"u"?Rp:rt.hrTimeToNanoseconds;function lu(t){return t}function du(t){if(t!==void 0)return(0,rt.hexToBase64)(t)}var Lp={encodeHrTime:pu,encodeSpanContext:rt.hexToBase64,encodeOptionalSpanContext:du};function _u(t){var e,r;if(t===void 0)return Lp;var n=(e=t.useLongBits)!==null&&e!==void 0?e:!0,o=(r=t.useHex)!==null&&r!==void 0?r:!1;return{encodeHrTime:n?pu:bp,encodeSpanContext:o?lu:rt.hexToBase64,encodeOptionalSpanContext:o?lu:du}}var Pp=function(t,e){var r=typeof Symbol=="function"&&t[Symbol.iterator];if(!r)return t;var n=r.call(t),o,i=[],s;try{for(;(e===void 0||e-- >0)&&!(o=n.next()).done;)i.push(o.value)}catch(u){s={error:u}}finally{try{o&&!o.done&&(r=n.return)&&r.call(n)}finally{if(s)throw s.error}}return i};function nt(t){return Object.keys(t).map(function(e){return hu(e,t[e])})}function hu(t,e){return{key:t,value:Eu(e)}}function Eu(t){var e=typeof t;return e==="string"?{stringValue:t}:e==="number"?Number.isInteger(t)?{intValue:t}:{doubleValue:t}:e==="boolean"?{boolValue:t}:t instanceof Uint8Array?{bytesValue:t}:Array.isArray(t)?{arrayValue:{values:t.map(Eu)}}:e==="object"&&t!=null?{kvlistValue:{values:Object.entries(t).map(function(r){var n=Pp(r,2),o=n[0],i=n[1];return hu(o,i)})}}:{}}function mu(t,e){var r,n=t.spanContext(),o=t.status;return{traceId:e.encodeSpanContext(n.traceId),spanId:e.encodeSpanContext(n.spanId),parentSpanId:e.encodeOptionalSpanContext(t.parentSpanId),traceState:(r=n.traceState)===null||r===void 0?void 0:r.serialize(),name:t.name,kind:t.kind==null?0:t.kind+1,startTimeUnixNano:e.encodeHrTime(t.startTime),endTimeUnixNano:e.encodeHrTime(t.endTime),attributes:nt(t.attributes),droppedAttributesCount:t.droppedAttributesCount,events:t.events.map(function(i){return Cp(i,e)}),droppedEventsCount:t.droppedEventsCount,status:{code:o.code,message:o.message},links:t.links.map(function(i){return Ip(i,e)}),droppedLinksCount:t.droppedLinksCount}}function Ip(t,e){var r;return{attributes:t.attributes?nt(t.attributes):[],spanId:e.encodeSpanContext(t.context.spanId),traceId:e.encodeSpanContext(t.context.traceId),traceState:(r=t.context.traceState)===null||r===void 0?void 0:r.serialize(),droppedAttributesCount:t.droppedAttributesCount||0}}function Cp(t,e){return{attributes:t.attributes?nt(t.attributes):[],name:t.name,timeUnixNano:e.encodeHrTime(t.time),droppedAttributesCount:t.droppedAttributesCount||0}}var Np=function(t){var e=typeof Symbol=="function"&&Symbol.iterator,r=e&&t[e],n=0;if(r)return r.call(t);if(t&&typeof t.length=="number")return{next:function(){return t&&n>=t.length&&(t=void 0),{value:t&&t[n++],done:!t}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")},wp=function(t,e){var r=typeof Symbol=="function"&&t[Symbol.iterator];if(!r)return t;var n=r.call(t),o,i=[],s;try{for(;(e===void 0||e-- >0)&&!(o=n.next()).done;)i.push(o.value)}catch(u){s={error:u}}finally{try{o&&!o.done&&(r=n.return)&&r.call(n)}finally{if(s)throw s.error}}return i};function ui(t,e){var r=_u(e);return{resourceSpans:xp(t,r)}}function Mp(t){var e,r,n=new Map;try{for(var o=Np(t),i=o.next();!i.done;i=o.next()){var s=i.value,u=n.get(s.resource);u||(u=new Map,n.set(s.resource,u));var c=s.instrumentationLibrary.name+"@"+(s.instrumentationLibrary.version||"")+":"+(s.instrumentationLibrary.schemaUrl||""),a=u.get(c);a||(a=[],u.set(c,a)),a.push(s)}}catch(f){e={error:f}}finally{try{i&&!i.done&&(r=o.return)&&r.call(o)}finally{if(e)throw e.error}}return n}function xp(t,e){for(var r=Mp(t),n=[],o=r.entries(),i=o.next();!i.done;){for(var s=wp(i.value,2),u=s[0],c=s[1],a=[],f=c.values(),p=f.next();!p.done;){var _=p.value;if(_.length>0){var S=_[0].instrumentationLibrary,x=S.name,O=S.version,B=S.schemaUrl,m=_.map(function(Y){return mu(Y,e)});a.push({scope:{name:x,version:O},spans:m,schemaUrl:B})}p=f.next()}var v={resource:{attributes:nt(u.attributes),droppedAttributesCount:0},scopeSpans:a,schemaUrl:void 0};n.push(v),i=o.next()}return n}var Cr=class{export(e,r){let n=ne();if(!n?.telemetry){l.diag.warn("@vercel/otel: no telemetry context found"),r({code:Ir.ExportResultCode.SUCCESS,error:void 0});return}try{let o=ui(e,{useHex:!0,useLongBits:!1});n.telemetry.reportSpans(o),r({code:Ir.ExportResultCode.SUCCESS,error:void 0})}catch(o){r({code:Ir.ExportResultCode.FAILED,error:o instanceof Error?o:new Error(String(o))})}}shutdown(){return Promise.resolve()}forceFlush(){return Promise.resolve()}};var Dp={ALL:l.DiagLogLevel.ALL,VERBOSE:l.DiagLogLevel.VERBOSE,DEBUG:l.DiagLogLevel.DEBUG,INFO:l.DiagLogLevel.INFO,WARN:l.DiagLogLevel.WARN,ERROR:l.DiagLogLevel.ERROR,NONE:l.DiagLogLevel.NONE},Nr=class{constructor(e={}){this.configuration=e}start(){let e=Up(),r=this.configuration,n=process.env.NEXT_RUNTIME||"nodejs",o=!!e.OTEL_SDK_DISABLED;if(process.env.OTEL_LOG_LEVEL&&l.diag.setLogger(new l.DiagConsoleLogger,{logLevel:Dp[process.env.OTEL_LOG_LEVEL.toUpperCase()]}),o)return;let i=r.idGenerator??new nr,s=r.contextManager??new yu.AsyncLocalStorageContextManager;s.enable(),this.contextManager=s;let u=e.OTEL_SERVICE_NAME||r.serviceName||"app",c=new F(Tr({[ci.SemanticResourceAttributes.SERVICE_NAME]:u,"node.ci":process.env.CI?!0:void 0,"node.env":"production",env:process.env.VERCEL_ENV||process.env.NEXT_PUBLIC_VERCEL_ENV,"vercel.region":process.env.VERCEL_REGION,"vercel.runtime":n,"vercel.sha":process.env.VERCEL_GIT_COMMIT_SHA||process.env.NEXT_PUBLIC_VERCEL_GIT_COMMIT_SHA,"vercel.host":process.env.VERCEL_URL||process.env.NEXT_PUBLIC_VERCEL_URL||void 0,"vercel.branch_host":process.env.VERCEL_BRANCH_URL||process.env.NEXT_PUBLIC_VERCEL_BRANCH_URL||void 0,"vercel.deployment_id":process.env.VERCEL_DEPLOYMENT_ID||void 0,[ci.SemanticResourceAttributes.SERVICE_VERSION]:process.env.VERCEL_DEPLOYMENT_ID,...r.attributes})),a=r.resourceDetectors??[wo];if(r.autoDetectResources??!0){let m={detectors:a};c=c.merge(xo(m))}let p=Gp(r.propagators,r,e),_=Vp(r.traceSampler,e),S=Hp(r.spanProcessors,r,e);S.length===0&&l.diag.warn("@vercel/otel: No span processors configured. No spans will be exported.");let x=r.spanLimits,O=new Go({resource:c,idGenerator:i,sampler:_,spanLimits:x});if(O.addSpanProcessor(new Sr(S,r.attributesFromHeaders)),O.register({contextManager:s,propagator:new Pe.CompositePropagator({propagators:p})}),this.tracerProvider=O,r.logRecordProcessor){let m=new yn({resource:c});this.loggerProvider=m,m.addLogRecordProcessor(r.logRecordProcessor),se.logs.setGlobalLoggerProvider(m)}if(r.metricReader||r.views){let m=new Cn({resource:c,views:r.views??[]});r.metricReader&&m.addMetricReader(r.metricReader),l.metrics.setGlobalMeterProvider(m),this.meterProvider=m}let B=Bp(r.instrumentations,r.instrumentationConfig);this.disableInstrumentations=(0,gu.registerInstrumentations)({instrumentations:B}),l.diag.info("@vercel/otel: started",u,n)}async shutdown(){let e=[];this.tracerProvider&&e.push(this.tracerProvider.shutdown()),this.loggerProvider&&e.push(this.loggerProvider.shutdown()),this.meterProvider&&e.push(this.meterProvider.shutdown()),l.diag.info("@vercel/otel: shutting down",e.length,process.env.NEXT_RUNTIME),await Promise.all(e),this.contextManager&&this.contextManager.disable();let{disableInstrumentations:r}=this;r&&r()}};function Up(){let t=(0,wr.parseEnvironment)(process.env);return{...wr.DEFAULT_ENVIRONMENT,...t}}function Bp(t,e){return(t??["auto"]).map(r=>r==="auto"?(l.diag.debug("@vercel/otel: Configure instrumentations: fetch",e?.fetch),[new tt(e?.fetch)]):r==="fetch"?(l.diag.debug("@vercel/otel: Configure instrumentations: fetch",e?.fetch),new tt(e?.fetch)):r).flat()}function Gp(t,e,r){let n=process.env.OTEL_PROPAGATORS&&r.OTEL_PROPAGATORS&&r.OTEL_PROPAGATORS.length>0?r.OTEL_PROPAGATORS:void 0;return(t??n??["auto"]).map(o=>{if(o==="none")return[];if(o==="auto"){let i=[];return i.push({name:"tracecontext",propagator:new St}),i.push({name:"baggage",propagator:new Pe.W3CBaggagePropagator}),i.push({name:"vercel-runtime",propagator:new Pr}),l.diag.debug(`@vercel/otel: Configure propagators: ${i.map(s=>s.name).join(", ")}`),i.map(s=>s.propagator)}if(o==="tracecontext")return l.diag.debug("@vercel/otel: Configure propagator: tracecontext"),new St;if(o==="baggage")return l.diag.debug("@vercel/otel: Configure propagator: baggage"),new Pe.W3CBaggagePropagator;if(typeof o=="string")throw new Error(`Unknown propagator: "${o}"`);return o}).flat()}var Tu="always_on",it=1;function Vp(t,e){if(t&&typeof t!="string")return t;let r=t&&t!=="auto"?t:e.OTEL_TRACES_SAMPLER||Tu;switch(l.diag.debug("@vercel/otel: Configure sampler: ",r),r){case"always_on":return new X;case"always_off":return new ae;case"parentbased_always_on":return new Se({root:new X});case"parentbased_always_off":return new Se({root:new ae});case"traceidratio":return new Xe(Su(e));case"parentbased_traceidratio":return new Se({root:new Xe(Su(e))});default:return l.diag.error(`@vercel/otel: OTEL_TRACES_SAMPLER value "${String(e.OTEL_TRACES_SAMPLER)} invalid, defaulting to ${Tu}".`),new X}}function Su(t){if(t.OTEL_TRACES_SAMPLER_ARG===void 0||t.OTEL_TRACES_SAMPLER_ARG==="")return l.diag.error(`@vercel/otel: OTEL_TRACES_SAMPLER_ARG is blank, defaulting to ${it}.`),it;l.diag.debug("@vercel/otel: Configure sampler probability: ",t.OTEL_TRACES_SAMPLER_ARG);let e=Number(t.OTEL_TRACES_SAMPLER_ARG);return isNaN(e)?(l.diag.error(`@vercel/otel: OTEL_TRACES_SAMPLER_ARG=${t.OTEL_TRACES_SAMPLER_ARG} was given, but it is invalid, defaulting to ${it}.`),it):e<0||e>1?(l.diag.error(`@vercel/otel: OTEL_TRACES_SAMPLER_ARG=${t.OTEL_TRACES_SAMPLER_ARG} was given, but it is out of range ([0..1]), defaulting to ${it}.`),it):e}function Hp(t,e,r){return[...(t??["auto"]).flatMap(n=>{if(n==="auto"){let o=[new De(new Cr)];if(process.env.VERCEL_OTEL_ENDPOINTS){let i=process.env.VERCEL_OTEL_ENDPOINTS_PORT||"4318",s=process.env.VERCEL_OTEL_ENDPOINTS_PROTOCOL||"http/protobuf";l.diag.debug("@vercel/otel: Configure vercel otel collector on port: ",i,s);let u={url:`http://localhost:${i}/v1/traces`,headers:{}},c=s==="http/protobuf"?new Ve(u):new Ze(u);o.push(new De(c))}else(!e.traceExporter||e.traceExporter==="auto"||r.OTEL_EXPORTER_OTLP_TRACES_ENDPOINT||r.OTEL_EXPORTER_OTLP_ENDPOINT)&&o.push(new De(Fp(r)));return o}return n}).filter(qp),...e.traceExporter&&e.traceExporter!=="auto"?[new De(e.traceExporter)]:[]]}function Fp(t){let e=process.env.OTEL_EXPORTER_OTLP_TRACES_PROTOCOL??process.env.OTEL_EXPORTER_OTLP_PROTOCOL??"http/protobuf",r=kp(t),n={...Pe.baggageUtils.parseKeyPairsIntoRecord(t.OTEL_EXPORTER_OTLP_HEADERS),...Pe.baggageUtils.parseKeyPairsIntoRecord(t.OTEL_EXPORTER_OTLP_TRACES_HEADERS)};switch(l.diag.debug("@vercel/otel: Configure trace exporter: ",e,r,`headers: ${Object.keys(n).join(",")||"<none>"}`),e){case"http/json":return new Ze({url:r,headers:n});case"http/protobuf":return new Ve({url:r,headers:n});default:return l.diag.warn(`@vercel/otel: Unsupported OTLP traces protocol: ${e}. Using http/protobuf.`),new Ve}}var vu="v1/traces",jp=`http://localhost:4318/${vu}`;function kp(t){let e=t.OTEL_EXPORTER_OTLP_TRACES_ENDPOINT;if(e&&typeof e=="string")return e;let r=t.OTEL_EXPORTER_OTLP_ENDPOINT;return r&&typeof r=="string"?`${r}/${vu}`:jp}function qp(t){return t!=null}function hT(t){let e;t?typeof t=="string"?e={serviceName:t}:e=t:e={},new Nr(e).start()}export{tt as FetchInstrumentation,Ze as OTLPHttpJsonTraceExporter,Ve as OTLPHttpProtoTraceExporter,hT as registerOTel};
|
|
17
17
|
//# sourceMappingURL=index.js.map
|