@dxos/observability 0.3.11-main.2f1331c → 0.3.11-main.463e5cd
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/README.md +9 -4
- package/dist/lib/browser/{chunk-2J5YS65Q.mjs → chunk-6ZTMPKEG.mjs} +3 -3
- package/dist/lib/browser/{chunk-2J5YS65Q.mjs.map → chunk-6ZTMPKEG.mjs.map} +3 -3
- package/dist/lib/browser/chunk-HPGC4HC7.mjs +83 -0
- package/dist/lib/browser/chunk-HPGC4HC7.mjs.map +7 -0
- package/dist/lib/browser/chunk-OCQVYNE3.mjs +842 -0
- package/dist/lib/browser/chunk-OCQVYNE3.mjs.map +7 -0
- package/dist/lib/browser/datadog/index.mjs +1 -1
- package/dist/lib/browser/index.mjs +32 -553
- package/dist/lib/browser/index.mjs.map +4 -4
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/browser/observability-QNG5QON4.mjs +10 -0
- package/dist/lib/browser/observability-QNG5QON4.mjs.map +7 -0
- package/dist/lib/browser/segment/index.mjs +8 -0
- package/dist/lib/browser/segment/index.mjs.map +7 -0
- package/dist/lib/node/chunk-BHF4PKAP.cjs +170 -0
- package/dist/lib/node/chunk-BHF4PKAP.cjs.map +7 -0
- package/dist/lib/node/chunk-CBMRJXSL.cjs +861 -0
- package/dist/lib/node/chunk-CBMRJXSL.cjs.map +7 -0
- package/dist/lib/node/{chunk-VDBBIYH6.cjs → chunk-ZJRKFREX.cjs} +6 -6
- package/dist/lib/node/{chunk-VDBBIYH6.cjs.map → chunk-ZJRKFREX.cjs.map} +3 -3
- package/dist/lib/node/datadog/index.cjs +3 -3
- package/dist/lib/node/datadog/index.cjs.map +1 -1
- package/dist/lib/node/index.cjs +31 -603
- package/dist/lib/node/index.cjs.map +4 -4
- package/dist/lib/node/meta.json +1 -1
- package/dist/lib/node/observability-JMKBRR4L.cjs +32 -0
- package/dist/lib/node/observability-JMKBRR4L.cjs.map +7 -0
- package/dist/lib/node/segment/index.cjs +30 -0
- package/dist/lib/node/segment/index.cjs.map +7 -0
- package/dist/types/src/datadog/metrics.d.ts +3 -1
- package/dist/types/src/datadog/metrics.d.ts.map +1 -1
- package/dist/types/src/datadog/metrics.js +1 -1
- package/dist/types/src/datadog/metrics.js.map +1 -1
- package/dist/types/src/helpers/browser-observability.d.ts +17 -0
- package/dist/types/src/helpers/browser-observability.d.ts.map +1 -0
- package/dist/types/src/helpers/browser-observability.js +166 -0
- package/dist/types/src/helpers/browser-observability.js.map +1 -0
- package/dist/types/src/helpers/common.d.ts +10 -0
- package/dist/types/src/helpers/common.d.ts.map +1 -0
- package/dist/types/src/helpers/common.js +23 -0
- package/dist/types/src/helpers/common.js.map +1 -0
- package/dist/types/src/helpers/index.d.ts +6 -0
- package/dist/types/src/helpers/index.d.ts.map +1 -0
- package/dist/types/src/helpers/index.js +25 -0
- package/dist/types/src/helpers/index.js.map +1 -0
- package/dist/types/src/{util.d.ts → helpers/map-spaces.d.ts} +2 -3
- package/dist/types/src/helpers/map-spaces.d.ts.map +1 -0
- package/dist/types/src/{util.js → helpers/map-spaces.js} +1 -2
- package/dist/types/src/helpers/map-spaces.js.map +1 -0
- package/dist/types/src/helpers/node-observability.d.ts +34 -0
- package/dist/types/src/helpers/node-observability.d.ts.map +1 -0
- package/dist/types/src/helpers/node-observability.js +106 -0
- package/dist/types/src/helpers/node-observability.js.map +1 -0
- package/dist/types/src/helpers/setup-telemetry-listeners.d.ts +4 -0
- package/dist/types/src/helpers/setup-telemetry-listeners.d.ts.map +1 -0
- package/dist/types/src/helpers/setup-telemetry-listeners.js +91 -0
- package/dist/types/src/helpers/setup-telemetry-listeners.js.map +1 -0
- package/dist/types/src/index.d.ts +1 -0
- package/dist/types/src/index.d.ts.map +1 -1
- package/dist/types/src/index.js +1 -0
- package/dist/types/src/index.js.map +1 -1
- package/dist/types/src/observability.d.ts +8 -8
- package/dist/types/src/observability.d.ts.map +1 -1
- package/dist/types/src/observability.js +51 -37
- package/dist/types/src/observability.js.map +1 -1
- package/dist/types/src/segment/browser.d.ts.map +1 -1
- package/dist/types/src/segment/browser.js +2 -2
- package/dist/types/src/segment/browser.js.map +1 -1
- package/dist/types/src/segment/node.d.ts.map +1 -1
- package/dist/types/src/segment/node.js +2 -2
- package/dist/types/src/segment/node.js.map +1 -1
- package/dist/types/src/segment/types.d.ts +3 -1
- package/dist/types/src/segment/types.d.ts.map +1 -1
- package/package.json +18 -14
- package/src/datadog/metrics.ts +3 -5
- package/src/helpers/browser-observability.ts +177 -0
- package/src/helpers/common.ts +25 -0
- package/src/helpers/index.ts +9 -0
- package/src/{util.ts → helpers/map-spaces.ts} +1 -2
- package/src/helpers/node-observability.ts +151 -0
- package/src/helpers/setup-telemetry-listeners.ts +110 -0
- package/src/index.ts +1 -0
- package/src/observability.ts +61 -39
- package/src/segment/browser.ts +3 -3
- package/src/segment/node.ts +3 -3
- package/src/segment/types.ts +1 -1
- package/dist/types/src/util.d.ts.map +0 -1
- package/dist/types/src/util.js.map +0 -1
|
@@ -0,0 +1,861 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __export = (target, all) => {
|
|
9
|
+
for (var name in all)
|
|
10
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
+
};
|
|
12
|
+
var __copyProps = (to, from, except, desc) => {
|
|
13
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
+
for (let key of __getOwnPropNames(from))
|
|
15
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
|
+
}
|
|
18
|
+
return to;
|
|
19
|
+
};
|
|
20
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
+
mod
|
|
27
|
+
));
|
|
28
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
+
var chunk_CBMRJXSL_exports = {};
|
|
30
|
+
__export(chunk_CBMRJXSL_exports, {
|
|
31
|
+
OBSERVABILITY_DISABLED_KEY: () => OBSERVABILITY_DISABLED_KEY,
|
|
32
|
+
OBSERVABILITY_GROUP_KEY: () => OBSERVABILITY_GROUP_KEY,
|
|
33
|
+
Observability: () => Observability,
|
|
34
|
+
getObservabilityGroup: () => getObservabilityGroup,
|
|
35
|
+
getObservabilityState: () => getObservabilityState,
|
|
36
|
+
getTelemetryIdentifier: () => getTelemetryIdentifier,
|
|
37
|
+
initializeAppObservability: () => initializeAppObservability,
|
|
38
|
+
initializeNodeObservability: () => initializeNodeObservability,
|
|
39
|
+
isObservabilityDisabled: () => isObservabilityDisabled,
|
|
40
|
+
mapSpaces: () => mapSpaces,
|
|
41
|
+
setupTelemetryListeners: () => setupTelemetryListeners,
|
|
42
|
+
showObservabilityBanner: () => showObservabilityBanner,
|
|
43
|
+
storeObservabilityDisabled: () => storeObservabilityDisabled,
|
|
44
|
+
storeObservabilityGroup: () => storeObservabilityGroup
|
|
45
|
+
});
|
|
46
|
+
module.exports = __toCommonJS(chunk_CBMRJXSL_exports);
|
|
47
|
+
var import_chunk_ZJRKFREX = require("./chunk-ZJRKFREX.cjs");
|
|
48
|
+
var import_chunk_BHF4PKAP = require("./chunk-BHF4PKAP.cjs");
|
|
49
|
+
var import_chunk_FSAOBKO2 = require("./chunk-FSAOBKO2.cjs");
|
|
50
|
+
var import_async = require("@dxos/async");
|
|
51
|
+
var import_context = require("@dxos/context");
|
|
52
|
+
var import_invariant = require("@dxos/invariant");
|
|
53
|
+
var import_log = require("@dxos/log");
|
|
54
|
+
var import_network_manager = require("@dxos/network-manager");
|
|
55
|
+
var import_services = require("@dxos/protocols/proto/dxos/client/services");
|
|
56
|
+
var import_util = require("@dxos/util");
|
|
57
|
+
var localForage = __toESM(require("localforage"));
|
|
58
|
+
var import_log2 = require("@dxos/log");
|
|
59
|
+
var import_js_yaml = __toESM(require("js-yaml"));
|
|
60
|
+
var import_node_fs = require("node:fs");
|
|
61
|
+
var import_promises = require("node:fs/promises");
|
|
62
|
+
var import_node_path = require("node:path");
|
|
63
|
+
var import_uuid = require("uuid");
|
|
64
|
+
var import_log3 = require("@dxos/log");
|
|
65
|
+
var cli_observability_secrets_default = {
|
|
66
|
+
SENTRY_DESTINATION: "https://2647916221e643869965e78469479aa4@o4504012000067584.ingest.sentry.io/4504012027265029",
|
|
67
|
+
TELEMETRY_API_KEY: "B00QG6PtJJrJ0VVFe0H5a6bcUUShKyZM",
|
|
68
|
+
IPDATA_API_KEY: "73dfdecdf979c18f07d50cf841bbdd9e589f237256326ac8cca23786",
|
|
69
|
+
DATADOG_API_KEY: null,
|
|
70
|
+
DATADOG_APP_KEY: null
|
|
71
|
+
};
|
|
72
|
+
var __dxlog_file = "/home/runner/work/dxos/dxos/packages/sdk/observability/src/helpers/browser-observability.ts";
|
|
73
|
+
var OBSERVABILITY_DISABLED_KEY = "observability-disabled";
|
|
74
|
+
var OBSERVABILITY_GROUP_KEY = "observability-group";
|
|
75
|
+
var isObservabilityDisabled = async (namespace) => {
|
|
76
|
+
try {
|
|
77
|
+
return await localForage.getItem(`${namespace}:${OBSERVABILITY_DISABLED_KEY}`) === "true";
|
|
78
|
+
} catch (err) {
|
|
79
|
+
import_log2.log.catch("Failed to check if observability is disabled, assuming it is", err, {
|
|
80
|
+
F: __dxlog_file,
|
|
81
|
+
L: 24,
|
|
82
|
+
S: void 0,
|
|
83
|
+
C: (f, a) => f(...a)
|
|
84
|
+
});
|
|
85
|
+
return true;
|
|
86
|
+
}
|
|
87
|
+
};
|
|
88
|
+
var storeObservabilityDisabled = async (namespace, value) => {
|
|
89
|
+
try {
|
|
90
|
+
await localForage.setItem(`${namespace}:${OBSERVABILITY_DISABLED_KEY}`, String(value));
|
|
91
|
+
} catch (err) {
|
|
92
|
+
import_log2.log.catch("Failed to store observability disabled", err, {
|
|
93
|
+
F: __dxlog_file,
|
|
94
|
+
L: 33,
|
|
95
|
+
S: void 0,
|
|
96
|
+
C: (f, a) => f(...a)
|
|
97
|
+
});
|
|
98
|
+
}
|
|
99
|
+
};
|
|
100
|
+
var getObservabilityGroup = async (namespace) => {
|
|
101
|
+
try {
|
|
102
|
+
return await localForage.getItem(`${namespace}:${OBSERVABILITY_GROUP_KEY}`) ?? void 0;
|
|
103
|
+
} catch (err) {
|
|
104
|
+
import_log2.log.catch("Failed to get observability group", err, {
|
|
105
|
+
F: __dxlog_file,
|
|
106
|
+
L: 41,
|
|
107
|
+
S: void 0,
|
|
108
|
+
C: (f, a) => f(...a)
|
|
109
|
+
});
|
|
110
|
+
}
|
|
111
|
+
};
|
|
112
|
+
var storeObservabilityGroup = async (namespace, value) => {
|
|
113
|
+
try {
|
|
114
|
+
await localForage.setItem(`${namespace}:${OBSERVABILITY_GROUP_KEY}`, value);
|
|
115
|
+
} catch (err) {
|
|
116
|
+
import_log2.log.catch("Failed to store observability group", err, {
|
|
117
|
+
F: __dxlog_file,
|
|
118
|
+
L: 49,
|
|
119
|
+
S: void 0,
|
|
120
|
+
C: (f, a) => f(...a)
|
|
121
|
+
});
|
|
122
|
+
}
|
|
123
|
+
};
|
|
124
|
+
var initializeAppObservability = async ({ namespace, config, mode = "basic", tracingEnable = true, replayEnable = true }) => {
|
|
125
|
+
(0, import_log2.log)("initializeAppObservability", {
|
|
126
|
+
config
|
|
127
|
+
}, {
|
|
128
|
+
F: __dxlog_file,
|
|
129
|
+
L: 72,
|
|
130
|
+
S: void 0,
|
|
131
|
+
C: (f, a) => f(...a)
|
|
132
|
+
});
|
|
133
|
+
const group = await getObservabilityGroup(namespace) ?? void 0;
|
|
134
|
+
const release = `${namespace}@${config.get("runtime.app.build.version")}`;
|
|
135
|
+
const environment = config.get("runtime.app.env.DX_ENVIRONMENT");
|
|
136
|
+
const observabilityDisabled = await isObservabilityDisabled(namespace);
|
|
137
|
+
const { Observability: Observability2 } = await import("./observability-JMKBRR4L.cjs");
|
|
138
|
+
const observability = new Observability2({
|
|
139
|
+
namespace,
|
|
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
|
+
replaySampleRate: 0.1,
|
|
152
|
+
replaySampleRateOnError: 1
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
});
|
|
156
|
+
if (observabilityDisabled) {
|
|
157
|
+
observability.setMode("disabled");
|
|
158
|
+
import_log2.log.info("observability disabled", void 0, {
|
|
159
|
+
F: __dxlog_file,
|
|
160
|
+
L: 113,
|
|
161
|
+
S: void 0,
|
|
162
|
+
C: (f, a) => f(...a)
|
|
163
|
+
});
|
|
164
|
+
return observability;
|
|
165
|
+
}
|
|
166
|
+
try {
|
|
167
|
+
const getIPData = async (config2) => {
|
|
168
|
+
const IP_DATA_CACHE_TIMEOUT = 6 * 60 * 60 * 1e3;
|
|
169
|
+
const cachedData = await localForage.getItem("dxos:observability:ipdata");
|
|
170
|
+
if (cachedData && cachedData.timestamp > Date.now() - IP_DATA_CACHE_TIMEOUT) {
|
|
171
|
+
return cachedData.data;
|
|
172
|
+
}
|
|
173
|
+
const IPDATA_API_KEY = config2.get("runtime.app.env.DX_IPDATA_API_KEY");
|
|
174
|
+
if (IPDATA_API_KEY) {
|
|
175
|
+
return fetch(`https://api.ipdata.co?api-key=${IPDATA_API_KEY}`).then((res) => res.json()).then((data) => {
|
|
176
|
+
localForage.setItem("dxos:observability:ipdata", {
|
|
177
|
+
data,
|
|
178
|
+
timestamp: Date.now()
|
|
179
|
+
}).catch((err) => observability.captureException(err));
|
|
180
|
+
return data;
|
|
181
|
+
}).catch((err) => observability.captureException(err));
|
|
182
|
+
}
|
|
183
|
+
};
|
|
184
|
+
observability.initialize();
|
|
185
|
+
const ipData = await getIPData(config);
|
|
186
|
+
ipData && observability.addIPDataTelemetryTags(ipData);
|
|
187
|
+
if (typeof navigator !== "undefined" && navigator.storage?.estimate) {
|
|
188
|
+
setInterval(async () => {
|
|
189
|
+
try {
|
|
190
|
+
const storageEstimate = await navigator.storage.estimate();
|
|
191
|
+
storageEstimate.usage && observability.setTag("storageUsage", storageEstimate.usage.toString(), "telemetry");
|
|
192
|
+
storageEstimate.quota && observability.setTag("storageQuota", storageEstimate.quota.toString(), "telemetry");
|
|
193
|
+
} catch (error) {
|
|
194
|
+
import_log2.log.warn("Failed to run estimate()", error, {
|
|
195
|
+
F: __dxlog_file,
|
|
196
|
+
L: 168,
|
|
197
|
+
S: void 0,
|
|
198
|
+
C: (f, a) => f(...a)
|
|
199
|
+
});
|
|
200
|
+
}
|
|
201
|
+
}, 1e4);
|
|
202
|
+
}
|
|
203
|
+
} catch (err) {
|
|
204
|
+
import_log2.log.error("Failed to initialize app observability", err, {
|
|
205
|
+
F: __dxlog_file,
|
|
206
|
+
L: 173,
|
|
207
|
+
S: void 0,
|
|
208
|
+
C: (f, a) => f(...a)
|
|
209
|
+
});
|
|
210
|
+
}
|
|
211
|
+
return observability;
|
|
212
|
+
};
|
|
213
|
+
var getTelemetryIdentifier = (client) => {
|
|
214
|
+
if (!client?.initialized) {
|
|
215
|
+
return void 0;
|
|
216
|
+
}
|
|
217
|
+
const identity = client.halo.identity.get();
|
|
218
|
+
if (identity) {
|
|
219
|
+
return identity.identityKey.truncate();
|
|
220
|
+
}
|
|
221
|
+
return void 0;
|
|
222
|
+
};
|
|
223
|
+
var __dxlog_file2 = "/home/runner/work/dxos/dxos/packages/sdk/observability/src/helpers/node-observability.ts";
|
|
224
|
+
var showObservabilityBanner = async (configDir, bannercb) => {
|
|
225
|
+
const path = (0, import_node_path.join)(configDir, ".observability-banner-printed");
|
|
226
|
+
if ((0, import_node_fs.existsSync)(path)) {
|
|
227
|
+
return;
|
|
228
|
+
}
|
|
229
|
+
bannercb(
|
|
230
|
+
// eslint-disable-next-line no-multi-str
|
|
231
|
+
"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_TELEMETRY=true."
|
|
232
|
+
);
|
|
233
|
+
await (0, import_promises.writeFile)(path, "", "utf-8");
|
|
234
|
+
};
|
|
235
|
+
var getObservabilityState = async (configDir) => {
|
|
236
|
+
if ((0, import_node_fs.existsSync)(configDir)) {
|
|
237
|
+
if (!(0, import_node_fs.statSync)(configDir).isDirectory()) {
|
|
238
|
+
throw new Error(`Config directory ${configDir} exists but is not a directory`);
|
|
239
|
+
}
|
|
240
|
+
} else {
|
|
241
|
+
await (0, import_promises.mkdir)(configDir, {
|
|
242
|
+
recursive: true
|
|
243
|
+
});
|
|
244
|
+
}
|
|
245
|
+
const idPath = (0, import_node_path.join)(configDir, "observability.yml");
|
|
246
|
+
if ((0, import_node_fs.existsSync)(idPath)) {
|
|
247
|
+
const context = await (0, import_promises.readFile)(idPath, "utf-8");
|
|
248
|
+
return validate(context) ?? initializeState(idPath);
|
|
249
|
+
}
|
|
250
|
+
return initializeState(idPath);
|
|
251
|
+
};
|
|
252
|
+
var initializeState = async (idPath) => {
|
|
253
|
+
const observabilityState = {
|
|
254
|
+
installationId: (0, import_uuid.v4)(),
|
|
255
|
+
group: process.env.DX_TELEMETRY_GROUP ?? void 0,
|
|
256
|
+
mode: process.env.DX_DISABLE_TELEMETRY ? "disabled" : process.env.DX_TELEMETRY_MODE ?? "basic"
|
|
257
|
+
};
|
|
258
|
+
await (0, import_promises.writeFile)(idPath, "# This file is automatically generated by the @dxos/cli.\n" + import_js_yaml.default.dump(observabilityState), "utf-8");
|
|
259
|
+
return observabilityState;
|
|
260
|
+
};
|
|
261
|
+
var validate = (contextString) => {
|
|
262
|
+
const context = import_js_yaml.default.load(contextString);
|
|
263
|
+
if (Boolean(context.installationId) && (0, import_uuid.validate)(context.installationId)) {
|
|
264
|
+
return {
|
|
265
|
+
...context,
|
|
266
|
+
mode: process.env.DX_DISABLE_TELEMETRY ? "disabled" : context.mode ?? "basic"
|
|
267
|
+
};
|
|
268
|
+
}
|
|
269
|
+
};
|
|
270
|
+
var initializeNodeObservability = async ({ namespace, config, installationId, group, mode = "basic", tracingEnable = true, replayEnable = true }) => {
|
|
271
|
+
(0, import_log3.log)("initializeCliObservability", {
|
|
272
|
+
config
|
|
273
|
+
}, {
|
|
274
|
+
F: __dxlog_file2,
|
|
275
|
+
L: 120,
|
|
276
|
+
S: void 0,
|
|
277
|
+
C: (f, a) => f(...a)
|
|
278
|
+
});
|
|
279
|
+
const release = `${namespace}@${config.get("runtime.app.build.version")}`;
|
|
280
|
+
const environment = config.get("runtime.app.env.DX_ENVIRONMENT");
|
|
281
|
+
const observability = new Observability({
|
|
282
|
+
namespace,
|
|
283
|
+
group,
|
|
284
|
+
mode,
|
|
285
|
+
errorLog: {
|
|
286
|
+
sentryInitOptions: {
|
|
287
|
+
environment,
|
|
288
|
+
release,
|
|
289
|
+
// TODO(wittjosiah): Configure this.
|
|
290
|
+
sampleRate: 1
|
|
291
|
+
},
|
|
292
|
+
logProcessor: true
|
|
293
|
+
}
|
|
294
|
+
});
|
|
295
|
+
observability.setTag("installationId", installationId);
|
|
296
|
+
const IPDATA_API_KEY = config.get("runtime.app.env.DX_IPDATA_API_KEY");
|
|
297
|
+
try {
|
|
298
|
+
const res = await fetch(`https://api.ipdata.co/?api-key=${IPDATA_API_KEY}`);
|
|
299
|
+
const ipData = await res.json();
|
|
300
|
+
ipData && observability.addIPDataTelemetryTags(ipData);
|
|
301
|
+
} catch (err) {
|
|
302
|
+
observability?.captureException(err);
|
|
303
|
+
}
|
|
304
|
+
return observability;
|
|
305
|
+
};
|
|
306
|
+
var mapSpaces = (spaces, options = {
|
|
307
|
+
verbose: false,
|
|
308
|
+
truncateKeys: false
|
|
309
|
+
}) => {
|
|
310
|
+
return spaces.map((space) => {
|
|
311
|
+
const { open, ready } = space.internal.data.metrics ?? {};
|
|
312
|
+
const startup = open && ready && ready.getTime() - open.getTime();
|
|
313
|
+
const pipeline = space.internal.data.pipeline;
|
|
314
|
+
const startDataMutations = pipeline?.currentEpoch?.subject.assertion.timeframe.totalMessages() ?? 0;
|
|
315
|
+
const epoch = pipeline?.currentEpoch?.subject.assertion.number;
|
|
316
|
+
const currentDataMutations = pipeline?.currentDataTimeframe?.totalMessages() ?? 0;
|
|
317
|
+
const totalDataMutations = pipeline?.targetDataTimeframe?.totalMessages() ?? 0;
|
|
318
|
+
return {
|
|
319
|
+
// TODO(nf): truncate keys for DD?
|
|
320
|
+
key: space.key.truncate(),
|
|
321
|
+
open: space.isOpen,
|
|
322
|
+
members: space.members.get().length,
|
|
323
|
+
objects: space.db.query().objects.length,
|
|
324
|
+
startup,
|
|
325
|
+
epoch,
|
|
326
|
+
// appliedEpoch,
|
|
327
|
+
startDataMutations,
|
|
328
|
+
currentDataMutations,
|
|
329
|
+
totalDataMutations,
|
|
330
|
+
// TODO(burdon): Negative?
|
|
331
|
+
progress: (Math.min(Math.abs((currentDataMutations - startDataMutations) / (totalDataMutations - startDataMutations)), 1) * 100).toFixed(0)
|
|
332
|
+
};
|
|
333
|
+
});
|
|
334
|
+
};
|
|
335
|
+
var lastFocusEvent = /* @__PURE__ */ new Date();
|
|
336
|
+
var totalTime = 0;
|
|
337
|
+
var setupTelemetryListeners = (namespace, client, observability) => {
|
|
338
|
+
const clickCallback = (event) => {
|
|
339
|
+
if (observability.group === "dxos" && event.target && !event.target.id) {
|
|
340
|
+
console.warn("Click event on element without id:", event.target);
|
|
341
|
+
}
|
|
342
|
+
setTimeout(() => observability.event({
|
|
343
|
+
identityId: getTelemetryIdentifier(client),
|
|
344
|
+
name: `${namespace}.window.click`,
|
|
345
|
+
properties: {
|
|
346
|
+
href: window.location.href,
|
|
347
|
+
id: event.target?.id,
|
|
348
|
+
path: event.path?.filter((el) => Boolean(el.tagName)).map((el) => `${el.tagName.toLowerCase()}${el.id ? `#${el.id}` : ""}`).reverse().join(">")
|
|
349
|
+
}
|
|
350
|
+
}));
|
|
351
|
+
};
|
|
352
|
+
const focusCallback = () => {
|
|
353
|
+
const now = /* @__PURE__ */ new Date();
|
|
354
|
+
setTimeout(() => observability.event({
|
|
355
|
+
identityId: getTelemetryIdentifier(client),
|
|
356
|
+
name: `${namespace}.window.focus`,
|
|
357
|
+
properties: {
|
|
358
|
+
href: window.location.href,
|
|
359
|
+
timeAway: now.getTime() - lastFocusEvent.getTime()
|
|
360
|
+
}
|
|
361
|
+
}));
|
|
362
|
+
lastFocusEvent = now;
|
|
363
|
+
};
|
|
364
|
+
const blurCallback = () => {
|
|
365
|
+
const now = /* @__PURE__ */ new Date();
|
|
366
|
+
const timeSpent = now.getTime() - lastFocusEvent.getTime();
|
|
367
|
+
setTimeout(() => observability.event({
|
|
368
|
+
identityId: getTelemetryIdentifier(client),
|
|
369
|
+
name: `${namespace}.window.blur`,
|
|
370
|
+
properties: {
|
|
371
|
+
href: window.location.href,
|
|
372
|
+
timeSpent
|
|
373
|
+
}
|
|
374
|
+
}));
|
|
375
|
+
lastFocusEvent = now;
|
|
376
|
+
totalTime = totalTime + timeSpent;
|
|
377
|
+
};
|
|
378
|
+
const unloadCallback = () => {
|
|
379
|
+
setTimeout(() => observability.event({
|
|
380
|
+
identityId: getTelemetryIdentifier(client),
|
|
381
|
+
name: `${namespace}.page.unload`,
|
|
382
|
+
properties: {
|
|
383
|
+
href: window.location.href,
|
|
384
|
+
timeSpent: totalTime
|
|
385
|
+
}
|
|
386
|
+
}));
|
|
387
|
+
};
|
|
388
|
+
const errorCallback = (event) => {
|
|
389
|
+
setTimeout(() => observability.event({
|
|
390
|
+
identityId: getTelemetryIdentifier(client),
|
|
391
|
+
name: `${namespace}.window.error`,
|
|
392
|
+
properties: {
|
|
393
|
+
href: window.location.href,
|
|
394
|
+
message: event.message,
|
|
395
|
+
filename: event.filename,
|
|
396
|
+
stack: event.error.stack
|
|
397
|
+
}
|
|
398
|
+
}));
|
|
399
|
+
};
|
|
400
|
+
window.addEventListener("click", clickCallback, true);
|
|
401
|
+
window.addEventListener("focus", focusCallback);
|
|
402
|
+
window.addEventListener("blur", blurCallback);
|
|
403
|
+
window.addEventListener("beforeunload", unloadCallback);
|
|
404
|
+
window.addEventListener("error", errorCallback);
|
|
405
|
+
return () => {
|
|
406
|
+
window.removeEventListener("click", clickCallback, true);
|
|
407
|
+
window.removeEventListener("focus", focusCallback);
|
|
408
|
+
window.removeEventListener("blur", blurCallback);
|
|
409
|
+
window.removeEventListener("beforeunload", unloadCallback);
|
|
410
|
+
window.removeEventListener("error", errorCallback);
|
|
411
|
+
};
|
|
412
|
+
};
|
|
413
|
+
var __dxlog_file3 = "/home/runner/work/dxos/dxos/packages/sdk/observability/src/observability.ts";
|
|
414
|
+
var SPACE_METRICS_MIN_INTERVAL = 1e3 * 60;
|
|
415
|
+
var DATADOG_IDLE_INTERVAL = 1e3 * 60 * 1;
|
|
416
|
+
var Observability = class {
|
|
417
|
+
// TODO(nf): make platform a required extension?
|
|
418
|
+
constructor({ namespace, config, secrets, group, mode, telemetry, errorLog }) {
|
|
419
|
+
this._mode = "disabled";
|
|
420
|
+
this._ctx = new import_context.Context();
|
|
421
|
+
this._tags = /* @__PURE__ */ new Map();
|
|
422
|
+
this.addIPDataTelemetryTags = (ipData) => {
|
|
423
|
+
this.setTag("city", ipData.city, "telemetry");
|
|
424
|
+
this.setTag("region", ipData.region, "telemetry");
|
|
425
|
+
this.setTag("country", ipData.country, "telemetry");
|
|
426
|
+
ipData.latitude && this.setTag("latitude", ipData.latitude.toString(), "telemetry");
|
|
427
|
+
ipData.longitude && this.setTag("longitude", ipData.longitude.toString(), "telemetry");
|
|
428
|
+
};
|
|
429
|
+
this._namespace = namespace;
|
|
430
|
+
this._config = config;
|
|
431
|
+
this._mode = mode ?? "disabled";
|
|
432
|
+
this._group = group;
|
|
433
|
+
this._secrets = this._loadSecrets(config, secrets);
|
|
434
|
+
this._telemetryBatchSize = telemetry?.batchSize ?? 30;
|
|
435
|
+
this._errorReportingOptions = errorLog?.sentryInitOptions;
|
|
436
|
+
this._errorLogProcessor = errorLog?.logProcessor ?? false;
|
|
437
|
+
if (this._group) {
|
|
438
|
+
this.setTag("group", this._group);
|
|
439
|
+
}
|
|
440
|
+
this.setTag("namespace", this._namespace);
|
|
441
|
+
if (this._mode === "full") {
|
|
442
|
+
}
|
|
443
|
+
}
|
|
444
|
+
_loadSecrets(config, secrets) {
|
|
445
|
+
if ((0, import_util.isNode)()) {
|
|
446
|
+
return cli_observability_secrets_default;
|
|
447
|
+
} else {
|
|
448
|
+
(0, import_invariant.invariant)(config, "runtime config is required", {
|
|
449
|
+
F: __dxlog_file3,
|
|
450
|
+
L: 115,
|
|
451
|
+
S: this,
|
|
452
|
+
A: [
|
|
453
|
+
"config",
|
|
454
|
+
"'runtime config is required'"
|
|
455
|
+
]
|
|
456
|
+
});
|
|
457
|
+
(0, import_log.log)("config", {
|
|
458
|
+
rtc: this._secrets,
|
|
459
|
+
config
|
|
460
|
+
}, {
|
|
461
|
+
F: __dxlog_file3,
|
|
462
|
+
L: 116,
|
|
463
|
+
S: this,
|
|
464
|
+
C: (f, a) => f(...a)
|
|
465
|
+
});
|
|
466
|
+
return {
|
|
467
|
+
DX_ENVIRONMENT: config.get("runtime.app.env.DX_ENVIRONMENT"),
|
|
468
|
+
DX_RELEASE: config.get("runtime.app.env.DX_RELEASE"),
|
|
469
|
+
SENTRY_DESTINATION: config.get("runtime.app.env.DX_SENTRY_DESTINATION"),
|
|
470
|
+
TELEMETRY_API_KEY: config.get("runtime.app.env.DX_TELEMETRY_API_KEY"),
|
|
471
|
+
IPDATA_API_KEY: config.get("runtime.app.env.DX_IPDATA_API_KEY"),
|
|
472
|
+
DATADOG_API_KEY: config.get("runtime.app.env.DX_DATADOG_API_KEY"),
|
|
473
|
+
DATADOG_APP_KEY: config.get("runtime.app.env.DX_DATADOG_APP_KEY"),
|
|
474
|
+
...secrets
|
|
475
|
+
};
|
|
476
|
+
}
|
|
477
|
+
}
|
|
478
|
+
initialize() {
|
|
479
|
+
this._initMetrics();
|
|
480
|
+
this._initTelemetry();
|
|
481
|
+
this._initErrorLogs();
|
|
482
|
+
}
|
|
483
|
+
async close() {
|
|
484
|
+
await this._ctx.dispose();
|
|
485
|
+
}
|
|
486
|
+
setMode(mode) {
|
|
487
|
+
this._mode = mode;
|
|
488
|
+
}
|
|
489
|
+
get mode() {
|
|
490
|
+
return this._mode;
|
|
491
|
+
}
|
|
492
|
+
get group() {
|
|
493
|
+
return this._group;
|
|
494
|
+
}
|
|
495
|
+
get enabled() {
|
|
496
|
+
return this._mode !== "disabled";
|
|
497
|
+
}
|
|
498
|
+
//
|
|
499
|
+
// Tags
|
|
500
|
+
//
|
|
501
|
+
setTag(key, value, scope) {
|
|
502
|
+
if (this.enabled && (scope === void 0 || scope === "all" || scope === "errors")) {
|
|
503
|
+
(0, import_chunk_FSAOBKO2.setTag)(key, value);
|
|
504
|
+
}
|
|
505
|
+
if (!scope) {
|
|
506
|
+
scope = "all";
|
|
507
|
+
}
|
|
508
|
+
this._tags.set(key, {
|
|
509
|
+
value,
|
|
510
|
+
scope
|
|
511
|
+
});
|
|
512
|
+
}
|
|
513
|
+
// TODO(wittjosiah): Improve privacy of telemetry identifiers. See `getTelemetryIdentifier`.
|
|
514
|
+
async setIdentityTags(client) {
|
|
515
|
+
client.services.services.IdentityService.queryIdentity().subscribe((idqr) => {
|
|
516
|
+
if (!idqr?.identity?.identityKey) {
|
|
517
|
+
(0, import_log.log)("empty response from identity service", {
|
|
518
|
+
idqr
|
|
519
|
+
}, {
|
|
520
|
+
F: __dxlog_file3,
|
|
521
|
+
L: 184,
|
|
522
|
+
S: this,
|
|
523
|
+
C: (f, a) => f(...a)
|
|
524
|
+
});
|
|
525
|
+
return;
|
|
526
|
+
}
|
|
527
|
+
this.setTag("identityKey", idqr.identity.identityKey.truncate());
|
|
528
|
+
});
|
|
529
|
+
client.services.services.DevicesService.queryDevices().subscribe((dqr) => {
|
|
530
|
+
if (!dqr || !dqr.devices || dqr.devices.length === 0) {
|
|
531
|
+
(0, import_log.log)("empty response from device service", {
|
|
532
|
+
device: dqr
|
|
533
|
+
}, {
|
|
534
|
+
F: __dxlog_file3,
|
|
535
|
+
L: 193,
|
|
536
|
+
S: this,
|
|
537
|
+
C: (f, a) => f(...a)
|
|
538
|
+
});
|
|
539
|
+
return;
|
|
540
|
+
}
|
|
541
|
+
(0, import_invariant.invariant)(dqr, "empty response from device service", {
|
|
542
|
+
F: __dxlog_file3,
|
|
543
|
+
L: 196,
|
|
544
|
+
S: this,
|
|
545
|
+
A: [
|
|
546
|
+
"dqr",
|
|
547
|
+
"'empty response from device service'"
|
|
548
|
+
]
|
|
549
|
+
});
|
|
550
|
+
const thisDevice = dqr.devices.find((device) => device.kind === import_services.DeviceKind.CURRENT);
|
|
551
|
+
if (!thisDevice) {
|
|
552
|
+
(0, import_log.log)("no current device", {
|
|
553
|
+
device: dqr
|
|
554
|
+
}, {
|
|
555
|
+
F: __dxlog_file3,
|
|
556
|
+
L: 200,
|
|
557
|
+
S: this,
|
|
558
|
+
C: (f, a) => f(...a)
|
|
559
|
+
});
|
|
560
|
+
return;
|
|
561
|
+
}
|
|
562
|
+
this.setTag("deviceKey", thisDevice.deviceKey.truncate());
|
|
563
|
+
if (thisDevice.profile?.label) {
|
|
564
|
+
this.setTag("deviceProfile", thisDevice.profile.label);
|
|
565
|
+
}
|
|
566
|
+
});
|
|
567
|
+
}
|
|
568
|
+
//
|
|
569
|
+
// Metrics
|
|
570
|
+
//
|
|
571
|
+
_initMetrics() {
|
|
572
|
+
if (this.enabled && this._secrets.DATADOG_API_KEY) {
|
|
573
|
+
this._metrics = new import_chunk_ZJRKFREX.DatadogMetrics({
|
|
574
|
+
apiKey: this._secrets.DATADOG_API_KEY,
|
|
575
|
+
getTags: () => Object.fromEntries(Array.from(this._tags).filter(([key, value]) => {
|
|
576
|
+
return value.scope === "all" || value.scope === "metrics";
|
|
577
|
+
}).map(([key, value]) => [
|
|
578
|
+
key,
|
|
579
|
+
value.value
|
|
580
|
+
])),
|
|
581
|
+
// TODO(nf): move/refactor from telementryContext, needed to read CORS proxy
|
|
582
|
+
config: this._config
|
|
583
|
+
});
|
|
584
|
+
} else {
|
|
585
|
+
(0, import_log.log)("datadog disabled", void 0, {
|
|
586
|
+
F: __dxlog_file3,
|
|
587
|
+
L: 230,
|
|
588
|
+
S: this,
|
|
589
|
+
C: (f, a) => f(...a)
|
|
590
|
+
});
|
|
591
|
+
}
|
|
592
|
+
}
|
|
593
|
+
/**
|
|
594
|
+
* Gauge metric.
|
|
595
|
+
*
|
|
596
|
+
* The default implementation uses Datadog.
|
|
597
|
+
*/
|
|
598
|
+
gauge(name, value, extraTags) {
|
|
599
|
+
this._metrics?.gauge(name, value, extraTags);
|
|
600
|
+
}
|
|
601
|
+
// TODO(nf): Refactor into ObservabilityExtensions.
|
|
602
|
+
startNetworkMetrics(client) {
|
|
603
|
+
const updateSignalMetrics = new import_async.Event();
|
|
604
|
+
updateSignalMetrics.on(this._ctx, async (networkStatus) => {
|
|
605
|
+
(0, import_log.log)("send signal metrics", void 0, {
|
|
606
|
+
F: __dxlog_file3,
|
|
607
|
+
L: 250,
|
|
608
|
+
S: this,
|
|
609
|
+
C: (f, a) => f(...a)
|
|
610
|
+
});
|
|
611
|
+
networkStatus.signaling.forEach(({ server, state }) => {
|
|
612
|
+
this.gauge("dxos.client.network.signal.connectionState", state, {
|
|
613
|
+
server
|
|
614
|
+
});
|
|
615
|
+
});
|
|
616
|
+
let swarmCount = 0;
|
|
617
|
+
const connectionStates = /* @__PURE__ */ new Map();
|
|
618
|
+
for (const state in import_network_manager.ConnectionState) {
|
|
619
|
+
connectionStates.set(state, 0);
|
|
620
|
+
}
|
|
621
|
+
let totalReadBufferSize = 0;
|
|
622
|
+
let totalWriteBufferSize = 0;
|
|
623
|
+
let totalChannelBufferSize = 0;
|
|
624
|
+
networkStatus.connectionInfo?.forEach((connectionInfo) => {
|
|
625
|
+
swarmCount++;
|
|
626
|
+
for (const conn of connectionInfo.connections ?? []) {
|
|
627
|
+
connectionStates.set(conn.state, (connectionStates.get(conn.state) ?? 0) + 1);
|
|
628
|
+
totalReadBufferSize += conn.readBufferSize ?? 0;
|
|
629
|
+
totalWriteBufferSize += conn.writeBufferSize ?? 0;
|
|
630
|
+
for (const stream of conn.streams ?? []) {
|
|
631
|
+
totalChannelBufferSize += stream.writeBufferSize ?? 0;
|
|
632
|
+
}
|
|
633
|
+
}
|
|
634
|
+
this.gauge("dxos.client.network.swarm.count", swarmCount);
|
|
635
|
+
for (const state in import_network_manager.ConnectionState) {
|
|
636
|
+
this.gauge("dxos.client.network.connection.count", connectionStates.get(state) ?? 0, {
|
|
637
|
+
state
|
|
638
|
+
});
|
|
639
|
+
}
|
|
640
|
+
this.gauge("dxox.client.network.totalReadBufferSize", totalReadBufferSize);
|
|
641
|
+
this.gauge("dxos.client.network.totalWriteBufferSize", totalWriteBufferSize);
|
|
642
|
+
this.gauge("dxos.client.network.totalChannelBufferSize", totalChannelBufferSize);
|
|
643
|
+
});
|
|
644
|
+
});
|
|
645
|
+
client.services.services.NetworkService?.queryStatus().subscribe((networkStatus) => {
|
|
646
|
+
updateSignalMetrics.emit(networkStatus);
|
|
647
|
+
});
|
|
648
|
+
}
|
|
649
|
+
startSpacesMetrics(client, namespace) {
|
|
650
|
+
const spaces = client.spaces.get();
|
|
651
|
+
const subscriptions = /* @__PURE__ */ new Map();
|
|
652
|
+
this._ctx.onDispose(() => subscriptions.forEach((subscription) => subscription.unsubscribe()));
|
|
653
|
+
const updateSpaceMetrics = new import_async.Event().debounce(SPACE_METRICS_MIN_INTERVAL);
|
|
654
|
+
updateSpaceMetrics.on(this._ctx, async () => {
|
|
655
|
+
(0, import_log.log)("send space update", void 0, {
|
|
656
|
+
F: __dxlog_file3,
|
|
657
|
+
L: 302,
|
|
658
|
+
S: this,
|
|
659
|
+
C: (f, a) => f(...a)
|
|
660
|
+
});
|
|
661
|
+
for (const data of mapSpaces(spaces, {
|
|
662
|
+
truncateKeys: true
|
|
663
|
+
})) {
|
|
664
|
+
this.gauge("dxos.client.space.members", data.members, {
|
|
665
|
+
key: data.key
|
|
666
|
+
});
|
|
667
|
+
this.gauge("dxos.client.space.objects", data.objects, {
|
|
668
|
+
key: data.key
|
|
669
|
+
});
|
|
670
|
+
this.gauge("dxos.client.space.epoch", data.epoch, {
|
|
671
|
+
key: data.key
|
|
672
|
+
});
|
|
673
|
+
this.gauge("dxos.client.space.currentDataMutations", data.currentDataMutations, {
|
|
674
|
+
key: data.key
|
|
675
|
+
});
|
|
676
|
+
this.event({
|
|
677
|
+
identityId: getTelemetryIdentifier(client),
|
|
678
|
+
name: `${namespace}.space.update`,
|
|
679
|
+
properties: data
|
|
680
|
+
});
|
|
681
|
+
}
|
|
682
|
+
});
|
|
683
|
+
const subscribeToSpaceUpdate = (space) => space.pipeline.subscribe({
|
|
684
|
+
next: () => {
|
|
685
|
+
updateSpaceMetrics.emit();
|
|
686
|
+
}
|
|
687
|
+
});
|
|
688
|
+
spaces.forEach((space) => {
|
|
689
|
+
subscriptions.set(space.key.toHex(), subscribeToSpaceUpdate(space));
|
|
690
|
+
});
|
|
691
|
+
client.spaces.subscribe({
|
|
692
|
+
next: async (spaces2) => {
|
|
693
|
+
spaces2.filter((space) => !subscriptions.has(space.key.toHex())).forEach((space) => {
|
|
694
|
+
subscriptions.set(space.key.toHex(), subscribeToSpaceUpdate(space));
|
|
695
|
+
});
|
|
696
|
+
}
|
|
697
|
+
});
|
|
698
|
+
(0, import_async.scheduleTaskInterval)(this._ctx, async () => updateSpaceMetrics.emit(), DATADOG_IDLE_INTERVAL);
|
|
699
|
+
}
|
|
700
|
+
async startRuntimeMetrics(client, frequency = DATADOG_IDLE_INTERVAL) {
|
|
701
|
+
const platform = await client.services.services.SystemService?.getPlatform();
|
|
702
|
+
(0, import_invariant.invariant)(platform, "platform is required", {
|
|
703
|
+
F: __dxlog_file3,
|
|
704
|
+
L: 345,
|
|
705
|
+
S: this,
|
|
706
|
+
A: [
|
|
707
|
+
"platform",
|
|
708
|
+
"'platform is required'"
|
|
709
|
+
]
|
|
710
|
+
});
|
|
711
|
+
this.setTag("platform_type", import_services.Platform.PLATFORM_TYPE[platform.type].toLowerCase());
|
|
712
|
+
if (this._mode === "full") {
|
|
713
|
+
if (platform.platform) {
|
|
714
|
+
this.setTag("platform", platform.platform);
|
|
715
|
+
}
|
|
716
|
+
if (platform.arch) {
|
|
717
|
+
this.setTag("arch", platform.arch);
|
|
718
|
+
}
|
|
719
|
+
if (platform.runtime) {
|
|
720
|
+
this.setTag("runtime", platform.runtime);
|
|
721
|
+
}
|
|
722
|
+
}
|
|
723
|
+
(0, import_async.scheduleTaskInterval)(this._ctx, async () => {
|
|
724
|
+
(0, import_log.log)("platform", void 0, {
|
|
725
|
+
F: __dxlog_file3,
|
|
726
|
+
L: 363,
|
|
727
|
+
S: this,
|
|
728
|
+
C: (f, a) => f(...a)
|
|
729
|
+
});
|
|
730
|
+
client.services.services.SystemService?.getPlatform().then((platform2) => {
|
|
731
|
+
(0, import_log.log)("platform", {
|
|
732
|
+
platform: platform2
|
|
733
|
+
}, {
|
|
734
|
+
F: __dxlog_file3,
|
|
735
|
+
L: 366,
|
|
736
|
+
S: this,
|
|
737
|
+
C: (f, a) => f(...a)
|
|
738
|
+
});
|
|
739
|
+
if (platform2.memory) {
|
|
740
|
+
this.gauge("dxos.client.runtime.rss", platform2.memory.rss);
|
|
741
|
+
this.gauge("dxos.client.runtime.heapTotal", platform2.memory.heapTotal);
|
|
742
|
+
this.gauge("dxos.client.runtime.heapUsed", platform2.memory.heapUsed);
|
|
743
|
+
}
|
|
744
|
+
}).catch((error) => (0, import_log.log)("platform error", {
|
|
745
|
+
error
|
|
746
|
+
}, {
|
|
747
|
+
F: __dxlog_file3,
|
|
748
|
+
L: 373,
|
|
749
|
+
S: this,
|
|
750
|
+
C: (f, a) => f(...a)
|
|
751
|
+
}));
|
|
752
|
+
}, frequency);
|
|
753
|
+
}
|
|
754
|
+
//
|
|
755
|
+
// Telemetry
|
|
756
|
+
//
|
|
757
|
+
_initTelemetry() {
|
|
758
|
+
if (this._secrets.TELEMETRY_API_KEY && this._mode !== "disabled") {
|
|
759
|
+
this._telemetry = new import_chunk_BHF4PKAP.SegmentTelemetry({
|
|
760
|
+
apiKey: this._secrets.TELEMETRY_API_KEY,
|
|
761
|
+
batchSize: this._telemetryBatchSize,
|
|
762
|
+
getTags: () => Object.fromEntries(Array.from(this._tags).filter(([key, value]) => {
|
|
763
|
+
return value.scope === "all" || value.scope === "telemetry";
|
|
764
|
+
}).map(([key, value]) => [
|
|
765
|
+
key,
|
|
766
|
+
value.value
|
|
767
|
+
]))
|
|
768
|
+
});
|
|
769
|
+
} else {
|
|
770
|
+
(0, import_log.log)("segment disabled", void 0, {
|
|
771
|
+
F: __dxlog_file3,
|
|
772
|
+
L: 398,
|
|
773
|
+
S: this,
|
|
774
|
+
C: (f, a) => f(...a)
|
|
775
|
+
});
|
|
776
|
+
}
|
|
777
|
+
}
|
|
778
|
+
/**
|
|
779
|
+
* A telemetry event.
|
|
780
|
+
*
|
|
781
|
+
* The default implementation uses Segment.
|
|
782
|
+
*/
|
|
783
|
+
event(options) {
|
|
784
|
+
this._telemetry?.event(options);
|
|
785
|
+
}
|
|
786
|
+
/**
|
|
787
|
+
* A telemetry page view.
|
|
788
|
+
*
|
|
789
|
+
* The default implementation uses Segment.
|
|
790
|
+
*/
|
|
791
|
+
page(options) {
|
|
792
|
+
this._telemetry?.page(options);
|
|
793
|
+
}
|
|
794
|
+
//
|
|
795
|
+
// Error Logs
|
|
796
|
+
//
|
|
797
|
+
_initErrorLogs() {
|
|
798
|
+
if (this._secrets.SENTRY_DESTINATION && this._mode !== "disabled") {
|
|
799
|
+
import_log.log.info("Initializing Sentry", {
|
|
800
|
+
dest: this._secrets.SENTRY_DESTINATION,
|
|
801
|
+
options: this._errorReportingOptions
|
|
802
|
+
}, {
|
|
803
|
+
F: __dxlog_file3,
|
|
804
|
+
L: 427,
|
|
805
|
+
S: this,
|
|
806
|
+
C: (f, a) => f(...a)
|
|
807
|
+
});
|
|
808
|
+
(0, import_chunk_FSAOBKO2.init)({
|
|
809
|
+
...this._errorReportingOptions,
|
|
810
|
+
destination: this._secrets.SENTRY_DESTINATION,
|
|
811
|
+
scrubFilenames: this._mode !== "full"
|
|
812
|
+
});
|
|
813
|
+
if (this._errorReportingOptions?.tracing) {
|
|
814
|
+
(0, import_chunk_FSAOBKO2.configureTracing)();
|
|
815
|
+
}
|
|
816
|
+
if (this._errorLogProcessor) {
|
|
817
|
+
(0, import_chunk_FSAOBKO2.enableSentryLogProcessor)();
|
|
818
|
+
}
|
|
819
|
+
this._tags.forEach((v, k) => {
|
|
820
|
+
if (v.scope === "all" || v.scope === "errors") {
|
|
821
|
+
(0, import_chunk_FSAOBKO2.setTag)(k, v.value);
|
|
822
|
+
}
|
|
823
|
+
});
|
|
824
|
+
} else {
|
|
825
|
+
(0, import_log.log)("sentry disabled", void 0, {
|
|
826
|
+
F: __dxlog_file3,
|
|
827
|
+
L: 450,
|
|
828
|
+
S: this,
|
|
829
|
+
C: (f, a) => f(...a)
|
|
830
|
+
});
|
|
831
|
+
}
|
|
832
|
+
}
|
|
833
|
+
/**
|
|
834
|
+
* Manually capture an exception.
|
|
835
|
+
*
|
|
836
|
+
* The default implementation uses Sentry.
|
|
837
|
+
*/
|
|
838
|
+
captureException(err) {
|
|
839
|
+
if (this.enabled) {
|
|
840
|
+
(0, import_chunk_FSAOBKO2.captureException)(err);
|
|
841
|
+
}
|
|
842
|
+
}
|
|
843
|
+
};
|
|
844
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
845
|
+
0 && (module.exports = {
|
|
846
|
+
OBSERVABILITY_DISABLED_KEY,
|
|
847
|
+
OBSERVABILITY_GROUP_KEY,
|
|
848
|
+
Observability,
|
|
849
|
+
getObservabilityGroup,
|
|
850
|
+
getObservabilityState,
|
|
851
|
+
getTelemetryIdentifier,
|
|
852
|
+
initializeAppObservability,
|
|
853
|
+
initializeNodeObservability,
|
|
854
|
+
isObservabilityDisabled,
|
|
855
|
+
mapSpaces,
|
|
856
|
+
setupTelemetryListeners,
|
|
857
|
+
showObservabilityBanner,
|
|
858
|
+
storeObservabilityDisabled,
|
|
859
|
+
storeObservabilityGroup
|
|
860
|
+
});
|
|
861
|
+
//# sourceMappingURL=chunk-CBMRJXSL.cjs.map
|