var d=Object.defineProperty;var y=(t,e,r)=>e in t?d(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r;var u=(t,e,r)=>(y(t,typeof e!="symbol"?e+"":e,r),r);import{$ as h,aP as o}from"./index-D8-yxEbK.js";import{aV as p,aQ as m,aW as z,aS as E,aT as D,aU as w,aR as L}from"./index-D8-yxEbK.js";import{LDObserve as c}from"./observability-CMDgcIl7.js";const s=h();class b{constructor(){u(this,"initialized",!1);u(this,"ldObserve")}isEnabled(){return typeof c<"u"}getName(){return"launchdarkly"}async initialize(e,r){if(this.initialized)return!0;if(!this.isEnabled())return s.info("LaunchDarkly client ID not provided, skipping LaunchDarkly initialization"),!1;try{return this.ldObserve=c,this.initialized=!0,!0}catch(i){return s.warn("Failed to initialize LaunchDarkly observability adapter:",i),!1}}incrementMetric(e,r){if(this.initialized)try{this.ldObserve.recordIncr({name:e,attributes:r==null?void 0:r.tags})}catch(i){s.warn(`Failed to increment metric ${e}:`,i)}}recordDistribution(e,r,i){if(this.initialized)try{this.ldObserve.recordHistogram({name:e,value:r,attributes:i==null?void 0:i.tags})}catch(a){s.warn(`Failed to record distribution ${e}:`,a)}}setGauge(e,r,i){if(this.initialized)try{this.ldObserve.recordGauge({name:e,value:r,attributes:i==null?void 0:i.tags})}catch(a){s.warn(`Failed to set gauge ${e}:`,a)}}captureException(e,r){if(this.initialized)try{const i=e instanceof Error?e:new Error(e),a={};if(r)for(const[l,n]of Object.entries(r))a[l]=String(n);r!=null&&r.source&&(a.source=String(r.source)),r!=null&&r.errorType?a.errorType=String(r.errorType):i.name&&(a.errorType=i.name),this.ldObserve.recordError(i,i.message||String(e),Object.keys(a).length>0?a:void 0)}catch(i){s.warn("[LaunchDarkly] Failed to capture exception:",i)}}captureMessage(e,r,i){if(this.initialized)try{if(r==="error"){const a={};if(i)for(const[l,n]of Object.entries(i))a[l]=String(n);this.ldObserve.recordError(new Error(e),e,Object.keys(a).length>0?a:void 0)}}catch(a){s.warn("Failed to capture message:",a)}}setUser(e){}setContext(e,r){}}try{o.register("launchdarkly",new b)}catch(t){console.debug("LaunchDarkly adapter not available:",t)}export{b as LaunchDarklyAdapter,p as METRIC_NAMES,m as ObservabilityRegistry,z as flushMetricQueue,E as incrementMetric,o as observabilityRegistry,D as recordDistribution,w as setGauge,L as trackError};
//# sourceMappingURL=index-DYrinCbS.js.map
