@pydantic/logfire-cf-workers 0.9.0 → 0.10.0
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 +20 -20
- package/dist/index.d.ts +20 -20
- package/dist/index.js +8 -8
- package/package.json +2 -2
package/dist/index.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const v=require("@opentelemetry/sdk-trace-base"),
|
|
1
|
+
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const v=require("@opentelemetry/sdk-trace-base"),g=require("@pydantic/otel-cf-workers"),r=require("logfire"),c=require("@opentelemetry/core"),m=require("@opentelemetry/otlp-transformer");async function d(t,e){const o=e.LOGFIRE_TOKEN;if(!o){console.warn("No token provided, not sending payload to Logfire");return}const n=r.resolveBaseUrl(e,void 0,o);for(const s of t)for(const a of s.logs)if(Array.isArray(a.message)){for(const i of a.message)if("resourceSpans"in i)try{return await fetch(`${n}/v1/traces`,{body:JSON.stringify(i),headers:{Authorization:o,"Content-Type":"application/json"},method:"POST"})}catch(u){console.error(u)}}}const T=Object.freeze(Object.defineProperty({__proto__:null,exportTailEventsToLogfire:d},Symbol.toStringTag,{value:"Module"})),E={1:"trace",5:"debug",9:"info",10:"notice",13:"warning",17:"error",21:"fatal"};class L{export(e,o){this.sendSpans(e,o)}forceFlush(){return Promise.resolve()}shutdown(){return this.sendSpans([]),this.forceFlush()}exportInfo(e){var o;return{attributes:e.attributes,duration:c.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:c.hrTimeToMicroseconds(e.startTime),traceId:e.spanContext().traceId,traceState:(o=e.spanContext().traceState)==null?void 0:o.serialize()}}sendSpans(e,o){for(const n of e){const s=E[n.attributes["logfire.level_num"]]??"info",{attributes:a,name:i,...u}=this.exportInfo(n);console.log(`Logfire: ${s} >> ${i}`),console.log("Attributes:"),console.log(JSON.stringify(a,null,2)),console.log("---"),console.log("Span details:"),console.log(JSON.stringify(u,null,2)),console.log("---")}o&&o({code:c.ExportResultCode.SUCCESS})}}class h{export(e,o){this._sendSpans(e,o)}shutdown(){return this._sendSpans([]),Promise.resolve()}_cleanNullValues(e){if(!e.resourceSpans)return e;for(const o of e.resourceSpans){l(o.resource);for(const n of o.scopeSpans){n.scope&&l(n.scope);for(const s of n.spans??[])l(s)}}return e}_sendSpans(e,o){const n=m.JsonTraceSerializer.serializeRequest(e),s=new TextDecoder().decode(n),a=JSON.parse(s),i=this._cleanNullValues(a);return console.log(i),o==null?void 0:o({code:c.ExportResultCode.SUCCESS})}}function l(t){t!=null&&t.attributes&&(t.attributes=t.attributes.filter(x))}function x(t){return Object.keys(t.value).length>0}function y(t){return e=>{const{LOGFIRE_ENVIRONMENT:o,LOGFIRE_TOKEN:n=""}=e,s=r.resolveBaseUrl(e,t.baseUrl,n),a=t.environment??o,i=t.additionalSpanProcessors??[];return t.console&&i.push(new v.SimpleSpanProcessor(new L)),Object.assign({},t,{additionalSpanProcessors:i,environment:a,exporter:{headers:{Authorization:n},url:`${s}/v1/traces`},idGenerator:new r.ULIDGenerator,postProcessor:u=>A(u)})}}function f(t){return e=>Object.assign({},t,{exporter:new h,idGenerator:new r.ULIDGenerator})}function p(t,e){return e.scrubbing!==void 0&&r.configureLogfireApi({scrubbing:e.scrubbing}),g.instrument(t,y(e))}function b(t,e){return g.instrument(t,f(e))}const S=p;function A(t){for(const e of t){for(const o of Object.keys(e.attributes)){const n=e.attributes[o];n==null&&delete e.attributes[o]}Object.assign(e.attributes,r.serializeAttributes(e.attributes))}return t}const C={...T,configureLogfireApi:r.configureLogfireApi,debug:r.debug,error:r.error,fatal:r.fatal,getTailConfig:f,info:r.info,instrument:S,instrumentInProcess:p,instrumentTail:b,Level:r.Level,log:r.log,logfireApiConfig:r.logfireApiConfig,LogfireAttributeScrubber:r.LogfireAttributeScrubber,NoopAttributeScrubber:r.NoopAttributeScrubber,notice:r.notice,reportError:r.reportError,resolveBaseUrl:r.resolveBaseUrl,resolveSendToLogfire:r.resolveSendToLogfire,serializeAttributes:r.serializeAttributes,span:r.span,startSpan:r.startSpan,trace:r.trace,ULIDGenerator:r.ULIDGenerator,warning:r.warning};exports.default=C;exports.exportTailEventsToLogfire=d;exports.getTailConfig=f;exports.instrument=S;exports.instrumentInProcess=p;exports.instrumentTail=b;
|
package/dist/index.d.cts
CHANGED
|
@@ -1,25 +1,25 @@
|
|
|
1
|
-
import { configureLogfireApi } from '
|
|
2
|
-
import { debug } from '
|
|
3
|
-
import { error } from '
|
|
4
|
-
import { fatal } from '
|
|
5
|
-
import { info } from '
|
|
6
|
-
import { log } from '
|
|
7
|
-
import { LogfireApiConfig } from '
|
|
8
|
-
import { LogfireAttributeScrubber } from '
|
|
9
|
-
import { NoopAttributeScrubber } from '
|
|
10
|
-
import { notice } from '
|
|
11
|
-
import { reportError as reportError_2 } from '
|
|
12
|
-
import { resolveBaseUrl } from '
|
|
13
|
-
import { resolveSendToLogfire } from '
|
|
14
|
-
import { ScrubbingOptions } from '
|
|
15
|
-
import { serializeAttributes } from '
|
|
16
|
-
import { span } from '
|
|
1
|
+
import { configureLogfireApi } from 'logfire';
|
|
2
|
+
import { debug } from 'logfire';
|
|
3
|
+
import { error } from 'logfire';
|
|
4
|
+
import { fatal } from 'logfire';
|
|
5
|
+
import { info } from 'logfire';
|
|
6
|
+
import { log } from 'logfire';
|
|
7
|
+
import { LogfireApiConfig } from 'logfire';
|
|
8
|
+
import { LogfireAttributeScrubber } from 'logfire';
|
|
9
|
+
import { NoopAttributeScrubber } from 'logfire';
|
|
10
|
+
import { notice } from 'logfire';
|
|
11
|
+
import { reportError as reportError_2 } from 'logfire';
|
|
12
|
+
import { resolveBaseUrl } from 'logfire';
|
|
13
|
+
import { resolveSendToLogfire } from 'logfire';
|
|
14
|
+
import { ScrubbingOptions } from 'logfire';
|
|
15
|
+
import { serializeAttributes } from 'logfire';
|
|
16
|
+
import { span } from 'logfire';
|
|
17
17
|
import { SpanProcessor } from '@opentelemetry/sdk-trace-base';
|
|
18
|
-
import { startSpan } from '
|
|
19
|
-
import { trace } from '
|
|
18
|
+
import { startSpan } from 'logfire';
|
|
19
|
+
import { trace } from 'logfire';
|
|
20
20
|
import { TraceConfig } from '@pydantic/otel-cf-workers';
|
|
21
|
-
import { ULIDGenerator } from '
|
|
22
|
-
import { warning } from '
|
|
21
|
+
import { ULIDGenerator } from 'logfire';
|
|
22
|
+
import { warning } from 'logfire';
|
|
23
23
|
|
|
24
24
|
declare type ConfigOptionsBase = Pick<TraceConfig, 'environment' | 'fetch' | 'handlers' | 'instrumentation' | 'propagator' | 'sampling' | 'scope' | 'service'>;
|
|
25
25
|
|
package/dist/index.d.ts
CHANGED
|
@@ -1,25 +1,25 @@
|
|
|
1
|
-
import { configureLogfireApi } from '
|
|
2
|
-
import { debug } from '
|
|
3
|
-
import { error } from '
|
|
4
|
-
import { fatal } from '
|
|
5
|
-
import { info } from '
|
|
6
|
-
import { log } from '
|
|
7
|
-
import { LogfireApiConfig } from '
|
|
8
|
-
import { LogfireAttributeScrubber } from '
|
|
9
|
-
import { NoopAttributeScrubber } from '
|
|
10
|
-
import { notice } from '
|
|
11
|
-
import { reportError as reportError_2 } from '
|
|
12
|
-
import { resolveBaseUrl } from '
|
|
13
|
-
import { resolveSendToLogfire } from '
|
|
14
|
-
import { ScrubbingOptions } from '
|
|
15
|
-
import { serializeAttributes } from '
|
|
16
|
-
import { span } from '
|
|
1
|
+
import { configureLogfireApi } from 'logfire';
|
|
2
|
+
import { debug } from 'logfire';
|
|
3
|
+
import { error } from 'logfire';
|
|
4
|
+
import { fatal } from 'logfire';
|
|
5
|
+
import { info } from 'logfire';
|
|
6
|
+
import { log } from 'logfire';
|
|
7
|
+
import { LogfireApiConfig } from 'logfire';
|
|
8
|
+
import { LogfireAttributeScrubber } from 'logfire';
|
|
9
|
+
import { NoopAttributeScrubber } from 'logfire';
|
|
10
|
+
import { notice } from 'logfire';
|
|
11
|
+
import { reportError as reportError_2 } from 'logfire';
|
|
12
|
+
import { resolveBaseUrl } from 'logfire';
|
|
13
|
+
import { resolveSendToLogfire } from 'logfire';
|
|
14
|
+
import { ScrubbingOptions } from 'logfire';
|
|
15
|
+
import { serializeAttributes } from 'logfire';
|
|
16
|
+
import { span } from 'logfire';
|
|
17
17
|
import { SpanProcessor } from '@opentelemetry/sdk-trace-base';
|
|
18
|
-
import { startSpan } from '
|
|
19
|
-
import { trace } from '
|
|
18
|
+
import { startSpan } from 'logfire';
|
|
19
|
+
import { trace } from 'logfire';
|
|
20
20
|
import { TraceConfig } from '@pydantic/otel-cf-workers';
|
|
21
|
-
import { ULIDGenerator } from '
|
|
22
|
-
import { warning } from '
|
|
21
|
+
import { ULIDGenerator } from 'logfire';
|
|
22
|
+
import { warning } from 'logfire';
|
|
23
23
|
|
|
24
24
|
declare type ConfigOptionsBase = Pick<TraceConfig, 'environment' | 'fetch' | 'handlers' | 'instrumentation' | 'propagator' | 'sampling' | 'scope' | 'service'>;
|
|
25
25
|
|
package/dist/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { SimpleSpanProcessor as v } from "@opentelemetry/sdk-trace-base";
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
2
|
+
import { instrument as p } from "@pydantic/otel-cf-workers";
|
|
3
|
+
import { resolveBaseUrl as u, warning as h, ULIDGenerator as l, trace as x, startSpan as y, span as E, serializeAttributes as d, resolveSendToLogfire as O, reportError as T, notice as C, NoopAttributeScrubber as L, LogfireAttributeScrubber as _, logfireApiConfig as A, log as N, Level as w, info as I, fatal as P, error as k, debug as z, configureLogfireApi as S } from "logfire";
|
|
4
4
|
import { hrTimeToMicroseconds as f, ExportResultCode as b } from "@opentelemetry/core";
|
|
5
5
|
import { JsonTraceSerializer as G } from "@opentelemetry/otlp-transformer";
|
|
6
6
|
async function R(t, e) {
|
|
@@ -137,10 +137,10 @@ function g(t) {
|
|
|
137
137
|
});
|
|
138
138
|
}
|
|
139
139
|
function m(t, e) {
|
|
140
|
-
return e.scrubbing !== void 0 &&
|
|
140
|
+
return e.scrubbing !== void 0 && S({ scrubbing: e.scrubbing }), p(t, V(e));
|
|
141
141
|
}
|
|
142
142
|
function j(t, e) {
|
|
143
|
-
return
|
|
143
|
+
return p(t, g(e));
|
|
144
144
|
}
|
|
145
145
|
const D = m;
|
|
146
146
|
function K(t) {
|
|
@@ -149,13 +149,13 @@ function K(t) {
|
|
|
149
149
|
const o = e.attributes[r];
|
|
150
150
|
o == null && delete e.attributes[r];
|
|
151
151
|
}
|
|
152
|
-
Object.assign(e.attributes,
|
|
152
|
+
Object.assign(e.attributes, d(e.attributes));
|
|
153
153
|
}
|
|
154
154
|
return t;
|
|
155
155
|
}
|
|
156
156
|
const X = {
|
|
157
157
|
...U,
|
|
158
|
-
configureLogfireApi:
|
|
158
|
+
configureLogfireApi: S,
|
|
159
159
|
debug: z,
|
|
160
160
|
error: k,
|
|
161
161
|
fatal: P,
|
|
@@ -164,7 +164,7 @@ const X = {
|
|
|
164
164
|
instrument: D,
|
|
165
165
|
instrumentInProcess: m,
|
|
166
166
|
instrumentTail: j,
|
|
167
|
-
// Re-export all from
|
|
167
|
+
// Re-export all from logfire
|
|
168
168
|
Level: w,
|
|
169
169
|
log: N,
|
|
170
170
|
logfireApiConfig: A,
|
|
@@ -174,7 +174,7 @@ const X = {
|
|
|
174
174
|
reportError: T,
|
|
175
175
|
resolveBaseUrl: u,
|
|
176
176
|
resolveSendToLogfire: O,
|
|
177
|
-
serializeAttributes:
|
|
177
|
+
serializeAttributes: d,
|
|
178
178
|
span: E,
|
|
179
179
|
startSpan: y,
|
|
180
180
|
trace: x,
|
package/package.json
CHANGED
|
@@ -26,7 +26,7 @@
|
|
|
26
26
|
"stats",
|
|
27
27
|
"monitoring"
|
|
28
28
|
],
|
|
29
|
-
"version": "0.
|
|
29
|
+
"version": "0.10.0",
|
|
30
30
|
"type": "module",
|
|
31
31
|
"main": "./dist/index.cjs",
|
|
32
32
|
"module": "./dist/index.js",
|
|
@@ -53,7 +53,7 @@
|
|
|
53
53
|
"postpack": "rm LICENSE"
|
|
54
54
|
},
|
|
55
55
|
"dependencies": {
|
|
56
|
-
"
|
|
56
|
+
"logfire": "*",
|
|
57
57
|
"@pydantic/otel-cf-workers": "^1.0.0-rc.54"
|
|
58
58
|
},
|
|
59
59
|
"devDependencies": {
|