@pydantic/logfire-cf-workers 0.4.1 → 0.4.3
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 +5 -0
- package/dist/index.d.ts +5 -0
- package/dist/index.js +12 -10
- package/package.json +2 -2
package/dist/index.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var
|
|
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;
|
package/dist/index.d.cts
CHANGED
|
@@ -17,6 +17,11 @@ export declare interface InProcessConfigOptions extends ConfigOptionsBase {
|
|
|
17
17
|
baseUrl?: string;
|
|
18
18
|
}
|
|
19
19
|
|
|
20
|
+
/**
|
|
21
|
+
* Alias for `instrumentInProcess` to maintain compatibility with previous versions.
|
|
22
|
+
*/
|
|
23
|
+
export declare const instrument: typeof instrumentInProcess;
|
|
24
|
+
|
|
20
25
|
export declare function instrumentInProcess<T>(handler: T, config: InProcessConfigOptions): T;
|
|
21
26
|
|
|
22
27
|
export declare function instrumentTail<T>(handler: T, config: TailConfigOptions): T;
|
package/dist/index.d.ts
CHANGED
|
@@ -17,6 +17,11 @@ export declare interface InProcessConfigOptions extends ConfigOptionsBase {
|
|
|
17
17
|
baseUrl?: string;
|
|
18
18
|
}
|
|
19
19
|
|
|
20
|
+
/**
|
|
21
|
+
* Alias for `instrumentInProcess` to maintain compatibility with previous versions.
|
|
22
|
+
*/
|
|
23
|
+
export declare const instrument: typeof instrumentInProcess;
|
|
24
|
+
|
|
20
25
|
export declare function instrumentInProcess<T>(handler: T, config: InProcessConfigOptions): T;
|
|
21
26
|
|
|
22
27
|
export declare function instrumentTail<T>(handler: T, config: TailConfigOptions): T;
|
package/dist/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
var d = Object.defineProperty;
|
|
2
|
-
var
|
|
3
|
-
var c = (e, t, r) =>
|
|
4
|
-
import { resolveBaseUrl as u, serializeAttributes as
|
|
2
|
+
var m = (e, t, r) => t in e ? d(e, t, { enumerable: !0, configurable: !0, writable: !0, value: r }) : e[t] = r;
|
|
3
|
+
var c = (e, t, r) => m(e, typeof t != "symbol" ? t + "" : t, r);
|
|
4
|
+
import { resolveBaseUrl as u, serializeAttributes as g } from "@pydantic/logfire-api";
|
|
5
5
|
import { instrument as f } from "@pydantic/otel-cf-workers";
|
|
6
6
|
import { ExportResultCode as S } from "@opentelemetry/core";
|
|
7
7
|
import { JsonTraceSerializer as y } from "@opentelemetry/otlp-transformer";
|
|
@@ -50,7 +50,7 @@ function T() {
|
|
|
50
50
|
e <<= BigInt(8), e |= BigInt(r);
|
|
51
51
|
return e;
|
|
52
52
|
}
|
|
53
|
-
async function
|
|
53
|
+
async function G(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");
|
|
@@ -85,7 +85,7 @@ function v(e) {
|
|
|
85
85
|
url: `${n}/v1/traces`
|
|
86
86
|
},
|
|
87
87
|
idGenerator: new l(),
|
|
88
|
-
postProcessor: (o) =>
|
|
88
|
+
postProcessor: (o) => I(o)
|
|
89
89
|
});
|
|
90
90
|
};
|
|
91
91
|
}
|
|
@@ -95,25 +95,27 @@ function x(e) {
|
|
|
95
95
|
idGenerator: new l()
|
|
96
96
|
});
|
|
97
97
|
}
|
|
98
|
-
function
|
|
98
|
+
function E(e, t) {
|
|
99
99
|
return f(e, v(t));
|
|
100
100
|
}
|
|
101
101
|
function P(e, t) {
|
|
102
102
|
return f(e, x(t));
|
|
103
103
|
}
|
|
104
|
-
|
|
104
|
+
const R = E;
|
|
105
|
+
function I(e) {
|
|
105
106
|
for (const t of e) {
|
|
106
107
|
for (const r of Object.keys(t.attributes)) {
|
|
107
108
|
const n = t.attributes[r];
|
|
108
109
|
n == null && delete t.attributes[r];
|
|
109
110
|
}
|
|
110
|
-
Object.assign(t.attributes,
|
|
111
|
+
Object.assign(t.attributes, g(t.attributes));
|
|
111
112
|
}
|
|
112
113
|
return e;
|
|
113
114
|
}
|
|
114
115
|
export {
|
|
115
|
-
|
|
116
|
+
G as exportTailEventsToLogfire,
|
|
116
117
|
x as getTailConfig,
|
|
117
|
-
|
|
118
|
+
R as instrument,
|
|
119
|
+
E as instrumentInProcess,
|
|
118
120
|
P as instrumentTail
|
|
119
121
|
};
|
package/package.json
CHANGED
|
@@ -22,7 +22,7 @@
|
|
|
22
22
|
"stats",
|
|
23
23
|
"monitoring"
|
|
24
24
|
],
|
|
25
|
-
"version": "0.4.
|
|
25
|
+
"version": "0.4.3",
|
|
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.51"
|
|
54
54
|
},
|
|
55
55
|
"devDependencies": {
|
|
56
56
|
"@cloudflare/workers-types": "4.20250311.0",
|