@pydantic/logfire-browser 0.8.0 → 0.8.1
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 -4
- package/dist/index.d.ts +5 -4
- package/dist/index.js +32 -33
- package/package.json +1 -2
package/dist/index.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var
|
|
1
|
+
"use strict";var E=Object.defineProperty;var f=(e,r,t)=>r in e?E(e,r,{enumerable:!0,configurable:!0,writable:!0,value:t}):e[r]=t;var l=(e,r,t)=>f(e,typeof r!="symbol"?r+"":r,t);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const i=require("@opentelemetry/api"),d=require("@opentelemetry/instrumentation"),_=require("@opentelemetry/resources"),u=require("@opentelemetry/sdk-trace-web"),o=require("@opentelemetry/semantic-conventions"),a=require("@opentelemetry/semantic-conventions/incubating"),c=require("@pydantic/logfire-api"),g=require("@opentelemetry/otlp-exporter-base"),R=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 b=p(c);class m extends g.OTLPExporterBase{constructor(r,t){const s={...g.mergeOtlpSharedConfigurationWithDefaults({compression:r.compression,concurrencyLimit:r.concurrencyLimit,timeoutMillis:r.timeoutMillis},{},g.getSharedConfigurationDefaults()),agentOptions:{keepAlive:!0},headers:()=>({"Content-Type":"application/json",...r.headers??{},...t?t():{}}),url:r.url??"http://localhost:4318/v1/traces"};super(R.createOtlpXhrExportDelegate(s,A.JsonTraceSerializer))}}const T="target_xpath",L="event_type";function h(){return{}}function w(e){e.diagLogLevel!==void 0&&i.diag.setLogger(new i.DiagConsoleLogger,e.diagLogLevel),e.scrubbing!==void 0&&b.configureLogfireApi({scrubbing:e.scrubbing});const r=_.resourceFromAttributes({[a.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?{[a.ATTR_DEPLOYMENT_ENVIRONMENT_NAME]:e.environment}:{},[o.ATTR_TELEMETRY_SDK_VERSION]:"0.8.1",...navigator.userAgentData?{[a.ATTR_BROWSER_BRANDS]:navigator.userAgentData.brands.map(s=>`${s.brand} ${s.version}`),[a.ATTR_BROWSER_MOBILE]:navigator.userAgentData.mobile,[a.ATTR_BROWSER_PLATFORM]:navigator.userAgentData.platform}:{[o.ATTR_USER_AGENT_ORIGINAL]:navigator.userAgent}});i.diag.info("logfire-browser: starting");const t=new u.WebTracerProvider({idGenerator:new c.ULIDGenerator,resource:r,spanProcessors:[new S(new u.BatchSpanProcessor(new m({...e.traceExporterConfig,url:e.traceUrl},e.traceExporterHeaders??h),e.batchSpanProcessorConfig))]});t.register({contextManager:e.contextManager??new u.StackContextManager});const n=d.registerInstrumentations({instrumentations:e.instrumentations??[],tracerProvider:t});return async()=>{i.diag.info("logfire-browser: shutting down"),n(),await t.forceFlush(),await t.shutdown(),i.diag.info("logfire-browser: shut down complete")}}class S{constructor(r){l(this,"wrapped");this.wrapped=r}async forceFlush(){return this.wrapped.forceFlush()}onEnd(r){this.wrapped.onEnd(r)}onStart(r,t){if(a.ATTR_HTTP_URL in r.attributes){const n=new URL(r.attributes[a.ATTR_HTTP_URL]);Reflect.set(r,"name",`${r.name} ${n.pathname}`)}T in r.attributes&&Reflect.set(r,"name",`${r.attributes[L]??"unknown"} ${r.attributes[T]??""}`),this.wrapped.onStart(r,t)}async shutdown(){return this.wrapped.shutdown()}}Object.defineProperty(exports,"DiagLogLevel",{enumerable:!0,get:()=>i.DiagLogLevel});exports.configure=w;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
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { BufferConfig } from '@opentelemetry/sdk-trace-web';
|
|
2
|
+
import { ContextManager } from '@opentelemetry/api';
|
|
2
3
|
import { DiagLogLevel } from '@opentelemetry/api';
|
|
3
4
|
import { Instrumentation } from '@opentelemetry/instrumentation';
|
|
4
5
|
import * as logfireApi from '@pydantic/logfire-api';
|
|
@@ -14,13 +15,13 @@ export declare interface LogfireConfigOptions {
|
|
|
14
15
|
*/
|
|
15
16
|
batchSpanProcessorConfig?: BufferConfig;
|
|
16
17
|
/**
|
|
17
|
-
*
|
|
18
|
+
* Pass a context manager (e.g. ZoneContextManager) to use.
|
|
18
19
|
*/
|
|
19
|
-
|
|
20
|
+
contextManager?: ContextManager;
|
|
20
21
|
/**
|
|
21
|
-
*
|
|
22
|
+
* Defines the available internal logging levels for the diagnostic logger.
|
|
22
23
|
*/
|
|
23
|
-
|
|
24
|
+
diagLogLevel?: DiagLogLevel;
|
|
24
25
|
/**
|
|
25
26
|
* The environment this service is running in, e.g. `staging` or `prod`. Sets the deployment.environment.name resource attribute. Useful for filtering within projects in the Logfire UI.
|
|
26
27
|
* Defaults to the `LOGFIRE_ENVIRONMENT` environment variable.
|
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { BufferConfig } from '@opentelemetry/sdk-trace-web';
|
|
2
|
+
import { ContextManager } from '@opentelemetry/api';
|
|
2
3
|
import { DiagLogLevel } from '@opentelemetry/api';
|
|
3
4
|
import { Instrumentation } from '@opentelemetry/instrumentation';
|
|
4
5
|
import * as logfireApi from '@pydantic/logfire-api';
|
|
@@ -14,13 +15,13 @@ export declare interface LogfireConfigOptions {
|
|
|
14
15
|
*/
|
|
15
16
|
batchSpanProcessorConfig?: BufferConfig;
|
|
16
17
|
/**
|
|
17
|
-
*
|
|
18
|
+
* Pass a context manager (e.g. ZoneContextManager) to use.
|
|
18
19
|
*/
|
|
19
|
-
|
|
20
|
+
contextManager?: ContextManager;
|
|
20
21
|
/**
|
|
21
|
-
*
|
|
22
|
+
* Defines the available internal logging levels for the diagnostic logger.
|
|
22
23
|
*/
|
|
23
|
-
|
|
24
|
+
diagLogLevel?: DiagLogLevel;
|
|
24
25
|
/**
|
|
25
26
|
* The environment this service is running in, e.g. `staging` or `prod`. Sets the deployment.environment.name resource attribute. Useful for filtering within projects in the Logfire UI.
|
|
26
27
|
* Defaults to the `LOGFIRE_ENVIRONMENT` environment variable.
|
package/dist/index.js
CHANGED
|
@@ -1,31 +1,30 @@
|
|
|
1
1
|
var u = Object.defineProperty;
|
|
2
|
-
var
|
|
3
|
-
var i = (e, r, t) =>
|
|
4
|
-
import { diag as
|
|
5
|
-
import { DiagLogLevel as
|
|
6
|
-
import { ZoneContextManager as m } from "@opentelemetry/context-zone";
|
|
2
|
+
var T = (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) => T(e, typeof r != "symbol" ? r + "" : r, t);
|
|
4
|
+
import { diag as a, DiagConsoleLogger as g } from "@opentelemetry/api";
|
|
5
|
+
import { DiagLogLevel as rr } from "@opentelemetry/api";
|
|
7
6
|
import { registerInstrumentations as E } from "@opentelemetry/instrumentation";
|
|
8
|
-
import { resourceFromAttributes as
|
|
9
|
-
import { WebTracerProvider as
|
|
7
|
+
import { resourceFromAttributes as m } from "@opentelemetry/resources";
|
|
8
|
+
import { WebTracerProvider as f, BatchSpanProcessor as l, StackContextManager as R } from "@opentelemetry/sdk-trace-web";
|
|
10
9
|
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
|
|
12
|
-
import * as
|
|
10
|
+
import { ATTR_BROWSER_PLATFORM as S, ATTR_BROWSER_MOBILE as b, ATTR_BROWSER_BRANDS as v, ATTR_DEPLOYMENT_ENVIRONMENT_NAME as D, ATTR_BROWSER_LANGUAGE as N, ATTR_HTTP_URL as s } from "@opentelemetry/semantic-conventions/incubating";
|
|
11
|
+
import * as x from "@pydantic/logfire-api";
|
|
13
12
|
import { ULIDGenerator as M } from "@pydantic/logfire-api";
|
|
14
13
|
export * from "@pydantic/logfire-api";
|
|
15
|
-
import { OTLPExporterBase as O, mergeOtlpSharedConfigurationWithDefaults as
|
|
14
|
+
import { OTLPExporterBase as O, mergeOtlpSharedConfigurationWithDefaults as P, getSharedConfigurationDefaults as C } from "@opentelemetry/otlp-exporter-base";
|
|
16
15
|
import { createOtlpXhrExportDelegate as G } from "@opentelemetry/otlp-exporter-base/browser-http";
|
|
17
16
|
import { JsonTraceSerializer as I } from "@opentelemetry/otlp-transformer";
|
|
18
17
|
class B extends O {
|
|
19
18
|
constructor(r, t) {
|
|
20
|
-
const
|
|
21
|
-
...
|
|
19
|
+
const n = {
|
|
20
|
+
...P(
|
|
22
21
|
{
|
|
23
22
|
compression: r.compression,
|
|
24
23
|
concurrencyLimit: r.concurrencyLimit,
|
|
25
24
|
timeoutMillis: r.timeoutMillis
|
|
26
25
|
},
|
|
27
26
|
{},
|
|
28
|
-
|
|
27
|
+
C()
|
|
29
28
|
),
|
|
30
29
|
agentOptions: { keepAlive: !0 },
|
|
31
30
|
headers: () => ({
|
|
@@ -35,7 +34,7 @@ class B extends O {
|
|
|
35
34
|
}),
|
|
36
35
|
url: r.url ?? "http://localhost:4318/v1/traces"
|
|
37
36
|
};
|
|
38
|
-
super(G(
|
|
37
|
+
super(G(n, I));
|
|
39
38
|
}
|
|
40
39
|
}
|
|
41
40
|
const c = "target_xpath", U = "event_type";
|
|
@@ -43,31 +42,31 @@ function y() {
|
|
|
43
42
|
return {};
|
|
44
43
|
}
|
|
45
44
|
function q(e) {
|
|
46
|
-
e.diagLogLevel !== void 0 &&
|
|
47
|
-
const r =
|
|
48
|
-
[
|
|
45
|
+
e.diagLogLevel !== void 0 && a.setLogger(new g(), e.diagLogLevel), e.scrubbing !== void 0 && x.configureLogfireApi({ scrubbing: e.scrubbing });
|
|
46
|
+
const r = m({
|
|
47
|
+
[N]: navigator.language,
|
|
49
48
|
[w]: e.serviceName ?? "logfire-browser",
|
|
50
49
|
[L]: e.serviceVersion ?? "0.0.1",
|
|
51
50
|
[h]: A,
|
|
52
51
|
[d]: "logfire-browser",
|
|
53
|
-
...e.environment ? { [
|
|
52
|
+
...e.environment ? { [D]: e.environment } : {},
|
|
54
53
|
// eslint-disable-next-line no-undef
|
|
55
|
-
[p]: "0.8.
|
|
54
|
+
[p]: "0.8.1",
|
|
56
55
|
...navigator.userAgentData ? {
|
|
57
|
-
[v]: navigator.userAgentData.brands.map((
|
|
58
|
-
[
|
|
59
|
-
[
|
|
56
|
+
[v]: navigator.userAgentData.brands.map((n) => `${n.brand} ${n.version}`),
|
|
57
|
+
[b]: navigator.userAgentData.mobile,
|
|
58
|
+
[S]: navigator.userAgentData.platform
|
|
60
59
|
} : {
|
|
61
60
|
[_]: navigator.userAgent
|
|
62
61
|
}
|
|
63
62
|
});
|
|
64
|
-
|
|
65
|
-
const t = new
|
|
63
|
+
a.info("logfire-browser: starting");
|
|
64
|
+
const t = new f({
|
|
66
65
|
idGenerator: new M(),
|
|
67
66
|
resource: r,
|
|
68
67
|
spanProcessors: [
|
|
69
68
|
new V(
|
|
70
|
-
new
|
|
69
|
+
new l(
|
|
71
70
|
new B(
|
|
72
71
|
{ ...e.traceExporterConfig, url: e.traceUrl },
|
|
73
72
|
e.traceExporterHeaders ?? y
|
|
@@ -77,15 +76,15 @@ function q(e) {
|
|
|
77
76
|
)
|
|
78
77
|
]
|
|
79
78
|
});
|
|
80
|
-
|
|
81
|
-
contextManager: new
|
|
82
|
-
})
|
|
83
|
-
const
|
|
79
|
+
t.register({
|
|
80
|
+
contextManager: e.contextManager ?? new R()
|
|
81
|
+
});
|
|
82
|
+
const o = E({
|
|
84
83
|
instrumentations: e.instrumentations ?? [],
|
|
85
84
|
tracerProvider: t
|
|
86
85
|
});
|
|
87
86
|
return async () => {
|
|
88
|
-
|
|
87
|
+
a.info("logfire-browser: shutting down"), o(), await t.forceFlush(), await t.shutdown(), a.info("logfire-browser: shut down complete");
|
|
89
88
|
};
|
|
90
89
|
}
|
|
91
90
|
class V {
|
|
@@ -101,8 +100,8 @@ class V {
|
|
|
101
100
|
}
|
|
102
101
|
onStart(r, t) {
|
|
103
102
|
if (s in r.attributes) {
|
|
104
|
-
const
|
|
105
|
-
Reflect.set(r, "name", `${r.name} ${
|
|
103
|
+
const o = new URL(r.attributes[s]);
|
|
104
|
+
Reflect.set(r, "name", `${r.name} ${o.pathname}`);
|
|
106
105
|
}
|
|
107
106
|
c in r.attributes && Reflect.set(r, "name", `${r.attributes[U] ?? "unknown"} ${r.attributes[c] ?? ""}`), this.wrapped.onStart(r, t);
|
|
108
107
|
}
|
|
@@ -111,6 +110,6 @@ class V {
|
|
|
111
110
|
}
|
|
112
111
|
}
|
|
113
112
|
export {
|
|
114
|
-
|
|
113
|
+
rr as DiagLogLevel,
|
|
115
114
|
q as configure
|
|
116
115
|
};
|
package/package.json
CHANGED
|
@@ -21,7 +21,7 @@
|
|
|
21
21
|
"stats",
|
|
22
22
|
"monitoring"
|
|
23
23
|
],
|
|
24
|
-
"version": "0.8.
|
|
24
|
+
"version": "0.8.1",
|
|
25
25
|
"type": "module",
|
|
26
26
|
"main": "./dist/index.cjs",
|
|
27
27
|
"module": "./dist/index.js",
|
|
@@ -50,7 +50,6 @@
|
|
|
50
50
|
},
|
|
51
51
|
"dependencies": {
|
|
52
52
|
"@opentelemetry/api": "^1.9.0",
|
|
53
|
-
"@opentelemetry/context-zone": "^2.0.1",
|
|
54
53
|
"@opentelemetry/core": "^2.0.1",
|
|
55
54
|
"@opentelemetry/exporter-trace-otlp-http": "^0.202.0",
|
|
56
55
|
"@opentelemetry/instrumentation": "^0.202.0",
|