@pydantic/logfire-cf-workers 0.11.9 → 0.11.10

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/index.cjs CHANGED
@@ -1 +1 @@
1
- Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:`Module`}});let e=require(`@opentelemetry/sdk-trace-base`),t=require(`@pydantic/otel-cf-workers`),n=require(`logfire`),r=require(`@opentelemetry/core`),i=require(`@opentelemetry/otlp-transformer`);async function a(e,t){let r=t.LOGFIRE_TOKEN;if(r===void 0||r===``){console.warn(`No token provided, not sending payload to Logfire`);return}let i=(0,n.resolveBaseUrl)(t,void 0,r),a=o(e);if(a!==null)try{return await fetch(`${i}/v1/traces`,{body:JSON.stringify(a),headers:{Authorization:r,"Content-Type":`application/json`},method:`POST`})}catch(e){console.error(e);return}}function o(e){for(let t of e)for(let e of t.logs)if(Array.isArray(e.message)){for(let t of e.message)if(s(t))return t}return null}function s(e){return typeof e==`object`&&!!e&&`resourceSpans`in e}const c={1:`trace`,5:`debug`,9:`info`,10:`notice`,13:`warning`,17:`error`,21:`fatal`};var l=class{export(e,t){this.sendSpans(e,t)}async forceFlush(){return Promise.resolve()}async shutdown(){return this.sendSpans([]),this.forceFlush()}exportInfo(e){return{attributes:e.attributes,duration:(0,r.hrTimeToMicroseconds)(e.duration),events:e.events,id:e.spanContext().spanId,instrumentationScope:e.instrumentationScope,kind:e.kind,links:e.links,name:e.name,parentSpanContext:e.parentSpanContext,resource:{attributes:e.resource.attributes},status:e.status,timestamp:(0,r.hrTimeToMicroseconds)(e.startTime),traceId:e.spanContext().traceId,traceState:e.spanContext().traceState?.serialize()}}sendSpans(e,t){for(let t of e){let e=c[t.attributes[`logfire.level_num`]]??`info`,{attributes:n,name:r,...i}=this.exportInfo(t);console.log(`Logfire: ${e} >> ${r}`),console.log(`Attributes:`),console.log(JSON.stringify(n,null,2)),console.log(`---`),console.log(`Span details:`),console.log(JSON.stringify(i,null,2)),console.log(`---`)}t&&t({code:r.ExportResultCode.SUCCESS})}},u=class{export(e,t){this._sendSpans(e,t)}async shutdown(){return this._sendSpans([]),Promise.resolve()}_cleanNullValues(e){if(!e.resourceSpans)return e;for(let t of e.resourceSpans){d(t.resource);for(let e of t.scopeSpans){e.scope&&d(e.scope);for(let t of e.spans??[])d(t)}}return e}_sendSpans(e,t){let n=i.JsonTraceSerializer.serializeRequest(e),a=new TextDecoder().decode(n),o=JSON.parse(a),s=this._cleanNullValues(o);return console.log(s),t?.({code:r.ExportResultCode.SUCCESS})}};function d(e){e?.attributes&&(e.attributes=e.attributes.filter(f))}function f(e){return Object.keys(e.value).length>0}function p(t){return r=>{let{LOGFIRE_ENVIRONMENT:i,LOGFIRE_TOKEN:a=``}=r,o=(0,n.resolveBaseUrl)(r,t.baseUrl,a),s=t.environment??i,c=t.additionalSpanProcessors??[];return t.console===!0&&c.push(new e.SimpleSpanProcessor(new l)),{...t,additionalSpanProcessors:c,exporter:{headers:{Authorization:a},url:`${o}/v1/traces`},idGenerator:new n.ULIDGenerator,postProcessor:e=>v(e),...s===void 0?{}:{environment:s}}}}function m(e){return t=>({...e,exporter:new u,idGenerator:new n.ULIDGenerator})}function h(e,r){return r.scrubbing!==void 0&&(0,n.configureLogfireApi)({scrubbing:r.scrubbing}),(0,t.instrument)(e,p(r))}function g(e,n){return(0,t.instrument)(e,m(n))}const _=h;function v(e){for(let t of e){for(let e of Object.keys(t.attributes))t.attributes[e]??delete t.attributes[e];Object.assign(t.attributes,(0,n.serializeAttributes)(t.attributes))}return e}const y={exportTailEventsToLogfire:a,configureLogfireApi:n.configureLogfireApi,debug:n.debug,error:n.error,fatal:n.fatal,getTailConfig:m,info:n.info,instrument:_,instrumentInProcess:h,instrumentTail:g,Level:n.Level,log:n.log,logfireApiConfig:n.logfireApiConfig,LogfireAttributeScrubber:n.LogfireAttributeScrubber,NoopAttributeScrubber:n.NoopAttributeScrubber,notice:n.notice,reportError:n.reportError,resolveBaseUrl:n.resolveBaseUrl,resolveSendToLogfire:n.resolveSendToLogfire,serializeAttributes:n.serializeAttributes,span:n.span,startSpan:n.startSpan,trace:n.trace,ULIDGenerator:n.ULIDGenerator,warning:n.warning};exports.default=y,exports.exportTailEventsToLogfire=a,exports.getTailConfig=m,exports.instrument=_,exports.instrumentInProcess=h,exports.instrumentTail=g;
1
+ Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:`Module`}});let e=require(`@opentelemetry/sdk-trace-base`),t=require(`@pydantic/otel-cf-workers`),n=require(`logfire`),r=require(`@opentelemetry/core`),i=require(`@opentelemetry/otlp-transformer`);async function a(e,t){let r=t.LOGFIRE_TOKEN;if(r===void 0||r===``){console.warn(`No token provided, not sending payload to Logfire`);return}let i=(0,n.resolveBaseUrl)(t,void 0,r),a=o(e);if(a!==null)try{return await fetch(`${i}/v1/traces`,{body:JSON.stringify(a),headers:{Authorization:r,"Content-Type":`application/json`},method:`POST`})}catch(e){console.error(e);return}}function o(e){for(let t of e)for(let e of t.logs)if(Array.isArray(e.message)){for(let t of e.message)if(s(t))return t}return null}function s(e){return typeof e==`object`&&!!e&&`resourceSpans`in e}const c={1:`trace`,5:`debug`,9:`info`,10:`notice`,13:`warning`,17:`error`,21:`fatal`};var l=class{export(e,t){this.sendSpans(e,t)}async forceFlush(){return Promise.resolve()}async shutdown(){return this.sendSpans([]),this.forceFlush()}exportInfo(e){return{attributes:e.attributes,duration:(0,r.hrTimeToMicroseconds)(e.duration),events:e.events,id:e.spanContext().spanId,instrumentationScope:e.instrumentationScope,kind:e.kind,links:e.links,name:e.name,parentSpanContext:e.parentSpanContext,resource:{attributes:e.resource.attributes},status:e.status,timestamp:(0,r.hrTimeToMicroseconds)(e.startTime),traceId:e.spanContext().traceId,traceState:e.spanContext().traceState?.serialize()}}sendSpans(e,t){for(let t of e){let e=c[t.attributes[`logfire.level_num`]]??`info`,{attributes:n,name:r,...i}=this.exportInfo(t);console.log(`Logfire: ${e} >> ${r}`),console.log(`Attributes:`),console.log(JSON.stringify(n,null,2)),console.log(`---`),console.log(`Span details:`),console.log(JSON.stringify(i,null,2)),console.log(`---`)}t&&t({code:r.ExportResultCode.SUCCESS})}},u=class{export(e,t){this.sendSpans(e,t)}async shutdown(){return this.sendSpans([]),Promise.resolve()}cleanNullValues(e){if(!e.resourceSpans)return e;for(let t of e.resourceSpans){d(t.resource);for(let e of t.scopeSpans){e.scope&&d(e.scope);for(let t of e.spans??[])d(t)}}return e}sendSpans(e,t){let n=i.JsonTraceSerializer.serializeRequest(e),a=new TextDecoder().decode(n),o=JSON.parse(a),s=this.cleanNullValues(o);return console.log(s),t?.({code:r.ExportResultCode.SUCCESS})}};function d(e){e?.attributes&&(e.attributes=e.attributes.filter(f))}function f(e){return Object.keys(e.value).length>0}function p(t){return r=>{let{LOGFIRE_ENVIRONMENT:i,LOGFIRE_TOKEN:a=``}=r,o=(0,n.resolveBaseUrl)(r,t.baseUrl,a),s=t.environment??i,c=t.additionalSpanProcessors??[];return t.console===!0&&c.push(new e.SimpleSpanProcessor(new l)),{...t,additionalSpanProcessors:c,exporter:{headers:{Authorization:a},url:`${o}/v1/traces`},idGenerator:new n.ULIDGenerator,postProcessor:e=>v(e),...s===void 0?{}:{environment:s}}}}function m(e){return t=>({...e,exporter:new u,idGenerator:new n.ULIDGenerator})}function h(e,r){return r.scrubbing!==void 0&&(0,n.configureLogfireApi)({scrubbing:r.scrubbing}),(0,t.instrument)(e,p(r))}function g(e,n){return(0,t.instrument)(e,m(n))}const _=h;function v(e){for(let t of e){for(let e of Object.keys(t.attributes))t.attributes[e]??delete t.attributes[e];Object.assign(t.attributes,(0,n.serializeAttributes)(t.attributes))}return e}const y={exportTailEventsToLogfire:a,configureLogfireApi:n.configureLogfireApi,debug:n.debug,error:n.error,fatal:n.fatal,getTailConfig:m,info:n.info,instrument:_,instrumentInProcess:h,instrumentTail:g,Level:n.Level,log:n.log,logfireApiConfig:n.logfireApiConfig,LogfireAttributeScrubber:n.LogfireAttributeScrubber,NoopAttributeScrubber:n.NoopAttributeScrubber,notice:n.notice,reportError:n.reportError,resolveBaseUrl:n.resolveBaseUrl,resolveSendToLogfire:n.resolveSendToLogfire,serializeAttributes:n.serializeAttributes,span:n.span,startSpan:n.startSpan,trace:n.trace,ULIDGenerator:n.ULIDGenerator,warning:n.warning};exports.default=y,exports.exportTailEventsToLogfire=a,exports.getTailConfig=m,exports.instrument=_,exports.instrumentInProcess=h,exports.instrumentTail=g;
package/dist/index.js CHANGED
@@ -1 +1 @@
1
- import{SimpleSpanProcessor as e}from"@opentelemetry/sdk-trace-base";import{instrument as t}from"@pydantic/otel-cf-workers";import{Level as n,LogfireAttributeScrubber as r,NoopAttributeScrubber as i,ULIDGenerator as a,configureLogfireApi as o,debug as s,error as c,fatal as l,info as u,log as d,logfireApiConfig as f,notice as p,reportError as m,resolveBaseUrl as h,resolveSendToLogfire as g,serializeAttributes as _,span as v,startSpan as y,trace as b,warning as x}from"logfire";import{ExportResultCode as S,hrTimeToMicroseconds as C}from"@opentelemetry/core";import{JsonTraceSerializer as w}from"@opentelemetry/otlp-transformer";async function T(e,t){let n=t.LOGFIRE_TOKEN;if(n===void 0||n===``){console.warn(`No token provided, not sending payload to Logfire`);return}let r=h(t,void 0,n),i=E(e);if(i!==null)try{return await fetch(`${r}/v1/traces`,{body:JSON.stringify(i),headers:{Authorization:n,"Content-Type":`application/json`},method:`POST`})}catch(e){console.error(e);return}}function E(e){for(let t of e)for(let e of t.logs)if(Array.isArray(e.message)){for(let t of e.message)if(D(t))return t}return null}function D(e){return typeof e==`object`&&!!e&&`resourceSpans`in e}const O={1:`trace`,5:`debug`,9:`info`,10:`notice`,13:`warning`,17:`error`,21:`fatal`};var k=class{export(e,t){this.sendSpans(e,t)}async forceFlush(){return Promise.resolve()}async shutdown(){return this.sendSpans([]),this.forceFlush()}exportInfo(e){return{attributes:e.attributes,duration:C(e.duration),events:e.events,id:e.spanContext().spanId,instrumentationScope:e.instrumentationScope,kind:e.kind,links:e.links,name:e.name,parentSpanContext:e.parentSpanContext,resource:{attributes:e.resource.attributes},status:e.status,timestamp:C(e.startTime),traceId:e.spanContext().traceId,traceState:e.spanContext().traceState?.serialize()}}sendSpans(e,t){for(let t of e){let e=O[t.attributes[`logfire.level_num`]]??`info`,{attributes:n,name:r,...i}=this.exportInfo(t);console.log(`Logfire: ${e} >> ${r}`),console.log(`Attributes:`),console.log(JSON.stringify(n,null,2)),console.log(`---`),console.log(`Span details:`),console.log(JSON.stringify(i,null,2)),console.log(`---`)}t&&t({code:S.SUCCESS})}},A=class{export(e,t){this._sendSpans(e,t)}async shutdown(){return this._sendSpans([]),Promise.resolve()}_cleanNullValues(e){if(!e.resourceSpans)return e;for(let t of e.resourceSpans){j(t.resource);for(let e of t.scopeSpans){e.scope&&j(e.scope);for(let t of e.spans??[])j(t)}}return e}_sendSpans(e,t){let n=w.serializeRequest(e),r=new TextDecoder().decode(n),i=JSON.parse(r),a=this._cleanNullValues(i);return console.log(a),t?.({code:S.SUCCESS})}};function j(e){e?.attributes&&(e.attributes=e.attributes.filter(M))}function M(e){return Object.keys(e.value).length>0}function N(t){return n=>{let{LOGFIRE_ENVIRONMENT:r,LOGFIRE_TOKEN:i=``}=n,o=h(n,t.baseUrl,i),s=t.environment??r,c=t.additionalSpanProcessors??[];return t.console===!0&&c.push(new e(new k)),{...t,additionalSpanProcessors:c,exporter:{headers:{Authorization:i},url:`${o}/v1/traces`},idGenerator:new a,postProcessor:e=>R(e),...s===void 0?{}:{environment:s}}}}function P(e){return t=>({...e,exporter:new A,idGenerator:new a})}function F(e,n){return n.scrubbing!==void 0&&o({scrubbing:n.scrubbing}),t(e,N(n))}function I(e,n){return t(e,P(n))}const L=F;function R(e){for(let t of e){for(let e of Object.keys(t.attributes))t.attributes[e]??delete t.attributes[e];Object.assign(t.attributes,_(t.attributes))}return e}const z={exportTailEventsToLogfire:T,configureLogfireApi:o,debug:s,error:c,fatal:l,getTailConfig:P,info:u,instrument:L,instrumentInProcess:F,instrumentTail:I,Level:n,log:d,logfireApiConfig:f,LogfireAttributeScrubber:r,NoopAttributeScrubber:i,notice:p,reportError:m,resolveBaseUrl:h,resolveSendToLogfire:g,serializeAttributes:_,span:v,startSpan:y,trace:b,ULIDGenerator:a,warning:x};export{z as default,T as exportTailEventsToLogfire,P as getTailConfig,L as instrument,F as instrumentInProcess,I as instrumentTail};
1
+ import{SimpleSpanProcessor as e}from"@opentelemetry/sdk-trace-base";import{instrument as t}from"@pydantic/otel-cf-workers";import{Level as n,LogfireAttributeScrubber as r,NoopAttributeScrubber as i,ULIDGenerator as a,configureLogfireApi as o,debug as s,error as c,fatal as l,info as u,log as d,logfireApiConfig as f,notice as p,reportError as m,resolveBaseUrl as h,resolveSendToLogfire as g,serializeAttributes as _,span as v,startSpan as y,trace as b,warning as x}from"logfire";import{ExportResultCode as S,hrTimeToMicroseconds as C}from"@opentelemetry/core";import{JsonTraceSerializer as w}from"@opentelemetry/otlp-transformer";async function T(e,t){let n=t.LOGFIRE_TOKEN;if(n===void 0||n===``){console.warn(`No token provided, not sending payload to Logfire`);return}let r=h(t,void 0,n),i=E(e);if(i!==null)try{return await fetch(`${r}/v1/traces`,{body:JSON.stringify(i),headers:{Authorization:n,"Content-Type":`application/json`},method:`POST`})}catch(e){console.error(e);return}}function E(e){for(let t of e)for(let e of t.logs)if(Array.isArray(e.message)){for(let t of e.message)if(D(t))return t}return null}function D(e){return typeof e==`object`&&!!e&&`resourceSpans`in e}const O={1:`trace`,5:`debug`,9:`info`,10:`notice`,13:`warning`,17:`error`,21:`fatal`};var k=class{export(e,t){this.sendSpans(e,t)}async forceFlush(){return Promise.resolve()}async shutdown(){return this.sendSpans([]),this.forceFlush()}exportInfo(e){return{attributes:e.attributes,duration:C(e.duration),events:e.events,id:e.spanContext().spanId,instrumentationScope:e.instrumentationScope,kind:e.kind,links:e.links,name:e.name,parentSpanContext:e.parentSpanContext,resource:{attributes:e.resource.attributes},status:e.status,timestamp:C(e.startTime),traceId:e.spanContext().traceId,traceState:e.spanContext().traceState?.serialize()}}sendSpans(e,t){for(let t of e){let e=O[t.attributes[`logfire.level_num`]]??`info`,{attributes:n,name:r,...i}=this.exportInfo(t);console.log(`Logfire: ${e} >> ${r}`),console.log(`Attributes:`),console.log(JSON.stringify(n,null,2)),console.log(`---`),console.log(`Span details:`),console.log(JSON.stringify(i,null,2)),console.log(`---`)}t&&t({code:S.SUCCESS})}},A=class{export(e,t){this.sendSpans(e,t)}async shutdown(){return this.sendSpans([]),Promise.resolve()}cleanNullValues(e){if(!e.resourceSpans)return e;for(let t of e.resourceSpans){j(t.resource);for(let e of t.scopeSpans){e.scope&&j(e.scope);for(let t of e.spans??[])j(t)}}return e}sendSpans(e,t){let n=w.serializeRequest(e),r=new TextDecoder().decode(n),i=JSON.parse(r),a=this.cleanNullValues(i);return console.log(a),t?.({code:S.SUCCESS})}};function j(e){e?.attributes&&(e.attributes=e.attributes.filter(M))}function M(e){return Object.keys(e.value).length>0}function N(t){return n=>{let{LOGFIRE_ENVIRONMENT:r,LOGFIRE_TOKEN:i=``}=n,o=h(n,t.baseUrl,i),s=t.environment??r,c=t.additionalSpanProcessors??[];return t.console===!0&&c.push(new e(new k)),{...t,additionalSpanProcessors:c,exporter:{headers:{Authorization:i},url:`${o}/v1/traces`},idGenerator:new a,postProcessor:e=>R(e),...s===void 0?{}:{environment:s}}}}function P(e){return t=>({...e,exporter:new A,idGenerator:new a})}function F(e,n){return n.scrubbing!==void 0&&o({scrubbing:n.scrubbing}),t(e,N(n))}function I(e,n){return t(e,P(n))}const L=F;function R(e){for(let t of e){for(let e of Object.keys(t.attributes))t.attributes[e]??delete t.attributes[e];Object.assign(t.attributes,_(t.attributes))}return e}const z={exportTailEventsToLogfire:T,configureLogfireApi:o,debug:s,error:c,fatal:l,getTailConfig:P,info:u,instrument:L,instrumentInProcess:F,instrumentTail:I,Level:n,log:d,logfireApiConfig:f,LogfireAttributeScrubber:r,NoopAttributeScrubber:i,notice:p,reportError:m,resolveBaseUrl:h,resolveSendToLogfire:g,serializeAttributes:_,span:v,startSpan:y,trace:b,ULIDGenerator:a,warning:x};export{z as default,T as exportTailEventsToLogfire,P as getTailConfig,L as instrument,F as instrumentInProcess,I as instrumentTail};
package/package.json CHANGED
@@ -26,7 +26,7 @@
26
26
  "stats",
27
27
  "monitoring"
28
28
  ],
29
- "version": "0.11.9",
29
+ "version": "0.11.10",
30
30
  "type": "module",
31
31
  "main": "./dist/index.cjs",
32
32
  "module": "./dist/index.js",
@@ -45,17 +45,17 @@
45
45
  },
46
46
  "dependencies": {
47
47
  "@pydantic/otel-cf-workers": "^1.0.0-rc.56",
48
- "logfire": "0.15.1"
48
+ "logfire": "0.15.2"
49
49
  },
50
50
  "devDependencies": {
51
- "@cloudflare/workers-types": "4.20250311.0",
51
+ "@cloudflare/workers-types": "4.20260528.1",
52
52
  "@opentelemetry/core": "^2.7.1",
53
- "@opentelemetry/otlp-transformer": "^0.217.0",
53
+ "@opentelemetry/otlp-transformer": ">=0.217.0 <0.300.0",
54
54
  "@opentelemetry/sdk-trace-base": "^2.7.1"
55
55
  },
56
56
  "peerDependencies": {
57
57
  "@opentelemetry/core": "^2.7.1",
58
- "@opentelemetry/otlp-transformer": "^0.217.0",
58
+ "@opentelemetry/otlp-transformer": ">=0.217.0 <0.300.0",
59
59
  "@opentelemetry/sdk-trace-base": "^2.7.1"
60
60
  },
61
61
  "files": [