@dxos/observability 0.6.2 → 0.6.3-main.038c693
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-HKNRDUTP.mjs → chunk-2CXA7PYK.mjs} +187 -221
- package/dist/lib/browser/chunk-2CXA7PYK.mjs.map +7 -0
- package/dist/lib/browser/index.mjs +1 -2
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/browser/observability-MXAPN7J6.mjs +7 -0
- package/dist/lib/browser/otel-BUKBDMAL.mjs +275 -0
- package/dist/lib/browser/otel-BUKBDMAL.mjs.map +7 -0
- package/dist/lib/browser/sentry-log-processor-DVUUOZ6G.mjs +132 -0
- package/dist/lib/browser/sentry-log-processor-DVUUOZ6G.mjs.map +7 -0
- package/dist/lib/node/{chunk-6QQAPUDU.cjs → chunk-HBLKTDQE.cjs} +190 -217
- package/dist/lib/node/chunk-HBLKTDQE.cjs.map +7 -0
- package/dist/lib/node/index.cjs +15 -16
- package/dist/lib/node/index.cjs.map +2 -2
- package/dist/lib/node/meta.json +1 -1
- package/dist/lib/node/{observability-7TFOBOTA.cjs → observability-4R6M4JMU.cjs} +6 -7
- package/dist/lib/node/observability-4R6M4JMU.cjs.map +7 -0
- package/dist/lib/node/otel-TSHMOAB4.cjs +276 -0
- package/dist/lib/node/otel-TSHMOAB4.cjs.map +7 -0
- package/dist/lib/node/sentry-log-processor-H6FUSKZI.cjs +150 -0
- package/dist/lib/node/sentry-log-processor-H6FUSKZI.cjs.map +7 -0
- package/dist/types/src/cli-observability-secrets.json +3 -1
- package/dist/types/src/helpers/browser-observability.d.ts.map +1 -1
- package/dist/types/src/helpers/browser-observability.js +1 -0
- package/dist/types/src/helpers/browser-observability.js.map +1 -1
- package/dist/types/src/observability.d.ts +12 -2
- package/dist/types/src/observability.d.ts.map +1 -1
- package/dist/types/src/observability.js +125 -42
- package/dist/types/src/observability.js.map +1 -1
- package/dist/types/src/otel/index.d.ts +5 -0
- package/dist/types/src/otel/index.d.ts.map +1 -0
- package/dist/types/src/otel/index.js +24 -0
- package/dist/types/src/otel/index.js.map +1 -0
- package/dist/types/src/otel/logs.d.ts +11 -0
- package/dist/types/src/otel/logs.d.ts.map +1 -0
- package/dist/types/src/otel/logs.js +72 -0
- package/dist/types/src/otel/logs.js.map +1 -0
- package/dist/types/src/otel/metrics.d.ts +14 -0
- package/dist/types/src/otel/metrics.d.ts.map +1 -0
- package/dist/types/src/otel/metrics.js +91 -0
- package/dist/types/src/otel/metrics.js.map +1 -0
- package/dist/types/src/otel/otel.d.ts +12 -0
- package/dist/types/src/otel/otel.d.ts.map +1 -0
- package/dist/types/src/otel/otel.js +15 -0
- package/dist/types/src/otel/otel.js.map +1 -0
- package/dist/types/src/otel/traces-browser.d.ts +8 -0
- package/dist/types/src/otel/traces-browser.d.ts.map +1 -0
- package/dist/types/src/otel/traces-browser.js +51 -0
- package/dist/types/src/otel/traces-browser.js.map +1 -0
- package/dist/types/src/otel/traces.d.ts +8 -0
- package/dist/types/src/otel/traces.d.ts.map +1 -0
- package/dist/types/src/otel/traces.js +44 -0
- package/dist/types/src/otel/traces.js.map +1 -0
- package/package.json +35 -20
- package/src/cli-observability-secrets.json +3 -1
- package/src/helpers/browser-observability.ts +1 -0
- package/src/observability.ts +141 -42
- package/src/otel/index.ts +8 -0
- package/src/otel/logs.ts +86 -0
- package/src/otel/metrics.ts +111 -0
- package/src/otel/otel.ts +21 -0
- package/src/otel/traces-browser.ts +59 -0
- package/src/otel/traces.ts +57 -0
- package/dist/lib/browser/chunk-HKNRDUTP.mjs.map +0 -7
- package/dist/lib/browser/observability-6FYBCIL6.mjs +0 -8
- package/dist/lib/node/chunk-6QQAPUDU.cjs.map +0 -7
- package/dist/lib/node/observability-7TFOBOTA.cjs.map +0 -7
- /package/dist/lib/browser/{observability-6FYBCIL6.mjs.map → observability-MXAPN7J6.mjs.map} +0 -0
|
@@ -1,9 +1,3 @@
|
|
|
1
|
-
import {
|
|
2
|
-
captureException,
|
|
3
|
-
captureMessage,
|
|
4
|
-
withScope
|
|
5
|
-
} from "./chunk-3LKCQYWD.mjs";
|
|
6
|
-
|
|
7
1
|
// packages/sdk/observability/src/observability.ts
|
|
8
2
|
import { Event, scheduleTaskInterval } from "@dxos/async";
|
|
9
3
|
import { Context } from "@dxos/context";
|
|
@@ -19,7 +13,9 @@ var cli_observability_secrets_default = {
|
|
|
19
13
|
TELEMETRY_API_KEY: "B00QG6PtJJrJ0VVFe0H5a6bcUUShKyZM",
|
|
20
14
|
IPDATA_API_KEY: "73dfdecdf979c18f07d50cf841bbdd9e589f237256326ac8cca23786",
|
|
21
15
|
DATADOG_API_KEY: null,
|
|
22
|
-
DATADOG_APP_KEY: null
|
|
16
|
+
DATADOG_APP_KEY: null,
|
|
17
|
+
OTEL_ENDPOINT: null,
|
|
18
|
+
OTEL_AUTHORIZATION: null
|
|
23
19
|
};
|
|
24
20
|
|
|
25
21
|
// packages/sdk/observability/src/helpers/browser-observability.ts
|
|
@@ -90,7 +86,7 @@ var initializeAppObservability = async ({ namespace, config, mode = "basic", tra
|
|
|
90
86
|
const release = `${namespace}@${config.get("runtime.app.build.version")}`;
|
|
91
87
|
const environment = config.get("runtime.app.env.DX_ENVIRONMENT");
|
|
92
88
|
const observabilityDisabled = await isObservabilityDisabled(namespace);
|
|
93
|
-
const { Observability: Observability2 } = await import("./observability-
|
|
89
|
+
const { Observability: Observability2 } = await import("./observability-MXAPN7J6.mjs");
|
|
94
90
|
const observability = new Observability2({
|
|
95
91
|
namespace,
|
|
96
92
|
release,
|
|
@@ -140,6 +136,7 @@ var initializeAppObservability = async ({ namespace, config, mode = "basic", tra
|
|
|
140
136
|
}
|
|
141
137
|
};
|
|
142
138
|
await observability.initialize();
|
|
139
|
+
observability.startErrorLogs();
|
|
143
140
|
const ipData = await getIPData(config);
|
|
144
141
|
ipData && observability.addIPDataTelemetryTags(ipData);
|
|
145
142
|
if (typeof navigator !== "undefined" && navigator.storage?.estimate) {
|
|
@@ -151,7 +148,7 @@ var initializeAppObservability = async ({ namespace, config, mode = "basic", tra
|
|
|
151
148
|
} catch (error) {
|
|
152
149
|
log.warn("Failed to run estimate()", error, {
|
|
153
150
|
F: __dxlog_file,
|
|
154
|
-
L:
|
|
151
|
+
L: 171,
|
|
155
152
|
S: void 0,
|
|
156
153
|
C: (f, a) => f(...a)
|
|
157
154
|
});
|
|
@@ -161,7 +158,7 @@ var initializeAppObservability = async ({ namespace, config, mode = "basic", tra
|
|
|
161
158
|
} catch (err) {
|
|
162
159
|
log.error("Failed to initialize app observability", err, {
|
|
163
160
|
F: __dxlog_file,
|
|
164
|
-
L:
|
|
161
|
+
L: 176,
|
|
165
162
|
S: void 0,
|
|
166
163
|
C: (f, a) => f(...a)
|
|
167
164
|
});
|
|
@@ -385,129 +382,6 @@ var setupTelemetryListeners = (namespace, client, observability) => {
|
|
|
385
382
|
};
|
|
386
383
|
};
|
|
387
384
|
|
|
388
|
-
// packages/sdk/observability/src/sentry/sentry-log-processor.ts
|
|
389
|
-
import { InvariantViolation } from "@dxos/invariant";
|
|
390
|
-
import { LogLevel, shouldLog } from "@dxos/log";
|
|
391
|
-
import { CircularBuffer, getDebugName } from "@dxos/util";
|
|
392
|
-
var MAX_LOG_BREADCRUMBS = 80;
|
|
393
|
-
var SentryLogProcessor = class {
|
|
394
|
-
constructor() {
|
|
395
|
-
this._breadcrumbs = new CircularBuffer(MAX_LOG_BREADCRUMBS);
|
|
396
|
-
this.logProcessor = (config, entry) => {
|
|
397
|
-
const { level, meta, error } = entry;
|
|
398
|
-
if (!shouldLog(entry, config.captureFilters) || meta?.S?.remoteSessionId) {
|
|
399
|
-
return;
|
|
400
|
-
}
|
|
401
|
-
if (entry.level !== LogLevel.WARN && entry.level !== LogLevel.ERROR) {
|
|
402
|
-
return;
|
|
403
|
-
}
|
|
404
|
-
withScope((scope) => {
|
|
405
|
-
const severity = convertLevel(level);
|
|
406
|
-
scope.setLevel(severity);
|
|
407
|
-
scope.setContext("dxoslog", entry.context ?? null);
|
|
408
|
-
if (meta) {
|
|
409
|
-
scope.setTag("transaction", `${getRelativeFilename(meta.F)}:${meta.L}`);
|
|
410
|
-
if (meta.S?.hostSessionId) {
|
|
411
|
-
scope.setTags({
|
|
412
|
-
service_host_issue: true,
|
|
413
|
-
service_host_session: meta.S?.hostSessionId
|
|
414
|
-
});
|
|
415
|
-
}
|
|
416
|
-
if (!Number.isNaN(meta.S?.uptimeSeconds)) {
|
|
417
|
-
scope.setExtra("uptime_seconds", meta.S?.uptimeSeconds);
|
|
418
|
-
}
|
|
419
|
-
}
|
|
420
|
-
const extendedMessage = formatMessageForSentry(entry);
|
|
421
|
-
let capturedError = error;
|
|
422
|
-
if (capturedError == null && entry.level === LogLevel.ERROR) {
|
|
423
|
-
capturedError = Object.values(entry.context ?? {}).find((v) => v instanceof Error);
|
|
424
|
-
}
|
|
425
|
-
if (capturedError) {
|
|
426
|
-
if (capturedError instanceof InvariantViolation) {
|
|
427
|
-
scope.setExtra("invariant_violation", true);
|
|
428
|
-
}
|
|
429
|
-
const isMessageDifferentFromStackTrace = error == null;
|
|
430
|
-
if (isMessageDifferentFromStackTrace) {
|
|
431
|
-
scope.setExtra("message", extendedMessage);
|
|
432
|
-
}
|
|
433
|
-
const eventId2 = captureException(capturedError);
|
|
434
|
-
this._addBreadcrumb(eventId2, extendedMessage, severity, entry.context);
|
|
435
|
-
return;
|
|
436
|
-
}
|
|
437
|
-
scope.setFingerprint([
|
|
438
|
-
entry.message
|
|
439
|
-
]);
|
|
440
|
-
const eventId = captureMessage(extendedMessage);
|
|
441
|
-
this._addBreadcrumb(eventId, extendedMessage, severity, entry.context);
|
|
442
|
-
});
|
|
443
|
-
};
|
|
444
|
-
}
|
|
445
|
-
addLogBreadcrumbsTo(event) {
|
|
446
|
-
event.breadcrumbs ??= [];
|
|
447
|
-
for (const breadcrumb of this._breadcrumbs) {
|
|
448
|
-
event.breadcrumbs.push(breadcrumb);
|
|
449
|
-
}
|
|
450
|
-
event.breadcrumbs.sort((b1, b2) => {
|
|
451
|
-
if (b1.timestamp === void 0 || b2.timestamp === void 0) {
|
|
452
|
-
return b1.timestamp === b2.timestamp ? 0 : b1.timestamp === void 0 ? -1 : 1;
|
|
453
|
-
}
|
|
454
|
-
return b1.timestamp - b2.timestamp;
|
|
455
|
-
});
|
|
456
|
-
}
|
|
457
|
-
_addBreadcrumb(eventId, message, severity, context) {
|
|
458
|
-
const breadcrumb = {
|
|
459
|
-
type: "console",
|
|
460
|
-
level: severity,
|
|
461
|
-
event_id: eventId,
|
|
462
|
-
category: "log",
|
|
463
|
-
message,
|
|
464
|
-
data: context,
|
|
465
|
-
timestamp: Math.floor(Date.now() / 1e3)
|
|
466
|
-
};
|
|
467
|
-
const lastRecorded = this._breadcrumbs.getLast();
|
|
468
|
-
if (lastRecorded && lastRecorded.message === breadcrumb.message) {
|
|
469
|
-
const firstBreadcrumbData = lastRecorded.data?.firstBreadcrumbData ?? lastRecorded.data ?? {};
|
|
470
|
-
const mergedBreadcrumbCount = Number.isNaN(lastRecorded.data?.mergedBreadcrumbCount) ? 1 : Number(lastRecorded.data?.mergedBreadcrumbCount);
|
|
471
|
-
lastRecorded.data = {
|
|
472
|
-
mergedBreadcrumbCount: mergedBreadcrumbCount + 1,
|
|
473
|
-
firstBreadcrumbData,
|
|
474
|
-
lastBreadcrumbData: breadcrumb.data
|
|
475
|
-
};
|
|
476
|
-
return;
|
|
477
|
-
}
|
|
478
|
-
this._breadcrumbs.push(breadcrumb);
|
|
479
|
-
}
|
|
480
|
-
};
|
|
481
|
-
var formatMessageForSentry = (entry) => {
|
|
482
|
-
let scopePrefix;
|
|
483
|
-
if (entry.meta?.S) {
|
|
484
|
-
const scope = entry.meta?.S;
|
|
485
|
-
scopePrefix = scope.name || getDebugName(scope);
|
|
486
|
-
}
|
|
487
|
-
if (scopePrefix == null) {
|
|
488
|
-
return entry.message;
|
|
489
|
-
}
|
|
490
|
-
const workerPrefix = entry.meta?.S?.hostSessionId ? "[worker] " : "";
|
|
491
|
-
return `${workerPrefix}${scopePrefix} ${entry.message}`;
|
|
492
|
-
};
|
|
493
|
-
var convertLevel = (level) => {
|
|
494
|
-
if (level === LogLevel.TRACE) {
|
|
495
|
-
return "debug";
|
|
496
|
-
}
|
|
497
|
-
if (level === LogLevel.WARN) {
|
|
498
|
-
return "warning";
|
|
499
|
-
}
|
|
500
|
-
return LogLevel[level].toLowerCase();
|
|
501
|
-
};
|
|
502
|
-
var getRelativeFilename = (filename) => {
|
|
503
|
-
const match = filename.match(/.+\/(packages\/.+\/.+)/);
|
|
504
|
-
if (match) {
|
|
505
|
-
const [, filePath] = match;
|
|
506
|
-
return filePath;
|
|
507
|
-
}
|
|
508
|
-
return filename;
|
|
509
|
-
};
|
|
510
|
-
|
|
511
385
|
// packages/sdk/observability/src/observability.ts
|
|
512
386
|
var __dxlog_file3 = "/home/runner/work/dxos/dxos/packages/sdk/observability/src/observability.ts";
|
|
513
387
|
var SPACE_METRICS_MIN_INTERVAL = 1e3 * 60;
|
|
@@ -519,7 +393,7 @@ var Observability = class {
|
|
|
519
393
|
// TODO(nf): accept upstream context?
|
|
520
394
|
this._ctx = new Context(void 0, {
|
|
521
395
|
F: __dxlog_file3,
|
|
522
|
-
L:
|
|
396
|
+
L: 91
|
|
523
397
|
});
|
|
524
398
|
this._tags = /* @__PURE__ */ new Map();
|
|
525
399
|
this.addIPDataTelemetryTags = (ipData) => {
|
|
@@ -566,6 +440,8 @@ var Observability = class {
|
|
|
566
440
|
process.env.IPDATA_API_KEY && (mergedSecrets.IPDATA_API_KEY = process.env.IPDATA_API_KEY);
|
|
567
441
|
process.env.DATADOG_API_KEY && (mergedSecrets.DATADOG_API_KEY = process.env.DATADOG_API_KEY);
|
|
568
442
|
process.env.DATADOG_APP_KEY && (mergedSecrets.DATADOG_APP_KEY = process.env.DATADOG_APP_KEY);
|
|
443
|
+
process.env.DX_OTEL_ENDPOINT && (mergedSecrets.OTEL_ENDPOINT = process.env.DX_OTEL_ENDPOINT);
|
|
444
|
+
process.env.DX_OTEL_AUTHORIZATION && (mergedSecrets.OTEL_AUTHORIZATION = process.env.DX_OTEL_AUTHORIZATION);
|
|
569
445
|
return mergedSecrets;
|
|
570
446
|
} else {
|
|
571
447
|
log3("config", {
|
|
@@ -573,7 +449,7 @@ var Observability = class {
|
|
|
573
449
|
config
|
|
574
450
|
}, {
|
|
575
451
|
F: __dxlog_file3,
|
|
576
|
-
L:
|
|
452
|
+
L: 156,
|
|
577
453
|
S: this,
|
|
578
454
|
C: (f, a) => f(...a)
|
|
579
455
|
});
|
|
@@ -585,6 +461,8 @@ var Observability = class {
|
|
|
585
461
|
IPDATA_API_KEY: config?.get("runtime.app.env.DX_IPDATA_API_KEY"),
|
|
586
462
|
DATADOG_API_KEY: config?.get("runtime.app.env.DX_DATADOG_API_KEY"),
|
|
587
463
|
DATADOG_APP_KEY: config?.get("runtime.app.env.DX_DATADOG_APP_KEY"),
|
|
464
|
+
OTEL_ENDPOINT: config?.get("runtime.app.env.DX_OTEL_ENDPOINT"),
|
|
465
|
+
OTEL_AUTHORIZATION: config?.get("runtime.app.env.DX_OTEL_AUTHORIZATION"),
|
|
588
466
|
...secrets
|
|
589
467
|
};
|
|
590
468
|
}
|
|
@@ -593,11 +471,14 @@ var Observability = class {
|
|
|
593
471
|
await this._initMetrics();
|
|
594
472
|
await this._initTelemetry();
|
|
595
473
|
await this._initErrorLogs();
|
|
474
|
+
await this._initTraces();
|
|
596
475
|
}
|
|
597
476
|
async close() {
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
477
|
+
const closes = [];
|
|
478
|
+
this._telemetry && closes.push(this._telemetry.close());
|
|
479
|
+
this._otelMetrics && closes.push(this._otelMetrics.close());
|
|
480
|
+
this._otelLogs && closes.push(this._otelLogs.close());
|
|
481
|
+
await Promise.all(closes);
|
|
601
482
|
await this._ctx.dispose();
|
|
602
483
|
}
|
|
603
484
|
setMode(mode) {
|
|
@@ -622,59 +503,63 @@ var Observability = class {
|
|
|
622
503
|
return this._tags.get(key);
|
|
623
504
|
}
|
|
624
505
|
// TODO(wittjosiah): Improve privacy of telemetry identifiers. See `getTelemetryIdentifier`.
|
|
625
|
-
async setIdentityTags(
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
client.services.services.DevicesService.queryDevices().subscribe((dqr) => {
|
|
641
|
-
if (!dqr || !dqr.devices || dqr.devices.length === 0) {
|
|
642
|
-
log3("empty response from device service", {
|
|
643
|
-
device: dqr
|
|
644
|
-
}, {
|
|
645
|
-
F: __dxlog_file3,
|
|
646
|
-
L: 218,
|
|
647
|
-
S: this,
|
|
648
|
-
C: (f, a) => f(...a)
|
|
649
|
-
});
|
|
650
|
-
return;
|
|
651
|
-
}
|
|
652
|
-
invariant(dqr, "empty response from device service", {
|
|
653
|
-
F: __dxlog_file3,
|
|
654
|
-
L: 221,
|
|
655
|
-
S: this,
|
|
656
|
-
A: [
|
|
657
|
-
"dqr",
|
|
658
|
-
"'empty response from device service'"
|
|
659
|
-
]
|
|
506
|
+
async setIdentityTags(clientServices) {
|
|
507
|
+
if (clientServices.IdentityService) {
|
|
508
|
+
clientServices.IdentityService.queryIdentity().subscribe((idqr) => {
|
|
509
|
+
if (!idqr?.identity?.identityKey) {
|
|
510
|
+
log3("empty response from identity service", {
|
|
511
|
+
idqr
|
|
512
|
+
}, {
|
|
513
|
+
F: __dxlog_file3,
|
|
514
|
+
L: 226,
|
|
515
|
+
S: this,
|
|
516
|
+
C: (f, a) => f(...a)
|
|
517
|
+
});
|
|
518
|
+
return;
|
|
519
|
+
}
|
|
520
|
+
this.setTag("identityKey", idqr.identity.identityKey.truncate());
|
|
660
521
|
});
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
522
|
+
}
|
|
523
|
+
if (clientServices.DevicesService) {
|
|
524
|
+
clientServices.DevicesService.queryDevices().subscribe((dqr) => {
|
|
525
|
+
if (!dqr || !dqr.devices || dqr.devices.length === 0) {
|
|
526
|
+
log3("empty response from device service", {
|
|
527
|
+
device: dqr
|
|
528
|
+
}, {
|
|
529
|
+
F: __dxlog_file3,
|
|
530
|
+
L: 236,
|
|
531
|
+
S: this,
|
|
532
|
+
C: (f, a) => f(...a)
|
|
533
|
+
});
|
|
534
|
+
return;
|
|
535
|
+
}
|
|
536
|
+
invariant(dqr, "empty response from device service", {
|
|
666
537
|
F: __dxlog_file3,
|
|
667
|
-
L:
|
|
538
|
+
L: 239,
|
|
668
539
|
S: this,
|
|
669
|
-
|
|
540
|
+
A: [
|
|
541
|
+
"dqr",
|
|
542
|
+
"'empty response from device service'"
|
|
543
|
+
]
|
|
670
544
|
});
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
|
|
545
|
+
const thisDevice = dqr.devices.find((device) => device.kind === DeviceKind.CURRENT);
|
|
546
|
+
if (!thisDevice) {
|
|
547
|
+
log3("no current device", {
|
|
548
|
+
device: dqr
|
|
549
|
+
}, {
|
|
550
|
+
F: __dxlog_file3,
|
|
551
|
+
L: 243,
|
|
552
|
+
S: this,
|
|
553
|
+
C: (f, a) => f(...a)
|
|
554
|
+
});
|
|
555
|
+
return;
|
|
556
|
+
}
|
|
557
|
+
this.setTag("deviceKey", thisDevice.deviceKey.truncate());
|
|
558
|
+
if (thisDevice.profile?.label) {
|
|
559
|
+
this.setTag("deviceProfile", thisDevice.profile.label);
|
|
560
|
+
}
|
|
561
|
+
});
|
|
562
|
+
}
|
|
678
563
|
}
|
|
679
564
|
//
|
|
680
565
|
// Metrics
|
|
@@ -696,7 +581,35 @@ var Observability = class {
|
|
|
696
581
|
} else {
|
|
697
582
|
log3("datadog disabled", void 0, {
|
|
698
583
|
F: __dxlog_file3,
|
|
699
|
-
L:
|
|
584
|
+
L: 275,
|
|
585
|
+
S: this,
|
|
586
|
+
C: (f, a) => f(...a)
|
|
587
|
+
});
|
|
588
|
+
}
|
|
589
|
+
if (this.enabled && this._secrets.OTEL_ENDPOINT && this._secrets.OTEL_AUTHORIZATION) {
|
|
590
|
+
const { OtelMetrics } = await import("./otel-BUKBDMAL.mjs");
|
|
591
|
+
this._otelMetrics = new OtelMetrics({
|
|
592
|
+
endpoint: this._secrets.OTEL_ENDPOINT,
|
|
593
|
+
authorizationHeader: this._secrets.OTEL_AUTHORIZATION,
|
|
594
|
+
serviceName: this._namespace,
|
|
595
|
+
serviceVersion: this.getTag("release")?.value ?? "0.0.0",
|
|
596
|
+
getTags: () => Object.fromEntries(Array.from(this._tags).filter(([key, value]) => {
|
|
597
|
+
return value.scope === "all" || value.scope === "metrics";
|
|
598
|
+
}).map(([key, value]) => [
|
|
599
|
+
key,
|
|
600
|
+
value.value
|
|
601
|
+
]))
|
|
602
|
+
});
|
|
603
|
+
log3("otel metrics enabled", void 0, {
|
|
604
|
+
F: __dxlog_file3,
|
|
605
|
+
L: 294,
|
|
606
|
+
S: this,
|
|
607
|
+
C: (f, a) => f(...a)
|
|
608
|
+
});
|
|
609
|
+
} else {
|
|
610
|
+
log3("otel metrics disabled", void 0, {
|
|
611
|
+
F: __dxlog_file3,
|
|
612
|
+
L: 296,
|
|
700
613
|
S: this,
|
|
701
614
|
C: (f, a) => f(...a)
|
|
702
615
|
});
|
|
@@ -709,14 +622,18 @@ var Observability = class {
|
|
|
709
622
|
*/
|
|
710
623
|
gauge(name, value, extraTags) {
|
|
711
624
|
this._metrics?.gauge(name, value, extraTags);
|
|
625
|
+
this._otelMetrics?.gauge(name, value, extraTags);
|
|
712
626
|
}
|
|
713
627
|
// TODO(nf): Refactor into ObservabilityExtensions.
|
|
714
|
-
startNetworkMetrics(
|
|
628
|
+
startNetworkMetrics(clientServices) {
|
|
629
|
+
if (!clientServices.NetworkService) {
|
|
630
|
+
return;
|
|
631
|
+
}
|
|
715
632
|
const updateSignalMetrics = new Event().debounce(NETWORK_METRICS_MIN_INTERVAL);
|
|
716
633
|
updateSignalMetrics.on(this._ctx, async () => {
|
|
717
634
|
log3("send signal metrics", void 0, {
|
|
718
635
|
F: __dxlog_file3,
|
|
719
|
-
L:
|
|
636
|
+
L: 319,
|
|
720
637
|
S: this,
|
|
721
638
|
C: (f, a) => f(...a)
|
|
722
639
|
});
|
|
@@ -754,7 +671,7 @@ var Observability = class {
|
|
|
754
671
|
this.gauge("dxos.client.network.totalChannelBufferSize", totalChannelBufferSize);
|
|
755
672
|
});
|
|
756
673
|
});
|
|
757
|
-
|
|
674
|
+
clientServices.NetworkService.queryStatus().subscribe((networkStatus) => {
|
|
758
675
|
this._lastNetworkStatus = networkStatus;
|
|
759
676
|
updateSignalMetrics.emit();
|
|
760
677
|
});
|
|
@@ -768,7 +685,7 @@ var Observability = class {
|
|
|
768
685
|
updateSpaceMetrics.on(this._ctx, async () => {
|
|
769
686
|
log3("send space metrics", void 0, {
|
|
770
687
|
F: __dxlog_file3,
|
|
771
|
-
L:
|
|
688
|
+
L: 373,
|
|
772
689
|
S: this,
|
|
773
690
|
C: (f, a) => f(...a)
|
|
774
691
|
});
|
|
@@ -793,7 +710,7 @@ var Observability = class {
|
|
|
793
710
|
updateSpaceTelemetry.on(this._ctx, async () => {
|
|
794
711
|
log3("send space telemetry", void 0, {
|
|
795
712
|
F: __dxlog_file3,
|
|
796
|
-
L:
|
|
713
|
+
L: 384,
|
|
797
714
|
S: this,
|
|
798
715
|
C: (f, a) => f(...a)
|
|
799
716
|
});
|
|
@@ -829,7 +746,7 @@ var Observability = class {
|
|
|
829
746
|
const platform = await client.services.services.SystemService?.getPlatform();
|
|
830
747
|
invariant(platform, "platform is required", {
|
|
831
748
|
F: __dxlog_file3,
|
|
832
|
-
L:
|
|
749
|
+
L: 421,
|
|
833
750
|
S: this,
|
|
834
751
|
A: [
|
|
835
752
|
"platform",
|
|
@@ -849,31 +766,25 @@ var Observability = class {
|
|
|
849
766
|
}
|
|
850
767
|
}
|
|
851
768
|
scheduleTaskInterval(this._ctx, async () => {
|
|
852
|
-
|
|
853
|
-
|
|
854
|
-
|
|
855
|
-
|
|
856
|
-
|
|
857
|
-
|
|
769
|
+
if (client.services.constructor.name === "WorkerClientServices") {
|
|
770
|
+
const memory = window.performance.memory;
|
|
771
|
+
if (memory) {
|
|
772
|
+
this.gauge("dxos.client.runtime.heapTotal", memory.totalJSHeapSize);
|
|
773
|
+
this.gauge("dxos.client.runtime.heapUsed", memory.usedJSHeapSize);
|
|
774
|
+
this.gauge("dxos.client.runtime.heapSizeLimit", memory.jsHeapSizeLimit);
|
|
775
|
+
}
|
|
776
|
+
}
|
|
858
777
|
client.services.services.SystemService?.getPlatform().then((platform2) => {
|
|
859
|
-
log3("platform", {
|
|
860
|
-
platform: platform2
|
|
861
|
-
}, {
|
|
862
|
-
F: __dxlog_file3,
|
|
863
|
-
L: 399,
|
|
864
|
-
S: this,
|
|
865
|
-
C: (f, a) => f(...a)
|
|
866
|
-
});
|
|
867
778
|
if (platform2.memory) {
|
|
868
|
-
this.gauge("dxos.client.runtime.rss", platform2.memory.rss);
|
|
869
|
-
this.gauge("dxos.client.runtime.heapTotal", platform2.memory.heapTotal);
|
|
870
|
-
this.gauge("dxos.client.runtime.heapUsed", platform2.memory.heapUsed);
|
|
779
|
+
this.gauge("dxos.client.services.runtime.rss", platform2.memory.rss);
|
|
780
|
+
this.gauge("dxos.client.services.runtime.heapTotal", platform2.memory.heapTotal);
|
|
781
|
+
this.gauge("dxos.client.services.runtime.heapUsed", platform2.memory.heapUsed);
|
|
871
782
|
}
|
|
872
783
|
}).catch((error) => log3("platform error", {
|
|
873
784
|
error
|
|
874
785
|
}, {
|
|
875
786
|
F: __dxlog_file3,
|
|
876
|
-
L:
|
|
787
|
+
L: 456,
|
|
877
788
|
S: this,
|
|
878
789
|
C: (f, a) => f(...a)
|
|
879
790
|
}));
|
|
@@ -898,7 +809,7 @@ var Observability = class {
|
|
|
898
809
|
} else {
|
|
899
810
|
log3("segment disabled", void 0, {
|
|
900
811
|
F: __dxlog_file3,
|
|
901
|
-
L:
|
|
812
|
+
L: 482,
|
|
902
813
|
S: this,
|
|
903
814
|
C: (f, a) => f(...a)
|
|
904
815
|
});
|
|
@@ -925,8 +836,9 @@ var Observability = class {
|
|
|
925
836
|
//
|
|
926
837
|
async _initErrorLogs() {
|
|
927
838
|
if (this._secrets.SENTRY_DESTINATION && this._mode !== "disabled") {
|
|
928
|
-
const { captureException
|
|
929
|
-
|
|
839
|
+
const { captureException, captureUserFeedback, init, setTag } = await import("./sentry/index.mjs");
|
|
840
|
+
const { SentryLogProcessor } = await import("./sentry-log-processor-DVUUOZ6G.mjs");
|
|
841
|
+
this._captureException = captureException;
|
|
930
842
|
this._captureUserFeedback = captureUserFeedback;
|
|
931
843
|
this._setTag = setTag;
|
|
932
844
|
log3.info("Initializing Sentry", {
|
|
@@ -934,18 +846,17 @@ var Observability = class {
|
|
|
934
846
|
options: this._errorReportingOptions
|
|
935
847
|
}, {
|
|
936
848
|
F: __dxlog_file3,
|
|
937
|
-
L:
|
|
849
|
+
L: 518,
|
|
938
850
|
S: this,
|
|
939
851
|
C: (f, a) => f(...a)
|
|
940
852
|
});
|
|
941
|
-
|
|
853
|
+
this._sentryLogProcessor = new SentryLogProcessor();
|
|
942
854
|
init({
|
|
943
855
|
...this._errorReportingOptions,
|
|
944
856
|
destination: this._secrets.SENTRY_DESTINATION,
|
|
945
857
|
scrubFilenames: this._mode !== "full",
|
|
946
|
-
onError: (event) =>
|
|
858
|
+
onError: (event) => this._sentryLogProcessor.addLogBreadcrumbsTo(event)
|
|
947
859
|
});
|
|
948
|
-
log3.runtimeConfig.processors.push(logProcessor.logProcessor);
|
|
949
860
|
this._tags.forEach((v, k) => {
|
|
950
861
|
if (v.scope === "all" || v.scope === "errors") {
|
|
951
862
|
setTag(k, v.value);
|
|
@@ -954,12 +865,67 @@ var Observability = class {
|
|
|
954
865
|
} else {
|
|
955
866
|
log3("sentry disabled", void 0, {
|
|
956
867
|
F: __dxlog_file3,
|
|
957
|
-
L:
|
|
868
|
+
L: 538,
|
|
869
|
+
S: this,
|
|
870
|
+
C: (f, a) => f(...a)
|
|
871
|
+
});
|
|
872
|
+
}
|
|
873
|
+
if (this._secrets.OTEL_ENDPOINT && this._secrets.OTEL_AUTHORIZATION && this._mode !== "disabled") {
|
|
874
|
+
const { OtelLogs } = await import("./otel-BUKBDMAL.mjs");
|
|
875
|
+
this._otelLogs = new OtelLogs({
|
|
876
|
+
endpoint: this._secrets.OTEL_ENDPOINT,
|
|
877
|
+
authorizationHeader: this._secrets.OTEL_AUTHORIZATION,
|
|
878
|
+
serviceName: this._namespace,
|
|
879
|
+
serviceVersion: this.getTag("release")?.value ?? "0.0.0",
|
|
880
|
+
getTags: () => Object.fromEntries(Array.from(this._tags).filter(([key, value]) => {
|
|
881
|
+
return value.scope === "all" || value.scope === "errors";
|
|
882
|
+
}).map(([key, value]) => [
|
|
883
|
+
key,
|
|
884
|
+
value.value
|
|
885
|
+
]))
|
|
886
|
+
});
|
|
887
|
+
log3("otel logs enabled", {
|
|
888
|
+
namespace: this._namespace
|
|
889
|
+
}, {
|
|
890
|
+
F: __dxlog_file3,
|
|
891
|
+
L: 557,
|
|
892
|
+
S: this,
|
|
893
|
+
C: (f, a) => f(...a)
|
|
894
|
+
});
|
|
895
|
+
} else {
|
|
896
|
+
log3("otel logs disabled", void 0, {
|
|
897
|
+
F: __dxlog_file3,
|
|
898
|
+
L: 559,
|
|
958
899
|
S: this,
|
|
959
900
|
C: (f, a) => f(...a)
|
|
960
901
|
});
|
|
961
902
|
}
|
|
962
903
|
}
|
|
904
|
+
startErrorLogs() {
|
|
905
|
+
this._sentryLogProcessor && log3.runtimeConfig.processors.push(this._sentryLogProcessor.logProcessor);
|
|
906
|
+
this._otelLogs && log3.runtimeConfig.processors.push(this._otelLogs.logProcessor);
|
|
907
|
+
}
|
|
908
|
+
startTraces() {
|
|
909
|
+
this._otelTraces && this._otelTraces.start();
|
|
910
|
+
}
|
|
911
|
+
// TODO(nf): refactor init based on providers and their capabilities
|
|
912
|
+
async _initTraces() {
|
|
913
|
+
if (this._secrets.OTEL_ENDPOINT && this._secrets.OTEL_AUTHORIZATION && this._mode !== "disabled") {
|
|
914
|
+
const { OtelTraces } = await import("./otel-BUKBDMAL.mjs");
|
|
915
|
+
this._otelTraces = new OtelTraces({
|
|
916
|
+
endpoint: this._secrets.OTEL_ENDPOINT,
|
|
917
|
+
authorizationHeader: this._secrets.OTEL_AUTHORIZATION,
|
|
918
|
+
serviceName: this._namespace,
|
|
919
|
+
serviceVersion: this.getTag("release")?.value ?? "0.0.0",
|
|
920
|
+
getTags: () => Object.fromEntries(Array.from(this._tags).filter(([key, value]) => {
|
|
921
|
+
return value.scope === "all" || value.scope === "metrics";
|
|
922
|
+
}).map(([key, value]) => [
|
|
923
|
+
key,
|
|
924
|
+
value.value
|
|
925
|
+
]))
|
|
926
|
+
});
|
|
927
|
+
}
|
|
928
|
+
}
|
|
963
929
|
/**
|
|
964
930
|
* Manually capture an exception.
|
|
965
931
|
*
|
|
@@ -996,4 +962,4 @@ export {
|
|
|
996
962
|
mapSpaces,
|
|
997
963
|
setupTelemetryListeners
|
|
998
964
|
};
|
|
999
|
-
//# sourceMappingURL=chunk-
|
|
965
|
+
//# sourceMappingURL=chunk-2CXA7PYK.mjs.map
|