@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 +1 -1
- package/dist/index.d.cts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +30 -29
- package/package.json +2 -2
package/dist/index.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var
|
|
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
|
|
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
|
|
9
|
-
class
|
|
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(
|
|
35
|
+
e != null && e.attributes && (e.attributes = e.attributes.filter(E));
|
|
36
36
|
}
|
|
37
|
-
function
|
|
37
|
+
function E(e) {
|
|
38
38
|
return Object.keys(e.value).length > 0;
|
|
39
39
|
}
|
|
40
|
-
class
|
|
40
|
+
class f extends v {
|
|
41
41
|
constructor() {
|
|
42
42
|
super(...arguments);
|
|
43
|
-
c(this, "generateTraceId", () =>
|
|
43
|
+
c(this, "generateTraceId", () => O().toString(16).padStart(32, "0"));
|
|
44
44
|
}
|
|
45
45
|
}
|
|
46
|
-
function
|
|
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
|
|
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
|
|
79
|
+
function T(e) {
|
|
80
80
|
return (t) => {
|
|
81
|
-
const {
|
|
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:
|
|
85
|
-
url: `${
|
|
85
|
+
headers: { Authorization: n },
|
|
86
|
+
url: `${o}/v1/traces`
|
|
86
87
|
},
|
|
87
|
-
idGenerator: new
|
|
88
|
-
postProcessor: (
|
|
88
|
+
idGenerator: new f(),
|
|
89
|
+
postProcessor: (i) => x(i)
|
|
89
90
|
});
|
|
90
91
|
};
|
|
91
92
|
}
|
|
92
|
-
function
|
|
93
|
+
function h(e) {
|
|
93
94
|
return (t) => Object.assign({}, e, {
|
|
94
|
-
exporter: new
|
|
95
|
-
idGenerator: new
|
|
95
|
+
exporter: new b(),
|
|
96
|
+
idGenerator: new f()
|
|
96
97
|
});
|
|
97
98
|
}
|
|
98
|
-
function
|
|
99
|
-
return
|
|
99
|
+
function I(e, t) {
|
|
100
|
+
return l(e, T(t));
|
|
100
101
|
}
|
|
101
|
-
function
|
|
102
|
-
return
|
|
102
|
+
function C(e, t) {
|
|
103
|
+
return l(e, h(t));
|
|
103
104
|
}
|
|
104
|
-
const
|
|
105
|
-
function
|
|
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
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
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.
|
|
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.
|
|
53
|
+
"@pydantic/otel-cf-workers": "^1.0.0-rc.53"
|
|
54
54
|
},
|
|
55
55
|
"devDependencies": {
|
|
56
56
|
"@cloudflare/workers-types": "4.20250311.0",
|