@pydantic/logfire-cf-workers 0.4.3 → 0.4.4

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
- "use strict";var S=Object.defineProperty;var y=(t,e,r)=>e in t?S(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);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const c=require("@pydantic/logfire-api"),l=require("@pydantic/otel-cf-workers"),T=require("@opentelemetry/core"),m=require("@opentelemetry/otlp-transformer"),b=require("@opentelemetry/sdk-trace-base");class v{export(e,r){this._sendSpans(e,r)}shutdown(){return this._sendSpans([]),Promise.resolve()}_cleanNullValues(e){if(!e.resourceSpans)return e;for(const r of e.resourceSpans){a(r.resource);for(const n of r.scopeSpans){n.scope&&a(n.scope);for(const s of n.spans??[])a(s)}}return e}_sendSpans(e,r){const n=m.JsonTraceSerializer.serializeRequest(e),s=new TextDecoder().decode(n),o=JSON.parse(s),i=this._cleanNullValues(o);return console.log(i),r==null?void 0:r({code:T.ExportResultCode.SUCCESS})}}function a(t){t!=null&&t.attributes&&(t.attributes=t.attributes.filter(O))}function O(t){return Object.keys(t.value).length>0}class f extends b.RandomIdGenerator{constructor(){super(...arguments);u(this,"generateTraceId",()=>h().toString(16).padStart(32,"0"))}}function h(){let t=BigInt(Date.now());const e=crypto.getRandomValues(new Uint8Array(10));for(const r of e)t<<=BigInt(8),t|=BigInt(r);return t}async function E(t,e){const r=e.LOGFIRE_TOKEN;if(!r){console.warn("No token provided, not sending payload to Logfire");return}const n=c.resolveBaseUrl(e,void 0,r);for(const s of t)for(const o of s.logs)if(Array.isArray(o.message)){for(const i of o.message)if("resourceSpans"in i)try{return await fetch(`${n}/v1/traces`,{body:JSON.stringify(i),headers:{Authorization:r,"Content-Type":"application/json"},method:"POST"})}catch(g){console.error(g)}}}function I(t){return e=>{const{LOGFIRE_TOKEN:r=""}=e,n=c.resolveBaseUrl(e,t.baseUrl,r);return Object.assign({},t,{exporter:{headers:{Authorization:r},url:`${n}/v1/traces`},idGenerator:new f,postProcessor:s=>w(s)})}}function p(t){return e=>Object.assign({},t,{exporter:new v,idGenerator:new f})}function d(t,e){return l.instrument(t,I(e))}function x(t,e){return l.instrument(t,p(e))}const A=d;function w(t){for(const e of t){for(const r of Object.keys(e.attributes)){const n=e.attributes[r];n==null&&delete e.attributes[r]}Object.assign(e.attributes,c.serializeAttributes(e.attributes))}return t}exports.exportTailEventsToLogfire=E;exports.getTailConfig=p;exports.instrument=A;exports.instrumentInProcess=d;exports.instrumentTail=x;
1
+ "use strict";var m=Object.defineProperty;var S=(t,e,r)=>e in t?m(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r;var u=(t,e,r)=>S(t,typeof e!="symbol"?e+"":e,r);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const c=require("@pydantic/logfire-api"),l=require("@pydantic/otel-cf-workers"),y=require("@opentelemetry/core"),T=require("@opentelemetry/otlp-transformer"),v=require("@opentelemetry/sdk-trace-base");class b{export(e,r){this._sendSpans(e,r)}shutdown(){return this._sendSpans([]),Promise.resolve()}_cleanNullValues(e){if(!e.resourceSpans)return e;for(const r of e.resourceSpans){a(r.resource);for(const n of r.scopeSpans){n.scope&&a(n.scope);for(const o of n.spans??[])a(o)}}return e}_sendSpans(e,r){const n=T.JsonTraceSerializer.serializeRequest(e),o=new TextDecoder().decode(n),s=JSON.parse(o),i=this._cleanNullValues(s);return console.log(i),r==null?void 0:r({code:y.ExportResultCode.SUCCESS})}}function a(t){t!=null&&t.attributes&&(t.attributes=t.attributes.filter(E))}function E(t){return Object.keys(t.value).length>0}class f extends v.RandomIdGenerator{constructor(){super(...arguments);u(this,"generateTraceId",()=>O().toString(16).padStart(32,"0"))}}function O(){let t=BigInt(Date.now());const e=crypto.getRandomValues(new Uint8Array(10));for(const r of e)t<<=BigInt(8),t|=BigInt(r);return t}async function I(t,e){const r=e.LOGFIRE_TOKEN;if(!r){console.warn("No token provided, not sending payload to Logfire");return}const n=c.resolveBaseUrl(e,void 0,r);for(const o of t)for(const s of o.logs)if(Array.isArray(s.message)){for(const i of s.message)if("resourceSpans"in i)try{return await fetch(`${n}/v1/traces`,{body:JSON.stringify(i),headers:{Authorization:r,"Content-Type":"application/json"},method:"POST"})}catch(g){console.error(g)}}}function h(t){return e=>{const{LOGFIRE_ENVIRONMENT:r,LOGFIRE_TOKEN:n=""}=e,o=c.resolveBaseUrl(e,t.baseUrl,n),s=t.environment??r;return Object.assign({},t,{environment:s,exporter:{headers:{Authorization:n},url:`${o}/v1/traces`},idGenerator:new f,postProcessor:i=>N(i)})}}function p(t){return e=>Object.assign({},t,{exporter:new b,idGenerator:new f})}function d(t,e){return l.instrument(t,h(e))}function x(t,e){return l.instrument(t,p(e))}const A=d;function N(t){for(const e of t){for(const r of Object.keys(e.attributes)){const n=e.attributes[r];n==null&&delete e.attributes[r]}Object.assign(e.attributes,c.serializeAttributes(e.attributes))}return t}exports.exportTailEventsToLogfire=I;exports.getTailConfig=p;exports.instrument=A;exports.instrumentInProcess=d;exports.instrumentTail=x;
package/dist/index.d.cts CHANGED
@@ -5,7 +5,7 @@ export declare interface CloudflareConfigOptions {
5
5
  token: string;
6
6
  }
7
7
 
8
- declare type ConfigOptionsBase = Pick<TraceConfig, 'fetch' | 'handlers' | 'instrumentation' | 'propagator' | 'sampling' | 'scope' | 'service'>;
8
+ declare type ConfigOptionsBase = Pick<TraceConfig, 'environment' | 'fetch' | 'handlers' | 'instrumentation' | 'propagator' | 'sampling' | 'scope' | 'service'>;
9
9
 
10
10
  declare type Env = Record<string, string | undefined>;
11
11
 
package/dist/index.d.ts CHANGED
@@ -5,7 +5,7 @@ export declare interface CloudflareConfigOptions {
5
5
  token: string;
6
6
  }
7
7
 
8
- declare type ConfigOptionsBase = Pick<TraceConfig, 'fetch' | 'handlers' | 'instrumentation' | 'propagator' | 'sampling' | 'scope' | 'service'>;
8
+ declare type ConfigOptionsBase = Pick<TraceConfig, 'environment' | 'fetch' | 'handlers' | 'instrumentation' | 'propagator' | 'sampling' | 'scope' | 'service'>;
9
9
 
10
10
  declare type Env = Record<string, string | undefined>;
11
11
 
package/dist/index.js CHANGED
@@ -2,11 +2,11 @@ var d = Object.defineProperty;
2
2
  var m = (e, t, r) => t in e ? d(e, t, { enumerable: !0, configurable: !0, writable: !0, value: r }) : e[t] = r;
3
3
  var c = (e, t, r) => m(e, typeof t != "symbol" ? t + "" : t, r);
4
4
  import { resolveBaseUrl as u, serializeAttributes as g } from "@pydantic/logfire-api";
5
- import { instrument as f } from "@pydantic/otel-cf-workers";
5
+ import { instrument as l } from "@pydantic/otel-cf-workers";
6
6
  import { ExportResultCode as S } from "@opentelemetry/core";
7
7
  import { JsonTraceSerializer as y } from "@opentelemetry/otlp-transformer";
8
- import { RandomIdGenerator as b } from "@opentelemetry/sdk-trace-base";
9
- class h {
8
+ import { RandomIdGenerator as v } from "@opentelemetry/sdk-trace-base";
9
+ class b {
10
10
  export(t, r) {
11
11
  this._sendSpans(t, r);
12
12
  }
@@ -32,25 +32,25 @@ class h {
32
32
  }
33
33
  }
34
34
  function a(e) {
35
- e != null && e.attributes && (e.attributes = e.attributes.filter(O));
35
+ e != null && e.attributes && (e.attributes = e.attributes.filter(E));
36
36
  }
37
- function O(e) {
37
+ function E(e) {
38
38
  return Object.keys(e.value).length > 0;
39
39
  }
40
- class l extends b {
40
+ class f extends v {
41
41
  constructor() {
42
42
  super(...arguments);
43
- c(this, "generateTraceId", () => T().toString(16).padStart(32, "0"));
43
+ c(this, "generateTraceId", () => O().toString(16).padStart(32, "0"));
44
44
  }
45
45
  }
46
- function T() {
46
+ function O() {
47
47
  let e = BigInt(Date.now());
48
48
  const t = crypto.getRandomValues(new Uint8Array(10));
49
49
  for (const r of t)
50
50
  e <<= BigInt(8), e |= BigInt(r);
51
51
  return e;
52
52
  }
53
- async function G(e, t) {
53
+ async function k(e, t) {
54
54
  const r = t.LOGFIRE_TOKEN;
55
55
  if (!r) {
56
56
  console.warn("No token provided, not sending payload to Logfire");
@@ -76,33 +76,34 @@ async function G(e, t) {
76
76
  }
77
77
  }
78
78
  }
79
- function v(e) {
79
+ function T(e) {
80
80
  return (t) => {
81
- const { LOGFIRE_TOKEN: r = "" } = t, n = u(t, e.baseUrl, r);
81
+ const { LOGFIRE_ENVIRONMENT: r, LOGFIRE_TOKEN: n = "" } = t, o = u(t, e.baseUrl, n), s = e.environment ?? r;
82
82
  return Object.assign({}, e, {
83
+ environment: s,
83
84
  exporter: {
84
- headers: { Authorization: r },
85
- url: `${n}/v1/traces`
85
+ headers: { Authorization: n },
86
+ url: `${o}/v1/traces`
86
87
  },
87
- idGenerator: new l(),
88
- postProcessor: (o) => I(o)
88
+ idGenerator: new f(),
89
+ postProcessor: (i) => x(i)
89
90
  });
90
91
  };
91
92
  }
92
- function x(e) {
93
+ function h(e) {
93
94
  return (t) => Object.assign({}, e, {
94
- exporter: new h(),
95
- idGenerator: new l()
95
+ exporter: new b(),
96
+ idGenerator: new f()
96
97
  });
97
98
  }
98
- function E(e, t) {
99
- return f(e, v(t));
99
+ function I(e, t) {
100
+ return l(e, T(t));
100
101
  }
101
- function P(e, t) {
102
- return f(e, x(t));
102
+ function C(e, t) {
103
+ return l(e, h(t));
103
104
  }
104
- const R = E;
105
- function I(e) {
105
+ const L = I;
106
+ function x(e) {
106
107
  for (const t of e) {
107
108
  for (const r of Object.keys(t.attributes)) {
108
109
  const n = t.attributes[r];
@@ -113,9 +114,9 @@ function I(e) {
113
114
  return e;
114
115
  }
115
116
  export {
116
- G as exportTailEventsToLogfire,
117
- x as getTailConfig,
118
- R as instrument,
119
- E as instrumentInProcess,
120
- P as instrumentTail
117
+ k as exportTailEventsToLogfire,
118
+ h as getTailConfig,
119
+ L as instrument,
120
+ I as instrumentInProcess,
121
+ C as instrumentTail
121
122
  };
package/package.json CHANGED
@@ -22,7 +22,7 @@
22
22
  "stats",
23
23
  "monitoring"
24
24
  ],
25
- "version": "0.4.3",
25
+ "version": "0.4.4",
26
26
  "type": "module",
27
27
  "main": "./dist/index.cjs",
28
28
  "module": "./dist/index.js",
@@ -50,7 +50,7 @@
50
50
  },
51
51
  "dependencies": {
52
52
  "@pydantic/logfire-api": "*",
53
- "@pydantic/otel-cf-workers": "^1.0.0-rc.51"
53
+ "@pydantic/otel-cf-workers": "^1.0.0-rc.53"
54
54
  },
55
55
  "devDependencies": {
56
56
  "@cloudflare/workers-types": "4.20250311.0",