@lunora/container 1.0.0-alpha.57 → 1.0.0-alpha.58
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/otel.mjs +1 -1
- package/package.json +2 -2
package/dist/otel.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as X}from"./packem_shared/abort-deadline-jwbW9Ala.mjs";import{S as G,s as K}from"./packem_shared/sampling-D21rpu_s.mjs";const k={debug:5,error:17,fatal:21,info:9,log:9,trace:1,warn:13},N=e=>`${String(Math.round(e))}000000`,z=Array.from({length:256},(e,t)=>t.toString(16).padStart(2,"0")),y=512,x=new Uint8Array(y);let T=y;const U=(e,t,r)=>{let n="";for(let o=0;o<r;o+=1)n+=z[e[t+o]];return n},P=e=>{if(e>y){const r=new Uint8Array(e);return crypto.getRandomValues(r),U(r,0,e)}T+e>y&&(crypto.getRandomValues(x),T=0);const t=U(x,T,e);return T+=e,t},A=/^[0-9a-f]+$/,W=e=>{if(e==null)return;const t=e.
|
|
1
|
+
import{a as X}from"./packem_shared/abort-deadline-jwbW9Ala.mjs";import{S as G,s as K}from"./packem_shared/sampling-D21rpu_s.mjs";const k={debug:5,error:17,fatal:21,info:9,log:9,trace:1,warn:13},N=e=>`${String(Math.round(e))}000000`,z=Array.from({length:256},(e,t)=>t.toString(16).padStart(2,"0")),y=512,x=new Uint8Array(y);let T=y;const U=(e,t,r)=>{let n="";for(let o=0;o<r;o+=1)n+=z[e[t+o]];return n},P=e=>{if(e>y){const r=new Uint8Array(e);return crypto.getRandomValues(r),U(r,0,e)}T+e>y&&(crypto.getRandomValues(x),T=0);const t=U(x,T,e);return T+=e,t},A=/^[0-9a-f]+$/,W=e=>{if(e==null)return;const t=e.split("-"),[r,n,o,s]=t;if(!(t.length<4||r===void 0||r.length!==2||!A.test(r)||r==="ff"||r==="00"&&t.length!==4||n===void 0||o===void 0||s===void 0||s.length!==2||!A.test(s)||n.length!==32||o.length!==16||!A.test(n)||!A.test(o)||n==="00000000000000000000000000000000"||o==="0000000000000000"))return{parentSpanId:o,sampled:(Number.parseInt(s,16)&1)===1,traceId:n}},h=(e,t)=>typeof t=="boolean"?{key:e,value:{boolValue:t}}:typeof t=="number"?Number.isFinite(t)?Number.isSafeInteger(t)?{key:e,value:{intValue:String(t)}}:{key:e,value:{doubleValue:t}}:{key:e,value:{stringValue:String(t)}}:{key:e,value:{stringValue:t}},D=e=>e===void 0?[]:Object.entries(e).map(([t,r])=>h(t,r)),q=(e,t,r)=>{const n={},o=new Map,s=(i,a)=>{const m=i.toLowerCase(),f=o.get(m);f===void 0?(o.set(m,i),n[i]=a):n[f]=a};for(const[i,a]of Object.entries(e))s(i,a);for(const[i,a]of Object.entries(t??{}))s(i,a);return r!==void 0&&r.length>0&&s("authorization",`Bearer ${r}`),n},C=e=>Array.isArray(e)?e:[e],H=(e,t)=>{const r={"service.name":e};for(const[n,o]of Object.entries(t??{}))r[n]=o;return Object.entries(r).map(([n,o])=>h(n,o))},J=(e,t,r,n)=>({resourceSpans:[{resource:{attributes:H(r,n)},scopeSpans:[{scope:{name:t},spans:C(e)}]}]}),Q=(e,t,r,n)=>({resourceLogs:[{resource:{attributes:H(r,n)},scopeLogs:[{logRecords:C(e),scope:{name:t}}]}]}),Z=512,ee=200,V=e=>{const t=e.maxItems??Z,r=e.maxDelayMs??ee;let n=[],o,s,i;const a=()=>{o!==void 0&&(clearTimeout(o),o=void 0)},m=async()=>{a();const d=n;n=[];const u=i;s=void 0,i=void 0;try{d.length>0&&await e.export(d)}catch{}finally{u?.()}},f=d=>{s===void 0&&(s=new Promise(u=>{i=u}),o=setTimeout(()=>{m()},r)),d?.(s)};return{add:(d,u)=>{for(n.push(d);n.length>t;)n.shift();f(u),n.length>=t&&m()},flush:async d=>{if(n.length===0){a();return}const u=m();return d?.(u),u},get size(){return n.length}}},te=e=>{const t={},r=e("SERVICE_VERSION")??e("CF_VERSION_METADATA")??e("VERCEL_GIT_COMMIT_SHA")??e("GITHUB_SHA")??e("COMMIT_SHA");r!==void 0&&(t["service.version"]=r);const n=e("DEPLOYMENT_ENVIRONMENT")??e("ENVIRONMENT")??e("NODE_ENV");return n!==void 0&&(t["deployment.environment"]=n),t},re=(e,t)=>{const r={},n=e("HOSTNAME")??e("COMPUTERNAME");n!==void 0&&(r["host.name"]=n);const o=e("KUBERNETES_POD_NAME")??(e("KUBERNETES_SERVICE_HOST")===void 0?void 0:e("HOSTNAME"));return o!==void 0&&(r["k8s.pod.name"]=o),t!==void 0&&Number.isFinite(t)&&(r["process.pid"]=t),r},B=(...e)=>{const t={};for(const r of e)if(r!==void 0)for(const[n,o]of Object.entries(r))t[n]=o;return t},ne=e=>e===void 0||e!=="0",oe=1e4,$=1,E=e=>process.env[e],se=()=>{const e=typeof process.pid!="number"?void 0:process.pid;return B(te(E),re(E,e))},ie=e=>e??(typeof globalThis.fetch=="function"?globalThis.fetch:void 0),ce=(e,t)=>{const r=D(e.attributes);e.error?.type!==void 0&&r.push(h("error.type",e.error.type));const n={attributes:r,endTimeUnixNano:N(e.endMs),flags:t?.sampled??!0?$:0,kind:1,name:e.name,...t===void 0?{}:{parentSpanId:t.parentSpanId},spanId:P(8),startTimeUnixNano:N(e.startMs),status:e.error===void 0?{code:1}:{code:2,message:e.error.message},traceId:t?.traceId??P(16)};return e.error&&(n.events=[{attributes:[h("exception.type",e.error.type??"Error"),h("exception.message",e.error.message)],name:"exception",timeUnixNano:N(e.endMs)}]),n},ae=(e,t,r)=>{const n=e.level??"info";return{attributes:D(e.attributes),body:{stringValue:e.message},severityNumber:k[n],severityText:n.toUpperCase(),timeUnixNano:N(e.ts??t),...r===void 0?{}:{flags:r.sampled?$:0,spanId:r.parentSpanId,traceId:r.traceId}}},Ee=(e={})=>{const t=e.endpoint??E("LUNORA_OTLP_ENDPOINT"),r=t!==void 0&&t.length>0,n=e.token??E("LUNORA_OTLP_TOKEN"),o=e.serviceName??E("LUNORA_SERVICE_NAME")??"lunora-container",s=e.request?.headers,i=W(e.traceparent??s?.get("traceparent")??E("LUNORA_TRACEPARENT")),a=i?.sampled!==!1,m=e.alwaysSampleErrors??ne(s?.get(G)??E("LUNORA_SAMPLE_ERRORS")),f=e.timeoutMs??oe,d=ie(e.fetch),u=q({"content-type":"application/json"},e.headers,n),j=e.detectResources===!0?se():void 0,S={};e.serviceVersion!==void 0&&(S["service.version"]=e.serviceVersion),e.deploymentEnvironment!==void 0&&(S["deployment.environment"]=e.deploymentEnvironment),e.resourceAttributes!==void 0&&Object.assign(S,e.resourceAttributes);const M=B(j,S);let p=t??"";for(;p.endsWith("/");)p=p.slice(0,-1);const F=`${p}/v1/traces`,Y=`${p}/v1/logs`,O=new Set,I=(c,R)=>{if(d===void 0)return e.onError?.(new TypeError("createContainerTelemetry: no `fetch` available — pass `fetch` in options for this runtime.")),Promise.resolve();const v=(async()=>{const l=X(void 0,f,()=>new DOMException(`OTLP export to ${c} timed out after ${String(f)}ms`,"TimeoutError"));try{const g=await d(c,{body:JSON.stringify(R),headers:u,method:"POST",signal:l.signal});g.ok||e.onError?.(new Error(`createContainerTelemetry: OTLP export to ${c} failed with status ${String(g.status)}.`));try{await g.body?.cancel()}catch{}}catch(g){e.onError?.(g)}finally{l.dispose()}})().finally(()=>{O.delete(v)});return O.add(v),v},L=V({export:c=>I(F,J(c,"@lunora/container",o,M))}),w=V({export:c=>I(Y,Q(c,"@lunora/container",o,M))}),b=c=>{!r||!K({isTraced:a,keepErrors:m},c.error!==void 0)||L.add(ce(c,i))};return{emitLog:c=>{r&&w.add(ae(c,Date.now(),i))},emitSpan:b,enabled:r,flush:async()=>{await Promise.allSettled([L.flush(),w.flush()]),await Promise.allSettled(O)},trace:async(c,R,_)=>{const v=Date.now();try{const l=await R();return b({attributes:_,endMs:Date.now(),name:c,startMs:v}),l}catch(l){throw b({attributes:_,endMs:Date.now(),error:{message:l instanceof Error?l.message:String(l),type:l instanceof Error?l.name:void 0},name:c,startMs:v}),l}}}};export{Ee as createContainerTelemetry};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lunora/container",
|
|
3
|
-
"version": "1.0.0-alpha.
|
|
3
|
+
"version": "1.0.0-alpha.58",
|
|
4
4
|
"description": "Cloudflare Containers for Lunora: defineContainer, generated Container DO classes, and the ctx.containers action surface",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"cloudflare",
|
|
@@ -56,7 +56,7 @@
|
|
|
56
56
|
"access": "public"
|
|
57
57
|
},
|
|
58
58
|
"dependencies": {
|
|
59
|
-
"@lunora/errors": "1.0.0-alpha.
|
|
59
|
+
"@lunora/errors": "1.0.0-alpha.42"
|
|
60
60
|
},
|
|
61
61
|
"engines": {
|
|
62
62
|
"node": "^22.15.0 || >=24.11.0"
|