@pydantic/logfire-browser 0.5.0 → 0.7.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 +6 -1
- package/dist/index.d.ts +6 -1
- package/dist/index.js +97 -38
- package/package.json +3 -1
package/dist/index.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const
|
|
1
|
+
"use strict";var f=Object.defineProperty;var E=(e,r,t)=>r in e?f(e,r,{enumerable:!0,configurable:!0,writable:!0,value:t}):e[r]=t;var g=(e,r,t)=>E(e,typeof r!="symbol"?r+"":r,t);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const a=require("@opentelemetry/api"),d=require("@opentelemetry/context-zone"),_=require("@opentelemetry/instrumentation"),R=require("@opentelemetry/resources"),l=require("@opentelemetry/sdk-trace-web"),o=require("@opentelemetry/semantic-conventions"),i=require("@opentelemetry/semantic-conventions/incubating"),c=require("@pydantic/logfire-api"),u=require("@opentelemetry/otlp-exporter-base"),b=require("@opentelemetry/otlp-exporter-base/browser-http"),A=require("@opentelemetry/otlp-transformer");function p(e){const r=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e){for(const t in e)if(t!=="default"){const n=Object.getOwnPropertyDescriptor(e,t);Object.defineProperty(r,t,n.get?n:{enumerable:!0,get:()=>e[t]})}}return r.default=e,Object.freeze(r)}const m=p(c);class L extends u.OTLPExporterBase{constructor(r,t){const s={...u.mergeOtlpSharedConfigurationWithDefaults({compression:r.compression,concurrencyLimit:r.concurrencyLimit,timeoutMillis:r.timeoutMillis},{},u.getSharedConfigurationDefaults()),agentOptions:{keepAlive:!0},headers:()=>({"Content-Type":"application/json",...r.headers??{},...t?t():{}}),url:r.url??"http://localhost:4318/v1/traces"};super(b.createOtlpXhrExportDelegate(s,A.JsonTraceSerializer))}}const T="target_xpath",h="event_type";function w(){return{}}function O(e){e.diagLogLevel!==void 0&&a.diag.setLogger(new a.DiagConsoleLogger,e.diagLogLevel),e.scrubbing!==void 0&&m.configureLogfireApi({scrubbing:e.scrubbing});const r=R.resourceFromAttributes({[i.ATTR_BROWSER_LANGUAGE]:navigator.language,[o.ATTR_SERVICE_NAME]:e.serviceName??"logfire-browser",[o.ATTR_SERVICE_VERSION]:e.serviceVersion??"0.0.1",[o.ATTR_TELEMETRY_SDK_LANGUAGE]:o.TELEMETRY_SDK_LANGUAGE_VALUE_WEBJS,[o.ATTR_TELEMETRY_SDK_NAME]:"logfire-browser",...e.environment?{[i.ATTR_DEPLOYMENT_ENVIRONMENT_NAME]:e.environment}:{},[o.ATTR_TELEMETRY_SDK_VERSION]:"0.7.0",...navigator.userAgentData?{[i.ATTR_BROWSER_BRANDS]:navigator.userAgentData.brands.map(s=>`${s.brand} ${s.version}`),[i.ATTR_BROWSER_MOBILE]:navigator.userAgentData.mobile,[i.ATTR_BROWSER_PLATFORM]:navigator.userAgentData.platform}:{[o.ATTR_USER_AGENT_ORIGINAL]:navigator.userAgent}});a.diag.info("logfire-browser: starting");const t=new l.WebTracerProvider({idGenerator:new c.ULIDGenerator,resource:r,spanProcessors:[new S(new l.BatchSpanProcessor(new L({...e.traceExporterConfig,url:e.traceUrl},e.traceExporterHeaders??w),e.batchSpanProcessorConfig))]});e.enableZoneContextManager!==!1&&(a.diag.info("logfire-browser: enable zone context manager"),t.register({contextManager:new d.ZoneContextManager}));const n=_.registerInstrumentations({instrumentations:e.instrumentations??[],tracerProvider:t});return async()=>{a.diag.info("logfire-browser: shutting down"),n(),await t.forceFlush(),await t.shutdown(),a.diag.info("logfire-browser: shut down complete")}}class S{constructor(r){g(this,"wrapped");this.wrapped=r}async forceFlush(){return this.wrapped.forceFlush()}onEnd(r){this.wrapped.onEnd(r)}onStart(r,t){if(i.ATTR_HTTP_URL in r.attributes){const n=new URL(r.attributes[i.ATTR_HTTP_URL]);Reflect.set(r,"name",`${r.name} ${n.pathname}`)}T in r.attributes&&Reflect.set(r,"name",`${r.attributes[h]??"unknown"} ${r.attributes[T]??""}`),this.wrapped.onStart(r,t)}async shutdown(){return this.wrapped.shutdown()}}Object.defineProperty(exports,"DiagLogLevel",{enumerable:!0,get:()=>a.DiagLogLevel});exports.configure=O;Object.keys(c).forEach(e=>{e!=="default"&&!Object.prototype.hasOwnProperty.call(exports,e)&&Object.defineProperty(exports,e,{enumerable:!0,get:()=>c[e]})});
|
package/dist/index.d.cts
CHANGED
|
@@ -33,7 +33,7 @@ export declare interface LogfireConfigOptions {
|
|
|
33
33
|
/**
|
|
34
34
|
* Options for scrubbing sensitive data. Set to False to disable.
|
|
35
35
|
*/
|
|
36
|
-
scrubbing?: false | logfireApi.
|
|
36
|
+
scrubbing?: false | logfireApi.ScrubbingOptions;
|
|
37
37
|
/**
|
|
38
38
|
* Name of this service.
|
|
39
39
|
*/
|
|
@@ -46,6 +46,11 @@ export declare interface LogfireConfigOptions {
|
|
|
46
46
|
* configures the trace exporter.
|
|
47
47
|
*/
|
|
48
48
|
traceExporterConfig?: TraceExporterConfig;
|
|
49
|
+
/**
|
|
50
|
+
* Any additional HTTP headers to be sent with the trace exporter requests.
|
|
51
|
+
* This is useful for authentication or other custom headers.
|
|
52
|
+
*/
|
|
53
|
+
traceExporterHeaders?: () => Record<string, string>;
|
|
49
54
|
/**
|
|
50
55
|
* The URL of your trace exporter proxy endpoint.
|
|
51
56
|
*/
|
package/dist/index.d.ts
CHANGED
|
@@ -33,7 +33,7 @@ export declare interface LogfireConfigOptions {
|
|
|
33
33
|
/**
|
|
34
34
|
* Options for scrubbing sensitive data. Set to False to disable.
|
|
35
35
|
*/
|
|
36
|
-
scrubbing?: false | logfireApi.
|
|
36
|
+
scrubbing?: false | logfireApi.ScrubbingOptions;
|
|
37
37
|
/**
|
|
38
38
|
* Name of this service.
|
|
39
39
|
*/
|
|
@@ -46,6 +46,11 @@ export declare interface LogfireConfigOptions {
|
|
|
46
46
|
* configures the trace exporter.
|
|
47
47
|
*/
|
|
48
48
|
traceExporterConfig?: TraceExporterConfig;
|
|
49
|
+
/**
|
|
50
|
+
* Any additional HTTP headers to be sent with the trace exporter requests.
|
|
51
|
+
* This is useful for authentication or other custom headers.
|
|
52
|
+
*/
|
|
53
|
+
traceExporterHeaders?: () => Record<string, string>;
|
|
49
54
|
/**
|
|
50
55
|
* The URL of your trace exporter proxy endpoint.
|
|
51
56
|
*/
|
package/dist/index.js
CHANGED
|
@@ -1,57 +1,116 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
import {
|
|
1
|
+
var u = Object.defineProperty;
|
|
2
|
+
var g = (e, r, t) => r in e ? u(e, r, { enumerable: !0, configurable: !0, writable: !0, value: t }) : e[r] = t;
|
|
3
|
+
var i = (e, r, t) => g(e, typeof r != "symbol" ? r + "" : r, t);
|
|
4
|
+
import { diag as o, DiagConsoleLogger as T } from "@opentelemetry/api";
|
|
5
|
+
import { DiagLogLevel as er } from "@opentelemetry/api";
|
|
6
|
+
import { ZoneContextManager as m } from "@opentelemetry/context-zone";
|
|
5
7
|
import { registerInstrumentations as E } from "@opentelemetry/instrumentation";
|
|
6
|
-
import { resourceFromAttributes as
|
|
7
|
-
import { WebTracerProvider as
|
|
8
|
-
import { TELEMETRY_SDK_LANGUAGE_VALUE_WEBJS as A, ATTR_USER_AGENT_ORIGINAL as
|
|
9
|
-
import { ATTR_BROWSER_PLATFORM as b, ATTR_BROWSER_MOBILE as
|
|
10
|
-
import * as
|
|
11
|
-
import { ULIDGenerator as
|
|
8
|
+
import { resourceFromAttributes as f } from "@opentelemetry/resources";
|
|
9
|
+
import { WebTracerProvider as l, BatchSpanProcessor as R } from "@opentelemetry/sdk-trace-web";
|
|
10
|
+
import { TELEMETRY_SDK_LANGUAGE_VALUE_WEBJS as A, ATTR_USER_AGENT_ORIGINAL as _, ATTR_TELEMETRY_SDK_VERSION as p, ATTR_TELEMETRY_SDK_NAME as d, ATTR_TELEMETRY_SDK_LANGUAGE as h, ATTR_SERVICE_VERSION as L, ATTR_SERVICE_NAME as w } from "@opentelemetry/semantic-conventions";
|
|
11
|
+
import { ATTR_BROWSER_PLATFORM as b, ATTR_BROWSER_MOBILE as S, ATTR_BROWSER_BRANDS as v, ATTR_DEPLOYMENT_ENVIRONMENT_NAME as x, ATTR_BROWSER_LANGUAGE as D, ATTR_HTTP_URL as s } from "@opentelemetry/semantic-conventions/incubating";
|
|
12
|
+
import * as N from "@pydantic/logfire-api";
|
|
13
|
+
import { ULIDGenerator as M } from "@pydantic/logfire-api";
|
|
12
14
|
export * from "@pydantic/logfire-api";
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
15
|
+
import { OTLPExporterBase as O, mergeOtlpSharedConfigurationWithDefaults as C, getSharedConfigurationDefaults as P } from "@opentelemetry/otlp-exporter-base";
|
|
16
|
+
import { createOtlpXhrExportDelegate as G } from "@opentelemetry/otlp-exporter-base/browser-http";
|
|
17
|
+
import { JsonTraceSerializer as I } from "@opentelemetry/otlp-transformer";
|
|
18
|
+
class B extends O {
|
|
19
|
+
constructor(r, t) {
|
|
20
|
+
const a = {
|
|
21
|
+
...C(
|
|
22
|
+
{
|
|
23
|
+
compression: r.compression,
|
|
24
|
+
concurrencyLimit: r.concurrencyLimit,
|
|
25
|
+
timeoutMillis: r.timeoutMillis
|
|
26
|
+
},
|
|
27
|
+
{},
|
|
28
|
+
P()
|
|
29
|
+
),
|
|
30
|
+
agentOptions: { keepAlive: !0 },
|
|
31
|
+
headers: () => ({
|
|
32
|
+
"Content-Type": "application/json",
|
|
33
|
+
...r.headers ?? {},
|
|
34
|
+
...t ? t() : {}
|
|
35
|
+
}),
|
|
36
|
+
url: r.url ?? "http://localhost:4318/v1/traces"
|
|
37
|
+
};
|
|
38
|
+
super(G(a, I));
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
const c = "target_xpath", U = "event_type";
|
|
42
|
+
function y() {
|
|
43
|
+
return {};
|
|
44
|
+
}
|
|
45
|
+
function q(e) {
|
|
46
|
+
e.diagLogLevel !== void 0 && o.setLogger(new T(), e.diagLogLevel), e.scrubbing !== void 0 && N.configureLogfireApi({ scrubbing: e.scrubbing });
|
|
47
|
+
const r = f({
|
|
48
|
+
[D]: navigator.language,
|
|
49
|
+
[w]: e.serviceName ?? "logfire-browser",
|
|
50
|
+
[L]: e.serviceVersion ?? "0.0.1",
|
|
51
|
+
[h]: A,
|
|
52
|
+
[d]: "logfire-browser",
|
|
53
|
+
...e.environment ? { [x]: e.environment } : {},
|
|
22
54
|
// eslint-disable-next-line no-undef
|
|
23
|
-
[
|
|
55
|
+
[p]: "0.7.0",
|
|
24
56
|
...navigator.userAgentData ? {
|
|
25
|
-
[
|
|
26
|
-
[
|
|
57
|
+
[v]: navigator.userAgentData.brands.map((a) => `${a.brand} ${a.version}`),
|
|
58
|
+
[S]: navigator.userAgentData.mobile,
|
|
27
59
|
[b]: navigator.userAgentData.platform
|
|
28
60
|
} : {
|
|
29
|
-
[
|
|
61
|
+
[_]: navigator.userAgent
|
|
30
62
|
}
|
|
31
63
|
});
|
|
32
|
-
|
|
33
|
-
const
|
|
34
|
-
idGenerator: new
|
|
35
|
-
resource:
|
|
64
|
+
o.info("logfire-browser: starting");
|
|
65
|
+
const t = new l({
|
|
66
|
+
idGenerator: new M(),
|
|
67
|
+
resource: r,
|
|
36
68
|
spanProcessors: [
|
|
37
|
-
new
|
|
38
|
-
new
|
|
39
|
-
|
|
69
|
+
new V(
|
|
70
|
+
new R(
|
|
71
|
+
new B(
|
|
72
|
+
{ ...e.traceExporterConfig, url: e.traceUrl },
|
|
73
|
+
e.traceExporterHeaders ?? y
|
|
74
|
+
),
|
|
75
|
+
e.batchSpanProcessorConfig
|
|
76
|
+
)
|
|
40
77
|
)
|
|
41
78
|
]
|
|
42
79
|
});
|
|
43
|
-
|
|
44
|
-
contextManager: new
|
|
80
|
+
e.enableZoneContextManager !== !1 && (o.info("logfire-browser: enable zone context manager"), t.register({
|
|
81
|
+
contextManager: new m()
|
|
45
82
|
}));
|
|
46
|
-
const
|
|
47
|
-
instrumentations:
|
|
48
|
-
tracerProvider:
|
|
83
|
+
const n = E({
|
|
84
|
+
instrumentations: e.instrumentations ?? [],
|
|
85
|
+
tracerProvider: t
|
|
49
86
|
});
|
|
50
87
|
return async () => {
|
|
51
|
-
|
|
88
|
+
o.info("logfire-browser: shutting down"), n(), await t.forceFlush(), await t.shutdown(), o.info("logfire-browser: shut down complete");
|
|
52
89
|
};
|
|
53
90
|
}
|
|
91
|
+
class V {
|
|
92
|
+
constructor(r) {
|
|
93
|
+
i(this, "wrapped");
|
|
94
|
+
this.wrapped = r;
|
|
95
|
+
}
|
|
96
|
+
async forceFlush() {
|
|
97
|
+
return this.wrapped.forceFlush();
|
|
98
|
+
}
|
|
99
|
+
onEnd(r) {
|
|
100
|
+
this.wrapped.onEnd(r);
|
|
101
|
+
}
|
|
102
|
+
onStart(r, t) {
|
|
103
|
+
if (s in r.attributes) {
|
|
104
|
+
const n = new URL(r.attributes[s]);
|
|
105
|
+
Reflect.set(r, "name", `${r.name} ${n.pathname}`);
|
|
106
|
+
}
|
|
107
|
+
c in r.attributes && Reflect.set(r, "name", `${r.attributes[U] ?? "unknown"} ${r.attributes[c] ?? ""}`), this.wrapped.onStart(r, t);
|
|
108
|
+
}
|
|
109
|
+
async shutdown() {
|
|
110
|
+
return this.wrapped.shutdown();
|
|
111
|
+
}
|
|
112
|
+
}
|
|
54
113
|
export {
|
|
55
|
-
|
|
56
|
-
|
|
114
|
+
er as DiagLogLevel,
|
|
115
|
+
q as configure
|
|
57
116
|
};
|
package/package.json
CHANGED
|
@@ -21,7 +21,7 @@
|
|
|
21
21
|
"stats",
|
|
22
22
|
"monitoring"
|
|
23
23
|
],
|
|
24
|
-
"version": "0.
|
|
24
|
+
"version": "0.7.0",
|
|
25
25
|
"type": "module",
|
|
26
26
|
"main": "./dist/index.cjs",
|
|
27
27
|
"module": "./dist/index.js",
|
|
@@ -51,8 +51,10 @@
|
|
|
51
51
|
"dependencies": {
|
|
52
52
|
"@opentelemetry/api": "^1.9.0",
|
|
53
53
|
"@opentelemetry/context-zone": "^2.0.1",
|
|
54
|
+
"@opentelemetry/core": "^2.0.1",
|
|
54
55
|
"@opentelemetry/exporter-trace-otlp-http": "^0.202.0",
|
|
55
56
|
"@opentelemetry/instrumentation": "^0.202.0",
|
|
57
|
+
"@opentelemetry/otlp-exporter-base": "^0.203.0",
|
|
56
58
|
"@opentelemetry/resources": "^2.0.1",
|
|
57
59
|
"@pydantic/logfire-api": "*"
|
|
58
60
|
},
|