@superblocksteam/telemetry 2.0.105-next.0 → 2.0.105-next.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/browser/console-logging.d.ts +18 -0
- package/dist/browser/console-logging.d.ts.map +1 -0
- package/dist/browser/console-logging.js +32 -0
- package/dist/browser/console-logging.js.map +1 -0
- package/dist/browser/early-console-buffer.d.ts +39 -0
- package/dist/browser/early-console-buffer.d.ts.map +1 -0
- package/dist/browser/early-console-buffer.js +157 -0
- package/dist/browser/early-console-buffer.js.map +1 -0
- package/dist/browser/index.d.ts +7 -0
- package/dist/browser/index.d.ts.map +1 -1
- package/dist/browser/index.js +22 -1
- package/dist/browser/index.js.map +1 -1
- package/dist/browser/init.d.ts +27 -3
- package/dist/browser/init.d.ts.map +1 -1
- package/dist/browser/init.js +159 -14
- package/dist/browser/init.js.map +1 -1
- package/dist/browser/instrumentations.d.ts +61 -0
- package/dist/browser/instrumentations.d.ts.map +1 -0
- package/dist/browser/instrumentations.js +74 -0
- package/dist/browser/instrumentations.js.map +1 -0
- package/dist/browser/logs.d.ts +52 -0
- package/dist/browser/logs.d.ts.map +1 -0
- package/dist/browser/logs.js +85 -0
- package/dist/browser/logs.js.map +1 -0
- package/dist/browser/metrics.d.ts +25 -0
- package/dist/browser/metrics.d.ts.map +1 -0
- package/dist/browser/metrics.js +37 -0
- package/dist/browser/metrics.js.map +1 -0
- package/dist/browser/sanitizer.d.ts +35 -0
- package/dist/browser/sanitizer.d.ts.map +1 -0
- package/dist/browser/sanitizer.js +211 -0
- package/dist/browser/sanitizer.js.map +1 -0
- package/dist/browser/traced-socket.d.ts +102 -0
- package/dist/browser/traced-socket.d.ts.map +1 -0
- package/dist/browser/traced-socket.js +186 -0
- package/dist/browser/traced-socket.js.map +1 -0
- package/dist/common/index.d.ts +1 -0
- package/dist/common/index.d.ts.map +1 -1
- package/dist/common/index.js +1 -0
- package/dist/common/index.js.map +1 -1
- package/dist/common/traced-socket-types.d.ts +43 -0
- package/dist/common/traced-socket-types.d.ts.map +1 -0
- package/dist/common/traced-socket-types.js +17 -0
- package/dist/common/traced-socket-types.js.map +1 -0
- package/dist/types/index.d.ts +5 -1
- package/dist/types/index.d.ts.map +1 -1
- package/dist-esm/browser/console-logging.d.ts +18 -0
- package/dist-esm/browser/console-logging.d.ts.map +1 -0
- package/dist-esm/browser/console-logging.js +27 -0
- package/dist-esm/browser/console-logging.js.map +1 -0
- package/dist-esm/browser/early-console-buffer.d.ts +39 -0
- package/dist-esm/browser/early-console-buffer.d.ts.map +1 -0
- package/dist-esm/browser/early-console-buffer.js +155 -0
- package/dist-esm/browser/early-console-buffer.js.map +1 -0
- package/dist-esm/browser/index.d.ts +7 -0
- package/dist-esm/browser/index.d.ts.map +1 -1
- package/dist-esm/browser/index.js +7 -0
- package/dist-esm/browser/index.js.map +1 -1
- package/dist-esm/browser/init.d.ts +27 -3
- package/dist-esm/browser/init.d.ts.map +1 -1
- package/dist-esm/browser/init.js +161 -16
- package/dist-esm/browser/init.js.map +1 -1
- package/dist-esm/browser/instrumentations.d.ts +61 -0
- package/dist-esm/browser/instrumentations.d.ts.map +1 -0
- package/dist-esm/browser/instrumentations.js +70 -0
- package/dist-esm/browser/instrumentations.js.map +1 -0
- package/dist-esm/browser/logs.d.ts +52 -0
- package/dist-esm/browser/logs.d.ts.map +1 -0
- package/dist-esm/browser/logs.js +78 -0
- package/dist-esm/browser/logs.js.map +1 -0
- package/dist-esm/browser/metrics.d.ts +25 -0
- package/dist-esm/browser/metrics.d.ts.map +1 -0
- package/dist-esm/browser/metrics.js +34 -0
- package/dist-esm/browser/metrics.js.map +1 -0
- package/dist-esm/browser/sanitizer.d.ts +35 -0
- package/dist-esm/browser/sanitizer.d.ts.map +1 -0
- package/dist-esm/browser/sanitizer.js +207 -0
- package/dist-esm/browser/sanitizer.js.map +1 -0
- package/dist-esm/browser/traced-socket.d.ts +102 -0
- package/dist-esm/browser/traced-socket.d.ts.map +1 -0
- package/dist-esm/browser/traced-socket.js +182 -0
- package/dist-esm/browser/traced-socket.js.map +1 -0
- package/dist-esm/common/index.d.ts +1 -0
- package/dist-esm/common/index.d.ts.map +1 -1
- package/dist-esm/common/index.js +1 -0
- package/dist-esm/common/index.js.map +1 -1
- package/dist-esm/common/traced-socket-types.d.ts +43 -0
- package/dist-esm/common/traced-socket-types.d.ts.map +1 -0
- package/dist-esm/common/traced-socket-types.js +16 -0
- package/dist-esm/common/traced-socket-types.js.map +1 -0
- package/dist-esm/types/index.d.ts +5 -1
- package/dist-esm/types/index.d.ts.map +1 -1
- package/package.json +6 -3
|
@@ -0,0 +1,182 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Browser-side TracedSocket for WebSocket tracing.
|
|
3
|
+
*
|
|
4
|
+
* Wraps a WebSocket client (or any WebSocket-like object) and adds
|
|
5
|
+
* OpenTelemetry tracing. Designed to speak the same envelope protocol as the
|
|
6
|
+
* server-side TracedSocket so that distributed traces link correctly across
|
|
7
|
+
* the browser–server boundary.
|
|
8
|
+
*
|
|
9
|
+
* Envelope format (matches @superblocksteam/shared SocketRequest):
|
|
10
|
+
* outbound: { request: { method, id, traceparent?, tracestate?, ... } }
|
|
11
|
+
* inbound: { request: { method, id, traceparent?, tracestate?, ... } }
|
|
12
|
+
* { response: { id, ... } }
|
|
13
|
+
*
|
|
14
|
+
* Propagation uses the W3C Trace Context propagator registered globally by
|
|
15
|
+
* initBrowserTelemetry() (see browser/init.ts). The carrier is the
|
|
16
|
+
* `request` object itself — the same convention as the server side.
|
|
17
|
+
*/
|
|
18
|
+
import { ROOT_CONTEXT, SpanKind, context as otelCtx, propagation, trace, } from "@opentelemetry/api";
|
|
19
|
+
import { SEMATTRS_MESSAGING_DESTINATION_KIND, SEMATTRS_MESSAGING_SYSTEM, } from "@opentelemetry/semantic-conventions";
|
|
20
|
+
const MESSAGING_ATTRS = {
|
|
21
|
+
[SEMATTRS_MESSAGING_SYSTEM]: "ws",
|
|
22
|
+
[SEMATTRS_MESSAGING_DESTINATION_KIND]: "websocket",
|
|
23
|
+
};
|
|
24
|
+
/**
|
|
25
|
+
* BrowserTracedSocket wraps a WebSocket and provides:
|
|
26
|
+
*
|
|
27
|
+
* 1. `decorateOutbound(msg)` — call this before sending any message.
|
|
28
|
+
* Injects traceparent/tracestate into msg.request so the server can
|
|
29
|
+
* extract the browser's active context.
|
|
30
|
+
*
|
|
31
|
+
* 2. `traceOutboundCall(method)` — wraps a client-initiated RPC call in a
|
|
32
|
+
* CLIENT span. Returns the span's end function.
|
|
33
|
+
*
|
|
34
|
+
* 3. `handleInbound(msg)` — call this when a message arrives from the server.
|
|
35
|
+
* Extracts the server's trace context and creates a SERVER span so that
|
|
36
|
+
* server-initiated pushes appear in the browser's trace.
|
|
37
|
+
*
|
|
38
|
+
* 4. `recordReconnect({ attempt })` — call this from the reconnect loop to
|
|
39
|
+
* create a ws.reconnect span.
|
|
40
|
+
*
|
|
41
|
+
* Lifecycle spans (ws.connect, ws.disconnect) are attached automatically via
|
|
42
|
+
* WebSocket open/close event listeners.
|
|
43
|
+
*/
|
|
44
|
+
export class BrowserTracedSocket {
|
|
45
|
+
ws;
|
|
46
|
+
tracer;
|
|
47
|
+
connectStartTime;
|
|
48
|
+
constructor(ws, config) {
|
|
49
|
+
this.ws = ws;
|
|
50
|
+
this.tracer = config.tracer ?? trace.getTracer("superblocks-ws", "0.0.0");
|
|
51
|
+
this.ws.addEventListener("open", this.onOpen);
|
|
52
|
+
this.ws.addEventListener("close", this.onClose);
|
|
53
|
+
}
|
|
54
|
+
// ------------------------------------------------------------------
|
|
55
|
+
// Lifecycle handlers
|
|
56
|
+
// ------------------------------------------------------------------
|
|
57
|
+
onOpen = (_event) => {
|
|
58
|
+
const durationMs = this.connectStartTime
|
|
59
|
+
? Date.now() - this.connectStartTime
|
|
60
|
+
: undefined;
|
|
61
|
+
this.tracer.startActiveSpan("ws.connect", {
|
|
62
|
+
kind: SpanKind.CLIENT,
|
|
63
|
+
attributes: {
|
|
64
|
+
...MESSAGING_ATTRS,
|
|
65
|
+
...(durationMs !== undefined
|
|
66
|
+
? { "ws.connect_duration_ms": durationMs }
|
|
67
|
+
: {}),
|
|
68
|
+
},
|
|
69
|
+
}, (span) => {
|
|
70
|
+
span.end();
|
|
71
|
+
});
|
|
72
|
+
};
|
|
73
|
+
onClose = (event) => {
|
|
74
|
+
const ev = event;
|
|
75
|
+
const code = ev.code ?? 1000;
|
|
76
|
+
const reason = ev.reason ?? "";
|
|
77
|
+
this.tracer.startActiveSpan("ws.disconnect", {
|
|
78
|
+
kind: SpanKind.CLIENT,
|
|
79
|
+
attributes: {
|
|
80
|
+
...MESSAGING_ATTRS,
|
|
81
|
+
"ws.close_code": code,
|
|
82
|
+
"ws.close_reason": reason,
|
|
83
|
+
},
|
|
84
|
+
}, (span) => {
|
|
85
|
+
span.end();
|
|
86
|
+
});
|
|
87
|
+
};
|
|
88
|
+
/**
|
|
89
|
+
* Records a ws.reconnect span. Call this from the reconnect loop just
|
|
90
|
+
* before opening a new WebSocket, passing the attempt counter so it shows
|
|
91
|
+
* up as a span attribute.
|
|
92
|
+
*/
|
|
93
|
+
recordReconnect({ attempt }) {
|
|
94
|
+
this.tracer.startActiveSpan("ws.reconnect", {
|
|
95
|
+
kind: SpanKind.CLIENT,
|
|
96
|
+
attributes: {
|
|
97
|
+
...MESSAGING_ATTRS,
|
|
98
|
+
"ws.reconnect_attempt": attempt,
|
|
99
|
+
},
|
|
100
|
+
}, (span) => {
|
|
101
|
+
span.end();
|
|
102
|
+
});
|
|
103
|
+
}
|
|
104
|
+
// ------------------------------------------------------------------
|
|
105
|
+
// Outbound
|
|
106
|
+
// ------------------------------------------------------------------
|
|
107
|
+
/**
|
|
108
|
+
* Injects W3C trace context into the message's request envelope.
|
|
109
|
+
* Call this on every outbound message before handing it to the transport.
|
|
110
|
+
*
|
|
111
|
+
* Mirrors the server-side TracedSocket.decorateToSend() behaviour so that
|
|
112
|
+
* the server can extract the browser's active context via propagation.extract.
|
|
113
|
+
*/
|
|
114
|
+
decorateOutbound(message) {
|
|
115
|
+
if (!message.request) {
|
|
116
|
+
return message;
|
|
117
|
+
}
|
|
118
|
+
// Skip if already injected (e.g. manual traceparent for testing)
|
|
119
|
+
if (message.request.traceparent || message.request.tracestate) {
|
|
120
|
+
return message;
|
|
121
|
+
}
|
|
122
|
+
propagation.inject(otelCtx.active(), message.request);
|
|
123
|
+
return message;
|
|
124
|
+
}
|
|
125
|
+
/**
|
|
126
|
+
* Creates a CLIENT span for a browser-initiated RPC call.
|
|
127
|
+
* Returns the span so the caller can end it after the response resolves.
|
|
128
|
+
*
|
|
129
|
+
* Usage:
|
|
130
|
+
* ```typescript
|
|
131
|
+
* const span = socket.traceOutboundCall("editor.runApi");
|
|
132
|
+
* const result = await socket.request("editor.runApi", params);
|
|
133
|
+
* span.end();
|
|
134
|
+
* ```
|
|
135
|
+
*/
|
|
136
|
+
traceOutboundCall(method) {
|
|
137
|
+
return this.tracer.startActiveSpan(`WS CLIENT ${method}`, {
|
|
138
|
+
kind: SpanKind.CLIENT,
|
|
139
|
+
attributes: {
|
|
140
|
+
...MESSAGING_ATTRS,
|
|
141
|
+
"ws.method": method,
|
|
142
|
+
},
|
|
143
|
+
}, (span) => span);
|
|
144
|
+
}
|
|
145
|
+
// ------------------------------------------------------------------
|
|
146
|
+
// Inbound
|
|
147
|
+
// ------------------------------------------------------------------
|
|
148
|
+
/**
|
|
149
|
+
* Handles an inbound message from the server.
|
|
150
|
+
* - Extracts the server's trace context from the request envelope.
|
|
151
|
+
* - Creates a SERVER span as a child of the server's trace so that
|
|
152
|
+
* server-initiated pushes appear in the browser's distributed trace.
|
|
153
|
+
* - Response-only messages (no request field) are ignored.
|
|
154
|
+
*/
|
|
155
|
+
handleInbound(message) {
|
|
156
|
+
if (!message.request) {
|
|
157
|
+
return;
|
|
158
|
+
}
|
|
159
|
+
const method = message.request.method ?? "unknown";
|
|
160
|
+
const parentCtx = propagation.extract(ROOT_CONTEXT, message.request);
|
|
161
|
+
otelCtx.with(parentCtx, () => {
|
|
162
|
+
this.tracer.startActiveSpan(`WS SERVER ${method}`, {
|
|
163
|
+
kind: SpanKind.CLIENT,
|
|
164
|
+
attributes: {
|
|
165
|
+
...MESSAGING_ATTRS,
|
|
166
|
+
"ws.method": method,
|
|
167
|
+
},
|
|
168
|
+
}, (span) => {
|
|
169
|
+
span.end();
|
|
170
|
+
});
|
|
171
|
+
});
|
|
172
|
+
}
|
|
173
|
+
// ------------------------------------------------------------------
|
|
174
|
+
// Cleanup
|
|
175
|
+
// ------------------------------------------------------------------
|
|
176
|
+
/** Remove lifecycle listeners. Call when tearing down the socket. */
|
|
177
|
+
dispose() {
|
|
178
|
+
this.ws.removeEventListener("open", this.onOpen);
|
|
179
|
+
this.ws.removeEventListener("close", this.onClose);
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
//# sourceMappingURL=traced-socket.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"traced-socket.js","sourceRoot":"","sources":["../../src/browser/traced-socket.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAEH,OAAO,EACL,YAAY,EACZ,QAAQ,EACR,OAAO,IAAI,OAAO,EAClB,WAAW,EACX,KAAK,GAEN,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EACL,mCAAmC,EACnC,yBAAyB,GAC1B,MAAM,qCAAqC,CAAC;AAsB7C,MAAM,eAAe,GAAG;IACtB,CAAC,yBAAyB,CAAC,EAAE,IAAI;IACjC,CAAC,mCAAmC,CAAC,EAAE,WAAW;CAC1C,CAAC;AAEX;;;;;;;;;;;;;;;;;;;GAmBG;AACH,MAAM,OAAO,mBAAmB;IAKX;IAJF,MAAM,CAAS;IACxB,gBAAgB,CAAqB;IAE7C,YACmB,EAAiB,EAClC,MAAiC;QADhB,OAAE,GAAF,EAAE,CAAe;QAGlC,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC,MAAM,IAAI,KAAK,CAAC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,CAAC,OAAO,EAAE,CAAC;YACrB,OAAO;QACT,CAAC;QAED,MAAM,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC,MAAM,IAAI,SAAS,CAAC;QACnD,MAAM,SAAS,GAAG,WAAW,CAAC,OAAO,CACnC,YAAY,EACZ,OAAO,CAAC,OAA4C,CACrD,CAAC;QAEF,OAAO,CAAC,IAAI,CAAC,SAAS,EAAE,GAAG,EAAE;YAC3B,IAAI,CAAC,MAAM,CAAC,eAAe,CACzB,aAAa,MAAM,EAAE,EACrB;gBACE,IAAI,EAAE,QAAQ,CAAC,MAAM;gBACrB,UAAU,EAAE;oBACV,GAAG,eAAe;oBAClB,WAAW,EAAE,MAAM;iBACpB;aACF,EACD,CAAC,IAAI,EAAE,EAAE;gBACP,IAAI,CAAC,GAAG,EAAE,CAAC;YACb,CAAC,CACF,CAAC;QACJ,CAAC,CAAC,CAAC;IACL,CAAC;IAED,qEAAqE;IACrE,UAAU;IACV,qEAAqE;IAErE,qEAAqE;IAC9D,OAAO;QACZ,IAAI,CAAC,EAAE,CAAC,mBAAmB,CAAC,MAAM,EAAE,IAAI,CAAC,MAAM,CAAC,CAAC;QACjD,IAAI,CAAC,EAAE,CAAC,mBAAmB,CAAC,OAAO,EAAE,IAAI,CAAC,OAAO,CAAC,CAAC;IACrD,CAAC;CACF"}
|
|
@@ -7,6 +7,7 @@
|
|
|
7
7
|
* in the tiered telemetry architecture. See obs/otel-collector/config-tiered.yaml.
|
|
8
8
|
*/
|
|
9
9
|
export * from "./deployment-type.js";
|
|
10
|
+
export * from "./traced-socket-types.js";
|
|
10
11
|
export * from "./resource.js";
|
|
11
12
|
export * from "./policy-evaluator.js";
|
|
12
13
|
export * from "./guardrails.js";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/common/index.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,cAAc,sBAAsB,CAAC;AACrC,cAAc,eAAe,CAAC;AAC9B,cAAc,uBAAuB,CAAC;AACtC,cAAc,iBAAiB,CAAC;AAChC,cAAc,6BAA6B,CAAC;AAC5C,cAAc,oBAAoB,CAAC;AACnC,cAAc,iBAAiB,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/common/index.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,cAAc,sBAAsB,CAAC;AACrC,cAAc,0BAA0B,CAAC;AACzC,cAAc,eAAe,CAAC;AAC9B,cAAc,uBAAuB,CAAC;AACtC,cAAc,iBAAiB,CAAC;AAChC,cAAc,6BAA6B,CAAC;AAC5C,cAAc,oBAAoB,CAAC;AACnC,cAAc,iBAAiB,CAAC"}
|
package/dist-esm/common/index.js
CHANGED
|
@@ -7,6 +7,7 @@
|
|
|
7
7
|
* in the tiered telemetry architecture. See obs/otel-collector/config-tiered.yaml.
|
|
8
8
|
*/
|
|
9
9
|
export * from "./deployment-type.js";
|
|
10
|
+
export * from "./traced-socket-types.js";
|
|
10
11
|
export * from "./resource.js";
|
|
11
12
|
export * from "./policy-evaluator.js";
|
|
12
13
|
export * from "./guardrails.js";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/common/index.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,cAAc,sBAAsB,CAAC;AACrC,cAAc,eAAe,CAAC;AAC9B,cAAc,uBAAuB,CAAC;AACtC,cAAc,iBAAiB,CAAC;AAChC,cAAc,6BAA6B,CAAC;AAC5C,cAAc,oBAAoB,CAAC;AACnC,cAAc,iBAAiB,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/common/index.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,cAAc,sBAAsB,CAAC;AACrC,cAAc,0BAA0B,CAAC;AACzC,cAAc,eAAe,CAAC;AAC9B,cAAc,uBAAuB,CAAC;AACtC,cAAc,iBAAiB,CAAC;AAChC,cAAc,6BAA6B,CAAC;AAC5C,cAAc,oBAAoB,CAAC;AACnC,cAAc,iBAAiB,CAAC"}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Shared TracedSocket types for WebSocket message envelopes.
|
|
3
|
+
*
|
|
4
|
+
* Both the browser (TracedSocket in telemetry/browser) and the server
|
|
5
|
+
* (TracedSocket in telemetry/node) inject and extract trace context using
|
|
6
|
+
* these field names. Keeping them in one place ensures the two sides speak
|
|
7
|
+
* the same envelope protocol so traces link correctly end-to-end.
|
|
8
|
+
*
|
|
9
|
+
* Envelope structure mirrors @superblocksteam/shared SocketRequest:
|
|
10
|
+
* { request?: { method, payload, id, traceparent?, tracestate?, ... } }
|
|
11
|
+
*
|
|
12
|
+
* The W3C Trace Context propagator writes/reads exactly these two fields.
|
|
13
|
+
* See: https://www.w3.org/TR/trace-context/
|
|
14
|
+
*/
|
|
15
|
+
/**
|
|
16
|
+
* W3C Trace Context fields that live inside a socket message's request object.
|
|
17
|
+
* The propagator uses these as the carrier for context injection/extraction.
|
|
18
|
+
*/
|
|
19
|
+
export interface SocketTraceContext {
|
|
20
|
+
traceparent?: string;
|
|
21
|
+
tracestate?: string;
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Minimal shape of the request portion of a socket message envelope.
|
|
25
|
+
* Both browser and server code passes this object as the propagation carrier.
|
|
26
|
+
*/
|
|
27
|
+
export interface SocketRequestEnvelope extends SocketTraceContext {
|
|
28
|
+
method?: string;
|
|
29
|
+
id?: number;
|
|
30
|
+
[key: string]: unknown;
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Minimal shape of the full socket message envelope.
|
|
34
|
+
* Request messages carry trace context; response messages do not.
|
|
35
|
+
*/
|
|
36
|
+
export interface SocketMessageEnvelope {
|
|
37
|
+
request?: SocketRequestEnvelope;
|
|
38
|
+
response?: {
|
|
39
|
+
id?: number;
|
|
40
|
+
[key: string]: unknown;
|
|
41
|
+
};
|
|
42
|
+
}
|
|
43
|
+
//# sourceMappingURL=traced-socket-types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"traced-socket-types.d.ts","sourceRoot":"","sources":["../../src/common/traced-socket-types.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAEH;;;GAGG;AACH,MAAM,WAAW,kBAAkB;IACjC,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB;AAED;;;GAGG;AACH,MAAM,WAAW,qBAAsB,SAAQ,kBAAkB;IAC/D,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC;CACxB;AAED;;;GAGG;AACH,MAAM,WAAW,qBAAqB;IACpC,OAAO,CAAC,EAAE,qBAAqB,CAAC;IAChC,QAAQ,CAAC,EAAE;QACT,EAAE,CAAC,EAAE,MAAM,CAAC;QACZ,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC;KACxB,CAAC;CACH"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Shared TracedSocket types for WebSocket message envelopes.
|
|
3
|
+
*
|
|
4
|
+
* Both the browser (TracedSocket in telemetry/browser) and the server
|
|
5
|
+
* (TracedSocket in telemetry/node) inject and extract trace context using
|
|
6
|
+
* these field names. Keeping them in one place ensures the two sides speak
|
|
7
|
+
* the same envelope protocol so traces link correctly end-to-end.
|
|
8
|
+
*
|
|
9
|
+
* Envelope structure mirrors @superblocksteam/shared SocketRequest:
|
|
10
|
+
* { request?: { method, payload, id, traceparent?, tracestate?, ... } }
|
|
11
|
+
*
|
|
12
|
+
* The W3C Trace Context propagator writes/reads exactly these two fields.
|
|
13
|
+
* See: https://www.w3.org/TR/trace-context/
|
|
14
|
+
*/
|
|
15
|
+
export {};
|
|
16
|
+
//# sourceMappingURL=traced-socket-types.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"traced-socket-types.js","sourceRoot":"","sources":["../../src/common/traced-socket-types.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG"}
|
|
@@ -61,7 +61,11 @@ export interface NodeTelemetryConfig extends BaseTelemetryConfig {
|
|
|
61
61
|
* Browser specific telemetry configuration.
|
|
62
62
|
*/
|
|
63
63
|
export interface BrowserTelemetryConfig extends BaseTelemetryConfig {
|
|
64
|
-
/** OTLP traces
|
|
64
|
+
/** OTLP base URL (e.g. "http://localhost:4318"). Signal-specific paths (/v1/traces, /v1/metrics, /v1/logs) are appended automatically. */
|
|
65
65
|
otlpUrl: string;
|
|
66
|
+
/** URL patterns to inject traceparent header into (for cross-origin propagation) */
|
|
67
|
+
propagateTraceUrls?: RegExp[];
|
|
68
|
+
/** URL patterns to skip instrumenting entirely */
|
|
69
|
+
ignoreUrls?: RegExp[];
|
|
66
70
|
}
|
|
67
71
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/types/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,cAAc,aAAa,CAAC;AAE5B;;GAEG;AACH,MAAM,WAAW,mBAAmB;IAClC,gDAAgD;IAChD,WAAW,EAAE,MAAM,CAAC;IAEpB,sCAAsC;IACtC,cAAc,EAAE,MAAM,CAAC;IAEvB,4EAA4E;IAC5E,WAAW,EAAE,MAAM,CAAC;IAEpB,qCAAqC;IACrC,kBAAkB,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CAC7C;AAED;;;GAGG;AACH,MAAM,WAAW,wBAAwB;IACvC,SAAS,EAAE,MAAM,CAAC;IAClB,IAAI,EAAE,MAAM,CAAC;IACb,SAAS,EAAE,QAAQ,GAAG,QAAQ,GAAG,QAAQ,CAAC;IAC1C,iBAAiB,EAAE,M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AAM,EAAE,CAAC;IAE9B,kDAAkD;IAClD,UAAU,CAAC,EAAE,MAAM,EAAE,CAAC;CACvB"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@superblocksteam/telemetry",
|
|
3
|
-
"version": "2.0.105-next.
|
|
3
|
+
"version": "2.0.105-next.1",
|
|
4
4
|
"description": "Superblocks Telemetry - Canonical OTEL bootstrap with tier-aware policy enforcement",
|
|
5
5
|
"license": "Superblocks Community Software License",
|
|
6
6
|
"repository": {
|
|
@@ -51,6 +51,9 @@
|
|
|
51
51
|
"@opentelemetry/exporter-logs-otlp-http": "^0.203.0",
|
|
52
52
|
"@opentelemetry/exporter-metrics-otlp-http": "^0.203.0",
|
|
53
53
|
"@opentelemetry/exporter-trace-otlp-http": "^0.203.0",
|
|
54
|
+
"@opentelemetry/instrumentation": "^0.55.0",
|
|
55
|
+
"@opentelemetry/instrumentation-fetch": "^0.55.0",
|
|
56
|
+
"@opentelemetry/instrumentation-xml-http-request": "^0.55.0",
|
|
54
57
|
"@opentelemetry/resources": "^2.0.1",
|
|
55
58
|
"@opentelemetry/sdk-logs": "^0.203.0",
|
|
56
59
|
"@opentelemetry/sdk-metrics": "^2.0.1",
|
|
@@ -73,10 +76,10 @@
|
|
|
73
76
|
"typescript": "^5.9.3",
|
|
74
77
|
"typescript-eslint": "^8.47.0",
|
|
75
78
|
"vitest": "^2.0.0",
|
|
76
|
-
"@superblocksteam/shared": "0.
|
|
79
|
+
"@superblocksteam/shared": "0.9577.0"
|
|
77
80
|
},
|
|
78
81
|
"peerDependencies": {
|
|
79
|
-
"@superblocksteam/shared": "0.
|
|
82
|
+
"@superblocksteam/shared": "0.9577.0"
|
|
80
83
|
},
|
|
81
84
|
"engines": {
|
|
82
85
|
"node": ">=24"
|