@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.
Files changed (54) hide show
  1. package/dist/lib/browser/{chunk-4OXG76Y3.mjs → chunk-4BMUWKD7.mjs} +425 -84
  2. package/dist/lib/browser/chunk-4BMUWKD7.mjs.map +7 -0
  3. package/dist/lib/browser/index.mjs +13 -323
  4. package/dist/lib/browser/index.mjs.map +4 -4
  5. package/dist/lib/browser/meta.json +1 -1
  6. package/dist/lib/browser/observability-2MFVX6KP.mjs +7 -0
  7. package/dist/lib/browser/{otel-BUKBDMAL.mjs → otel-WFASQZXZ.mjs} +5 -3
  8. package/dist/lib/browser/otel-WFASQZXZ.mjs.map +7 -0
  9. package/dist/lib/node/{chunk-AMV7JU2O.cjs → chunk-4377UHKI.cjs} +419 -73
  10. package/dist/lib/node/chunk-4377UHKI.cjs.map +7 -0
  11. package/dist/lib/node/index.cjs +15 -340
  12. package/dist/lib/node/index.cjs.map +4 -4
  13. package/dist/lib/node/meta.json +1 -1
  14. package/dist/lib/node/{observability-Y2NU446N.cjs → observability-5VIENMKC.cjs} +6 -6
  15. package/dist/lib/node/{observability-Y2NU446N.cjs.map → observability-5VIENMKC.cjs.map} +2 -2
  16. package/dist/lib/node/{otel-TSHMOAB4.cjs → otel-PN3H25QV.cjs} +7 -5
  17. package/dist/lib/node/otel-PN3H25QV.cjs.map +7 -0
  18. package/dist/lib/node-esm/{chunk-D7JZEGRD.mjs → chunk-UA3GVRAT.mjs} +425 -84
  19. package/dist/lib/node-esm/chunk-UA3GVRAT.mjs.map +7 -0
  20. package/dist/lib/node-esm/index.mjs +13 -323
  21. package/dist/lib/node-esm/index.mjs.map +4 -4
  22. package/dist/lib/node-esm/meta.json +1 -1
  23. package/dist/lib/node-esm/{observability-RAXT3Z2H.mjs → observability-KXS3AJRW.mjs} +2 -2
  24. package/dist/lib/node-esm/{otel-YI7HAFOG.mjs → otel-CYD4GJC2.mjs} +5 -3
  25. package/dist/lib/node-esm/otel-CYD4GJC2.mjs.map +7 -0
  26. package/dist/types/src/cli-observability-secrets.json +2 -2
  27. package/dist/types/src/helpers/browser-observability.d.ts.map +1 -1
  28. package/dist/types/src/helpers/browser-observability.js +2 -1
  29. package/dist/types/src/helpers/browser-observability.js.map +1 -1
  30. package/dist/types/src/helpers/setup-telemetry-listeners.js +13 -10
  31. package/dist/types/src/helpers/setup-telemetry-listeners.js.map +1 -1
  32. package/dist/types/src/observability.d.ts +1 -0
  33. package/dist/types/src/observability.d.ts.map +1 -1
  34. package/dist/types/src/observability.js +31 -23
  35. package/dist/types/src/observability.js.map +1 -1
  36. package/dist/types/src/otel/logs.d.ts +10 -2
  37. package/dist/types/src/otel/logs.d.ts.map +1 -1
  38. package/dist/types/src/otel/logs.js +4 -1
  39. package/dist/types/src/otel/logs.js.map +1 -1
  40. package/package.json +22 -31
  41. package/src/cli-observability-secrets.json +2 -2
  42. package/src/helpers/browser-observability.ts +2 -1
  43. package/src/helpers/setup-telemetry-listeners.ts +1 -1
  44. package/src/observability.ts +33 -24
  45. package/src/otel/logs.ts +17 -3
  46. package/dist/lib/browser/chunk-4OXG76Y3.mjs.map +0 -7
  47. package/dist/lib/browser/observability-WZNQCJ5C.mjs +0 -7
  48. package/dist/lib/browser/otel-BUKBDMAL.mjs.map +0 -7
  49. package/dist/lib/node/chunk-AMV7JU2O.cjs.map +0 -7
  50. package/dist/lib/node/otel-TSHMOAB4.cjs.map +0 -7
  51. package/dist/lib/node-esm/chunk-D7JZEGRD.mjs.map +0 -7
  52. package/dist/lib/node-esm/otel-YI7HAFOG.mjs.map +0 -7
  53. /package/dist/lib/browser/{observability-WZNQCJ5C.mjs.map → observability-2MFVX6KP.mjs.map} +0 -0
  54. /package/dist/lib/node-esm/{observability-RAXT3Z2H.mjs.map → observability-KXS3AJRW.mjs.map} +0 -0
@@ -5,7 +5,7 @@ import { Event, scheduleTaskInterval } from "@dxos/async";
5
5
  import { PublicKey } from "@dxos/client";
6
6
  import { Context } from "@dxos/context";
7
7
  import { invariant } from "@dxos/invariant";
8
- import { log } from "@dxos/log";
8
+ import { log as log3, LogLevel } from "@dxos/log";
9
9
  import { ConnectionState } from "@dxos/network-manager";
10
10
  import { DeviceKind, Platform } from "@dxos/protocols/proto/dxos/client/services";
11
11
  import { isNode } from "@dxos/util";
@@ -15,8 +15,157 @@ var cli_observability_secrets_default = {
15
15
  SENTRY_DESTINATION: "https://2647916221e643869965e78469479aa4@o4504012000067584.ingest.sentry.io/4504012027265029",
16
16
  TELEMETRY_API_KEY: "B00QG6PtJJrJ0VVFe0H5a6bcUUShKyZM",
17
17
  IPDATA_API_KEY: "73dfdecdf979c18f07d50cf841bbdd9e589f237256326ac8cca23786",
18
- OTEL_ENDPOINT: null,
19
- OTEL_AUTHORIZATION: null
18
+ OTEL_ENDPOINT: "https://otlp-proxy.dxos.workers.dev",
19
+ OTEL_AUTHORIZATION: "Basic OTA3MzIzOmdsY19leUp2SWpvaU1URXdNVEl6TnlJc0ltNGlPaUp6ZEdGamF5MDVNRGN6TWpNdGFXNTBaV2R5WVhScGIyNHRZMnh2ZFdSbWJHRnlaUzF2ZEd4d0xYQnliM2g1SWl3aWF5STZJalZ2Tkd4cFYydE5iRmszTlRNMGJUVXpTemRTVjNBeVNpSXNJbTBpT25zaWNpSTZJbkJ5YjJRdGRYTXRaV0Z6ZEMwd0luMTk="
20
+ };
21
+
22
+ // packages/sdk/observability/src/helpers/browser-observability.ts
23
+ import * as localForage from "localforage";
24
+ import { log } from "@dxos/log";
25
+ var __dxlog_file = "/home/runner/work/dxos/dxos/packages/sdk/observability/src/helpers/browser-observability.ts";
26
+ var OBSERVABILITY_DISABLED_KEY = "observability-disabled";
27
+ var OBSERVABILITY_GROUP_KEY = "observability-group";
28
+ var isObservabilityDisabled = async (namespace) => {
29
+ try {
30
+ return await localForage.getItem(`${namespace}:${OBSERVABILITY_DISABLED_KEY}`) === "true";
31
+ } catch (err) {
32
+ log.catch("Failed to check if observability is disabled, assuming it is", err, {
33
+ F: __dxlog_file,
34
+ L: 24,
35
+ S: void 0,
36
+ C: (f, a) => f(...a)
37
+ });
38
+ return true;
39
+ }
40
+ };
41
+ var storeObservabilityDisabled = async (namespace, value) => {
42
+ try {
43
+ await localForage.setItem(`${namespace}:${OBSERVABILITY_DISABLED_KEY}`, String(value));
44
+ } catch (err) {
45
+ log.catch("Failed to store observability disabled", err, {
46
+ F: __dxlog_file,
47
+ L: 33,
48
+ S: void 0,
49
+ C: (f, a) => f(...a)
50
+ });
51
+ }
52
+ };
53
+ var getObservabilityGroup = async (namespace) => {
54
+ try {
55
+ return await localForage.getItem(`${namespace}:${OBSERVABILITY_GROUP_KEY}`) ?? void 0;
56
+ } catch (err) {
57
+ log.catch("Failed to get observability group", err, {
58
+ F: __dxlog_file,
59
+ L: 41,
60
+ S: void 0,
61
+ C: (f, a) => f(...a)
62
+ });
63
+ }
64
+ };
65
+ var storeObservabilityGroup = async (namespace, value) => {
66
+ try {
67
+ await localForage.setItem(`${namespace}:${OBSERVABILITY_GROUP_KEY}`, value);
68
+ } catch (err) {
69
+ log.catch("Failed to store observability group", err, {
70
+ F: __dxlog_file,
71
+ L: 49,
72
+ S: void 0,
73
+ C: (f, a) => f(...a)
74
+ });
75
+ }
76
+ };
77
+ var initializeAppObservability = async ({ namespace, config, mode = "basic", tracingEnable = true, replayEnable = true }) => {
78
+ log("initializeAppObservability", {
79
+ config
80
+ }, {
81
+ F: __dxlog_file,
82
+ L: 72,
83
+ S: void 0,
84
+ C: (f, a) => f(...a)
85
+ });
86
+ const group = await getObservabilityGroup(namespace) ?? void 0;
87
+ const release = `${namespace}@${config.get("runtime.app.build.version")}`;
88
+ const environment = config.get("runtime.app.env.DX_ENVIRONMENT");
89
+ const observabilityDisabled = await isObservabilityDisabled(namespace);
90
+ const { Observability: Observability2 } = await import("./observability-KXS3AJRW.mjs");
91
+ const observability = new Observability2({
92
+ namespace,
93
+ release,
94
+ environment,
95
+ group,
96
+ mode,
97
+ config,
98
+ errorLog: {
99
+ sentryInitOptions: {
100
+ environment,
101
+ release,
102
+ tracing: tracingEnable,
103
+ replay: replayEnable,
104
+ // TODO(wittjosiah): Configure these.
105
+ sampleRate: 1,
106
+ // TODO(mykola): Lower this to 0.1.
107
+ replaySampleRate: 1,
108
+ replaySampleRateOnError: 1
109
+ }
110
+ }
111
+ });
112
+ if (observabilityDisabled) {
113
+ observability.setMode("disabled");
114
+ log.info("observability disabled", void 0, {
115
+ F: __dxlog_file,
116
+ L: 116,
117
+ S: void 0,
118
+ C: (f, a) => f(...a)
119
+ });
120
+ return observability;
121
+ }
122
+ try {
123
+ const getIPData = async (config2) => {
124
+ const IP_DATA_CACHE_TIMEOUT = 6 * 60 * 60 * 1e3;
125
+ const cachedData = await localForage.getItem("dxos:observability:ipdata");
126
+ if (cachedData && cachedData.timestamp > Date.now() - IP_DATA_CACHE_TIMEOUT) {
127
+ return cachedData.data;
128
+ }
129
+ const IPDATA_API_KEY = config2.get("runtime.app.env.DX_IPDATA_API_KEY");
130
+ if (IPDATA_API_KEY) {
131
+ return fetch(`https://api.ipdata.co?api-key=${IPDATA_API_KEY}`).then((res) => res.json()).then((data) => {
132
+ localForage.setItem("dxos:observability:ipdata", {
133
+ data,
134
+ timestamp: Date.now()
135
+ }).catch((err) => observability.captureException(err));
136
+ return data;
137
+ }).catch((err) => observability.captureException(err));
138
+ }
139
+ };
140
+ await observability.initialize();
141
+ observability.startErrorLogs();
142
+ const ipData = await getIPData(config);
143
+ ipData && observability.addIPDataTelemetryTags(ipData);
144
+ if (typeof navigator !== "undefined" && navigator.storage?.estimate) {
145
+ setInterval(async () => {
146
+ try {
147
+ const storageEstimate = await navigator.storage.estimate();
148
+ storageEstimate.usage && observability.setTag("storageUsage", storageEstimate.usage.toString(), "telemetry");
149
+ storageEstimate.quota && observability.setTag("storageQuota", storageEstimate.quota.toString(), "telemetry");
150
+ } catch (error) {
151
+ log.warn("Failed to run estimate()", error, {
152
+ F: __dxlog_file,
153
+ L: 172,
154
+ S: void 0,
155
+ C: (f, a) => f(...a)
156
+ });
157
+ }
158
+ }, 1e4);
159
+ }
160
+ } catch (err) {
161
+ log.error("Failed to initialize app observability", err, {
162
+ F: __dxlog_file,
163
+ L: 177,
164
+ S: void 0,
165
+ C: (f, a) => f(...a)
166
+ });
167
+ }
168
+ return observability;
20
169
  };
21
170
 
22
171
  // packages/sdk/observability/src/helpers/common.ts
@@ -31,6 +180,98 @@ var getTelemetryIdentifier = (client) => {
31
180
  return void 0;
32
181
  };
33
182
 
183
+ // packages/sdk/observability/src/helpers/node-observability.ts
184
+ import yaml from "js-yaml";
185
+ import { existsSync, statSync } from "node:fs";
186
+ import { mkdir, readFile, writeFile } from "node:fs/promises";
187
+ import { join } from "node:path";
188
+ import { v4 as uuid, validate as validateUuid } from "uuid";
189
+ import { log as log2 } from "@dxos/log";
190
+ var __dxlog_file2 = "/home/runner/work/dxos/dxos/packages/sdk/observability/src/helpers/node-observability.ts";
191
+ var showObservabilityBanner = async (configDir, bannercb) => {
192
+ const path = join(configDir, ".observability-banner-printed");
193
+ if (existsSync(path)) {
194
+ return;
195
+ }
196
+ bannercb(
197
+ // eslint-disable-next-line no-multi-str
198
+ "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."
199
+ );
200
+ await writeFile(path, "", "utf-8");
201
+ };
202
+ var getObservabilityState = async (configDir) => {
203
+ if (existsSync(configDir)) {
204
+ if (!statSync(configDir).isDirectory()) {
205
+ throw new Error(`Config directory ${configDir} exists but is not a directory`);
206
+ }
207
+ } else {
208
+ await mkdir(configDir, {
209
+ recursive: true
210
+ });
211
+ }
212
+ const idPath = join(configDir, "observability.yml");
213
+ if (existsSync(idPath)) {
214
+ const context = await readFile(idPath, "utf-8");
215
+ return validate(context) ?? initializeState(idPath);
216
+ }
217
+ return initializeState(idPath);
218
+ };
219
+ var initializeState = async (idPath) => {
220
+ const observabilityState = {
221
+ installationId: uuid(),
222
+ group: process.env.DX_OBSERVABILITY_GROUP ?? void 0,
223
+ mode: process.env.DX_DISABLE_OBSERVABILITY ? "disabled" : process.env.DX_OBSERVABILITY_MODE ?? "basic"
224
+ };
225
+ await writeFile(idPath, "# This file is automatically generated by the @dxos/cli.\n" + yaml.dump(observabilityState), "utf-8");
226
+ return observabilityState;
227
+ };
228
+ var validate = (contextString) => {
229
+ const context = yaml.load(contextString);
230
+ if (Boolean(context.installationId) && validateUuid(context.installationId)) {
231
+ return {
232
+ ...context,
233
+ mode: process.env.DX_DISABLE_OBSERVABILITY ? "disabled" : context.mode ?? "basic"
234
+ };
235
+ }
236
+ };
237
+ var initializeNodeObservability = async ({ namespace, version, config, installationId, group, mode = "basic", tracingEnable = true, replayEnable = true }) => {
238
+ log2("initializeCliObservability", {
239
+ config
240
+ }, {
241
+ F: __dxlog_file2,
242
+ L: 110,
243
+ S: void 0,
244
+ C: (f, a) => f(...a)
245
+ });
246
+ const release = `${namespace}@${version}`;
247
+ const environment = process.env.DX_ENVIRONMENT ?? "unknown";
248
+ const observability = new Observability({
249
+ namespace,
250
+ release,
251
+ environment,
252
+ group,
253
+ mode,
254
+ errorLog: {
255
+ sentryInitOptions: {
256
+ environment,
257
+ release,
258
+ // TODO(wittjosiah): Configure this.
259
+ sampleRate: 1
260
+ }
261
+ }
262
+ });
263
+ observability.setTag("installationId", installationId);
264
+ const IPDATA_API_KEY = config.get("runtime.app.env.DX_IPDATA_API_KEY");
265
+ try {
266
+ const res = await fetch(`https://api.ipdata.co/?api-key=${IPDATA_API_KEY}`);
267
+ const ipData = await res.json();
268
+ ipData && observability.addIPDataTelemetryTags(ipData);
269
+ } catch (err) {
270
+ observability?.captureException(err);
271
+ }
272
+ return observability;
273
+ };
274
+
34
275
  // packages/sdk/observability/src/helpers/map-spaces.ts
35
276
  var mapSpaces = (spaces, options = {
36
277
  verbose: false,
@@ -62,8 +303,89 @@ var mapSpaces = (spaces, options = {
62
303
  });
63
304
  };
64
305
 
306
+ // packages/sdk/observability/src/helpers/setup-telemetry-listeners.ts
307
+ var lastFocusEvent = /* @__PURE__ */ new Date();
308
+ var totalTime = 0;
309
+ var setupTelemetryListeners = (namespace, client, observability) => {
310
+ const clickCallback = (event) => {
311
+ const id = event.target?.id;
312
+ if (!id) {
313
+ return;
314
+ }
315
+ setTimeout(() => observability.event({
316
+ identityId: getTelemetryIdentifier(client),
317
+ name: `${namespace}.window.click`,
318
+ properties: {
319
+ href: window.location.href,
320
+ id: event.target?.id,
321
+ path: event.composedPath().filter((el) => Boolean(el.tagName)).map((el) => `${el.tagName.toLowerCase()}${el.id ? `#${el.id}` : ""}`).reverse().join(">")
322
+ }
323
+ }));
324
+ };
325
+ const focusCallback = () => {
326
+ const now = /* @__PURE__ */ new Date();
327
+ setTimeout(() => observability.event({
328
+ identityId: getTelemetryIdentifier(client),
329
+ name: `${namespace}.window.focus`,
330
+ properties: {
331
+ href: window.location.href,
332
+ timeAway: now.getTime() - lastFocusEvent.getTime()
333
+ }
334
+ }));
335
+ lastFocusEvent = now;
336
+ };
337
+ const blurCallback = () => {
338
+ const now = /* @__PURE__ */ new Date();
339
+ const timeSpent = now.getTime() - lastFocusEvent.getTime();
340
+ setTimeout(() => observability.event({
341
+ identityId: getTelemetryIdentifier(client),
342
+ name: `${namespace}.window.blur`,
343
+ properties: {
344
+ href: window.location.href,
345
+ timeSpent
346
+ }
347
+ }));
348
+ lastFocusEvent = now;
349
+ totalTime = totalTime + timeSpent;
350
+ };
351
+ const unloadCallback = () => {
352
+ setTimeout(() => observability.event({
353
+ identityId: getTelemetryIdentifier(client),
354
+ name: `${namespace}.page.unload`,
355
+ properties: {
356
+ href: window.location.href,
357
+ timeSpent: totalTime
358
+ }
359
+ }));
360
+ };
361
+ const errorCallback = (event) => {
362
+ setTimeout(() => observability.event({
363
+ identityId: getTelemetryIdentifier(client),
364
+ name: `${namespace}.window.error`,
365
+ properties: {
366
+ href: window.location.href,
367
+ message: event.message,
368
+ filename: event.filename,
369
+ stack: event.error?.stack
370
+ }
371
+ }));
372
+ };
373
+ window.addEventListener("click", clickCallback, true);
374
+ window.addEventListener("focus", focusCallback);
375
+ window.addEventListener("blur", blurCallback);
376
+ window.addEventListener("beforeunload", unloadCallback);
377
+ window.addEventListener("error", errorCallback);
378
+ return () => {
379
+ window.removeEventListener("click", clickCallback, true);
380
+ window.removeEventListener("focus", focusCallback);
381
+ window.removeEventListener("blur", blurCallback);
382
+ window.removeEventListener("beforeunload", unloadCallback);
383
+ window.removeEventListener("error", errorCallback);
384
+ };
385
+ };
386
+
65
387
  // packages/sdk/observability/src/observability.ts
66
- var __dxlog_file = "/home/runner/work/dxos/dxos/packages/sdk/observability/src/observability.ts";
388
+ var __dxlog_file3 = "/home/runner/work/dxos/dxos/packages/sdk/observability/src/observability.ts";
67
389
  var SPACE_METRICS_MIN_INTERVAL = 1e3 * 60;
68
390
  var SPACE_TELEMETRY_MIN_INTERVAL = 1e3 * 60 * 60;
69
391
  var NETWORK_METRICS_MIN_INTERVAL = 1e3 * 60 * 5;
@@ -72,7 +394,7 @@ var Observability = class {
72
394
  constructor({ namespace, environment, release, config, secrets, group, mode, telemetry, errorLog }) {
73
395
  // TODO(nf): accept upstream context?
74
396
  this._ctx = new Context(void 0, {
75
- F: __dxlog_file,
397
+ F: __dxlog_file3,
76
398
  L: 87
77
399
  });
78
400
  this._tags = /* @__PURE__ */ new Map();
@@ -123,11 +445,11 @@ var Observability = class {
123
445
  process.env.DX_OTEL_AUTHORIZATION && (mergedSecrets.OTEL_AUTHORIZATION = process.env.DX_OTEL_AUTHORIZATION);
124
446
  return mergedSecrets;
125
447
  } else {
126
- log("config", {
448
+ log3("config", {
127
449
  rtc: this._secrets,
128
450
  config
129
451
  }, {
130
- F: __dxlog_file,
452
+ F: __dxlog_file3,
131
453
  L: 151,
132
454
  S: this,
133
455
  C: (f, a) => f(...a)
@@ -145,6 +467,7 @@ var Observability = class {
145
467
  }
146
468
  }
147
469
  async initialize() {
470
+ await this._initLogs();
148
471
  await this._initMetrics();
149
472
  await this._initTelemetry();
150
473
  await this._initErrorLogs();
@@ -184,11 +507,11 @@ var Observability = class {
184
507
  if (clientServices.IdentityService) {
185
508
  clientServices.IdentityService.queryIdentity().subscribe((idqr) => {
186
509
  if (!idqr?.identity?.identityKey) {
187
- log("empty response from identity service", {
510
+ log3("empty response from identity service", {
188
511
  idqr
189
512
  }, {
190
- F: __dxlog_file,
191
- L: 219,
513
+ F: __dxlog_file3,
514
+ L: 220,
192
515
  S: this,
193
516
  C: (f, a) => f(...a)
194
517
  });
@@ -200,19 +523,19 @@ var Observability = class {
200
523
  if (clientServices.DevicesService) {
201
524
  clientServices.DevicesService.queryDevices().subscribe((dqr) => {
202
525
  if (!dqr || !dqr.devices || dqr.devices.length === 0) {
203
- log("empty response from device service", {
526
+ log3("empty response from device service", {
204
527
  device: dqr
205
528
  }, {
206
- F: __dxlog_file,
207
- L: 229,
529
+ F: __dxlog_file3,
530
+ L: 230,
208
531
  S: this,
209
532
  C: (f, a) => f(...a)
210
533
  });
211
534
  return;
212
535
  }
213
536
  invariant(dqr, "empty response from device service", {
214
- F: __dxlog_file,
215
- L: 232,
537
+ F: __dxlog_file3,
538
+ L: 233,
216
539
  S: this,
217
540
  A: [
218
541
  "dqr",
@@ -221,11 +544,11 @@ var Observability = class {
221
544
  });
222
545
  const thisDevice = dqr.devices.find((device) => device.kind === DeviceKind.CURRENT);
223
546
  if (!thisDevice) {
224
- log("no current device", {
547
+ log3("no current device", {
225
548
  device: dqr
226
549
  }, {
227
- F: __dxlog_file,
228
- L: 236,
550
+ F: __dxlog_file3,
551
+ L: 237,
229
552
  S: this,
230
553
  C: (f, a) => f(...a)
231
554
  });
@@ -239,11 +562,49 @@ var Observability = class {
239
562
  }
240
563
  }
241
564
  //
565
+ // Logs
566
+ //
567
+ async _initLogs() {
568
+ if (this._secrets.OTEL_ENDPOINT && this._secrets.OTEL_AUTHORIZATION && this._mode !== "disabled") {
569
+ const { OtelLogs } = await import("./otel-CYD4GJC2.mjs");
570
+ this._otelLogs = new OtelLogs({
571
+ endpoint: this._secrets.OTEL_ENDPOINT,
572
+ authorizationHeader: this._secrets.OTEL_AUTHORIZATION,
573
+ serviceName: this._namespace,
574
+ serviceVersion: this.getTag("release")?.value ?? "0.0.0",
575
+ getTags: () => Object.fromEntries(Array.from(this._tags).filter(([key, value]) => {
576
+ return value.scope === "all" || value.scope === "errors";
577
+ }).map(([key, value]) => [
578
+ key,
579
+ value.value
580
+ ])),
581
+ logLevel: LogLevel.VERBOSE,
582
+ includeSharedWorkerLogs: false
583
+ });
584
+ this._otelLogs && log3.runtimeConfig.processors.push(this._otelLogs.logProcessor);
585
+ log3("otel logs enabled", {
586
+ namespace: this._namespace
587
+ }, {
588
+ F: __dxlog_file3,
589
+ L: 272,
590
+ S: this,
591
+ C: (f, a) => f(...a)
592
+ });
593
+ } else {
594
+ log3("otel logs disabled", void 0, {
595
+ F: __dxlog_file3,
596
+ L: 274,
597
+ S: this,
598
+ C: (f, a) => f(...a)
599
+ });
600
+ }
601
+ }
602
+ //
242
603
  // Metrics
243
604
  //
244
605
  async _initMetrics() {
245
606
  if (this.enabled && this._secrets.OTEL_ENDPOINT && this._secrets.OTEL_AUTHORIZATION) {
246
- const { OtelMetrics } = await import("./otel-YI7HAFOG.mjs");
607
+ const { OtelMetrics } = await import("./otel-CYD4GJC2.mjs");
247
608
  this._otelMetrics = new OtelMetrics({
248
609
  endpoint: this._secrets.OTEL_ENDPOINT,
249
610
  authorizationHeader: this._secrets.OTEL_AUTHORIZATION,
@@ -256,16 +617,16 @@ var Observability = class {
256
617
  value.value
257
618
  ]))
258
619
  });
259
- log("otel metrics enabled", void 0, {
260
- F: __dxlog_file,
261
- L: 268,
620
+ log3("otel metrics enabled", void 0, {
621
+ F: __dxlog_file3,
622
+ L: 299,
262
623
  S: this,
263
624
  C: (f, a) => f(...a)
264
625
  });
265
626
  } else {
266
- log("otel metrics disabled", void 0, {
267
- F: __dxlog_file,
268
- L: 270,
627
+ log3("otel metrics disabled", void 0, {
628
+ F: __dxlog_file3,
629
+ L: 301,
269
630
  S: this,
270
631
  C: (f, a) => f(...a)
271
632
  });
@@ -286,13 +647,13 @@ var Observability = class {
286
647
  }
287
648
  const updateSignalMetrics = new Event().debounce(NETWORK_METRICS_MIN_INTERVAL);
288
649
  updateSignalMetrics.on(this._ctx, async () => {
289
- log("send signal metrics", void 0, {
290
- F: __dxlog_file,
291
- L: 292,
650
+ log3("send signal metrics", void 0, {
651
+ F: __dxlog_file3,
652
+ L: 323,
292
653
  S: this,
293
654
  C: (f, a) => f(...a)
294
655
  });
295
- (this._lastNetworkStatus?.signaling).forEach(({ server, state }) => {
656
+ this._lastNetworkStatus?.signaling?.forEach(({ server, state }) => {
296
657
  this.gauge("dxos.client.network.signal.connectionState", state, {
297
658
  server
298
659
  });
@@ -338,9 +699,9 @@ var Observability = class {
338
699
  this._ctx.onDispose(() => subscriptions.forEach((subscription) => subscription.unsubscribe()));
339
700
  const updateSpaceMetrics = new Event().debounce(SPACE_METRICS_MIN_INTERVAL);
340
701
  updateSpaceMetrics.on(this._ctx, async () => {
341
- log("send space metrics", void 0, {
342
- F: __dxlog_file,
343
- L: 346,
702
+ log3("send space metrics", void 0, {
703
+ F: __dxlog_file3,
704
+ L: 377,
344
705
  S: this,
345
706
  C: (f, a) => f(...a)
346
707
  });
@@ -363,9 +724,9 @@ var Observability = class {
363
724
  });
364
725
  const updateSpaceTelemetry = new Event().debounce(SPACE_TELEMETRY_MIN_INTERVAL);
365
726
  updateSpaceTelemetry.on(this._ctx, async () => {
366
- log("send space telemetry", void 0, {
367
- F: __dxlog_file,
368
- L: 357,
727
+ log3("send space telemetry", void 0, {
728
+ F: __dxlog_file3,
729
+ L: 388,
369
730
  S: this,
370
731
  C: (f, a) => f(...a)
371
732
  });
@@ -400,8 +761,8 @@ var Observability = class {
400
761
  async startRuntimeMetrics(client, frequency = NETWORK_METRICS_MIN_INTERVAL) {
401
762
  const platform = await client.services.services.SystemService?.getPlatform();
402
763
  invariant(platform, "platform is required", {
403
- F: __dxlog_file,
404
- L: 394,
764
+ F: __dxlog_file3,
765
+ L: 425,
405
766
  S: this,
406
767
  A: [
407
768
  "platform",
@@ -435,11 +796,11 @@ var Observability = class {
435
796
  this.gauge("dxos.client.services.runtime.heapTotal", platform2.memory.heapTotal);
436
797
  this.gauge("dxos.client.services.runtime.heapUsed", platform2.memory.heapUsed);
437
798
  }
438
- }).catch((error) => log("platform error", {
799
+ }).catch((error) => log3("platform error", {
439
800
  error
440
801
  }, {
441
- F: __dxlog_file,
442
- L: 429,
802
+ F: __dxlog_file3,
803
+ L: 460,
443
804
  S: this,
444
805
  C: (f, a) => f(...a)
445
806
  }));
@@ -462,9 +823,9 @@ var Observability = class {
462
823
  ]))
463
824
  });
464
825
  } else {
465
- log("segment disabled", void 0, {
466
- F: __dxlog_file,
467
- L: 455,
826
+ log3("segment disabled", void 0, {
827
+ F: __dxlog_file3,
828
+ L: 486,
468
829
  S: this,
469
830
  C: (f, a) => f(...a)
470
831
  });
@@ -496,12 +857,12 @@ var Observability = class {
496
857
  this._captureException = captureException;
497
858
  this._captureUserFeedback = captureUserFeedback;
498
859
  this._setTag = setTag;
499
- log.info("Initializing Sentry", {
860
+ log3.info("Initializing Sentry", {
500
861
  dest: this._secrets.SENTRY_DESTINATION,
501
862
  options: this._errorReportingOptions
502
863
  }, {
503
- F: __dxlog_file,
504
- L: 491,
864
+ F: __dxlog_file3,
865
+ L: 522,
505
866
  S: this,
506
867
  C: (f, a) => f(...a)
507
868
  });
@@ -518,47 +879,16 @@ var Observability = class {
518
879
  }
519
880
  });
520
881
  } else {
521
- log("sentry disabled", void 0, {
522
- F: __dxlog_file,
523
- L: 511,
524
- S: this,
525
- C: (f, a) => f(...a)
526
- });
527
- }
528
- if (this._secrets.OTEL_ENDPOINT && this._secrets.OTEL_AUTHORIZATION && this._mode !== "disabled") {
529
- const { OtelLogs } = await import("./otel-YI7HAFOG.mjs");
530
- this._otelLogs = new OtelLogs({
531
- endpoint: this._secrets.OTEL_ENDPOINT,
532
- authorizationHeader: this._secrets.OTEL_AUTHORIZATION,
533
- serviceName: this._namespace,
534
- serviceVersion: this.getTag("release")?.value ?? "0.0.0",
535
- getTags: () => Object.fromEntries(Array.from(this._tags).filter(([key, value]) => {
536
- return value.scope === "all" || value.scope === "errors";
537
- }).map(([key, value]) => [
538
- key,
539
- value.value
540
- ]))
541
- });
542
- log("otel logs enabled", {
543
- namespace: this._namespace
544
- }, {
545
- F: __dxlog_file,
546
- L: 530,
547
- S: this,
548
- C: (f, a) => f(...a)
549
- });
550
- } else {
551
- log("otel logs disabled", void 0, {
552
- F: __dxlog_file,
553
- L: 532,
882
+ log3("sentry disabled", void 0, {
883
+ F: __dxlog_file3,
884
+ L: 542,
554
885
  S: this,
555
886
  C: (f, a) => f(...a)
556
887
  });
557
888
  }
558
889
  }
559
890
  startErrorLogs() {
560
- this._sentryLogProcessor && log.runtimeConfig.processors.push(this._sentryLogProcessor.logProcessor);
561
- this._otelLogs && log.runtimeConfig.processors.push(this._otelLogs.logProcessor);
891
+ this._sentryLogProcessor && log3.runtimeConfig.processors.push(this._sentryLogProcessor.logProcessor);
562
892
  }
563
893
  startTraces() {
564
894
  this._otelTraces && this._otelTraces.start();
@@ -566,7 +896,7 @@ var Observability = class {
566
896
  // TODO(nf): refactor init based on providers and their capabilities
567
897
  async _initTraces() {
568
898
  if (this._secrets.OTEL_ENDPOINT && this._secrets.OTEL_AUTHORIZATION && this._mode !== "disabled") {
569
- const { OtelTraces } = await import("./otel-YI7HAFOG.mjs");
899
+ const { OtelTraces } = await import("./otel-CYD4GJC2.mjs");
570
900
  this._otelTraces = new OtelTraces({
571
901
  endpoint: this._secrets.OTEL_ENDPOINT,
572
902
  authorizationHeader: this._secrets.OTEL_AUTHORIZATION,
@@ -603,7 +933,18 @@ var Observability = class {
603
933
 
604
934
  export {
605
935
  Observability,
936
+ OBSERVABILITY_DISABLED_KEY,
937
+ OBSERVABILITY_GROUP_KEY,
938
+ isObservabilityDisabled,
939
+ storeObservabilityDisabled,
940
+ getObservabilityGroup,
941
+ storeObservabilityGroup,
942
+ initializeAppObservability,
606
943
  getTelemetryIdentifier,
607
- mapSpaces
944
+ showObservabilityBanner,
945
+ getObservabilityState,
946
+ initializeNodeObservability,
947
+ mapSpaces,
948
+ setupTelemetryListeners
608
949
  };
609
- //# sourceMappingURL=chunk-D7JZEGRD.mjs.map
950
+ //# sourceMappingURL=chunk-UA3GVRAT.mjs.map