@vercel/otel 1.13.0 → 1.13.1
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 Nu=Object.create;var xr=Object.defineProperty;var wu=Object.getOwnPropertyDe
|
|
|
13
13
|
To resolve the conflict:`,On(a,t))),i=c):l.diag.warn("A view or instrument with the name ",t.name,` has already been registered and is incompatible with another registered view.
|
|
14
14
|
`,`Details:
|
|
15
15
|
`,Rn(a,t),`To resolve the conflict:
|
|
16
|
-
`,On(a,t))}}catch(f){n={error:f}}finally{try{u&&!u.done&&(o=s.return)&&o.call(s)}finally{if(n)throw n.error}}return i},e}();var va=function(){function e(t){this._backingStorages=t}return e.prototype.record=function(t,r,n,o){this._backingStorages.forEach(function(i){i.record(t,r,n,o)})},e}();E();E();var Aa=function(){function e(t,r){this._instrumentName=t,this._valueType=r,this._buffer=new Q}return e.prototype.observe=function(t,r){if(r===void 0&&(r={}),typeof t!="number"){l.diag.warn("non-number value provided to metric "+this._instrumentName+": "+t);return}this._valueType===l.ValueType.INT&&!Number.isInteger(t)&&(l.diag.warn("INT value type cannot accept a floating-point value for "+this._instrumentName+", ignoring the fractional digits."),t=Math.trunc(t),!Number.isInteger(t))||this._buffer.set(r,t)},e}();var Ra=function(){function e(){this._buffer=new Map}return e.prototype.observe=function(t,r,n){if(n===void 0&&(n={}),!!fe(t)){var o=this._buffer.get(t);if(o==null&&(o=new Q,this._buffer.set(t,o)),typeof r!="number"){l.diag.warn("non-number value provided to metric "+t._descriptor.name+": "+r);return}t._descriptor.valueType===l.ValueType.INT&&!Number.isInteger(r)&&(l.diag.warn("INT value type cannot accept a floating-point value for "+t._descriptor.name+", ignoring the fractional digits."),r=Math.trunc(r),!Number.isInteger(r))||o.set(n,r)}},e}();var Ln=function(e,t,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(e,t||[])).next())})},Pn=function(e,t){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=t.call(e,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}}},Oa=function(e,t){var r=typeof Symbol=="function"&&e[Symbol.iterator];if(!r)return e;var n=r.call(e),o,i=[],s;try{for(;(t===void 0||t-- >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},ba=function(e,t,r){if(r||arguments.length===2)for(var n=0,o=t.length,i;n<o;n++)(i||!(n in t))&&(i||(i=Array.prototype.slice.call(t,0,n)),i[n]=t[n]);return e.concat(i||Array.prototype.slice.call(t))},La=function(){function e(){this._callbacks=[],this._batchCallbacks=[]}return e.prototype.addCallback=function(t,r){var n=this._findCallback(t,r);n>=0||this._callbacks.push({callback:t,instrument:r})},e.prototype.removeCallback=function(t,r){var n=this._findCallback(t,r);n<0||this._callbacks.splice(n,1)},e.prototype.addBatchCallback=function(t,r){var n=new Set(r.filter(fe));if(n.size===0){l.diag.error("BatchObservableCallback is not associated with valid instruments",r);return}var o=this._findBatchCallback(t,n);o>=0||this._batchCallbacks.push({callback:t,instruments:n})},e.prototype.removeBatchCallback=function(t,r){var n=new Set(r.filter(fe)),o=this._findBatchCallback(t,n);o<0||this._batchCallbacks.splice(o,1)},e.prototype.observe=function(t,r){return Ln(this,void 0,void 0,function(){var n,o,i,s;return Pn(this,function(u){switch(u.label){case 0:return n=this._observeCallbacks(t,r),o=this._observeBatchCallbacks(t,r),[4,na(ba(ba([],Oa(n),!1),Oa(o),!1))];case 1:return i=u.sent(),s=i.filter(ia).map(function(c){return c.reason}),[2,s]}})})},e.prototype._observeCallbacks=function(t,r){var n=this;return this._callbacks.map(function(o){var i=o.callback,s=o.instrument;return Ln(n,void 0,void 0,function(){var u,c;return Pn(this,function(a){switch(a.label){case 0:return u=new Aa(s._descriptor.name,s._descriptor.valueType),c=Promise.resolve(i(u)),r!=null&&(c=yn(c,r)),[4,c];case 1:return a.sent(),s._metricStorages.forEach(function(f){f.record(u._buffer,t)}),[2]}})})})},e.prototype._observeBatchCallbacks=function(t,r){var n=this;return this._batchCallbacks.map(function(o){var i=o.callback,s=o.instruments;return Ln(n,void 0,void 0,function(){var u,c;return Pn(this,function(a){switch(a.label){case 0:return u=new Ra,c=Promise.resolve(i(u)),r!=null&&(c=yn(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(d){d.record(p,t)})}),[2]}})})})},e.prototype._findCallback=function(t,r){return this._callbacks.findIndex(function(n){return n.callback===t&&n.instrument===r})},e.prototype._findBatchCallback=function(t,r){return this._batchCallbacks.findIndex(function(n){return n.callback===t&&oa(n.instruments,r)})},e}();var Ef=function(){var e=function(t,r){return e=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])},e(t,r)};return function(t,r){if(typeof r!="function"&&r!==null)throw new TypeError("Class extends value "+String(r)+" is not a constructor or null");e(t,r);function n(){this.constructor=t}t.prototype=r===null?Object.create(r):(n.prototype=r.prototype,new n)}}(),Pa=function(e){Ef(t,e);function t(r,n,o,i){var s=e.call(this,r)||this;return s._attributesProcessor=o,s._deltaMetricStorage=new ur(n),s._temporalMetricStorage=new cr(n,i),s}return t.prototype.record=function(r,n,o,i){n=this._attributesProcessor.process(n,o),this._deltaMetricStorage.record(r,n,o,i)},t.prototype.collect=function(r,n){var o=this._deltaMetricStorage.collect();return this._temporalMetricStorage.buildMetrics(r,this._instrumentDescriptor,o,n)},t}(sr);var Ia=function(){var e=function(t,r){return e=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])},e(t,r)};return function(t,r){if(typeof r!="function"&&r!==null)throw new TypeError("Class extends value "+String(r)+" is not a constructor or null");e(t,r);function n(){this.constructor=t}t.prototype=r===null?Object.create(r):(n.prototype=r.prototype,new n)}}(),lr=function(){function e(){}return e.Noop=function(){return Tf},e}();var mf=function(e){Ia(t,e);function t(){return e!==null&&e.apply(this,arguments)||this}return t.prototype.process=function(r,n){return r},t}(lr);var uE=function(e){Ia(t,e);function t(r){var n=e.call(this)||this;return n._allowedAttributeNames=r,n}return t.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},t}(lr);var Tf=new mf;var Sf=function(e,t,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(e,t||[])).next())})},gf=function(e,t){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=t.call(e,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}}},yf=function(e,t){var r=typeof Symbol=="function"&&e[Symbol.iterator];if(!r)return e;var n=r.call(e),o,i=[],s;try{for(;(t===void 0||t-- >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},Ca=function(){function e(t,r){this._meterProviderSharedState=t,this._instrumentationScope=r,this.metricStorageRegistry=new ya,this.observableRegistry=new La,this.meter=new ma(this)}return e.prototype.registerMetricStorage=function(t){var r=this._registerMetricStorage(t,Pa);return r.length===1?r[0]:new va(r)},e.prototype.registerAsyncMetricStorage=function(t){var r=this._registerMetricStorage(t,ga);return r},e.prototype.collect=function(t,r,n){return Sf(this,void 0,void 0,function(){var o,i,s;return gf(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(t),i.length===0?[2,null]:(s=i.map(function(c){return c.collect(t,r)}).filter(ta),s.length===0?[2,{errors:o}]:[2,{scopeMetrics:{scope:this._instrumentationScope,metrics:s},errors:o}])}})})},e.prototype._registerMetricStorage=function(t,r){var n=this,o=this._meterProviderSharedState.viewRegistry.findViews(t,this._instrumentationScope),i=o.map(function(c){var a=sa(c,t),f=n.metricStorageRegistry.findOrUpdateCompatibleStorage(a);if(f!=null)return f;var p=c.aggregation.createAggregator(a),d=new r(a,p,c.attributesProcessor,n._meterProviderSharedState.metricCollectors);return n.metricStorageRegistry.register(d),d});if(i.length===0){var s=this._meterProviderSharedState.selectAggregations(t.type),u=s.map(function(c){var a=yf(c,2),f=a[0],p=a[1],d=n.metricStorageRegistry.findOrUpdateCompatibleCollectorStorage(f,t);if(d!=null)return d;var m=p.createAggregator(t),g=new r(t,m,lr.Noop(),[f]);return n.metricStorageRegistry.registerForCollector(f,g),g});i=i.concat(u)}return i},e}();var vf=function(e){var t=typeof Symbol=="function"&&Symbol.iterator,r=t&&e[t],n=0;if(r)return r.call(e);if(e&&typeof e.length=="number")return{next:function(){return e&&n>=e.length&&(e=void 0),{value:e&&e[n++],done:!e}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")},Na=function(){function e(t){this.resource=t,this.viewRegistry=new ca,this.metricCollectors=[],this.meterSharedStates=new Map}return e.prototype.getMeterSharedState=function(t){var r=ra(t),n=this.meterSharedStates.get(r);return n==null&&(n=new Ca(this,t),this.meterSharedStates.set(r,n)),n},e.prototype.selectAggregations=function(t){var r,n,o=[];try{for(var i=vf(this.metricCollectors),s=i.next();!s.done;s=i.next()){var u=s.value;o.push([u,u.selectAggregation(t)])}}catch(c){r={error:c}}finally{try{s&&!s.done&&(n=i.return)&&n.call(i)}finally{if(r)throw r.error}}return o},e}();var wa=v(P()),fr=function(e,t,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(e,t||[])).next())})},pr=function(e,t){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=t.call(e,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}}},Af=function(e,t){var r=typeof Symbol=="function"&&e[Symbol.iterator];if(!r)return e;var n=r.call(e),o,i=[],s;try{for(;(t===void 0||t-- >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},Rf=function(e,t,r){if(r||arguments.length===2)for(var n=0,o=t.length,i;n<o;n++)(i||!(n in t))&&(i||(i=Array.prototype.slice.call(t,0,n)),i[n]=t[n]);return e.concat(i||Array.prototype.slice.call(t))},Ma=function(){function e(t,r){this._sharedState=t,this._metricReader=r}return e.prototype.collect=function(t){return fr(this,void 0,void 0,function(){var r,n,o,i,s=this;return pr(this,function(u){switch(u.label){case 0:return r=(0,wa.millisToHrTime)(Date.now()),n=[],o=[],i=Array.from(this._sharedState.meterSharedStates.values()).map(function(c){return fr(s,void 0,void 0,function(){var a;return pr(this,function(f){switch(f.label){case 0:return[4,c.collect(this,r,t)];case 1:return a=f.sent(),a?.scopeMetrics!=null&&n.push(a.scopeMetrics),a?.errors!=null&&o.push.apply(o,Rf([],Af(a.errors),!1)),[2]}})})}),[4,Promise.all(i)];case 1:return u.sent(),[2,{resourceMetrics:{resource:this._sharedState.resource,scopeMetrics:n},errors:o}]}})})},e.prototype.forceFlush=function(t){return fr(this,void 0,void 0,function(){return pr(this,function(r){switch(r.label){case 0:return[4,this._metricReader.forceFlush(t)];case 1:return r.sent(),[2]}})})},e.prototype.shutdown=function(t){return fr(this,void 0,void 0,function(){return pr(this,function(r){switch(r.label){case 0:return[4,this._metricReader.shutdown(t)];case 1:return r.sent(),[2]}})})},e.prototype.selectAggregationTemporality=function(t){return this._metricReader.selectAggregationTemporality(t)},e.prototype.selectAggregation=function(t){return this._metricReader.selectAggregation(t)},e}();var xa=function(e,t,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(e,t||[])).next())})},Da=function(e,t){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=t.call(e,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}}},Of=function(e){var t=typeof Symbol=="function"&&Symbol.iterator,r=t&&e[t],n=0;if(r)return r.call(e);if(e&&typeof e.length=="number")return{next:function(){return e&&n>=e.length&&(e=void 0),{value:e&&e[n++],done:!e}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")},In=function(){function e(t){var r,n,o;this._shutdown=!1;var i=H.default().merge((o=t?.resource)!==null&&o!==void 0?o:H.empty());if(this._sharedState=new Na(i),t?.views!=null&&t.views.length>0)try{for(var s=Of(t.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 e.prototype.getMeter=function(t,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:t,version:r,schemaUrl:n.schemaUrl}).meter},e.prototype.addMetricReader=function(t){var r=new Ma(this._sharedState,t);t.setMetricProducer(r),this._sharedState.metricCollectors.push(r)},e.prototype.shutdown=function(t){return xa(this,void 0,void 0,function(){return Da(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(t)}))]);case 1:return r.sent(),[2]}})})},e.prototype.forceFlush=function(t){return xa(this,void 0,void 0,function(){return Da(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(t)}))];case 1:return r.sent(),[2]}})})},e}();var Nr=v(Oe(),1),Iu=v(Va(),1),Ot=v(P(),1);var Ha="http.method",Fa="http.url",hr="http.host",ja="http.scheme",wn="http.status_code",ka="http.user_agent",Mn="http.response_content_length_uncompressed",qa="net.peer.port",Xa="net.peer.name";var Ka="service.name",Wa="service.version";E();var Nf=Symbol.for("@vercel/request-context");function nt(){return globalThis[Nf]?.get()}function Er(e){return Object.fromEntries(Object.entries(e).filter(([t,r])=>r!==void 0))}function Ya(e){return e?e.split("::").at(-1):void 0}function za(e=nt(),t){if(!e)return;let r=t?Mf(t,e.headers):void 0;return Er({[hr]:e.headers.host,[ka]:e.headers["user-agent"],"http.referer":e.headers.referer,"vercel.request_id":Ya(e.headers["x-vercel-id"]),"vercel.matched_path":e.headers["x-matched-path"],"vercel.edge_region":process.env.VERCEL_REGION,...r})}var wf={keys(e){return[]},get(e,t){return e[t.toLocaleLowerCase()]}};function Mf(e,t){if(typeof e=="function")return e(t,wf);let r={};for(let[n,o]of Object.entries(e)){let i=t[o.toLocaleLowerCase()];i!==void 0&&(r[n]=i)}return r}E();function zt(e){return(e&l.TraceFlags.SAMPLED)!==0}var mr=class{constructor(t,r){this.processors=t;this.attributesFromHeaders=r;this.rootSpanIds=new Map;this.waitSpanEnd=new Map}forceFlush(){return Promise.all(this.processors.map(t=>t.forceFlush().catch(r=>{l.diag.error("@vercel/otel: forceFlush failed:",r)}))).then(()=>{})}shutdown(){return Promise.all(this.processors.map(t=>t.shutdown().catch(()=>{}))).then(()=>{})}onStart(t,r){let{traceId:n,spanId:o,traceFlags:i}=t.spanContext(),s=!t.parentSpanId||!this.rootSpanIds.has(n);if(s?this.rootSpanIds.set(n,{rootSpanId:o,open:[]}):this.rootSpanIds.get(n)?.open.push(t),s&&zt(i)){let u=nt(),c=za(u,this.attributesFromHeaders);c&&t.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(t,r)}onEnd(t){let{traceId:r,spanId:n,traceFlags:o}=t.spanContext(),i=zt(o),s=this.rootSpanIds.get(r),u=s?.rootSpanId===n;if(i){let c=Df(t);c&&Object.assign(t.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(t);if(u){let c=this.waitSpanEnd.get(r);c&&(this.waitSpanEnd.delete(r),c())}}},xf={[l.SpanKind.INTERNAL]:"internal",[l.SpanKind.SERVER]:"server",[l.SpanKind.CLIENT]:"client",[l.SpanKind.PRODUCER]:"producer",[l.SpanKind.CONSUMER]:"consumer"};function Df(e){let{kind:t,attributes:r}=e,{"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(e.kind===l.SpanKind.SERVER&&u&&c&&typeof u=="string"&&typeof c=="string")return{"operation.name":"web.request","resource.name":a};let f=e.instrumentationLibrary.name,p=s??i;if(p&&typeof p=="string"){let d=$a(f,p);return c?{"operation.name":d,"resource.name":a}:{"operation.name":d}}return{"operation.name":$a(f,t===l.SpanKind.INTERNAL?"":xf[t])}}function $a(e,t){if(!e)return t;let r=e.replace(/[ @./]/g,"_");return r.startsWith("_")&&(r=r.slice(1)),t?`${r}.${t}`:r}var fs=v(Fn(),1);var ls=v(cs(),1);E();var $t=class extends ls.OTLPExporterBase{constructor(t={}){super(t),t.headers&&(this._headers=t.headers)}onShutdown(){l.diag.debug("@vercel/otel/otlp: onShutdown")}onInit(){l.diag.debug("@vercel/otel/otlp: onInit")}send(t,r,n){if(this._shutdownOnce.isCalled){l.diag.debug("@vercel/otel/otlp: Shutdown already started. Cannot send objects");return}let o=this.convert(t),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(t){throw new Error("Method not implemented.")}};var rp="v1/traces",np=`http://localhost:4318/${rp}`;function yr(e){return typeof e.url=="string"?e.url:np}var Qt=class{constructor(t={}){this.impl=new Xn(t)}export(t,r){this.impl.export(t,r)}shutdown(){return this.impl.shutdown()}forceFlush(){return this.impl.forceFlush()}},Xn=class extends $t{convert(t){return(0,fs.createExportTraceServiceRequest)(t,{useHex:!0,useLongBits:!1})}toMessage(t){return{body:JSON.stringify(t),contentType:"application/json"}}getDefaultUrl(t){return yr(t)}};var du=v(Fn(),1);var lu=v(cu(),1);function fu(e){let t=new lu.Writer;return _p(e,t),t.finish()}function _p(e,t){if(e.resourceSpans!=null&&e.resourceSpans.length)for(let r=0;r<e.resourceSpans.length;++r)hp(e.resourceSpans[r],t.uint32(10).fork()).ldelim();return t}function hp(e,t){if(e.resource!=null&&Ep(e.resource,t.uint32(10).fork()).ldelim(),e.scopeSpans!=null&&e.scopeSpans.length)for(let r=0;r<e.scopeSpans.length;++r)mp(e.scopeSpans[r],t.uint32(18).fork()).ldelim();return e.schemaUrl!=null&&t.uint32(26).string(e.schemaUrl),t}function Ep(e,t){if(e.attributes!=null&&e.attributes.length)for(let r=0;r<e.attributes.length;++r)Jt(e.attributes[r],t.uint32(10).fork()).ldelim();return e.droppedAttributesCount!=null&&t.uint32(16).uint32(e.droppedAttributesCount),t}function mp(e,t){if(e.scope!=null&&gp(e.scope,t.uint32(10).fork()).ldelim(),e.spans!=null&&e.spans.length)for(let r=0;r<e.spans.length;++r)yp(e.spans[r],t.uint32(18).fork()).ldelim();return e.schemaUrl!=null&&t.uint32(26).string(e.schemaUrl),t}function Jt(e,t){return e.key!=null&&t.uint32(10).string(e.key),e.value!=null&&pu(e.value,t.uint32(18).fork()).ldelim(),t}function pu(e,t){return e.stringValue!=null&&t.uint32(10).string(e.stringValue),e.boolValue!=null&&t.uint32(16).bool(e.boolValue),e.intValue!=null&&t.uint32(24).int64(e.intValue),e.doubleValue!=null&&t.uint32(33).double(e.doubleValue),e.arrayValue!=null&&Tp(e.arrayValue,t.uint32(42).fork()).ldelim(),e.kvlistValue!=null&&Sp(e.kvlistValue,t.uint32(50).fork()).ldelim(),e.bytesValue!=null&&t.uint32(58).bytes(e.bytesValue),t}function Tp(e,t){if(e.values!=null&&e.values.length)for(let r=0;r<e.values.length;++r)pu(e.values[r],t.uint32(10).fork()).ldelim();return t}function Sp(e,t){if(e.values!=null&&e.values.length)for(let r=0;r<e.values.length;++r)Jt(e.values[r],t.uint32(10).fork()).ldelim();return t}function gp(e,t){if(e.name!=null&&t.uint32(10).string(e.name),e.version!=null&&t.uint32(18).string(e.version),e.attributes!=null&&e.attributes.length)for(let r=0;r<e.attributes.length;++r)Jt(e.attributes[r],t.uint32(26).fork()).ldelim();return e.droppedAttributesCount!=null&&t.uint32(32).uint32(e.droppedAttributesCount),t}function yp(e,t){if(e.traceId!=null&&t.uint32(10).bytes(e.traceId),e.spanId!=null&&t.uint32(18).bytes(e.spanId),e.traceState!=null&&t.uint32(26).string(e.traceState),e.parentSpanId!=null&&t.uint32(34).bytes(e.parentSpanId),e.name!=null&&t.uint32(42).string(e.name),e.kind!=null&&t.uint32(48).int32(e.kind),e.startTimeUnixNano!=null&&t.uint32(57).fixed64(e.startTimeUnixNano),e.endTimeUnixNano!=null&&t.uint32(65).fixed64(e.endTimeUnixNano),e.attributes!=null&&e.attributes.length)for(let r=0;r<e.attributes.length;++r)Jt(e.attributes[r],t.uint32(74).fork()).ldelim();if(e.droppedAttributesCount!=null&&t.uint32(80).uint32(e.droppedAttributesCount),e.events!=null&&e.events.length)for(let r=0;r<e.events.length;++r)Ap(e.events[r],t.uint32(90).fork()).ldelim();if(e.droppedEventsCount!=null&&t.uint32(96).uint32(e.droppedEventsCount),e.links!=null&&e.links.length)for(let r=0;r<e.links.length;++r)Rp(e.links[r],t.uint32(106).fork()).ldelim();return e.droppedLinksCount!=null&&t.uint32(112).uint32(e.droppedLinksCount),e.status!=null&&vp(e.status,t.uint32(122).fork()).ldelim(),t}function vp(e,t){return e.message!=null&&t.uint32(18).string(e.message),e.code!=null&&t.uint32(24).int32(e.code),t}function Ap(e,t){if(e.timeUnixNano!=null&&t.uint32(9).fixed64(e.timeUnixNano),e.name!=null&&t.uint32(18).string(e.name),e.attributes!=null&&e.attributes.length)for(let r=0;r<e.attributes.length;++r)Jt(e.attributes[r],t.uint32(26).fork()).ldelim();return e.droppedAttributesCount!=null&&t.uint32(32).uint32(e.droppedAttributesCount),t}function Rp(e,t){if(e.traceId!=null&&t.uint32(10).bytes(e.traceId),e.spanId!=null&&t.uint32(18).bytes(e.spanId),e.traceState!=null&&t.uint32(26).string(e.traceState),e.attributes!=null&&e.attributes.length)for(let r=0;r<e.attributes.length;++r)Jt(e.attributes[r],t.uint32(34).fork()).ldelim();return e.droppedAttributesCount!=null&&t.uint32(40).uint32(e.droppedAttributesCount),t}var Bt=class{constructor(t={}){this.impl=new oi(t)}export(t,r){this.impl.export(t,r)}shutdown(){return this.impl.shutdown()}forceFlush(){return this.impl.forceFlush()}},oi=class extends $t{convert(t){return(0,du.createExportTraceServiceRequest)(t,void 0)}toMessage(t){return{body:fu(t),contentType:"application/x-protobuf",headers:{accept:"application/x-protobuf"}}}getDefaultUrl(t){return yr(t)}};E();function _u(e,t){return e.replace(/\{(?<temp1>[^{}]+)\}/g,(r,n)=>{let o=t[n];return o!==void 0?String(o):r})}var te=class{constructor(t={}){this.instrumentationName="@vercel/otel/fetch";this.instrumentationVersion="1.0.0";this.config=t}getConfig(){return this.config}setConfig(){}setTracerProvider(t){this.tracerProvider=t}setMeterProvider(){}shouldIgnore(t,r){let n=this.config.ignoreUrls??[];if(r?.opentelemetry?.ignore!==void 0)return r.opentelemetry.ignore;if(n.length===0)return!1;let o=t.toString();return n.some(i=>typeof i=="string"?i==="*"?!0:o.startsWith(i):i.test(o))}shouldPropagate(t,r){let n=process.env.VERCEL_URL||process.env.NEXT_PUBLIC_VERCEL_URL||null,o=process.env.VERCEL_BRANCH_URL||process.env.NEXT_PUBLIC_VERCEL_BRANCH_URL||null,i=this.config.propagateContextUrls??[],s=this.config.dontPropagateContextUrls??[];if(r?.opentelemetry?.propagateContext)return r.opentelemetry.propagateContext;let u=t.toString();return s.length>0&&s.some(c=>typeof c=="string"?c==="*"?!0:u.startsWith(c):c.test(u))?!1:n&&t.protocol==="https:"&&(t.host===n||t.host===o||t.host===nt()?.headers.host)||!n&&t.protocol==="http:"&&t.hostname==="localhost"?!0:i.some(c=>typeof c=="string"?c==="*"?!0:u.startsWith(c):c.test(u))}startSpan({tracer:t,url:r,fetchType:n,method:o="GET",name:i,attributes:s={}}){let u=this.config.resourceNameTemplate,c={[Ha]:o,[Fa]:r.toString(),[hr]:r.host,[ja]:r.protocol.replace(":",""),[Xa]:r.hostname,[qa]:r.port},a=u?_u(u,c):Lp(r.toString()),f=i??`${n} ${o} ${r.toString()}`,p=l.context.active();return t.startSpan(f,{kind:l.SpanKind.CLIENT,attributes:{...c,"operation.name":`${n}.${o}`,"http.client.name":n,"resource.name":a,...s}},p)}instrumentHttp(t,r){let{tracerProvider:n}=this;if(!n)return;let o=n.getTracer(this.instrumentationName,this.instrumentationVersion),{attributesFromRequestHeaders:i,attributesFromResponseHeaders:s}=this.config,u=t.request,c=t.get,a=f=>(p,d,m)=>{let g,C={},M;if(typeof p=="string"||p instanceof URL?(g=new URL(p.toString()),typeof d=="function"?M=d:d&&typeof m=="function"?(C=d,M=m):d&&(C=d)):(C=p,typeof d=="function"&&(M=d),g=Ip(C,r)),this.shouldIgnore(g))return f.apply(this,[g,C,M]);let T=this.startSpan({tracer:o,url:g,fetchType:"http",method:C.method||"GET"});if(!T.isRecording()||!zt(T.spanContext().traceFlags))return T.end(),f.apply(this,[g,C,M]);if(this.shouldPropagate(g)){let et=l.context.active(),q=l.trace.setSpan(et,T);l.propagation.inject(q,C.headers||{},bp)}i&&br(T,i,C.headers||{},Eu);try{let et=Date.now(),q=f.apply(this,[g,C,M]);return q.prependListener("response",U=>{let wr=Date.now()-et;T.setAttribute("http.response_time",wr),U.statusCode!==void 0?(T.setAttribute(wn,U.statusCode),U.statusCode>=500&&Gt(T,`Status: ${U.statusCode}`)):Gt(T,"Response status code is undefined"),s&&br(T,s,U.headers,Eu),q.listenerCount("response")<=1&&U.resume(),U.on("end",()=>{let bt,Mr=U.statusCode;U.aborted&&!U.complete?bt={code:l.SpanStatusCode.ERROR}:Mr&&Mr>=100&&Mr<500?bt={code:l.SpanStatusCode.UNSET}:bt={code:l.SpanStatusCode.ERROR},T.setStatus(bt),T.isRecording()&&(U.headers["content-length"]&&T.setAttribute(Mn,U.headers["content-length"]),T.end())})}),q.on("error",U=>{T.isRecording()&&(Gt(T,U),T.end())}),q.on("close",()=>{T.isRecording()&&T.end()}),q}catch(et){throw Gt(T,et),T.end(),et}};t.request=a(u),t.get=a(c)}instrumentFetch(){let{tracerProvider:t}=this;if(!t)return;let r=t.getTracer(this.instrumentationName,this.instrumentationVersion),{attributesFromRequestHeaders:n,attributesFromResponseHeaders:o}=this.config;process.env.NEXT_OTEL_FETCH_DISABLED="1";let i=globalThis.fetch;this.originalFetch=i;let s=async(u,c)=>{let a=c;if(a?.next?.internal)return i(u,a);let f=new Request(u instanceof Request?u.clone():u,a),p=new URL(f.url);if(this.shouldIgnore(p,a))return i(u,a);let d=this.startSpan({tracer:r,url:p,fetchType:"fetch",method:f.method,name:a?.opentelemetry?.spanName,attributes:a?.opentelemetry?.attributes});if(!d.isRecording()||!zt(d.spanContext().traceFlags))return d.end(),i(u,a);if(this.shouldPropagate(p,a)){let m=l.context.active(),g=l.trace.setSpan(m,d);l.propagation.inject(g,f.headers,Op)}n&&br(d,n,f.headers,hu);try{let m=Date.now();a?.body&&a.body instanceof FormData&&f.headers.delete("content-type");let g=await i(u,{...a,headers:f.headers}),C=Date.now()-m;return d.setAttribute(wn,g.status),d.setAttribute("http.response_time",C),o&&br(d,o,g.headers,hu),g.status>=500&&Gt(d,`Status: ${g.status} (${g.statusText})`),g.body?Pp(g).then(M=>{d.isRecording()&&(d.setAttribute(Mn,M),d.end())},M=>{d.isRecording()&&(Gt(d,M),d.end())}):d.end(),g}catch(m){throw Gt(d,m),d.end(),m}};globalThis.fetch=s}enable(){this.disable(),this.instrumentFetch();try{let t=ci("node:http"),r=ci("node:https");this.instrumentHttp(t,"http:"),this.instrumentHttp(r,"https:")}catch{}}disable(){this.originalFetch&&(globalThis.fetch=this.originalFetch)}},Op={set(e,t,r){e.set(t,r)}},hu={get(e,t){let r=e.get(t);if(r!==null)return r.includes(",")?r.split(",").map(n=>n.trimStart()):r},keys(e){let t=[];return e.forEach((r,n)=>{t.push(n)}),t}},bp={set(e,t,r){e[t.toLowerCase()]=r}},Eu={get(e,t){return e[t.toLowerCase()]},keys(e){return Object.keys(e)}};function Lp(e){let t=e.indexOf("?");return t===-1?e:e.substring(0,t)}function Pp(e){let t=0,n=e.clone().body?.getReader();if(!n)return Promise.resolve(0);let o=()=>n.read().then(({done:i,value:s})=>{if(!i)return t+=s.byteLength,o()});return o().then(()=>t)}function Gt(e,t){if(t instanceof Error)e.recordException(t),e.setStatus({code:l.SpanStatusCode.ERROR,message:t.message});else{let r=String(t);e.setStatus({code:l.SpanStatusCode.ERROR,message:r})}}function br(e,t,r,n){for(let[o,i]of Object.entries(t)){let s=n.get(r,i);s!==void 0&&e.setAttribute(o,s)}}function Ip(e,t){if(e.socketPath)throw new Error("Cannot construct a network URL: options.socketPath is specified, indicating a Unix domain socket.");let r=e.protocol??t;r&&!r.endsWith(":")&&(r+=":");let n=e.hostname,o=e.port??e.defaultPort;if(!n&&e.host){let a=e.host.split(":");n=a[0];let f=a[1];if(a.length>1&&f&&o===void 0){let p=parseInt(f,10);isNaN(p)||(o=p)}}n||(n="localhost");let i;if(o!==void 0&&o!==""){let a=parseInt(String(o),10);isNaN(a)?i=r==="https:"?443:80:i=a}else i=r==="https:"?443:80;let s=e.path||"/",u=`${r}//${n}:${i}`,c=new URL(s,u);if(e.auth){let a=e.auth.split(":");c.username=decodeURIComponent(a[0]||""),a.length>1&&(c.password=decodeURIComponent(a[1]||""))}return c}E();var mu=v(P(),1),Cp="00",ai="traceparent",si="tracestate",Te=class{fields(){return[ai,si]}inject(t,r,n){let o=l.trace.getSpanContext(t);if(!o||(0,mu.isTracingSuppressed)(t)||!(0,l.isSpanContextValid)(o))return;let i=`${Cp}-${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(t,r,n){let o=n.get(r,ai);if(!o)return t;let i=Array.isArray(o)?o[0]:o;if(typeof i!="string")return t;let s=Np(i);if(!s)return t;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(t,s)}};function Np(e){let[t,r,n,o,i]=e.split("-");return!t||!r||!n||!o||t.length!==2||r.length!==32||n.length!==16||o.length!==2||t==="00"&&i?null:{traceId:r,spanId:n,traceFlags:parseInt(o,16)}}E();var Lr=class{fields(){return[]}inject(){}extract(t){let r=nt();if(!r?.telemetry)return l.diag.warn("@vercel/otel: Vercel telemetry extension not found."),t;let{rootSpanContext:n}=r.telemetry;return n?(l.diag.debug("@vercel/otel: Extracted root SpanContext from Vercel request context.",n),l.trace.setSpanContext(t,{...n,isRemote:!0,traceFlags:n.traceFlags||l.TraceFlags.SAMPLED})):t}};E();var Pr=v(P(),1);var ee=v(P()),wp=BigInt(1e9);function Su(e){return BigInt(e[0])*wp+BigInt(e[1])}function Mp(e){var t=Number(BigInt.asUintN(32,e)),r=Number(BigInt.asUintN(32,e>>BigInt(32)));return{low:t,high:r}}function gu(e){var t=Su(e);return Mp(t)}function xp(e){var t=Su(e);return t.toString()}var Dp=typeof BigInt<"u"?xp:ee.hrTimeToNanoseconds;function Tu(e){return e}function yu(e){if(e!==void 0)return(0,ee.hexToBase64)(e)}var Up={encodeHrTime:gu,encodeSpanContext:ee.hexToBase64,encodeOptionalSpanContext:yu};function vu(e){var t,r;if(e===void 0)return Up;var n=(t=e.useLongBits)!==null&&t!==void 0?t:!0,o=(r=e.useHex)!==null&&r!==void 0?r:!1;return{encodeHrTime:n?gu:Dp,encodeSpanContext:o?Tu:ee.hexToBase64,encodeOptionalSpanContext:o?Tu:yu}}var Bp=function(e,t){var r=typeof Symbol=="function"&&e[Symbol.iterator];if(!r)return e;var n=r.call(e),o,i=[],s;try{for(;(t===void 0||t-- >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 re(e){return Object.keys(e).map(function(t){return Au(t,e[t])})}function Au(e,t){return{key:e,value:Ru(t)}}function Ru(e){var t=typeof e;return t==="string"?{stringValue:e}:t==="number"?Number.isInteger(e)?{intValue:e}:{doubleValue:e}:t==="boolean"?{boolValue:e}:e instanceof Uint8Array?{bytesValue:e}:Array.isArray(e)?{arrayValue:{values:e.map(Ru)}}:t==="object"&&e!=null?{kvlistValue:{values:Object.entries(e).map(function(r){var n=Bp(r,2),o=n[0],i=n[1];return Au(o,i)})}}:{}}function Ou(e,t){var r,n=e.spanContext(),o=e.status;return{traceId:t.encodeSpanContext(n.traceId),spanId:t.encodeSpanContext(n.spanId),parentSpanId:t.encodeOptionalSpanContext(e.parentSpanId),traceState:(r=n.traceState)===null||r===void 0?void 0:r.serialize(),name:e.name,kind:e.kind==null?0:e.kind+1,startTimeUnixNano:t.encodeHrTime(e.startTime),endTimeUnixNano:t.encodeHrTime(e.endTime),attributes:re(e.attributes),droppedAttributesCount:e.droppedAttributesCount,events:e.events.map(function(i){return Vp(i,t)}),droppedEventsCount:e.droppedEventsCount,status:{code:o.code,message:o.message},links:e.links.map(function(i){return Gp(i,t)}),droppedLinksCount:e.droppedLinksCount}}function Gp(e,t){var r;return{attributes:e.attributes?re(e.attributes):[],spanId:t.encodeSpanContext(e.context.spanId),traceId:t.encodeSpanContext(e.context.traceId),traceState:(r=e.context.traceState)===null||r===void 0?void 0:r.serialize(),droppedAttributesCount:e.droppedAttributesCount||0}}function Vp(e,t){return{attributes:e.attributes?re(e.attributes):[],name:e.name,timeUnixNano:t.encodeHrTime(e.time),droppedAttributesCount:e.droppedAttributesCount||0}}var Hp=function(e){var t=typeof Symbol=="function"&&Symbol.iterator,r=t&&e[t],n=0;if(r)return r.call(e);if(e&&typeof e.length=="number")return{next:function(){return e&&n>=e.length&&(e=void 0),{value:e&&e[n++],done:!e}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")},Fp=function(e,t){var r=typeof Symbol=="function"&&e[Symbol.iterator];if(!r)return e;var n=r.call(e),o,i=[],s;try{for(;(t===void 0||t-- >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(e,t){var r=vu(t);return{resourceSpans:kp(e,r)}}function jp(e){var t,r,n=new Map;try{for(var o=Hp(e),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){t={error:f}}finally{try{i&&!i.done&&(r=o.return)&&r.call(o)}finally{if(t)throw t.error}}return n}function kp(e,t){for(var r=jp(e),n=[],o=r.entries(),i=o.next();!i.done;){for(var s=Fp(i.value,2),u=s[0],c=s[1],a=[],f=c.values(),p=f.next();!p.done;){var d=p.value;if(d.length>0){var m=d[0].instrumentationLibrary,g=m.name,C=m.version,M=m.schemaUrl,T=d.map(function(q){return Ou(q,t)});a.push({scope:{name:g,version:C},spans:T,schemaUrl:M})}p=f.next()}var et={resource:{attributes:re(u.attributes),droppedAttributesCount:0},scopeSpans:a,schemaUrl:void 0};n.push(et),i=o.next()}return n}var Ir=class{export(t,r){let n=nt();if(!n?.telemetry){l.diag.warn("@vercel/otel: no telemetry context found"),r({code:Pr.ExportResultCode.SUCCESS,error:void 0});return}try{let o=ui(t,{useHex:!0,useLongBits:!1});n.telemetry.reportSpans(o),r({code:Pr.ExportResultCode.SUCCESS,error:void 0})}catch(o){r({code:Pr.ExportResultCode.FAILED,error:o instanceof Error?o:new Error(String(o))})}}shutdown(){return Promise.resolve()}forceFlush(){return Promise.resolve()}};var qp={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},Cr=class{constructor(t={}){this.configuration=t}start(){let t=Xp(),r=this.configuration,n=process.env.NEXT_RUNTIME||"nodejs",o=!!t.OTEL_SDK_DISABLED;if(process.env.OTEL_LOG_LEVEL&&l.diag.setLogger(new l.DiagConsoleLogger,{logLevel:qp[process.env.OTEL_LOG_LEVEL.toUpperCase()]}),o)return;let i=r.idGenerator??new tr,s=r.contextManager??new Iu.AsyncLocalStorageContextManager;s.enable(),this.contextManager=s;let u=t.OTEL_SERVICE_NAME||r.serviceName||"app",c=new H(Er({[Ka]: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,[Wa]:process.env.VERCEL_DEPLOYMENT_ID,...r.attributes})),a=r.resourceDetectors??[No];if(r.autoDetectResources??!0){let T={detectors:a};c=c.merge(Mo(T))}let p=Wp(r.propagators,r,t),d=Yp(r.traceSampler,t),m=zp(r.spanProcessors,r,t);m.length===0&&l.diag.warn("@vercel/otel: No span processors configured. No spans will be exported.");let g=r.spanLimits,C=new Bo({resource:c,idGenerator:i,sampler:d,spanLimits:g});if(C.addSpanProcessor(new mr(m,r.attributesFromHeaders)),C.register({contextManager:s,propagator:new Ot.CompositePropagator({propagators:p})}),this.tracerProvider=C,r.logRecordProcessor){let T=new gn({resource:c});this.loggerProvider=T,T.addLogRecordProcessor(r.logRecordProcessor),st.logs.setGlobalLoggerProvider(T)}if(r.metricReader||r.views){let T=new In({resource:c,views:r.views??[]});r.metricReader&&T.addMetricReader(r.metricReader),l.metrics.setGlobalMeterProvider(T),this.meterProvider=T}let M=Kp(r.instrumentations,r.instrumentationConfig);this.disableInstrumentations=(0,Pu.registerInstrumentations)({instrumentations:M}),l.diag.info("@vercel/otel: started",u,n)}async shutdown(){let t=[];this.tracerProvider&&t.push(this.tracerProvider.shutdown()),this.loggerProvider&&t.push(this.loggerProvider.shutdown()),this.meterProvider&&t.push(this.meterProvider.shutdown()),l.diag.info("@vercel/otel: shutting down",t.length,process.env.NEXT_RUNTIME),await Promise.all(t),this.contextManager&&this.contextManager.disable();let{disableInstrumentations:r}=this;r&&r()}};function Xp(){let e=(0,Nr.parseEnvironment)(process.env);return{...Nr.DEFAULT_ENVIRONMENT,...e}}function Kp(e,t){return(e??["auto"]).map(r=>r==="auto"?(l.diag.debug("@vercel/otel: Configure instrumentations: fetch",t?.fetch),[new te(t?.fetch)]):r==="fetch"?(l.diag.debug("@vercel/otel: Configure instrumentations: fetch",t?.fetch),new te(t?.fetch)):r).flat()}function Wp(e,t,r){let n=process.env.OTEL_PROPAGATORS&&r.OTEL_PROPAGATORS&&r.OTEL_PROPAGATORS.length>0?r.OTEL_PROPAGATORS:void 0;return(e??n??["auto"]).map(o=>{if(o==="none")return[];if(o==="auto"){let i=[];return i.push({name:"tracecontext",propagator:new Te}),i.push({name:"baggage",propagator:new Ot.W3CBaggagePropagator}),i.push({name:"vercel-runtime",propagator:new Lr}),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 Te;if(o==="baggage")return l.diag.debug("@vercel/otel: Configure propagator: baggage"),new Ot.W3CBaggagePropagator;if(typeof o=="string")throw new Error(`Unknown propagator: "${o}"`);return o}).flat()}var bu="always_on",ne=1;function Yp(e,t){if(e&&typeof e!="string")return e;let r=e&&e!=="auto"?e:t.OTEL_TRACES_SAMPLER||bu;switch(l.diag.debug("@vercel/otel: Configure sampler: ",r),r){case"always_on":return new X;case"always_off":return new at;case"parentbased_always_on":return new Et({root:new X});case"parentbased_always_off":return new Et({root:new at});case"traceidratio":return new kt(Lu(t));case"parentbased_traceidratio":return new Et({root:new kt(Lu(t))});default:return l.diag.error(`@vercel/otel: OTEL_TRACES_SAMPLER value "${String(t.OTEL_TRACES_SAMPLER)} invalid, defaulting to ${bu}".`),new X}}function Lu(e){if(e.OTEL_TRACES_SAMPLER_ARG===void 0||e.OTEL_TRACES_SAMPLER_ARG==="")return l.diag.error(`@vercel/otel: OTEL_TRACES_SAMPLER_ARG is blank, defaulting to ${ne}.`),ne;l.diag.debug("@vercel/otel: Configure sampler probability: ",e.OTEL_TRACES_SAMPLER_ARG);let t=Number(e.OTEL_TRACES_SAMPLER_ARG);return isNaN(t)?(l.diag.error(`@vercel/otel: OTEL_TRACES_SAMPLER_ARG=${e.OTEL_TRACES_SAMPLER_ARG} was given, but it is invalid, defaulting to ${ne}.`),ne):t<0||t>1?(l.diag.error(`@vercel/otel: OTEL_TRACES_SAMPLER_ARG=${e.OTEL_TRACES_SAMPLER_ARG} was given, but it is out of range ([0..1]), defaulting to ${ne}.`),ne):t}function zp(e,t,r){return[...(e??["auto"]).flatMap(n=>{if(n==="auto"){let o=[new Mt(new Ir)];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 Bt(u):new Qt(u);o.push(new Mt(c))}else(!t.traceExporter||t.traceExporter==="auto"||r.OTEL_EXPORTER_OTLP_TRACES_ENDPOINT||r.OTEL_EXPORTER_OTLP_ENDPOINT)&&o.push(new Mt($p(r)));return o}return n}).filter(Jp),...t.traceExporter&&t.traceExporter!=="auto"?[new Mt(t.traceExporter)]:[]]}function $p(e){let t=process.env.OTEL_EXPORTER_OTLP_TRACES_PROTOCOL??process.env.OTEL_EXPORTER_OTLP_PROTOCOL??"http/protobuf",r=Zp(e),n={...Ot.baggageUtils.parseKeyPairsIntoRecord(e.OTEL_EXPORTER_OTLP_HEADERS),...Ot.baggageUtils.parseKeyPairsIntoRecord(e.OTEL_EXPORTER_OTLP_TRACES_HEADERS)};switch(l.diag.debug("@vercel/otel: Configure trace exporter: ",t,r,`headers: ${Object.keys(n).join(",")||"<none>"}`),t){case"http/json":return new Qt({url:r,headers:n});case"http/protobuf":return new Bt({url:r,headers:n});default:return l.diag.warn(`@vercel/otel: Unsupported OTLP traces protocol: ${t}. Using http/protobuf.`),new Bt}}var Cu="v1/traces",Qp=`http://localhost:4318/${Cu}`;function Zp(e){let t=e.OTEL_EXPORTER_OTLP_TRACES_ENDPOINT;if(t&&typeof t=="string")return t;let r=e.OTEL_EXPORTER_OTLP_ENDPOINT;return r&&typeof r=="string"?`${r}/${Cu}`:Qp}function Jp(e){return e!=null}function RT(e){let t;e?typeof e=="string"?t={serviceName:e}:t=e:t={},new Cr(t).start()}export{te as FetchInstrumentation,Qt as OTLPHttpJsonTraceExporter,Bt as OTLPHttpProtoTraceExporter,RT as registerOTel};
|
|
16
|
+
`,On(a,t))}}catch(f){n={error:f}}finally{try{u&&!u.done&&(o=s.return)&&o.call(s)}finally{if(n)throw n.error}}return i},e}();var va=function(){function e(t){this._backingStorages=t}return e.prototype.record=function(t,r,n,o){this._backingStorages.forEach(function(i){i.record(t,r,n,o)})},e}();E();E();var Aa=function(){function e(t,r){this._instrumentName=t,this._valueType=r,this._buffer=new Q}return e.prototype.observe=function(t,r){if(r===void 0&&(r={}),typeof t!="number"){l.diag.warn("non-number value provided to metric "+this._instrumentName+": "+t);return}this._valueType===l.ValueType.INT&&!Number.isInteger(t)&&(l.diag.warn("INT value type cannot accept a floating-point value for "+this._instrumentName+", ignoring the fractional digits."),t=Math.trunc(t),!Number.isInteger(t))||this._buffer.set(r,t)},e}();var Ra=function(){function e(){this._buffer=new Map}return e.prototype.observe=function(t,r,n){if(n===void 0&&(n={}),!!fe(t)){var o=this._buffer.get(t);if(o==null&&(o=new Q,this._buffer.set(t,o)),typeof r!="number"){l.diag.warn("non-number value provided to metric "+t._descriptor.name+": "+r);return}t._descriptor.valueType===l.ValueType.INT&&!Number.isInteger(r)&&(l.diag.warn("INT value type cannot accept a floating-point value for "+t._descriptor.name+", ignoring the fractional digits."),r=Math.trunc(r),!Number.isInteger(r))||o.set(n,r)}},e}();var Ln=function(e,t,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(e,t||[])).next())})},Pn=function(e,t){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=t.call(e,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}}},Oa=function(e,t){var r=typeof Symbol=="function"&&e[Symbol.iterator];if(!r)return e;var n=r.call(e),o,i=[],s;try{for(;(t===void 0||t-- >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},ba=function(e,t,r){if(r||arguments.length===2)for(var n=0,o=t.length,i;n<o;n++)(i||!(n in t))&&(i||(i=Array.prototype.slice.call(t,0,n)),i[n]=t[n]);return e.concat(i||Array.prototype.slice.call(t))},La=function(){function e(){this._callbacks=[],this._batchCallbacks=[]}return e.prototype.addCallback=function(t,r){var n=this._findCallback(t,r);n>=0||this._callbacks.push({callback:t,instrument:r})},e.prototype.removeCallback=function(t,r){var n=this._findCallback(t,r);n<0||this._callbacks.splice(n,1)},e.prototype.addBatchCallback=function(t,r){var n=new Set(r.filter(fe));if(n.size===0){l.diag.error("BatchObservableCallback is not associated with valid instruments",r);return}var o=this._findBatchCallback(t,n);o>=0||this._batchCallbacks.push({callback:t,instruments:n})},e.prototype.removeBatchCallback=function(t,r){var n=new Set(r.filter(fe)),o=this._findBatchCallback(t,n);o<0||this._batchCallbacks.splice(o,1)},e.prototype.observe=function(t,r){return Ln(this,void 0,void 0,function(){var n,o,i,s;return Pn(this,function(u){switch(u.label){case 0:return n=this._observeCallbacks(t,r),o=this._observeBatchCallbacks(t,r),[4,na(ba(ba([],Oa(n),!1),Oa(o),!1))];case 1:return i=u.sent(),s=i.filter(ia).map(function(c){return c.reason}),[2,s]}})})},e.prototype._observeCallbacks=function(t,r){var n=this;return this._callbacks.map(function(o){var i=o.callback,s=o.instrument;return Ln(n,void 0,void 0,function(){var u,c;return Pn(this,function(a){switch(a.label){case 0:return u=new Aa(s._descriptor.name,s._descriptor.valueType),c=Promise.resolve(i(u)),r!=null&&(c=yn(c,r)),[4,c];case 1:return a.sent(),s._metricStorages.forEach(function(f){f.record(u._buffer,t)}),[2]}})})})},e.prototype._observeBatchCallbacks=function(t,r){var n=this;return this._batchCallbacks.map(function(o){var i=o.callback,s=o.instruments;return Ln(n,void 0,void 0,function(){var u,c;return Pn(this,function(a){switch(a.label){case 0:return u=new Ra,c=Promise.resolve(i(u)),r!=null&&(c=yn(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(d){d.record(p,t)})}),[2]}})})})},e.prototype._findCallback=function(t,r){return this._callbacks.findIndex(function(n){return n.callback===t&&n.instrument===r})},e.prototype._findBatchCallback=function(t,r){return this._batchCallbacks.findIndex(function(n){return n.callback===t&&oa(n.instruments,r)})},e}();var Ef=function(){var e=function(t,r){return e=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])},e(t,r)};return function(t,r){if(typeof r!="function"&&r!==null)throw new TypeError("Class extends value "+String(r)+" is not a constructor or null");e(t,r);function n(){this.constructor=t}t.prototype=r===null?Object.create(r):(n.prototype=r.prototype,new n)}}(),Pa=function(e){Ef(t,e);function t(r,n,o,i){var s=e.call(this,r)||this;return s._attributesProcessor=o,s._deltaMetricStorage=new ur(n),s._temporalMetricStorage=new cr(n,i),s}return t.prototype.record=function(r,n,o,i){n=this._attributesProcessor.process(n,o),this._deltaMetricStorage.record(r,n,o,i)},t.prototype.collect=function(r,n){var o=this._deltaMetricStorage.collect();return this._temporalMetricStorage.buildMetrics(r,this._instrumentDescriptor,o,n)},t}(sr);var Ia=function(){var e=function(t,r){return e=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])},e(t,r)};return function(t,r){if(typeof r!="function"&&r!==null)throw new TypeError("Class extends value "+String(r)+" is not a constructor or null");e(t,r);function n(){this.constructor=t}t.prototype=r===null?Object.create(r):(n.prototype=r.prototype,new n)}}(),lr=function(){function e(){}return e.Noop=function(){return Tf},e}();var mf=function(e){Ia(t,e);function t(){return e!==null&&e.apply(this,arguments)||this}return t.prototype.process=function(r,n){return r},t}(lr);var uE=function(e){Ia(t,e);function t(r){var n=e.call(this)||this;return n._allowedAttributeNames=r,n}return t.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},t}(lr);var Tf=new mf;var Sf=function(e,t,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(e,t||[])).next())})},gf=function(e,t){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=t.call(e,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}}},yf=function(e,t){var r=typeof Symbol=="function"&&e[Symbol.iterator];if(!r)return e;var n=r.call(e),o,i=[],s;try{for(;(t===void 0||t-- >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},Ca=function(){function e(t,r){this._meterProviderSharedState=t,this._instrumentationScope=r,this.metricStorageRegistry=new ya,this.observableRegistry=new La,this.meter=new ma(this)}return e.prototype.registerMetricStorage=function(t){var r=this._registerMetricStorage(t,Pa);return r.length===1?r[0]:new va(r)},e.prototype.registerAsyncMetricStorage=function(t){var r=this._registerMetricStorage(t,ga);return r},e.prototype.collect=function(t,r,n){return Sf(this,void 0,void 0,function(){var o,i,s;return gf(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(t),i.length===0?[2,null]:(s=i.map(function(c){return c.collect(t,r)}).filter(ta),s.length===0?[2,{errors:o}]:[2,{scopeMetrics:{scope:this._instrumentationScope,metrics:s},errors:o}])}})})},e.prototype._registerMetricStorage=function(t,r){var n=this,o=this._meterProviderSharedState.viewRegistry.findViews(t,this._instrumentationScope),i=o.map(function(c){var a=sa(c,t),f=n.metricStorageRegistry.findOrUpdateCompatibleStorage(a);if(f!=null)return f;var p=c.aggregation.createAggregator(a),d=new r(a,p,c.attributesProcessor,n._meterProviderSharedState.metricCollectors);return n.metricStorageRegistry.register(d),d});if(i.length===0){var s=this._meterProviderSharedState.selectAggregations(t.type),u=s.map(function(c){var a=yf(c,2),f=a[0],p=a[1],d=n.metricStorageRegistry.findOrUpdateCompatibleCollectorStorage(f,t);if(d!=null)return d;var m=p.createAggregator(t),g=new r(t,m,lr.Noop(),[f]);return n.metricStorageRegistry.registerForCollector(f,g),g});i=i.concat(u)}return i},e}();var vf=function(e){var t=typeof Symbol=="function"&&Symbol.iterator,r=t&&e[t],n=0;if(r)return r.call(e);if(e&&typeof e.length=="number")return{next:function(){return e&&n>=e.length&&(e=void 0),{value:e&&e[n++],done:!e}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")},Na=function(){function e(t){this.resource=t,this.viewRegistry=new ca,this.metricCollectors=[],this.meterSharedStates=new Map}return e.prototype.getMeterSharedState=function(t){var r=ra(t),n=this.meterSharedStates.get(r);return n==null&&(n=new Ca(this,t),this.meterSharedStates.set(r,n)),n},e.prototype.selectAggregations=function(t){var r,n,o=[];try{for(var i=vf(this.metricCollectors),s=i.next();!s.done;s=i.next()){var u=s.value;o.push([u,u.selectAggregation(t)])}}catch(c){r={error:c}}finally{try{s&&!s.done&&(n=i.return)&&n.call(i)}finally{if(r)throw r.error}}return o},e}();var wa=v(P()),fr=function(e,t,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(e,t||[])).next())})},pr=function(e,t){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=t.call(e,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}}},Af=function(e,t){var r=typeof Symbol=="function"&&e[Symbol.iterator];if(!r)return e;var n=r.call(e),o,i=[],s;try{for(;(t===void 0||t-- >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},Rf=function(e,t,r){if(r||arguments.length===2)for(var n=0,o=t.length,i;n<o;n++)(i||!(n in t))&&(i||(i=Array.prototype.slice.call(t,0,n)),i[n]=t[n]);return e.concat(i||Array.prototype.slice.call(t))},Ma=function(){function e(t,r){this._sharedState=t,this._metricReader=r}return e.prototype.collect=function(t){return fr(this,void 0,void 0,function(){var r,n,o,i,s=this;return pr(this,function(u){switch(u.label){case 0:return r=(0,wa.millisToHrTime)(Date.now()),n=[],o=[],i=Array.from(this._sharedState.meterSharedStates.values()).map(function(c){return fr(s,void 0,void 0,function(){var a;return pr(this,function(f){switch(f.label){case 0:return[4,c.collect(this,r,t)];case 1:return a=f.sent(),a?.scopeMetrics!=null&&n.push(a.scopeMetrics),a?.errors!=null&&o.push.apply(o,Rf([],Af(a.errors),!1)),[2]}})})}),[4,Promise.all(i)];case 1:return u.sent(),[2,{resourceMetrics:{resource:this._sharedState.resource,scopeMetrics:n},errors:o}]}})})},e.prototype.forceFlush=function(t){return fr(this,void 0,void 0,function(){return pr(this,function(r){switch(r.label){case 0:return[4,this._metricReader.forceFlush(t)];case 1:return r.sent(),[2]}})})},e.prototype.shutdown=function(t){return fr(this,void 0,void 0,function(){return pr(this,function(r){switch(r.label){case 0:return[4,this._metricReader.shutdown(t)];case 1:return r.sent(),[2]}})})},e.prototype.selectAggregationTemporality=function(t){return this._metricReader.selectAggregationTemporality(t)},e.prototype.selectAggregation=function(t){return this._metricReader.selectAggregation(t)},e}();var xa=function(e,t,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(e,t||[])).next())})},Da=function(e,t){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=t.call(e,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}}},Of=function(e){var t=typeof Symbol=="function"&&Symbol.iterator,r=t&&e[t],n=0;if(r)return r.call(e);if(e&&typeof e.length=="number")return{next:function(){return e&&n>=e.length&&(e=void 0),{value:e&&e[n++],done:!e}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")},In=function(){function e(t){var r,n,o;this._shutdown=!1;var i=H.default().merge((o=t?.resource)!==null&&o!==void 0?o:H.empty());if(this._sharedState=new Na(i),t?.views!=null&&t.views.length>0)try{for(var s=Of(t.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 e.prototype.getMeter=function(t,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:t,version:r,schemaUrl:n.schemaUrl}).meter},e.prototype.addMetricReader=function(t){var r=new Ma(this._sharedState,t);t.setMetricProducer(r),this._sharedState.metricCollectors.push(r)},e.prototype.shutdown=function(t){return xa(this,void 0,void 0,function(){return Da(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(t)}))]);case 1:return r.sent(),[2]}})})},e.prototype.forceFlush=function(t){return xa(this,void 0,void 0,function(){return Da(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(t)}))];case 1:return r.sent(),[2]}})})},e}();var Nr=v(Oe(),1),Iu=v(Va(),1),Ot=v(P(),1);var Ha="http.method",Fa="http.url",hr="http.host",ja="http.scheme",wn="http.status_code",ka="http.user_agent",Mn="http.response_content_length_uncompressed",qa="net.peer.port",Xa="net.peer.name";var Ka="service.name",Wa="service.version";E();var Nf=Symbol.for("@vercel/request-context");function nt(){return globalThis[Nf]?.get()}function Er(e){return Object.fromEntries(Object.entries(e).filter(([t,r])=>r!==void 0))}function Ya(e){return e?e.split("::").at(-1):void 0}function za(e=nt(),t){if(!e)return;let r=t?Mf(t,e.headers):void 0;return Er({[hr]:e.headers.host,[ka]:e.headers["user-agent"],"http.referer":e.headers.referer,"vercel.request_id":Ya(e.headers["x-vercel-id"]),"vercel.matched_path":e.headers["x-matched-path"],"vercel.edge_region":process.env.VERCEL_REGION,...r})}var wf={keys(e){return[]},get(e,t){return e[t.toLocaleLowerCase()]}};function Mf(e,t){if(typeof e=="function")return e(t,wf);let r={};for(let[n,o]of Object.entries(e)){let i=t[o.toLocaleLowerCase()];i!==void 0&&(r[n]=i)}return r}E();function zt(e){return(e&l.TraceFlags.SAMPLED)!==0}var mr=class{constructor(t,r){this.processors=t;this.attributesFromHeaders=r;this.rootSpanIds=new Map;this.waitSpanEnd=new Map}forceFlush(){return Promise.all(this.processors.map(t=>t.forceFlush().catch(r=>{l.diag.error("@vercel/otel: forceFlush failed:",r)}))).then(()=>{})}shutdown(){return Promise.all(this.processors.map(t=>t.shutdown().catch(()=>{}))).then(()=>{})}onStart(t,r){let{traceId:n,spanId:o,traceFlags:i}=t.spanContext(),s=!t.parentSpanId||!this.rootSpanIds.has(n);if(s?this.rootSpanIds.set(n,{rootSpanId:o,open:[]}):this.rootSpanIds.get(n)?.open.push(t),s&&zt(i)){let u=nt(),c=za(u,this.attributesFromHeaders);c&&t.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(t,r)}onEnd(t){let{traceId:r,spanId:n,traceFlags:o}=t.spanContext(),i=zt(o),s=this.rootSpanIds.get(r),u=s?.rootSpanId===n;if(i){let c=Df(t);c&&Object.assign(t.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(t);if(u){let c=this.waitSpanEnd.get(r);c&&(this.waitSpanEnd.delete(r),c())}}},xf={[l.SpanKind.INTERNAL]:"internal",[l.SpanKind.SERVER]:"server",[l.SpanKind.CLIENT]:"client",[l.SpanKind.PRODUCER]:"producer",[l.SpanKind.CONSUMER]:"consumer"};function Df(e){let{kind:t,attributes:r}=e,{"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(e.kind===l.SpanKind.SERVER&&u&&c&&typeof u=="string"&&typeof c=="string")return{"operation.name":"web.request","resource.name":a};let f=e.instrumentationLibrary.name,p=s??i;if(p&&typeof p=="string"){let d=$a(f,p);return c?{"operation.name":d,"resource.name":a}:{"operation.name":d}}return{"operation.name":$a(f,t===l.SpanKind.INTERNAL?"":xf[t])}}function $a(e,t){if(!e)return t;let r=e.replace(/[ @./]/g,"_");return r.startsWith("_")&&(r=r.slice(1)),t?`${r}.${t}`:r}var fs=v(Fn(),1);var ls=v(cs(),1);E();var $t=class extends ls.OTLPExporterBase{constructor(t={}){super(t),t.headers&&(this._headers=t.headers)}onShutdown(){l.diag.debug("@vercel/otel/otlp: onShutdown")}onInit(){l.diag.debug("@vercel/otel/otlp: onInit")}send(t,r,n){if(this._shutdownOnce.isCalled){l.diag.debug("@vercel/otel/otlp: Shutdown already started. Cannot send objects");return}let o=this.convert(t),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(t){throw new Error("Method not implemented.")}};var rp="v1/traces",np=`http://localhost:4318/${rp}`;function yr(e){return typeof e.url=="string"?e.url:np}var Qt=class{constructor(t={}){this.impl=new Xn(t)}export(t,r){this.impl.export(t,r)}shutdown(){return this.impl.shutdown()}forceFlush(){return this.impl.forceFlush()}},Xn=class extends $t{convert(t){return(0,fs.createExportTraceServiceRequest)(t,{useHex:!0,useLongBits:!1})}toMessage(t){return{body:JSON.stringify(t),contentType:"application/json"}}getDefaultUrl(t){return yr(t)}};var du=v(Fn(),1);var lu=v(cu(),1);function fu(e){let t=new lu.Writer;return _p(e,t),t.finish()}function _p(e,t){if(e.resourceSpans!=null&&e.resourceSpans.length)for(let r=0;r<e.resourceSpans.length;++r)hp(e.resourceSpans[r],t.uint32(10).fork()).ldelim();return t}function hp(e,t){if(e.resource!=null&&Ep(e.resource,t.uint32(10).fork()).ldelim(),e.scopeSpans!=null&&e.scopeSpans.length)for(let r=0;r<e.scopeSpans.length;++r)mp(e.scopeSpans[r],t.uint32(18).fork()).ldelim();return e.schemaUrl!=null&&t.uint32(26).string(e.schemaUrl),t}function Ep(e,t){if(e.attributes!=null&&e.attributes.length)for(let r=0;r<e.attributes.length;++r)Jt(e.attributes[r],t.uint32(10).fork()).ldelim();return e.droppedAttributesCount!=null&&t.uint32(16).uint32(e.droppedAttributesCount),t}function mp(e,t){if(e.scope!=null&&gp(e.scope,t.uint32(10).fork()).ldelim(),e.spans!=null&&e.spans.length)for(let r=0;r<e.spans.length;++r)yp(e.spans[r],t.uint32(18).fork()).ldelim();return e.schemaUrl!=null&&t.uint32(26).string(e.schemaUrl),t}function Jt(e,t){return e.key!=null&&t.uint32(10).string(e.key),e.value!=null&&pu(e.value,t.uint32(18).fork()).ldelim(),t}function pu(e,t){return e.stringValue!=null&&t.uint32(10).string(e.stringValue),e.boolValue!=null&&t.uint32(16).bool(e.boolValue),e.intValue!=null&&t.uint32(24).int64(e.intValue),e.doubleValue!=null&&t.uint32(33).double(e.doubleValue),e.arrayValue!=null&&Tp(e.arrayValue,t.uint32(42).fork()).ldelim(),e.kvlistValue!=null&&Sp(e.kvlistValue,t.uint32(50).fork()).ldelim(),e.bytesValue!=null&&t.uint32(58).bytes(e.bytesValue),t}function Tp(e,t){if(e.values!=null&&e.values.length)for(let r=0;r<e.values.length;++r)pu(e.values[r],t.uint32(10).fork()).ldelim();return t}function Sp(e,t){if(e.values!=null&&e.values.length)for(let r=0;r<e.values.length;++r)Jt(e.values[r],t.uint32(10).fork()).ldelim();return t}function gp(e,t){if(e.name!=null&&t.uint32(10).string(e.name),e.version!=null&&t.uint32(18).string(e.version),e.attributes!=null&&e.attributes.length)for(let r=0;r<e.attributes.length;++r)Jt(e.attributes[r],t.uint32(26).fork()).ldelim();return e.droppedAttributesCount!=null&&t.uint32(32).uint32(e.droppedAttributesCount),t}function yp(e,t){if(e.traceId!=null&&t.uint32(10).bytes(e.traceId),e.spanId!=null&&t.uint32(18).bytes(e.spanId),e.traceState!=null&&t.uint32(26).string(e.traceState),e.parentSpanId!=null&&t.uint32(34).bytes(e.parentSpanId),e.name!=null&&t.uint32(42).string(e.name),e.kind!=null&&t.uint32(48).int32(e.kind),e.startTimeUnixNano!=null&&t.uint32(57).fixed64(e.startTimeUnixNano),e.endTimeUnixNano!=null&&t.uint32(65).fixed64(e.endTimeUnixNano),e.attributes!=null&&e.attributes.length)for(let r=0;r<e.attributes.length;++r)Jt(e.attributes[r],t.uint32(74).fork()).ldelim();if(e.droppedAttributesCount!=null&&t.uint32(80).uint32(e.droppedAttributesCount),e.events!=null&&e.events.length)for(let r=0;r<e.events.length;++r)Ap(e.events[r],t.uint32(90).fork()).ldelim();if(e.droppedEventsCount!=null&&t.uint32(96).uint32(e.droppedEventsCount),e.links!=null&&e.links.length)for(let r=0;r<e.links.length;++r)Rp(e.links[r],t.uint32(106).fork()).ldelim();return e.droppedLinksCount!=null&&t.uint32(112).uint32(e.droppedLinksCount),e.status!=null&&vp(e.status,t.uint32(122).fork()).ldelim(),t}function vp(e,t){return e.message!=null&&t.uint32(18).string(e.message),e.code!=null&&t.uint32(24).int32(e.code),t}function Ap(e,t){if(e.timeUnixNano!=null&&t.uint32(9).fixed64(e.timeUnixNano),e.name!=null&&t.uint32(18).string(e.name),e.attributes!=null&&e.attributes.length)for(let r=0;r<e.attributes.length;++r)Jt(e.attributes[r],t.uint32(26).fork()).ldelim();return e.droppedAttributesCount!=null&&t.uint32(32).uint32(e.droppedAttributesCount),t}function Rp(e,t){if(e.traceId!=null&&t.uint32(10).bytes(e.traceId),e.spanId!=null&&t.uint32(18).bytes(e.spanId),e.traceState!=null&&t.uint32(26).string(e.traceState),e.attributes!=null&&e.attributes.length)for(let r=0;r<e.attributes.length;++r)Jt(e.attributes[r],t.uint32(34).fork()).ldelim();return e.droppedAttributesCount!=null&&t.uint32(40).uint32(e.droppedAttributesCount),t}var Bt=class{constructor(t={}){this.impl=new oi(t)}export(t,r){this.impl.export(t,r)}shutdown(){return this.impl.shutdown()}forceFlush(){return this.impl.forceFlush()}},oi=class extends $t{convert(t){return(0,du.createExportTraceServiceRequest)(t,void 0)}toMessage(t){return{body:fu(t),contentType:"application/x-protobuf",headers:{accept:"application/x-protobuf"}}}getDefaultUrl(t){return yr(t)}};E();function _u(e,t){return e.replace(/\{(?<temp1>[^{}]+)\}/g,(r,n)=>{let o=t[n];return o!==void 0?String(o):r})}var te=class{constructor(t={}){this.instrumentationName="@vercel/otel/fetch";this.instrumentationVersion="1.0.0";this.config=t}getConfig(){return this.config}setConfig(){}setTracerProvider(t){this.tracerProvider=t}setMeterProvider(){}shouldIgnore(t,r){let n=this.config.ignoreUrls??[];if(r?.opentelemetry?.ignore!==void 0)return r.opentelemetry.ignore;if(n.length===0)return!1;let o=t.toString();return n.some(i=>typeof i=="string"?i==="*"?!0:o.startsWith(i):i.test(o))}shouldPropagate(t,r){let n=process.env.VERCEL_URL||process.env.NEXT_PUBLIC_VERCEL_URL||null,o=process.env.VERCEL_BRANCH_URL||process.env.NEXT_PUBLIC_VERCEL_BRANCH_URL||null,i=this.config.propagateContextUrls??[],s=this.config.dontPropagateContextUrls??[];if(r?.opentelemetry?.propagateContext)return r.opentelemetry.propagateContext;let u=t.toString();return s.length>0&&s.some(c=>typeof c=="string"?c==="*"?!0:u.startsWith(c):c.test(u))?!1:n&&t.protocol==="https:"&&(t.host===n||t.host===o||t.host===nt()?.headers.host)||!n&&t.protocol==="http:"&&t.hostname==="localhost"?!0:i.some(c=>typeof c=="string"?c==="*"?!0:u.startsWith(c):c.test(u))}startSpan({tracer:t,url:r,fetchType:n,method:o="GET",name:i,attributes:s={}}){let u=this.config.resourceNameTemplate,c={[Ha]:o,[Fa]:r.toString(),[hr]:r.host,[ja]:r.protocol.replace(":",""),[Xa]:r.hostname,[qa]:r.port},a=u?_u(u,c):Lp(r.toString()),f=i??`${n} ${o} ${r.toString()}`,p=l.context.active();return t.startSpan(f,{kind:l.SpanKind.CLIENT,attributes:{...c,"operation.name":`${n}.${o}`,"http.client.name":n,"resource.name":a,...s}},p)}instrumentHttp(t,r){let{tracerProvider:n}=this;if(!n)return;let o=n.getTracer(this.instrumentationName,this.instrumentationVersion),{attributesFromRequestHeaders:i,attributesFromResponseHeaders:s}=this.config,u=t.request,c=t.get,a=f=>(p,d,m)=>{let g,C={},M;if(typeof p=="string"||p instanceof URL?(g=new URL(p.toString()),typeof d=="function"?M=d:d&&typeof m=="function"?(C=d,M=m):d&&(C=d)):(C=p,typeof d=="function"&&(M=d),g=Ip(C,r)),this.shouldIgnore(g))return f.apply(this,[g,C,M]);let T=this.startSpan({tracer:o,url:g,fetchType:"http",method:C.method||"GET"});if(!T.isRecording()||!zt(T.spanContext().traceFlags))return T.end(),f.apply(this,[g,C,M]);if(this.shouldPropagate(g)){let et=l.context.active(),q=l.trace.setSpan(et,T);l.propagation.inject(q,C.headers||{},bp)}i&&br(T,i,C.headers||{},Eu);try{let et=Date.now(),q=f.apply(this,[g,C,M]);return q.prependListener("response",U=>{let wr=Date.now()-et;T.setAttribute("http.response_time",wr),U.statusCode!==void 0?(T.setAttribute(wn,U.statusCode),U.statusCode>=500&&Gt(T,`Status: ${U.statusCode}`)):Gt(T,"Response status code is undefined"),s&&br(T,s,U.headers,Eu),q.listenerCount("response")<=1&&U.resume(),U.on("end",()=>{let bt,Mr=U.statusCode;U.aborted&&!U.complete?bt={code:l.SpanStatusCode.ERROR}:Mr&&Mr>=100&&Mr<500?bt={code:l.SpanStatusCode.UNSET}:bt={code:l.SpanStatusCode.ERROR},T.setStatus(bt),T.isRecording()&&(U.headers["content-length"]&&T.setAttribute(Mn,U.headers["content-length"]),T.end())})}),q.on("error",U=>{T.isRecording()&&(Gt(T,U),T.end())}),q.on("close",()=>{T.isRecording()&&T.end()}),q}catch(et){throw Gt(T,et),T.end(),et}};t.request=a(u),t.get=a(c)}instrumentFetch(){let{tracerProvider:t}=this;if(!t)return;let r=t.getTracer(this.instrumentationName,this.instrumentationVersion),{attributesFromRequestHeaders:n,attributesFromResponseHeaders:o}=this.config;process.env.NEXT_OTEL_FETCH_DISABLED="1";let i=globalThis.fetch;this.originalFetch=i;let s=async(u,c)=>{let a=c;if(a?.next?.internal)return i(u,a);let f=new Request(u instanceof Request?u.clone():u,a),p=new URL(f.url);if(this.shouldIgnore(p,a))return i(u,a);let d=this.startSpan({tracer:r,url:p,fetchType:"fetch",method:f.method,name:a?.opentelemetry?.spanName,attributes:a?.opentelemetry?.attributes});if(!d.isRecording()||!zt(d.spanContext().traceFlags))return d.end(),i(u,a);if(this.shouldPropagate(p,a)){let m=l.context.active(),g=l.trace.setSpan(m,d);l.propagation.inject(g,f.headers,Op)}n&&br(d,n,f.headers,hu);try{let m=Date.now();a?.body&&a.body instanceof FormData&&f.headers.delete("content-type");let g=await i(u,{...a,headers:f.headers}),C=Date.now()-m;return d.setAttribute(wn,g.status),d.setAttribute("http.response_time",C),o&&br(d,o,g.headers,hu),g.status>=500&&Gt(d,`Status: ${g.status} (${g.statusText})`),g.body?Pp(g).then(M=>{d.isRecording()&&(d.setAttribute(Mn,M),d.end())},M=>{d.isRecording()&&(Gt(d,M),d.end())}):d.end(),g}catch(m){throw Gt(d,m),d.end(),m}};globalThis.fetch=s}enable(){this.disable(),this.instrumentFetch();try{let t=ci("node:http"),r=ci("node:https");this.instrumentHttp(t,"http:"),this.instrumentHttp(r,"https:")}catch{}}disable(){this.originalFetch&&(globalThis.fetch=this.originalFetch)}},Op={set(e,t,r){e.set(t,r)}},hu={get(e,t){let r=e.get(t);if(r!==null)return r.includes(",")?r.split(",").map(n=>n.trimStart()):r},keys(e){let t=[];return e.forEach((r,n)=>{t.push(n)}),t}},bp={set(e,t,r){e[t.toLowerCase()]=r}},Eu={get(e,t){return e[t.toLowerCase()]},keys(e){return Object.keys(e)}};function Lp(e){let t=e.indexOf("?");return t===-1?e:e.substring(0,t)}function Pp(e){let t=0,n=e.clone().body?.getReader();if(!n)return Promise.resolve(0);let o=()=>n.read().then(({done:i,value:s})=>{if(!i)return t+=s.byteLength,o()});return o().then(()=>t)}function Gt(e,t){if(t instanceof Error)e.recordException(t),e.setStatus({code:l.SpanStatusCode.ERROR,message:t.message});else{let r=String(t);e.setStatus({code:l.SpanStatusCode.ERROR,message:r})}}function br(e,t,r,n){for(let[o,i]of Object.entries(t)){let s=n.get(r,i);s!==void 0&&e.setAttribute(o,s)}}function Ip(e,t){if(e.socketPath)throw new Error("Cannot construct a network URL: options.socketPath is specified, indicating a Unix domain socket.");let r=e.protocol??t;r&&!r.endsWith(":")&&(r+=":");let n=e.hostname,o=e.port??e.defaultPort;if(!n&&e.host){let a=e.host.split(":");n=a[0];let f=a[1];if(a.length>1&&f&&o===void 0){let p=parseInt(f,10);isNaN(p)||(o=p)}}n||(n="localhost");let i;if(o!==void 0&&o!==""){let a=parseInt(String(o),10);isNaN(a)?i=r==="https:"?443:80:i=a}else i=r==="https:"?443:80;let s=e.path||"/",u=`${r}//${n}:${i}`,c=new URL(s,u);if(e.auth){let a=e.auth.split(":");c.username=decodeURIComponent(a[0]||""),a.length>1&&(c.password=decodeURIComponent(a[1]||""))}return c}E();var mu=v(P(),1),Cp="00",ai="traceparent",si="tracestate",Te=class{fields(){return[ai,si]}inject(t,r,n){let o=l.trace.getSpanContext(t);if(!o||(0,mu.isTracingSuppressed)(t)||!(0,l.isSpanContextValid)(o))return;let i=`${Cp}-${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(t,r,n){let o=n.get(r,ai);if(!o)return t;let i=Array.isArray(o)?o[0]:o;if(typeof i!="string")return t;let s=Np(i);if(!s)return t;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(t,s)}};function Np(e){let[t,r,n,o,i]=e.split("-");return!t||!r||!n||!o||t.length!==2||r.length!==32||n.length!==16||o.length!==2||t==="00"&&i?null:{traceId:r,spanId:n,traceFlags:parseInt(o,16)}}E();var Lr=class{fields(){return[]}inject(){}extract(t){let r=nt();if(!r?.telemetry)return l.diag.warn("@vercel/otel: Vercel telemetry extension not found."),t;let{rootSpanContext:n}=r.telemetry;return n?(l.diag.debug("@vercel/otel: Extracted root SpanContext from Vercel request context.",n),l.trace.setSpanContext(t,{...n,isRemote:!0,traceFlags:n.traceFlags||l.TraceFlags.SAMPLED})):t}};E();var Pr=v(P(),1);var ee=v(P()),wp=BigInt(1e9);function Su(e){return BigInt(e[0])*wp+BigInt(e[1])}function Mp(e){var t=Number(BigInt.asUintN(32,e)),r=Number(BigInt.asUintN(32,e>>BigInt(32)));return{low:t,high:r}}function gu(e){var t=Su(e);return Mp(t)}function xp(e){var t=Su(e);return t.toString()}var Dp=typeof BigInt<"u"?xp:ee.hrTimeToNanoseconds;function Tu(e){return e}function yu(e){if(e!==void 0)return(0,ee.hexToBase64)(e)}var Up={encodeHrTime:gu,encodeSpanContext:ee.hexToBase64,encodeOptionalSpanContext:yu};function vu(e){var t,r;if(e===void 0)return Up;var n=(t=e.useLongBits)!==null&&t!==void 0?t:!0,o=(r=e.useHex)!==null&&r!==void 0?r:!1;return{encodeHrTime:n?gu:Dp,encodeSpanContext:o?Tu:ee.hexToBase64,encodeOptionalSpanContext:o?Tu:yu}}var Bp=function(e,t){var r=typeof Symbol=="function"&&e[Symbol.iterator];if(!r)return e;var n=r.call(e),o,i=[],s;try{for(;(t===void 0||t-- >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 re(e){return Object.keys(e).map(function(t){return Au(t,e[t])})}function Au(e,t){return{key:e,value:Ru(t)}}function Ru(e){var t=typeof e;return t==="string"?{stringValue:e}:t==="number"?Number.isInteger(e)?{intValue:e}:{doubleValue:e}:t==="boolean"?{boolValue:e}:e instanceof Uint8Array?{bytesValue:e}:Array.isArray(e)?{arrayValue:{values:e.map(Ru)}}:t==="object"&&e!=null?{kvlistValue:{values:Object.entries(e).map(function(r){var n=Bp(r,2),o=n[0],i=n[1];return Au(o,i)})}}:{}}function Ou(e,t){var r,n=e.spanContext(),o=e.status;return{traceId:t.encodeSpanContext(n.traceId),spanId:t.encodeSpanContext(n.spanId),parentSpanId:t.encodeOptionalSpanContext(e.parentSpanId),traceState:(r=n.traceState)===null||r===void 0?void 0:r.serialize(),name:e.name,kind:e.kind==null?0:e.kind+1,startTimeUnixNano:t.encodeHrTime(e.startTime),endTimeUnixNano:t.encodeHrTime(e.endTime),attributes:re(e.attributes),droppedAttributesCount:e.droppedAttributesCount,events:e.events.map(function(i){return Vp(i,t)}),droppedEventsCount:e.droppedEventsCount,status:{code:o.code,message:o.message},links:e.links.map(function(i){return Gp(i,t)}),droppedLinksCount:e.droppedLinksCount}}function Gp(e,t){var r;return{attributes:e.attributes?re(e.attributes):[],spanId:t.encodeSpanContext(e.context.spanId),traceId:t.encodeSpanContext(e.context.traceId),traceState:(r=e.context.traceState)===null||r===void 0?void 0:r.serialize(),droppedAttributesCount:e.droppedAttributesCount||0}}function Vp(e,t){return{attributes:e.attributes?re(e.attributes):[],name:e.name,timeUnixNano:t.encodeHrTime(e.time),droppedAttributesCount:e.droppedAttributesCount||0}}var Hp=function(e){var t=typeof Symbol=="function"&&Symbol.iterator,r=t&&e[t],n=0;if(r)return r.call(e);if(e&&typeof e.length=="number")return{next:function(){return e&&n>=e.length&&(e=void 0),{value:e&&e[n++],done:!e}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")},Fp=function(e,t){var r=typeof Symbol=="function"&&e[Symbol.iterator];if(!r)return e;var n=r.call(e),o,i=[],s;try{for(;(t===void 0||t-- >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(e,t){var r=vu(t);return{resourceSpans:kp(e,r)}}function jp(e){var t,r,n=new Map;try{for(var o=Hp(e),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){t={error:f}}finally{try{i&&!i.done&&(r=o.return)&&r.call(o)}finally{if(t)throw t.error}}return n}function kp(e,t){for(var r=jp(e),n=[],o=r.entries(),i=o.next();!i.done;){for(var s=Fp(i.value,2),u=s[0],c=s[1],a=[],f=c.values(),p=f.next();!p.done;){var d=p.value;if(d.length>0){var m=d[0].instrumentationLibrary,g=m.name,C=m.version,M=m.schemaUrl,T=d.map(function(q){return Ou(q,t)});a.push({scope:{name:g,version:C},spans:T,schemaUrl:M})}p=f.next()}var et={resource:{attributes:re(u.attributes),droppedAttributesCount:0},scopeSpans:a,schemaUrl:void 0};n.push(et),i=o.next()}return n}var Ir=class{export(t,r){let n=nt();if(!n?.telemetry){l.diag.warn("@vercel/otel: no telemetry context found"),r({code:Pr.ExportResultCode.SUCCESS,error:void 0});return}try{let o=ui(t,{useHex:!0,useLongBits:!1});n.telemetry.reportSpans(o),r({code:Pr.ExportResultCode.SUCCESS,error:void 0})}catch(o){r({code:Pr.ExportResultCode.FAILED,error:o instanceof Error?o:new Error(String(o))})}}shutdown(){return Promise.resolve()}forceFlush(){return Promise.resolve()}};var qp={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},Cr=class{constructor(t={}){this.configuration=t}start(){let t=Xp(),r=this.configuration,n=process.env.NEXT_RUNTIME||"nodejs",o=!!t.OTEL_SDK_DISABLED;if(process.env.OTEL_LOG_LEVEL&&l.diag.setLogger(new l.DiagConsoleLogger,{logLevel:qp[process.env.OTEL_LOG_LEVEL.toUpperCase()]}),o)return;let i=r.idGenerator??new tr,s=r.contextManager??new Iu.AsyncLocalStorageContextManager;s.enable(),this.contextManager=s;let u=t.OTEL_SERVICE_NAME||r.serviceName||"app",c=new H(Er({[Ka]: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,[Wa]:process.env.VERCEL_DEPLOYMENT_ID,"vercel.project_id":process.env.VERCEL_PROJECT_ID||void 0,...r.attributes})),a=r.resourceDetectors??[No];if(r.autoDetectResources??!0){let T={detectors:a};c=c.merge(Mo(T))}let p=Wp(r.propagators,r,t),d=Yp(r.traceSampler,t),m=zp(r.spanProcessors,r,t);m.length===0&&l.diag.warn("@vercel/otel: No span processors configured. No spans will be exported.");let g=r.spanLimits,C=new Bo({resource:c,idGenerator:i,sampler:d,spanLimits:g});if(C.addSpanProcessor(new mr(m,r.attributesFromHeaders)),C.register({contextManager:s,propagator:new Ot.CompositePropagator({propagators:p})}),this.tracerProvider=C,r.logRecordProcessor){let T=new gn({resource:c});this.loggerProvider=T,T.addLogRecordProcessor(r.logRecordProcessor),st.logs.setGlobalLoggerProvider(T)}if(r.metricReader||r.views){let T=new In({resource:c,views:r.views??[]});r.metricReader&&T.addMetricReader(r.metricReader),l.metrics.setGlobalMeterProvider(T),this.meterProvider=T}let M=Kp(r.instrumentations,r.instrumentationConfig);this.disableInstrumentations=(0,Pu.registerInstrumentations)({instrumentations:M}),l.diag.info("@vercel/otel: started",u,n)}async shutdown(){let t=[];this.tracerProvider&&t.push(this.tracerProvider.shutdown()),this.loggerProvider&&t.push(this.loggerProvider.shutdown()),this.meterProvider&&t.push(this.meterProvider.shutdown()),l.diag.info("@vercel/otel: shutting down",t.length,process.env.NEXT_RUNTIME),await Promise.all(t),this.contextManager&&this.contextManager.disable();let{disableInstrumentations:r}=this;r&&r()}};function Xp(){let e=(0,Nr.parseEnvironment)(process.env);return{...Nr.DEFAULT_ENVIRONMENT,...e}}function Kp(e,t){return(e??["auto"]).map(r=>r==="auto"?(l.diag.debug("@vercel/otel: Configure instrumentations: fetch",t?.fetch),[new te(t?.fetch)]):r==="fetch"?(l.diag.debug("@vercel/otel: Configure instrumentations: fetch",t?.fetch),new te(t?.fetch)):r).flat()}function Wp(e,t,r){let n=process.env.OTEL_PROPAGATORS&&r.OTEL_PROPAGATORS&&r.OTEL_PROPAGATORS.length>0?r.OTEL_PROPAGATORS:void 0;return(e??n??["auto"]).map(o=>{if(o==="none")return[];if(o==="auto"){let i=[];return i.push({name:"tracecontext",propagator:new Te}),i.push({name:"baggage",propagator:new Ot.W3CBaggagePropagator}),i.push({name:"vercel-runtime",propagator:new Lr}),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 Te;if(o==="baggage")return l.diag.debug("@vercel/otel: Configure propagator: baggage"),new Ot.W3CBaggagePropagator;if(typeof o=="string")throw new Error(`Unknown propagator: "${o}"`);return o}).flat()}var bu="always_on",ne=1;function Yp(e,t){if(e&&typeof e!="string")return e;let r=e&&e!=="auto"?e:t.OTEL_TRACES_SAMPLER||bu;switch(l.diag.debug("@vercel/otel: Configure sampler: ",r),r){case"always_on":return new X;case"always_off":return new at;case"parentbased_always_on":return new Et({root:new X});case"parentbased_always_off":return new Et({root:new at});case"traceidratio":return new kt(Lu(t));case"parentbased_traceidratio":return new Et({root:new kt(Lu(t))});default:return l.diag.error(`@vercel/otel: OTEL_TRACES_SAMPLER value "${String(t.OTEL_TRACES_SAMPLER)} invalid, defaulting to ${bu}".`),new X}}function Lu(e){if(e.OTEL_TRACES_SAMPLER_ARG===void 0||e.OTEL_TRACES_SAMPLER_ARG==="")return l.diag.error(`@vercel/otel: OTEL_TRACES_SAMPLER_ARG is blank, defaulting to ${ne}.`),ne;l.diag.debug("@vercel/otel: Configure sampler probability: ",e.OTEL_TRACES_SAMPLER_ARG);let t=Number(e.OTEL_TRACES_SAMPLER_ARG);return isNaN(t)?(l.diag.error(`@vercel/otel: OTEL_TRACES_SAMPLER_ARG=${e.OTEL_TRACES_SAMPLER_ARG} was given, but it is invalid, defaulting to ${ne}.`),ne):t<0||t>1?(l.diag.error(`@vercel/otel: OTEL_TRACES_SAMPLER_ARG=${e.OTEL_TRACES_SAMPLER_ARG} was given, but it is out of range ([0..1]), defaulting to ${ne}.`),ne):t}function zp(e,t,r){return[...(e??["auto"]).flatMap(n=>{if(n==="auto"){let o=[new Mt(new Ir)];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 Bt(u):new Qt(u);o.push(new Mt(c))}else(!t.traceExporter||t.traceExporter==="auto"||r.OTEL_EXPORTER_OTLP_TRACES_ENDPOINT||r.OTEL_EXPORTER_OTLP_ENDPOINT)&&o.push(new Mt($p(r)));return o}return n}).filter(Jp),...t.traceExporter&&t.traceExporter!=="auto"?[new Mt(t.traceExporter)]:[]]}function $p(e){let t=process.env.OTEL_EXPORTER_OTLP_TRACES_PROTOCOL??process.env.OTEL_EXPORTER_OTLP_PROTOCOL??"http/protobuf",r=Zp(e),n={...Ot.baggageUtils.parseKeyPairsIntoRecord(e.OTEL_EXPORTER_OTLP_HEADERS),...Ot.baggageUtils.parseKeyPairsIntoRecord(e.OTEL_EXPORTER_OTLP_TRACES_HEADERS)};switch(l.diag.debug("@vercel/otel: Configure trace exporter: ",t,r,`headers: ${Object.keys(n).join(",")||"<none>"}`),t){case"http/json":return new Qt({url:r,headers:n});case"http/protobuf":return new Bt({url:r,headers:n});default:return l.diag.warn(`@vercel/otel: Unsupported OTLP traces protocol: ${t}. Using http/protobuf.`),new Bt}}var Cu="v1/traces",Qp=`http://localhost:4318/${Cu}`;function Zp(e){let t=e.OTEL_EXPORTER_OTLP_TRACES_ENDPOINT;if(t&&typeof t=="string")return t;let r=e.OTEL_EXPORTER_OTLP_ENDPOINT;return r&&typeof r=="string"?`${r}/${Cu}`:Qp}function Jp(e){return e!=null}function RT(e){let t;e?typeof e=="string"?t={serviceName:e}:t=e:t={},new Cr(t).start()}export{te as FetchInstrumentation,Qt as OTLPHttpJsonTraceExporter,Bt as OTLPHttpProtoTraceExporter,RT as registerOTel};
|
|
17
17
|
//# sourceMappingURL=index.js.map
|