@dxos/observability 0.6.14-main.2b6a0f3 → 0.6.14-main.f49f251
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/lib/browser/{chunk-4OXG76Y3.mjs → chunk-4BMUWKD7.mjs} +425 -84
- package/dist/lib/browser/chunk-4BMUWKD7.mjs.map +7 -0
- package/dist/lib/browser/index.mjs +13 -323
- package/dist/lib/browser/index.mjs.map +4 -4
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/browser/observability-2MFVX6KP.mjs +7 -0
- package/dist/lib/browser/{otel-BUKBDMAL.mjs → otel-WFASQZXZ.mjs} +5 -3
- package/dist/lib/browser/otel-WFASQZXZ.mjs.map +7 -0
- package/dist/lib/node/{chunk-AMV7JU2O.cjs → chunk-4377UHKI.cjs} +419 -73
- package/dist/lib/node/chunk-4377UHKI.cjs.map +7 -0
- package/dist/lib/node/index.cjs +15 -340
- package/dist/lib/node/index.cjs.map +4 -4
- package/dist/lib/node/meta.json +1 -1
- package/dist/lib/node/{observability-Y2NU446N.cjs → observability-5VIENMKC.cjs} +6 -6
- package/dist/lib/node/{observability-Y2NU446N.cjs.map → observability-5VIENMKC.cjs.map} +2 -2
- package/dist/lib/node/{otel-TSHMOAB4.cjs → otel-PN3H25QV.cjs} +7 -5
- package/dist/lib/node/otel-PN3H25QV.cjs.map +7 -0
- package/dist/lib/node-esm/{chunk-D7JZEGRD.mjs → chunk-UA3GVRAT.mjs} +425 -84
- package/dist/lib/node-esm/chunk-UA3GVRAT.mjs.map +7 -0
- package/dist/lib/node-esm/index.mjs +13 -323
- package/dist/lib/node-esm/index.mjs.map +4 -4
- package/dist/lib/node-esm/meta.json +1 -1
- package/dist/lib/node-esm/{observability-RAXT3Z2H.mjs → observability-KXS3AJRW.mjs} +2 -2
- package/dist/lib/node-esm/{otel-YI7HAFOG.mjs → otel-CYD4GJC2.mjs} +5 -3
- package/dist/lib/node-esm/otel-CYD4GJC2.mjs.map +7 -0
- package/dist/types/src/cli-observability-secrets.json +2 -2
- package/dist/types/src/helpers/browser-observability.d.ts.map +1 -1
- package/dist/types/src/helpers/browser-observability.js +2 -1
- package/dist/types/src/helpers/browser-observability.js.map +1 -1
- package/dist/types/src/helpers/setup-telemetry-listeners.js +13 -10
- package/dist/types/src/helpers/setup-telemetry-listeners.js.map +1 -1
- package/dist/types/src/observability.d.ts +1 -0
- package/dist/types/src/observability.d.ts.map +1 -1
- package/dist/types/src/observability.js +31 -23
- package/dist/types/src/observability.js.map +1 -1
- package/dist/types/src/otel/logs.d.ts +10 -2
- package/dist/types/src/otel/logs.d.ts.map +1 -1
- package/dist/types/src/otel/logs.js +4 -1
- package/dist/types/src/otel/logs.js.map +1 -1
- package/package.json +22 -31
- package/src/cli-observability-secrets.json +2 -2
- package/src/helpers/browser-observability.ts +2 -1
- package/src/helpers/setup-telemetry-listeners.ts +1 -1
- package/src/observability.ts +33 -24
- package/src/otel/logs.ts +17 -3
- package/dist/lib/browser/chunk-4OXG76Y3.mjs.map +0 -7
- package/dist/lib/browser/observability-WZNQCJ5C.mjs +0 -7
- package/dist/lib/browser/otel-BUKBDMAL.mjs.map +0 -7
- package/dist/lib/node/chunk-AMV7JU2O.cjs.map +0 -7
- package/dist/lib/node/otel-TSHMOAB4.cjs.map +0 -7
- package/dist/lib/node-esm/chunk-D7JZEGRD.mjs.map +0 -7
- package/dist/lib/node-esm/otel-YI7HAFOG.mjs.map +0 -7
- /package/dist/lib/browser/{observability-WZNQCJ5C.mjs.map → observability-2MFVX6KP.mjs.map} +0 -0
- /package/dist/lib/node-esm/{observability-RAXT3Z2H.mjs.map → observability-KXS3AJRW.mjs.map} +0 -0
|
@@ -26,13 +26,24 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
26
26
|
mod
|
|
27
27
|
));
|
|
28
28
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
-
var
|
|
30
|
-
__export(
|
|
29
|
+
var chunk_4377UHKI_exports = {};
|
|
30
|
+
__export(chunk_4377UHKI_exports, {
|
|
31
|
+
OBSERVABILITY_DISABLED_KEY: () => OBSERVABILITY_DISABLED_KEY,
|
|
32
|
+
OBSERVABILITY_GROUP_KEY: () => OBSERVABILITY_GROUP_KEY,
|
|
31
33
|
Observability: () => Observability,
|
|
34
|
+
getObservabilityGroup: () => getObservabilityGroup,
|
|
35
|
+
getObservabilityState: () => getObservabilityState,
|
|
32
36
|
getTelemetryIdentifier: () => getTelemetryIdentifier,
|
|
33
|
-
|
|
37
|
+
initializeAppObservability: () => initializeAppObservability,
|
|
38
|
+
initializeNodeObservability: () => initializeNodeObservability,
|
|
39
|
+
isObservabilityDisabled: () => isObservabilityDisabled,
|
|
40
|
+
mapSpaces: () => mapSpaces,
|
|
41
|
+
setupTelemetryListeners: () => setupTelemetryListeners,
|
|
42
|
+
showObservabilityBanner: () => showObservabilityBanner,
|
|
43
|
+
storeObservabilityDisabled: () => storeObservabilityDisabled,
|
|
44
|
+
storeObservabilityGroup: () => storeObservabilityGroup
|
|
34
45
|
});
|
|
35
|
-
module.exports = __toCommonJS(
|
|
46
|
+
module.exports = __toCommonJS(chunk_4377UHKI_exports);
|
|
36
47
|
var import_async = require("@dxos/async");
|
|
37
48
|
var import_client = require("@dxos/client");
|
|
38
49
|
var import_context = require("@dxos/context");
|
|
@@ -41,12 +52,165 @@ var import_log = require("@dxos/log");
|
|
|
41
52
|
var import_network_manager = require("@dxos/network-manager");
|
|
42
53
|
var import_services = require("@dxos/protocols/proto/dxos/client/services");
|
|
43
54
|
var import_util = require("@dxos/util");
|
|
55
|
+
var localForage = __toESM(require("localforage"));
|
|
56
|
+
var import_log2 = require("@dxos/log");
|
|
57
|
+
var import_js_yaml = __toESM(require("js-yaml"));
|
|
58
|
+
var import_node_fs = require("node:fs");
|
|
59
|
+
var import_promises = require("node:fs/promises");
|
|
60
|
+
var import_node_path = require("node:path");
|
|
61
|
+
var import_uuid = require("uuid");
|
|
62
|
+
var import_log3 = require("@dxos/log");
|
|
44
63
|
var cli_observability_secrets_default = {
|
|
45
64
|
SENTRY_DESTINATION: "https://2647916221e643869965e78469479aa4@o4504012000067584.ingest.sentry.io/4504012027265029",
|
|
46
65
|
TELEMETRY_API_KEY: "B00QG6PtJJrJ0VVFe0H5a6bcUUShKyZM",
|
|
47
66
|
IPDATA_API_KEY: "73dfdecdf979c18f07d50cf841bbdd9e589f237256326ac8cca23786",
|
|
48
|
-
OTEL_ENDPOINT:
|
|
49
|
-
OTEL_AUTHORIZATION:
|
|
67
|
+
OTEL_ENDPOINT: "https://otlp-proxy.dxos.workers.dev",
|
|
68
|
+
OTEL_AUTHORIZATION: "Basic OTA3MzIzOmdsY19leUp2SWpvaU1URXdNVEl6TnlJc0ltNGlPaUp6ZEdGamF5MDVNRGN6TWpNdGFXNTBaV2R5WVhScGIyNHRZMnh2ZFdSbWJHRnlaUzF2ZEd4d0xYQnliM2g1SWl3aWF5STZJalZ2Tkd4cFYydE5iRmszTlRNMGJUVXpTemRTVjNBeVNpSXNJbTBpT25zaWNpSTZJbkJ5YjJRdGRYTXRaV0Z6ZEMwd0luMTk="
|
|
69
|
+
};
|
|
70
|
+
var __dxlog_file = "/home/runner/work/dxos/dxos/packages/sdk/observability/src/helpers/browser-observability.ts";
|
|
71
|
+
var OBSERVABILITY_DISABLED_KEY = "observability-disabled";
|
|
72
|
+
var OBSERVABILITY_GROUP_KEY = "observability-group";
|
|
73
|
+
var isObservabilityDisabled = async (namespace) => {
|
|
74
|
+
try {
|
|
75
|
+
return await localForage.getItem(`${namespace}:${OBSERVABILITY_DISABLED_KEY}`) === "true";
|
|
76
|
+
} catch (err) {
|
|
77
|
+
import_log2.log.catch("Failed to check if observability is disabled, assuming it is", err, {
|
|
78
|
+
F: __dxlog_file,
|
|
79
|
+
L: 24,
|
|
80
|
+
S: void 0,
|
|
81
|
+
C: (f, a) => f(...a)
|
|
82
|
+
});
|
|
83
|
+
return true;
|
|
84
|
+
}
|
|
85
|
+
};
|
|
86
|
+
var storeObservabilityDisabled = async (namespace, value) => {
|
|
87
|
+
try {
|
|
88
|
+
await localForage.setItem(`${namespace}:${OBSERVABILITY_DISABLED_KEY}`, String(value));
|
|
89
|
+
} catch (err) {
|
|
90
|
+
import_log2.log.catch("Failed to store observability disabled", err, {
|
|
91
|
+
F: __dxlog_file,
|
|
92
|
+
L: 33,
|
|
93
|
+
S: void 0,
|
|
94
|
+
C: (f, a) => f(...a)
|
|
95
|
+
});
|
|
96
|
+
}
|
|
97
|
+
};
|
|
98
|
+
var getObservabilityGroup = async (namespace) => {
|
|
99
|
+
try {
|
|
100
|
+
return await localForage.getItem(`${namespace}:${OBSERVABILITY_GROUP_KEY}`) ?? void 0;
|
|
101
|
+
} catch (err) {
|
|
102
|
+
import_log2.log.catch("Failed to get observability group", err, {
|
|
103
|
+
F: __dxlog_file,
|
|
104
|
+
L: 41,
|
|
105
|
+
S: void 0,
|
|
106
|
+
C: (f, a) => f(...a)
|
|
107
|
+
});
|
|
108
|
+
}
|
|
109
|
+
};
|
|
110
|
+
var storeObservabilityGroup = async (namespace, value) => {
|
|
111
|
+
try {
|
|
112
|
+
await localForage.setItem(`${namespace}:${OBSERVABILITY_GROUP_KEY}`, value);
|
|
113
|
+
} catch (err) {
|
|
114
|
+
import_log2.log.catch("Failed to store observability group", err, {
|
|
115
|
+
F: __dxlog_file,
|
|
116
|
+
L: 49,
|
|
117
|
+
S: void 0,
|
|
118
|
+
C: (f, a) => f(...a)
|
|
119
|
+
});
|
|
120
|
+
}
|
|
121
|
+
};
|
|
122
|
+
var initializeAppObservability = async ({ namespace, config, mode = "basic", tracingEnable = true, replayEnable = true }) => {
|
|
123
|
+
(0, import_log2.log)("initializeAppObservability", {
|
|
124
|
+
config
|
|
125
|
+
}, {
|
|
126
|
+
F: __dxlog_file,
|
|
127
|
+
L: 72,
|
|
128
|
+
S: void 0,
|
|
129
|
+
C: (f, a) => f(...a)
|
|
130
|
+
});
|
|
131
|
+
const group = await getObservabilityGroup(namespace) ?? void 0;
|
|
132
|
+
const release = `${namespace}@${config.get("runtime.app.build.version")}`;
|
|
133
|
+
const environment = config.get("runtime.app.env.DX_ENVIRONMENT");
|
|
134
|
+
const observabilityDisabled = await isObservabilityDisabled(namespace);
|
|
135
|
+
const { Observability: Observability2 } = await import("./observability-5VIENMKC.cjs");
|
|
136
|
+
const observability = new Observability2({
|
|
137
|
+
namespace,
|
|
138
|
+
release,
|
|
139
|
+
environment,
|
|
140
|
+
group,
|
|
141
|
+
mode,
|
|
142
|
+
config,
|
|
143
|
+
errorLog: {
|
|
144
|
+
sentryInitOptions: {
|
|
145
|
+
environment,
|
|
146
|
+
release,
|
|
147
|
+
tracing: tracingEnable,
|
|
148
|
+
replay: replayEnable,
|
|
149
|
+
// TODO(wittjosiah): Configure these.
|
|
150
|
+
sampleRate: 1,
|
|
151
|
+
// TODO(mykola): Lower this to 0.1.
|
|
152
|
+
replaySampleRate: 1,
|
|
153
|
+
replaySampleRateOnError: 1
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
});
|
|
157
|
+
if (observabilityDisabled) {
|
|
158
|
+
observability.setMode("disabled");
|
|
159
|
+
import_log2.log.info("observability disabled", void 0, {
|
|
160
|
+
F: __dxlog_file,
|
|
161
|
+
L: 116,
|
|
162
|
+
S: void 0,
|
|
163
|
+
C: (f, a) => f(...a)
|
|
164
|
+
});
|
|
165
|
+
return observability;
|
|
166
|
+
}
|
|
167
|
+
try {
|
|
168
|
+
const getIPData = async (config2) => {
|
|
169
|
+
const IP_DATA_CACHE_TIMEOUT = 6 * 60 * 60 * 1e3;
|
|
170
|
+
const cachedData = await localForage.getItem("dxos:observability:ipdata");
|
|
171
|
+
if (cachedData && cachedData.timestamp > Date.now() - IP_DATA_CACHE_TIMEOUT) {
|
|
172
|
+
return cachedData.data;
|
|
173
|
+
}
|
|
174
|
+
const IPDATA_API_KEY = config2.get("runtime.app.env.DX_IPDATA_API_KEY");
|
|
175
|
+
if (IPDATA_API_KEY) {
|
|
176
|
+
return fetch(`https://api.ipdata.co?api-key=${IPDATA_API_KEY}`).then((res) => res.json()).then((data) => {
|
|
177
|
+
localForage.setItem("dxos:observability:ipdata", {
|
|
178
|
+
data,
|
|
179
|
+
timestamp: Date.now()
|
|
180
|
+
}).catch((err) => observability.captureException(err));
|
|
181
|
+
return data;
|
|
182
|
+
}).catch((err) => observability.captureException(err));
|
|
183
|
+
}
|
|
184
|
+
};
|
|
185
|
+
await observability.initialize();
|
|
186
|
+
observability.startErrorLogs();
|
|
187
|
+
const ipData = await getIPData(config);
|
|
188
|
+
ipData && observability.addIPDataTelemetryTags(ipData);
|
|
189
|
+
if (typeof navigator !== "undefined" && navigator.storage?.estimate) {
|
|
190
|
+
setInterval(async () => {
|
|
191
|
+
try {
|
|
192
|
+
const storageEstimate = await navigator.storage.estimate();
|
|
193
|
+
storageEstimate.usage && observability.setTag("storageUsage", storageEstimate.usage.toString(), "telemetry");
|
|
194
|
+
storageEstimate.quota && observability.setTag("storageQuota", storageEstimate.quota.toString(), "telemetry");
|
|
195
|
+
} catch (error) {
|
|
196
|
+
import_log2.log.warn("Failed to run estimate()", error, {
|
|
197
|
+
F: __dxlog_file,
|
|
198
|
+
L: 172,
|
|
199
|
+
S: void 0,
|
|
200
|
+
C: (f, a) => f(...a)
|
|
201
|
+
});
|
|
202
|
+
}
|
|
203
|
+
}, 1e4);
|
|
204
|
+
}
|
|
205
|
+
} catch (err) {
|
|
206
|
+
import_log2.log.error("Failed to initialize app observability", err, {
|
|
207
|
+
F: __dxlog_file,
|
|
208
|
+
L: 177,
|
|
209
|
+
S: void 0,
|
|
210
|
+
C: (f, a) => f(...a)
|
|
211
|
+
});
|
|
212
|
+
}
|
|
213
|
+
return observability;
|
|
50
214
|
};
|
|
51
215
|
var getTelemetryIdentifier = (client) => {
|
|
52
216
|
if (!client?.initialized) {
|
|
@@ -58,6 +222,90 @@ var getTelemetryIdentifier = (client) => {
|
|
|
58
222
|
}
|
|
59
223
|
return void 0;
|
|
60
224
|
};
|
|
225
|
+
var __dxlog_file2 = "/home/runner/work/dxos/dxos/packages/sdk/observability/src/helpers/node-observability.ts";
|
|
226
|
+
var showObservabilityBanner = async (configDir, bannercb) => {
|
|
227
|
+
const path = (0, import_node_path.join)(configDir, ".observability-banner-printed");
|
|
228
|
+
if ((0, import_node_fs.existsSync)(path)) {
|
|
229
|
+
return;
|
|
230
|
+
}
|
|
231
|
+
bannercb(
|
|
232
|
+
// eslint-disable-next-line no-multi-str
|
|
233
|
+
"Basic observability data will be sent to the DXOS team in order to improve the product. This includes performance metrics, error logs, and usage data. No personally identifiable information, other than your public key, is included with this data and no private data ever leaves your devices. To disable sending observability data, set the environment variable DX_DISABLE_OBSERVABILITY=true."
|
|
234
|
+
);
|
|
235
|
+
await (0, import_promises.writeFile)(path, "", "utf-8");
|
|
236
|
+
};
|
|
237
|
+
var getObservabilityState = async (configDir) => {
|
|
238
|
+
if ((0, import_node_fs.existsSync)(configDir)) {
|
|
239
|
+
if (!(0, import_node_fs.statSync)(configDir).isDirectory()) {
|
|
240
|
+
throw new Error(`Config directory ${configDir} exists but is not a directory`);
|
|
241
|
+
}
|
|
242
|
+
} else {
|
|
243
|
+
await (0, import_promises.mkdir)(configDir, {
|
|
244
|
+
recursive: true
|
|
245
|
+
});
|
|
246
|
+
}
|
|
247
|
+
const idPath = (0, import_node_path.join)(configDir, "observability.yml");
|
|
248
|
+
if ((0, import_node_fs.existsSync)(idPath)) {
|
|
249
|
+
const context = await (0, import_promises.readFile)(idPath, "utf-8");
|
|
250
|
+
return validate(context) ?? initializeState(idPath);
|
|
251
|
+
}
|
|
252
|
+
return initializeState(idPath);
|
|
253
|
+
};
|
|
254
|
+
var initializeState = async (idPath) => {
|
|
255
|
+
const observabilityState = {
|
|
256
|
+
installationId: (0, import_uuid.v4)(),
|
|
257
|
+
group: process.env.DX_OBSERVABILITY_GROUP ?? void 0,
|
|
258
|
+
mode: process.env.DX_DISABLE_OBSERVABILITY ? "disabled" : process.env.DX_OBSERVABILITY_MODE ?? "basic"
|
|
259
|
+
};
|
|
260
|
+
await (0, import_promises.writeFile)(idPath, "# This file is automatically generated by the @dxos/cli.\n" + import_js_yaml.default.dump(observabilityState), "utf-8");
|
|
261
|
+
return observabilityState;
|
|
262
|
+
};
|
|
263
|
+
var validate = (contextString) => {
|
|
264
|
+
const context = import_js_yaml.default.load(contextString);
|
|
265
|
+
if (Boolean(context.installationId) && (0, import_uuid.validate)(context.installationId)) {
|
|
266
|
+
return {
|
|
267
|
+
...context,
|
|
268
|
+
mode: process.env.DX_DISABLE_OBSERVABILITY ? "disabled" : context.mode ?? "basic"
|
|
269
|
+
};
|
|
270
|
+
}
|
|
271
|
+
};
|
|
272
|
+
var initializeNodeObservability = async ({ namespace, version, config, installationId, group, mode = "basic", tracingEnable = true, replayEnable = true }) => {
|
|
273
|
+
(0, import_log3.log)("initializeCliObservability", {
|
|
274
|
+
config
|
|
275
|
+
}, {
|
|
276
|
+
F: __dxlog_file2,
|
|
277
|
+
L: 110,
|
|
278
|
+
S: void 0,
|
|
279
|
+
C: (f, a) => f(...a)
|
|
280
|
+
});
|
|
281
|
+
const release = `${namespace}@${version}`;
|
|
282
|
+
const environment = process.env.DX_ENVIRONMENT ?? "unknown";
|
|
283
|
+
const observability = new Observability({
|
|
284
|
+
namespace,
|
|
285
|
+
release,
|
|
286
|
+
environment,
|
|
287
|
+
group,
|
|
288
|
+
mode,
|
|
289
|
+
errorLog: {
|
|
290
|
+
sentryInitOptions: {
|
|
291
|
+
environment,
|
|
292
|
+
release,
|
|
293
|
+
// TODO(wittjosiah): Configure this.
|
|
294
|
+
sampleRate: 1
|
|
295
|
+
}
|
|
296
|
+
}
|
|
297
|
+
});
|
|
298
|
+
observability.setTag("installationId", installationId);
|
|
299
|
+
const IPDATA_API_KEY = config.get("runtime.app.env.DX_IPDATA_API_KEY");
|
|
300
|
+
try {
|
|
301
|
+
const res = await fetch(`https://api.ipdata.co/?api-key=${IPDATA_API_KEY}`);
|
|
302
|
+
const ipData = await res.json();
|
|
303
|
+
ipData && observability.addIPDataTelemetryTags(ipData);
|
|
304
|
+
} catch (err) {
|
|
305
|
+
observability?.captureException(err);
|
|
306
|
+
}
|
|
307
|
+
return observability;
|
|
308
|
+
};
|
|
61
309
|
var mapSpaces = (spaces, options = {
|
|
62
310
|
verbose: false,
|
|
63
311
|
truncateKeys: false
|
|
@@ -87,7 +335,86 @@ var mapSpaces = (spaces, options = {
|
|
|
87
335
|
};
|
|
88
336
|
});
|
|
89
337
|
};
|
|
90
|
-
var
|
|
338
|
+
var lastFocusEvent = /* @__PURE__ */ new Date();
|
|
339
|
+
var totalTime = 0;
|
|
340
|
+
var setupTelemetryListeners = (namespace, client, observability) => {
|
|
341
|
+
const clickCallback = (event) => {
|
|
342
|
+
const id = event.target?.id;
|
|
343
|
+
if (!id) {
|
|
344
|
+
return;
|
|
345
|
+
}
|
|
346
|
+
setTimeout(() => observability.event({
|
|
347
|
+
identityId: getTelemetryIdentifier(client),
|
|
348
|
+
name: `${namespace}.window.click`,
|
|
349
|
+
properties: {
|
|
350
|
+
href: window.location.href,
|
|
351
|
+
id: event.target?.id,
|
|
352
|
+
path: event.composedPath().filter((el) => Boolean(el.tagName)).map((el) => `${el.tagName.toLowerCase()}${el.id ? `#${el.id}` : ""}`).reverse().join(">")
|
|
353
|
+
}
|
|
354
|
+
}));
|
|
355
|
+
};
|
|
356
|
+
const focusCallback = () => {
|
|
357
|
+
const now = /* @__PURE__ */ new Date();
|
|
358
|
+
setTimeout(() => observability.event({
|
|
359
|
+
identityId: getTelemetryIdentifier(client),
|
|
360
|
+
name: `${namespace}.window.focus`,
|
|
361
|
+
properties: {
|
|
362
|
+
href: window.location.href,
|
|
363
|
+
timeAway: now.getTime() - lastFocusEvent.getTime()
|
|
364
|
+
}
|
|
365
|
+
}));
|
|
366
|
+
lastFocusEvent = now;
|
|
367
|
+
};
|
|
368
|
+
const blurCallback = () => {
|
|
369
|
+
const now = /* @__PURE__ */ new Date();
|
|
370
|
+
const timeSpent = now.getTime() - lastFocusEvent.getTime();
|
|
371
|
+
setTimeout(() => observability.event({
|
|
372
|
+
identityId: getTelemetryIdentifier(client),
|
|
373
|
+
name: `${namespace}.window.blur`,
|
|
374
|
+
properties: {
|
|
375
|
+
href: window.location.href,
|
|
376
|
+
timeSpent
|
|
377
|
+
}
|
|
378
|
+
}));
|
|
379
|
+
lastFocusEvent = now;
|
|
380
|
+
totalTime = totalTime + timeSpent;
|
|
381
|
+
};
|
|
382
|
+
const unloadCallback = () => {
|
|
383
|
+
setTimeout(() => observability.event({
|
|
384
|
+
identityId: getTelemetryIdentifier(client),
|
|
385
|
+
name: `${namespace}.page.unload`,
|
|
386
|
+
properties: {
|
|
387
|
+
href: window.location.href,
|
|
388
|
+
timeSpent: totalTime
|
|
389
|
+
}
|
|
390
|
+
}));
|
|
391
|
+
};
|
|
392
|
+
const errorCallback = (event) => {
|
|
393
|
+
setTimeout(() => observability.event({
|
|
394
|
+
identityId: getTelemetryIdentifier(client),
|
|
395
|
+
name: `${namespace}.window.error`,
|
|
396
|
+
properties: {
|
|
397
|
+
href: window.location.href,
|
|
398
|
+
message: event.message,
|
|
399
|
+
filename: event.filename,
|
|
400
|
+
stack: event.error?.stack
|
|
401
|
+
}
|
|
402
|
+
}));
|
|
403
|
+
};
|
|
404
|
+
window.addEventListener("click", clickCallback, true);
|
|
405
|
+
window.addEventListener("focus", focusCallback);
|
|
406
|
+
window.addEventListener("blur", blurCallback);
|
|
407
|
+
window.addEventListener("beforeunload", unloadCallback);
|
|
408
|
+
window.addEventListener("error", errorCallback);
|
|
409
|
+
return () => {
|
|
410
|
+
window.removeEventListener("click", clickCallback, true);
|
|
411
|
+
window.removeEventListener("focus", focusCallback);
|
|
412
|
+
window.removeEventListener("blur", blurCallback);
|
|
413
|
+
window.removeEventListener("beforeunload", unloadCallback);
|
|
414
|
+
window.removeEventListener("error", errorCallback);
|
|
415
|
+
};
|
|
416
|
+
};
|
|
417
|
+
var __dxlog_file3 = "/home/runner/work/dxos/dxos/packages/sdk/observability/src/observability.ts";
|
|
91
418
|
var SPACE_METRICS_MIN_INTERVAL = 1e3 * 60;
|
|
92
419
|
var SPACE_TELEMETRY_MIN_INTERVAL = 1e3 * 60 * 60;
|
|
93
420
|
var NETWORK_METRICS_MIN_INTERVAL = 1e3 * 60 * 5;
|
|
@@ -95,7 +422,7 @@ var Observability = class {
|
|
|
95
422
|
// TODO(nf): make platform a required extension?
|
|
96
423
|
constructor({ namespace, environment, release, config, secrets, group, mode, telemetry, errorLog }) {
|
|
97
424
|
this._ctx = new import_context.Context(void 0, {
|
|
98
|
-
F:
|
|
425
|
+
F: __dxlog_file3,
|
|
99
426
|
L: 87
|
|
100
427
|
});
|
|
101
428
|
this._tags = /* @__PURE__ */ new Map();
|
|
@@ -150,7 +477,7 @@ var Observability = class {
|
|
|
150
477
|
rtc: this._secrets,
|
|
151
478
|
config
|
|
152
479
|
}, {
|
|
153
|
-
F:
|
|
480
|
+
F: __dxlog_file3,
|
|
154
481
|
L: 151,
|
|
155
482
|
S: this,
|
|
156
483
|
C: (f, a) => f(...a)
|
|
@@ -168,6 +495,7 @@ var Observability = class {
|
|
|
168
495
|
}
|
|
169
496
|
}
|
|
170
497
|
async initialize() {
|
|
498
|
+
await this._initLogs();
|
|
171
499
|
await this._initMetrics();
|
|
172
500
|
await this._initTelemetry();
|
|
173
501
|
await this._initErrorLogs();
|
|
@@ -210,8 +538,8 @@ var Observability = class {
|
|
|
210
538
|
(0, import_log.log)("empty response from identity service", {
|
|
211
539
|
idqr
|
|
212
540
|
}, {
|
|
213
|
-
F:
|
|
214
|
-
L:
|
|
541
|
+
F: __dxlog_file3,
|
|
542
|
+
L: 220,
|
|
215
543
|
S: this,
|
|
216
544
|
C: (f, a) => f(...a)
|
|
217
545
|
});
|
|
@@ -226,16 +554,16 @@ var Observability = class {
|
|
|
226
554
|
(0, import_log.log)("empty response from device service", {
|
|
227
555
|
device: dqr
|
|
228
556
|
}, {
|
|
229
|
-
F:
|
|
230
|
-
L:
|
|
557
|
+
F: __dxlog_file3,
|
|
558
|
+
L: 230,
|
|
231
559
|
S: this,
|
|
232
560
|
C: (f, a) => f(...a)
|
|
233
561
|
});
|
|
234
562
|
return;
|
|
235
563
|
}
|
|
236
564
|
(0, import_invariant.invariant)(dqr, "empty response from device service", {
|
|
237
|
-
F:
|
|
238
|
-
L:
|
|
565
|
+
F: __dxlog_file3,
|
|
566
|
+
L: 233,
|
|
239
567
|
S: this,
|
|
240
568
|
A: [
|
|
241
569
|
"dqr",
|
|
@@ -247,8 +575,8 @@ var Observability = class {
|
|
|
247
575
|
(0, import_log.log)("no current device", {
|
|
248
576
|
device: dqr
|
|
249
577
|
}, {
|
|
250
|
-
F:
|
|
251
|
-
L:
|
|
578
|
+
F: __dxlog_file3,
|
|
579
|
+
L: 237,
|
|
252
580
|
S: this,
|
|
253
581
|
C: (f, a) => f(...a)
|
|
254
582
|
});
|
|
@@ -262,11 +590,49 @@ var Observability = class {
|
|
|
262
590
|
}
|
|
263
591
|
}
|
|
264
592
|
//
|
|
593
|
+
// Logs
|
|
594
|
+
//
|
|
595
|
+
async _initLogs() {
|
|
596
|
+
if (this._secrets.OTEL_ENDPOINT && this._secrets.OTEL_AUTHORIZATION && this._mode !== "disabled") {
|
|
597
|
+
const { OtelLogs } = await import("./otel-PN3H25QV.cjs");
|
|
598
|
+
this._otelLogs = new OtelLogs({
|
|
599
|
+
endpoint: this._secrets.OTEL_ENDPOINT,
|
|
600
|
+
authorizationHeader: this._secrets.OTEL_AUTHORIZATION,
|
|
601
|
+
serviceName: this._namespace,
|
|
602
|
+
serviceVersion: this.getTag("release")?.value ?? "0.0.0",
|
|
603
|
+
getTags: () => Object.fromEntries(Array.from(this._tags).filter(([key, value]) => {
|
|
604
|
+
return value.scope === "all" || value.scope === "errors";
|
|
605
|
+
}).map(([key, value]) => [
|
|
606
|
+
key,
|
|
607
|
+
value.value
|
|
608
|
+
])),
|
|
609
|
+
logLevel: import_log.LogLevel.VERBOSE,
|
|
610
|
+
includeSharedWorkerLogs: false
|
|
611
|
+
});
|
|
612
|
+
this._otelLogs && import_log.log.runtimeConfig.processors.push(this._otelLogs.logProcessor);
|
|
613
|
+
(0, import_log.log)("otel logs enabled", {
|
|
614
|
+
namespace: this._namespace
|
|
615
|
+
}, {
|
|
616
|
+
F: __dxlog_file3,
|
|
617
|
+
L: 272,
|
|
618
|
+
S: this,
|
|
619
|
+
C: (f, a) => f(...a)
|
|
620
|
+
});
|
|
621
|
+
} else {
|
|
622
|
+
(0, import_log.log)("otel logs disabled", void 0, {
|
|
623
|
+
F: __dxlog_file3,
|
|
624
|
+
L: 274,
|
|
625
|
+
S: this,
|
|
626
|
+
C: (f, a) => f(...a)
|
|
627
|
+
});
|
|
628
|
+
}
|
|
629
|
+
}
|
|
630
|
+
//
|
|
265
631
|
// Metrics
|
|
266
632
|
//
|
|
267
633
|
async _initMetrics() {
|
|
268
634
|
if (this.enabled && this._secrets.OTEL_ENDPOINT && this._secrets.OTEL_AUTHORIZATION) {
|
|
269
|
-
const { OtelMetrics } = await import("./otel-
|
|
635
|
+
const { OtelMetrics } = await import("./otel-PN3H25QV.cjs");
|
|
270
636
|
this._otelMetrics = new OtelMetrics({
|
|
271
637
|
endpoint: this._secrets.OTEL_ENDPOINT,
|
|
272
638
|
authorizationHeader: this._secrets.OTEL_AUTHORIZATION,
|
|
@@ -280,15 +646,15 @@ var Observability = class {
|
|
|
280
646
|
]))
|
|
281
647
|
});
|
|
282
648
|
(0, import_log.log)("otel metrics enabled", void 0, {
|
|
283
|
-
F:
|
|
284
|
-
L:
|
|
649
|
+
F: __dxlog_file3,
|
|
650
|
+
L: 299,
|
|
285
651
|
S: this,
|
|
286
652
|
C: (f, a) => f(...a)
|
|
287
653
|
});
|
|
288
654
|
} else {
|
|
289
655
|
(0, import_log.log)("otel metrics disabled", void 0, {
|
|
290
|
-
F:
|
|
291
|
-
L:
|
|
656
|
+
F: __dxlog_file3,
|
|
657
|
+
L: 301,
|
|
292
658
|
S: this,
|
|
293
659
|
C: (f, a) => f(...a)
|
|
294
660
|
});
|
|
@@ -310,12 +676,12 @@ var Observability = class {
|
|
|
310
676
|
const updateSignalMetrics = new import_async.Event().debounce(NETWORK_METRICS_MIN_INTERVAL);
|
|
311
677
|
updateSignalMetrics.on(this._ctx, async () => {
|
|
312
678
|
(0, import_log.log)("send signal metrics", void 0, {
|
|
313
|
-
F:
|
|
314
|
-
L:
|
|
679
|
+
F: __dxlog_file3,
|
|
680
|
+
L: 323,
|
|
315
681
|
S: this,
|
|
316
682
|
C: (f, a) => f(...a)
|
|
317
683
|
});
|
|
318
|
-
|
|
684
|
+
this._lastNetworkStatus?.signaling?.forEach(({ server, state }) => {
|
|
319
685
|
this.gauge("dxos.client.network.signal.connectionState", state, {
|
|
320
686
|
server
|
|
321
687
|
});
|
|
@@ -362,8 +728,8 @@ var Observability = class {
|
|
|
362
728
|
const updateSpaceMetrics = new import_async.Event().debounce(SPACE_METRICS_MIN_INTERVAL);
|
|
363
729
|
updateSpaceMetrics.on(this._ctx, async () => {
|
|
364
730
|
(0, import_log.log)("send space metrics", void 0, {
|
|
365
|
-
F:
|
|
366
|
-
L:
|
|
731
|
+
F: __dxlog_file3,
|
|
732
|
+
L: 377,
|
|
367
733
|
S: this,
|
|
368
734
|
C: (f, a) => f(...a)
|
|
369
735
|
});
|
|
@@ -387,8 +753,8 @@ var Observability = class {
|
|
|
387
753
|
const updateSpaceTelemetry = new import_async.Event().debounce(SPACE_TELEMETRY_MIN_INTERVAL);
|
|
388
754
|
updateSpaceTelemetry.on(this._ctx, async () => {
|
|
389
755
|
(0, import_log.log)("send space telemetry", void 0, {
|
|
390
|
-
F:
|
|
391
|
-
L:
|
|
756
|
+
F: __dxlog_file3,
|
|
757
|
+
L: 388,
|
|
392
758
|
S: this,
|
|
393
759
|
C: (f, a) => f(...a)
|
|
394
760
|
});
|
|
@@ -423,8 +789,8 @@ var Observability = class {
|
|
|
423
789
|
async startRuntimeMetrics(client, frequency = NETWORK_METRICS_MIN_INTERVAL) {
|
|
424
790
|
const platform = await client.services.services.SystemService?.getPlatform();
|
|
425
791
|
(0, import_invariant.invariant)(platform, "platform is required", {
|
|
426
|
-
F:
|
|
427
|
-
L:
|
|
792
|
+
F: __dxlog_file3,
|
|
793
|
+
L: 425,
|
|
428
794
|
S: this,
|
|
429
795
|
A: [
|
|
430
796
|
"platform",
|
|
@@ -461,8 +827,8 @@ var Observability = class {
|
|
|
461
827
|
}).catch((error) => (0, import_log.log)("platform error", {
|
|
462
828
|
error
|
|
463
829
|
}, {
|
|
464
|
-
F:
|
|
465
|
-
L:
|
|
830
|
+
F: __dxlog_file3,
|
|
831
|
+
L: 460,
|
|
466
832
|
S: this,
|
|
467
833
|
C: (f, a) => f(...a)
|
|
468
834
|
}));
|
|
@@ -486,8 +852,8 @@ var Observability = class {
|
|
|
486
852
|
});
|
|
487
853
|
} else {
|
|
488
854
|
(0, import_log.log)("segment disabled", void 0, {
|
|
489
|
-
F:
|
|
490
|
-
L:
|
|
855
|
+
F: __dxlog_file3,
|
|
856
|
+
L: 486,
|
|
491
857
|
S: this,
|
|
492
858
|
C: (f, a) => f(...a)
|
|
493
859
|
});
|
|
@@ -523,8 +889,8 @@ var Observability = class {
|
|
|
523
889
|
dest: this._secrets.SENTRY_DESTINATION,
|
|
524
890
|
options: this._errorReportingOptions
|
|
525
891
|
}, {
|
|
526
|
-
F:
|
|
527
|
-
L:
|
|
892
|
+
F: __dxlog_file3,
|
|
893
|
+
L: 522,
|
|
528
894
|
S: this,
|
|
529
895
|
C: (f, a) => f(...a)
|
|
530
896
|
});
|
|
@@ -542,38 +908,8 @@ var Observability = class {
|
|
|
542
908
|
});
|
|
543
909
|
} else {
|
|
544
910
|
(0, import_log.log)("sentry disabled", void 0, {
|
|
545
|
-
F:
|
|
546
|
-
L:
|
|
547
|
-
S: this,
|
|
548
|
-
C: (f, a) => f(...a)
|
|
549
|
-
});
|
|
550
|
-
}
|
|
551
|
-
if (this._secrets.OTEL_ENDPOINT && this._secrets.OTEL_AUTHORIZATION && this._mode !== "disabled") {
|
|
552
|
-
const { OtelLogs } = await import("./otel-TSHMOAB4.cjs");
|
|
553
|
-
this._otelLogs = new OtelLogs({
|
|
554
|
-
endpoint: this._secrets.OTEL_ENDPOINT,
|
|
555
|
-
authorizationHeader: this._secrets.OTEL_AUTHORIZATION,
|
|
556
|
-
serviceName: this._namespace,
|
|
557
|
-
serviceVersion: this.getTag("release")?.value ?? "0.0.0",
|
|
558
|
-
getTags: () => Object.fromEntries(Array.from(this._tags).filter(([key, value]) => {
|
|
559
|
-
return value.scope === "all" || value.scope === "errors";
|
|
560
|
-
}).map(([key, value]) => [
|
|
561
|
-
key,
|
|
562
|
-
value.value
|
|
563
|
-
]))
|
|
564
|
-
});
|
|
565
|
-
(0, import_log.log)("otel logs enabled", {
|
|
566
|
-
namespace: this._namespace
|
|
567
|
-
}, {
|
|
568
|
-
F: __dxlog_file,
|
|
569
|
-
L: 530,
|
|
570
|
-
S: this,
|
|
571
|
-
C: (f, a) => f(...a)
|
|
572
|
-
});
|
|
573
|
-
} else {
|
|
574
|
-
(0, import_log.log)("otel logs disabled", void 0, {
|
|
575
|
-
F: __dxlog_file,
|
|
576
|
-
L: 532,
|
|
911
|
+
F: __dxlog_file3,
|
|
912
|
+
L: 542,
|
|
577
913
|
S: this,
|
|
578
914
|
C: (f, a) => f(...a)
|
|
579
915
|
});
|
|
@@ -581,7 +917,6 @@ var Observability = class {
|
|
|
581
917
|
}
|
|
582
918
|
startErrorLogs() {
|
|
583
919
|
this._sentryLogProcessor && import_log.log.runtimeConfig.processors.push(this._sentryLogProcessor.logProcessor);
|
|
584
|
-
this._otelLogs && import_log.log.runtimeConfig.processors.push(this._otelLogs.logProcessor);
|
|
585
920
|
}
|
|
586
921
|
startTraces() {
|
|
587
922
|
this._otelTraces && this._otelTraces.start();
|
|
@@ -589,7 +924,7 @@ var Observability = class {
|
|
|
589
924
|
// TODO(nf): refactor init based on providers and their capabilities
|
|
590
925
|
async _initTraces() {
|
|
591
926
|
if (this._secrets.OTEL_ENDPOINT && this._secrets.OTEL_AUTHORIZATION && this._mode !== "disabled") {
|
|
592
|
-
const { OtelTraces } = await import("./otel-
|
|
927
|
+
const { OtelTraces } = await import("./otel-PN3H25QV.cjs");
|
|
593
928
|
this._otelTraces = new OtelTraces({
|
|
594
929
|
endpoint: this._secrets.OTEL_ENDPOINT,
|
|
595
930
|
authorizationHeader: this._secrets.OTEL_AUTHORIZATION,
|
|
@@ -625,8 +960,19 @@ var Observability = class {
|
|
|
625
960
|
};
|
|
626
961
|
// Annotate the CommonJS export names for ESM import in node:
|
|
627
962
|
0 && (module.exports = {
|
|
963
|
+
OBSERVABILITY_DISABLED_KEY,
|
|
964
|
+
OBSERVABILITY_GROUP_KEY,
|
|
628
965
|
Observability,
|
|
966
|
+
getObservabilityGroup,
|
|
967
|
+
getObservabilityState,
|
|
629
968
|
getTelemetryIdentifier,
|
|
630
|
-
|
|
969
|
+
initializeAppObservability,
|
|
970
|
+
initializeNodeObservability,
|
|
971
|
+
isObservabilityDisabled,
|
|
972
|
+
mapSpaces,
|
|
973
|
+
setupTelemetryListeners,
|
|
974
|
+
showObservabilityBanner,
|
|
975
|
+
storeObservabilityDisabled,
|
|
976
|
+
storeObservabilityGroup
|
|
631
977
|
});
|
|
632
|
-
//# sourceMappingURL=chunk-
|
|
978
|
+
//# sourceMappingURL=chunk-4377UHKI.cjs.map
|