"use strict";var A=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports),T=A((e,t)=>{var r=/^[!#$%&'*+\-.^_`|~0-9A-Za-z]+$/,o=/[\r\n\0]/;t.exports={validateOtelHeaders:function(e){let t,n={};if(!e||"object"!=typeof e||Array.isArray(e))return n;try{t=Object.keys(e)}catch{return n}let a=0;for(let c of t){let t,s;if("string"!=typeof c||!r.test(c))continue;try{t=e[c]}catch{continue}if("string"==typeof t)s=t;else{if("number"!=typeof t&&"boolean"!=typeof t)continue;s=String(t)}if(o.test(s))continue;let i=Buffer.byteLength(c,"utf8")+Buffer.byteLength(s,"utf8");a+i>8192||(a+=i,n[c]=s)}return n},MAX_TOTAL_BYTES:8192}}),f=A((e,t)=>{t.exports={WORKER_FLUSH_TIMEOUT_MS:5e3,EXECUTION_HANDLER_GRACE_MS:7e3,PROCESS_MANAGER_GRACE_MS:8e3,PERFTEST_CLEANUP_GRACE_MS:9e3,PARENT_TRACING_FLUSH_TIMEOUT_MS:1500,WORKER_ABORT_FALLBACK_MS:4e3}}),{validateOtelHeaders:w}=T(),{WORKER_FLUSH_TIMEOUT_MS:m}=f(),O="postman-performance-test",d=m;function F(e){return"full"===e?"full":"minimal"}function M(){try{let e=require("@opentelemetry/api"),{NodeTracerProvider:t,BatchSpanProcessor:r}=require("@opentelemetry/sdk-trace-node"),{OTLPTraceExporter:o}=require("@opentelemetry/exporter-trace-otlp-http"),{resourceFromAttributes:n}=require("@opentelemetry/resources"),{ATTR_SERVICE_NAME:a}=require("@opentelemetry/semantic-conventions");return{api:e,NodeTracerProvider:t,BatchSpanProcessor:r,OTLPTraceExporter:o,resourceFromAttributes:n,ATTR_SERVICE_NAME:a}}catch(e){try{console.debug(`[perftest] OpenTelemetry packages unavailable: ${e&&e.message?e.message:e}`)}catch{}return null}}function h(e){try{let t=new URL(e);return"http:"===t.protocol||"https:"===t.protocol}catch{return!1}}var y={spanContext:()=>({traceId:"",spanId:"",traceFlags:0}),setAttribute(){return this},setAttributes(){return this},addEvent(){return this},setStatus(){return this},end(){},isRecording:()=>!1,recordException(){},updateName(){return this}},C={startSpan:()=>y};function I(e){let t={tracer:C,provider:null,api:null};if(!e||!e.otelCollectorUrl)return t;if(!h(e.otelCollectorUrl)){try{console.warn("[perftest] Invalid otelCollectorUrl. Tracing disabled.")}catch{}return t}let r=M();if(!r){try{console.warn("[perftest] OpenTelemetry packages not found. Tracing disabled.")}catch{}return t}try{let{api:t,NodeTracerProvider:o,BatchSpanProcessor:n,OTLPTraceExporter:a,resourceFromAttributes:c,ATTR_SERVICE_NAME:s}=r,i=e.otelServiceName||O,l=c({[s]:i}),u={url:e.otelCollectorUrl},p=w(e.otelHeaders);Object.keys(p).length>0&&(u.headers=p);let E=new a(u),_=new o({resource:l,spanProcessors:[new n(E)]});return{tracer:_.getTracer(i),provider:_,api:t}}catch(e){try{console.warn(`[perftest] Failed to initialize tracing: ${e.message}. Tracing disabled.`)}catch{}return t}}async function G(e,t=d){if(!e)return;let r,o=!1,n=async()=>{try{"function"==typeof e.forceFlush&&await e.forceFlush()}catch{}try{"function"==typeof e.shutdown&&(o=!0,await e.shutdown())}catch{}};try{await Promise.race([n(),new Promise((e,o)=>{r=setTimeout(()=>o(Error("otel shutdown timeout")),t)})])}catch{if(!o&&"function"==typeof e.shutdown)try{Promise.resolve().then(()=>e.shutdown()).catch(()=>{})}catch{}}finally{r&&clearTimeout(r)}}module.exports={createTracer:I,shutdownProvider:G,tryRequireOtel:M,validateUrl:h,normalizeOtelSpanDetail:F,NOOP_TRACER:C,NOOP_SPAN:y,DEFAULT_SERVICE_NAME:O,FLUSH_TIMEOUT_MS:d};