@pydantic/logfire-cf-workers 2.0.26 → 2.0.27
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.d.ts +6 -1
- package/dist/index.js +1 -1
- package/package.json +2 -2
package/dist/index.d.ts
CHANGED
|
@@ -28,7 +28,12 @@ export interface InProcessConfigOptions extends ConfigOptionsBase {
|
|
|
28
28
|
*/
|
|
29
29
|
scrubbing?: false | ScrubbingOptions;
|
|
30
30
|
}
|
|
31
|
-
export interface TailConfigOptions extends ConfigOptionsBase {
|
|
31
|
+
export interface TailConfigOptions extends ConfigOptionsBase {
|
|
32
|
+
/**
|
|
33
|
+
* Options for scrubbing sensitive data before spans are handed to the tail worker. Set to False to disable.
|
|
34
|
+
*/
|
|
35
|
+
scrubbing?: false | ScrubbingOptions;
|
|
36
|
+
}
|
|
32
37
|
export declare function getTailConfig(config: TailConfigOptions): (env: Env) => TraceConfig;
|
|
33
38
|
export declare function instrumentInProcess<T>(handler: T, config: InProcessConfigOptions): T;
|
|
34
39
|
export declare function instrumentDO<Env = unknown, T extends DOClass<Env> = DOClass<Env>>(doClass: T, config: InProcessConfigOptions): T;
|
package/dist/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{SimpleSpanProcessor as e}from"@opentelemetry/sdk-trace-base";import{OTLP_EXPORTER_USER_AGENT as t,instrument as n,instrumentDO as r}from"@pydantic/otel-cf-workers";import{Level as i,LogfireAttributeScrubber as a,NoopAttributeScrubber as o,ULIDGenerator as s,configureLogfireApi as c,debug as l,error as u,fatal as d,info as f,log as p,logfireApiConfig as m,notice as h,reportError as g,resolveBaseUrl as _,resolveSendToLogfire as v,
|
|
1
|
+
import{SimpleSpanProcessor as e}from"@opentelemetry/sdk-trace-base";import{OTLP_EXPORTER_USER_AGENT as t,instrument as n,instrumentDO as r}from"@pydantic/otel-cf-workers";import{Level as i,LogfireAttributeScrubber as a,NoopAttributeScrubber as o,ULIDGenerator as s,configureLogfireApi as c,debug as l,error as u,fatal as d,info as f,log as p,logfireApiConfig as m,notice as h,reportError as g,resolveBaseUrl as _,resolveSendToLogfire as v,scrubSpanForExport as y,scrubbedSpanCopy as b,serializeAttributes as x,span as S,startPendingSpan as C,startSpan as w,trace as T,warning as E,withSettings as D,withTags as O}from"logfire";import{ExportResultCode as k,hrTimeToMicroseconds as A}from"@opentelemetry/core";import{JsonTraceSerializer as j}from"@opentelemetry/otlp-transformer";const M=`logfire-js/2.0.27`;async function N(e,n){let r=n.LOGFIRE_TOKEN;if(r===void 0||r===``){console.warn(`No token provided, not sending payload to Logfire`);return}let i=_(n,void 0,r),a=P(e);if(a!==null)try{return await fetch(`${i}/v1/traces`,{body:JSON.stringify(a),headers:{Authorization:r,"Content-Type":`application/json`,"User-Agent":`${M} ${t}`},method:`POST`})}catch(e){console.error(e);return}}function P(e){for(let t of e)for(let e of t.logs)if(Array.isArray(e.message)){for(let t of e.message)if(F(t))return t}return null}function F(e){return typeof e==`object`&&!!e&&`resourceSpans`in e}const I={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:A(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:A(e.startTime),traceId:e.spanContext().traceId,traceState:e.spanContext().traceState?.serialize()}}sendSpans(e,t){for(let t of e.map(e=>b(e))){let e=I[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:k.SUCCESS})}},R=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){z(t.resource);for(let e of t.scopeSpans){e.scope&&z(e.scope);for(let t of e.spans??[])z(t)}}return e}sendSpans(e,t){for(let t of e)y(t);let n=j.serializeRequest(e),r=new TextDecoder().decode(n),i=JSON.parse(r),a=this.cleanNullValues(i);return console.log(a),t?.({code:k.SUCCESS})}};function z(e){e?.attributes&&(e.attributes=e.attributes.filter(B))}function B(e){return Object.keys(e.value).length>0}function V(e,t){if(typeof e!=`object`||!e)return;let n=e[t];return typeof n==`string`?n:void 0}function H(e){e.scrubbing!==void 0&&c({scrubbing:e.scrubbing})}function U(t){return n=>{let r=V(n,`LOGFIRE_TOKEN`)??``,i=V(n,`LOGFIRE_ENVIRONMENT`),a=_(n,t.baseUrl,r),o=t.environment??i,c=[...t.additionalSpanProcessors??[]];return t.console===!0&&c.push(new e(new L)),{...t,additionalSpanProcessors:c,exporter:{headers:{Authorization:r},url:`${a}/v1/traces`,userAgent:M},idGenerator:new s,postProcessor:e=>Y(e),...o===void 0?{}:{environment:o}}}}function W(e){return H(e),t=>({...e,exporter:new R,idGenerator:new s})}function G(e,t){return H(t),n(e,U(t))}function K(e,t){return H(t),r(e,U(t))}function q(e,t){return n(e,W(t))}const J=G;function Y(e){for(let t of e){for(let e of Object.keys(t.attributes))t.attributes[e]??delete t.attributes[e];let e=`logfire.span_type`in t.attributes,n=x(t.attributes);for(let[e,r]of Object.entries(n))Object.defineProperty(t.attributes,e,{configurable:!0,enumerable:!0,value:r,writable:!0});y(t,e?{}:{alreadyScrubbed:n})}return e}const X={exportTailEventsToLogfire:N,configureLogfireApi:c,debug:l,error:u,fatal:d,getTailConfig:W,info:f,instrument:J,instrumentDO:K,instrumentInProcess:G,instrumentTail:q,Level:i,log:p,logfireApiConfig:m,LogfireAttributeScrubber:a,NoopAttributeScrubber:o,notice:h,reportError:g,resolveBaseUrl:_,resolveSendToLogfire:v,serializeAttributes:x,span:S,startPendingSpan:C,startSpan:w,trace:T,ULIDGenerator:s,warning:E,withSettings:D,withTags:O};export{X as default,N as exportTailEventsToLogfire,W as getTailConfig,J as instrument,K as instrumentDO,G as instrumentInProcess,q as instrumentTail};
|
package/package.json
CHANGED
|
@@ -26,7 +26,7 @@
|
|
|
26
26
|
"stats",
|
|
27
27
|
"monitoring"
|
|
28
28
|
],
|
|
29
|
-
"version": "2.0.
|
|
29
|
+
"version": "2.0.27",
|
|
30
30
|
"type": "module",
|
|
31
31
|
"main": "./dist/index.js",
|
|
32
32
|
"module": "./dist/index.js",
|
|
@@ -39,7 +39,7 @@
|
|
|
39
39
|
},
|
|
40
40
|
"dependencies": {
|
|
41
41
|
"@pydantic/otel-cf-workers": "2.1.6",
|
|
42
|
-
"logfire": "0.23.
|
|
42
|
+
"logfire": "0.23.3"
|
|
43
43
|
},
|
|
44
44
|
"devDependencies": {
|
|
45
45
|
"@cloudflare/workers-types": "4.20260528.1",
|