@dxos/observability 0.3.11-next.e28df4f → 0.3.11-next.ee2b64c
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-ROSK6U3K.mjs → chunk-HPGC4HC7.mjs} +3 -3
- package/dist/lib/browser/chunk-HPGC4HC7.mjs.map +7 -0
- package/dist/lib/browser/{chunk-STWCJK52.mjs → chunk-OCQVYNE3.mjs} +223 -129
- 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 +9 -5
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/browser/observability-QNG5QON4.mjs +10 -0
- package/dist/lib/browser/segment/index.mjs +1 -1
- package/dist/lib/node/{chunk-ARUBPK2W.cjs → chunk-BHF4PKAP.cjs} +6 -6
- package/dist/lib/node/chunk-BHF4PKAP.cjs.map +7 -0
- package/dist/lib/node/{chunk-DE7OVD7T.cjs → chunk-CBMRJXSL.cjs} +211 -119
- 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 +20 -16
- package/dist/lib/node/index.cjs.map +2 -2
- package/dist/lib/node/meta.json +1 -1
- package/dist/lib/node/{observability-YMIQHLME.cjs → observability-JMKBRR4L.cjs} +8 -8
- package/dist/lib/node/observability-JMKBRR4L.cjs.map +7 -0
- package/dist/lib/node/segment/index.cjs +2 -2
- package/dist/lib/node/segment/index.cjs.map +1 -1
- 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/{app-observability.d.ts → browser-observability.d.ts} +4 -6
- package/dist/types/src/helpers/browser-observability.d.ts.map +1 -0
- package/dist/types/src/helpers/{app-observability.js → browser-observability.js} +22 -51
- 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 +3 -1
- package/dist/types/src/helpers/index.d.ts.map +1 -1
- package/dist/types/src/helpers/index.js +3 -1
- package/dist/types/src/helpers/index.js.map +1 -1
- 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.map +1 -1
- package/dist/types/src/helpers/setup-telemetry-listeners.js +7 -12
- package/dist/types/src/helpers/setup-telemetry-listeners.js.map +1 -1
- package/dist/types/src/observability.d.ts +5 -4
- package/dist/types/src/observability.d.ts.map +1 -1
- package/dist/types/src/observability.js +29 -16
- 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 +17 -14
- package/src/datadog/metrics.ts +3 -5
- package/src/helpers/{app-observability.ts → browser-observability.ts} +26 -54
- package/src/helpers/common.ts +25 -0
- package/src/helpers/index.ts +3 -1
- package/src/helpers/node-observability.ts +151 -0
- package/src/helpers/setup-telemetry-listeners.ts +2 -7
- package/src/observability.ts +40 -20
- package/src/segment/browser.ts +3 -3
- package/src/segment/node.ts +3 -3
- package/src/segment/types.ts +1 -1
- package/dist/lib/browser/chunk-ROSK6U3K.mjs.map +0 -7
- package/dist/lib/browser/chunk-STWCJK52.mjs.map +0 -7
- package/dist/lib/browser/observability-XIDFB6PJ.mjs +0 -10
- package/dist/lib/node/chunk-ARUBPK2W.cjs.map +0 -7
- package/dist/lib/node/chunk-DE7OVD7T.cjs.map +0 -7
- package/dist/lib/node/observability-YMIQHLME.cjs.map +0 -7
- package/dist/types/src/helpers/app-observability.d.ts.map +0 -1
- package/dist/types/src/helpers/app-observability.js.map +0 -1
- /package/dist/lib/browser/{observability-XIDFB6PJ.mjs.map → observability-QNG5QON4.mjs.map} +0 -0
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import {
|
|
2
2
|
DatadogMetrics
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-6ZTMPKEG.mjs";
|
|
4
4
|
import {
|
|
5
5
|
SegmentTelemetry
|
|
6
|
-
} from "./chunk-
|
|
6
|
+
} from "./chunk-HPGC4HC7.mjs";
|
|
7
7
|
import {
|
|
8
8
|
captureException,
|
|
9
9
|
configureTracing,
|
|
@@ -16,7 +16,7 @@ import {
|
|
|
16
16
|
import { Event, scheduleTaskInterval } from "@dxos/async";
|
|
17
17
|
import { Context } from "@dxos/context";
|
|
18
18
|
import { invariant } from "@dxos/invariant";
|
|
19
|
-
import { log as
|
|
19
|
+
import { log as log3 } from "@dxos/log";
|
|
20
20
|
import { ConnectionState } from "@dxos/network-manager";
|
|
21
21
|
import { DeviceKind, Platform } from "@dxos/protocols/proto/dxos/client/services";
|
|
22
22
|
import { isNode } from "@dxos/util";
|
|
@@ -30,46 +30,19 @@ var cli_observability_secrets_default = {
|
|
|
30
30
|
DATADOG_APP_KEY: null
|
|
31
31
|
};
|
|
32
32
|
|
|
33
|
-
// packages/sdk/observability/src/helpers/
|
|
33
|
+
// packages/sdk/observability/src/helpers/browser-observability.ts
|
|
34
34
|
import * as localForage from "localforage";
|
|
35
35
|
import { log } from "@dxos/log";
|
|
36
|
-
var __dxlog_file = "/home/runner/work/dxos/dxos/packages/sdk/observability/src/helpers/
|
|
37
|
-
var
|
|
38
|
-
var
|
|
39
|
-
var OBSERVABILITY_GROUP_KEY = "telemetry-group";
|
|
40
|
-
if (typeof navigator !== "undefined" && navigator.storage?.estimate) {
|
|
41
|
-
setInterval(async () => {
|
|
42
|
-
try {
|
|
43
|
-
const storageEstimate = await navigator.storage.estimate();
|
|
44
|
-
BASE_TELEMETRY_PROPERTIES.storageUsage = storageEstimate.usage;
|
|
45
|
-
BASE_TELEMETRY_PROPERTIES.storageQuota = storageEstimate.quota;
|
|
46
|
-
} catch (error) {
|
|
47
|
-
log.warn("Failed to run estimate()", error, {
|
|
48
|
-
F: __dxlog_file,
|
|
49
|
-
L: 27,
|
|
50
|
-
S: void 0,
|
|
51
|
-
C: (f, a) => f(...a)
|
|
52
|
-
});
|
|
53
|
-
}
|
|
54
|
-
}, 1e4);
|
|
55
|
-
}
|
|
56
|
-
var getTelemetryIdentifier = (client) => {
|
|
57
|
-
if (!client?.initialized) {
|
|
58
|
-
return void 0;
|
|
59
|
-
}
|
|
60
|
-
const identity = client.halo.identity.get();
|
|
61
|
-
if (identity) {
|
|
62
|
-
return identity.identityKey.truncate();
|
|
63
|
-
}
|
|
64
|
-
return void 0;
|
|
65
|
-
};
|
|
36
|
+
var __dxlog_file = "/home/runner/work/dxos/dxos/packages/sdk/observability/src/helpers/browser-observability.ts";
|
|
37
|
+
var OBSERVABILITY_DISABLED_KEY = "observability-disabled";
|
|
38
|
+
var OBSERVABILITY_GROUP_KEY = "observability-group";
|
|
66
39
|
var isObservabilityDisabled = async (namespace) => {
|
|
67
40
|
try {
|
|
68
41
|
return await localForage.getItem(`${namespace}:${OBSERVABILITY_DISABLED_KEY}`) === "true";
|
|
69
42
|
} catch (err) {
|
|
70
43
|
log.catch("Failed to check if observability is disabled, assuming it is", err, {
|
|
71
44
|
F: __dxlog_file,
|
|
72
|
-
L:
|
|
45
|
+
L: 24,
|
|
73
46
|
S: void 0,
|
|
74
47
|
C: (f, a) => f(...a)
|
|
75
48
|
});
|
|
@@ -82,7 +55,7 @@ var storeObservabilityDisabled = async (namespace, value) => {
|
|
|
82
55
|
} catch (err) {
|
|
83
56
|
log.catch("Failed to store observability disabled", err, {
|
|
84
57
|
F: __dxlog_file,
|
|
85
|
-
L:
|
|
58
|
+
L: 33,
|
|
86
59
|
S: void 0,
|
|
87
60
|
C: (f, a) => f(...a)
|
|
88
61
|
});
|
|
@@ -94,7 +67,7 @@ var getObservabilityGroup = async (namespace) => {
|
|
|
94
67
|
} catch (err) {
|
|
95
68
|
log.catch("Failed to get observability group", err, {
|
|
96
69
|
F: __dxlog_file,
|
|
97
|
-
L:
|
|
70
|
+
L: 41,
|
|
98
71
|
S: void 0,
|
|
99
72
|
C: (f, a) => f(...a)
|
|
100
73
|
});
|
|
@@ -106,7 +79,7 @@ var storeObservabilityGroup = async (namespace, value) => {
|
|
|
106
79
|
} catch (err) {
|
|
107
80
|
log.catch("Failed to store observability group", err, {
|
|
108
81
|
F: __dxlog_file,
|
|
109
|
-
L:
|
|
82
|
+
L: 49,
|
|
110
83
|
S: void 0,
|
|
111
84
|
C: (f, a) => f(...a)
|
|
112
85
|
});
|
|
@@ -117,18 +90,15 @@ var initializeAppObservability = async ({ namespace, config, mode = "basic", tra
|
|
|
117
90
|
config
|
|
118
91
|
}, {
|
|
119
92
|
F: __dxlog_file,
|
|
120
|
-
L:
|
|
93
|
+
L: 72,
|
|
121
94
|
S: void 0,
|
|
122
95
|
C: (f, a) => f(...a)
|
|
123
96
|
});
|
|
124
97
|
const group = await getObservabilityGroup(namespace) ?? void 0;
|
|
125
98
|
const release = `${namespace}@${config.get("runtime.app.build.version")}`;
|
|
126
99
|
const environment = config.get("runtime.app.env.DX_ENVIRONMENT");
|
|
127
|
-
BASE_TELEMETRY_PROPERTIES.group = group;
|
|
128
|
-
BASE_TELEMETRY_PROPERTIES.release = release;
|
|
129
|
-
BASE_TELEMETRY_PROPERTIES.environment = environment;
|
|
130
100
|
const observabilityDisabled = await isObservabilityDisabled(namespace);
|
|
131
|
-
const { Observability: Observability2 } = await import("./observability-
|
|
101
|
+
const { Observability: Observability2 } = await import("./observability-QNG5QON4.mjs");
|
|
132
102
|
const observability = new Observability2({
|
|
133
103
|
namespace,
|
|
134
104
|
group,
|
|
@@ -151,7 +121,7 @@ var initializeAppObservability = async ({ namespace, config, mode = "basic", tra
|
|
|
151
121
|
observability.setMode("disabled");
|
|
152
122
|
log.info("observability disabled", void 0, {
|
|
153
123
|
F: __dxlog_file,
|
|
154
|
-
L:
|
|
124
|
+
L: 113,
|
|
155
125
|
S: void 0,
|
|
156
126
|
C: (f, a) => f(...a)
|
|
157
127
|
});
|
|
@@ -160,14 +130,14 @@ var initializeAppObservability = async ({ namespace, config, mode = "basic", tra
|
|
|
160
130
|
try {
|
|
161
131
|
const getIPData = async (config2) => {
|
|
162
132
|
const IP_DATA_CACHE_TIMEOUT = 6 * 60 * 60 * 1e3;
|
|
163
|
-
const cachedData = await localForage.getItem("dxos:
|
|
133
|
+
const cachedData = await localForage.getItem("dxos:observability:ipdata");
|
|
164
134
|
if (cachedData && cachedData.timestamp > Date.now() - IP_DATA_CACHE_TIMEOUT) {
|
|
165
135
|
return cachedData.data;
|
|
166
136
|
}
|
|
167
137
|
const IPDATA_API_KEY = config2.get("runtime.app.env.DX_IPDATA_API_KEY");
|
|
168
138
|
if (IPDATA_API_KEY) {
|
|
169
139
|
return fetch(`https://api.ipdata.co?api-key=${IPDATA_API_KEY}`).then((res) => res.json()).then((data) => {
|
|
170
|
-
localForage.setItem("dxos:
|
|
140
|
+
localForage.setItem("dxos:observability:ipdata", {
|
|
171
141
|
data,
|
|
172
142
|
timestamp: Date.now()
|
|
173
143
|
}).catch((err) => observability.captureException(err));
|
|
@@ -175,19 +145,29 @@ var initializeAppObservability = async ({ namespace, config, mode = "basic", tra
|
|
|
175
145
|
}).catch((err) => observability.captureException(err));
|
|
176
146
|
}
|
|
177
147
|
};
|
|
148
|
+
observability.initialize();
|
|
178
149
|
const ipData = await getIPData(config);
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
150
|
+
ipData && observability.addIPDataTelemetryTags(ipData);
|
|
151
|
+
if (typeof navigator !== "undefined" && navigator.storage?.estimate) {
|
|
152
|
+
setInterval(async () => {
|
|
153
|
+
try {
|
|
154
|
+
const storageEstimate = await navigator.storage.estimate();
|
|
155
|
+
storageEstimate.usage && observability.setTag("storageUsage", storageEstimate.usage.toString(), "telemetry");
|
|
156
|
+
storageEstimate.quota && observability.setTag("storageQuota", storageEstimate.quota.toString(), "telemetry");
|
|
157
|
+
} catch (error) {
|
|
158
|
+
log.warn("Failed to run estimate()", error, {
|
|
159
|
+
F: __dxlog_file,
|
|
160
|
+
L: 168,
|
|
161
|
+
S: void 0,
|
|
162
|
+
C: (f, a) => f(...a)
|
|
163
|
+
});
|
|
164
|
+
}
|
|
165
|
+
}, 1e4);
|
|
185
166
|
}
|
|
186
|
-
observability.initialize();
|
|
187
167
|
} catch (err) {
|
|
188
168
|
log.error("Failed to initialize app observability", err, {
|
|
189
169
|
F: __dxlog_file,
|
|
190
|
-
L:
|
|
170
|
+
L: 173,
|
|
191
171
|
S: void 0,
|
|
192
172
|
C: (f, a) => f(...a)
|
|
193
173
|
});
|
|
@@ -195,6 +175,109 @@ var initializeAppObservability = async ({ namespace, config, mode = "basic", tra
|
|
|
195
175
|
return observability;
|
|
196
176
|
};
|
|
197
177
|
|
|
178
|
+
// packages/sdk/observability/src/helpers/common.ts
|
|
179
|
+
var getTelemetryIdentifier = (client) => {
|
|
180
|
+
if (!client?.initialized) {
|
|
181
|
+
return void 0;
|
|
182
|
+
}
|
|
183
|
+
const identity = client.halo.identity.get();
|
|
184
|
+
if (identity) {
|
|
185
|
+
return identity.identityKey.truncate();
|
|
186
|
+
}
|
|
187
|
+
return void 0;
|
|
188
|
+
};
|
|
189
|
+
|
|
190
|
+
// packages/sdk/observability/src/helpers/node-observability.ts
|
|
191
|
+
import yaml from "js-yaml";
|
|
192
|
+
import { existsSync, statSync } from "@dxos/node-std/fs";
|
|
193
|
+
import { mkdir, readFile, writeFile } from "@dxos/node-std/fs/promises";
|
|
194
|
+
import { join } from "@dxos/node-std/path";
|
|
195
|
+
import { v4 as uuid, validate as validateUuid } from "uuid";
|
|
196
|
+
import { log as log2 } from "@dxos/log";
|
|
197
|
+
var __dxlog_file2 = "/home/runner/work/dxos/dxos/packages/sdk/observability/src/helpers/node-observability.ts";
|
|
198
|
+
var showObservabilityBanner = async (configDir, bannercb) => {
|
|
199
|
+
const path = join(configDir, ".observability-banner-printed");
|
|
200
|
+
if (existsSync(path)) {
|
|
201
|
+
return;
|
|
202
|
+
}
|
|
203
|
+
bannercb(
|
|
204
|
+
// eslint-disable-next-line no-multi-str
|
|
205
|
+
"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."
|
|
206
|
+
);
|
|
207
|
+
await writeFile(path, "", "utf-8");
|
|
208
|
+
};
|
|
209
|
+
var getObservabilityState = async (configDir) => {
|
|
210
|
+
if (existsSync(configDir)) {
|
|
211
|
+
if (!statSync(configDir).isDirectory()) {
|
|
212
|
+
throw new Error(`Config directory ${configDir} exists but is not a directory`);
|
|
213
|
+
}
|
|
214
|
+
} else {
|
|
215
|
+
await mkdir(configDir, {
|
|
216
|
+
recursive: true
|
|
217
|
+
});
|
|
218
|
+
}
|
|
219
|
+
const idPath = join(configDir, "observability.yml");
|
|
220
|
+
if (existsSync(idPath)) {
|
|
221
|
+
const context = await readFile(idPath, "utf-8");
|
|
222
|
+
return validate(context) ?? initializeState(idPath);
|
|
223
|
+
}
|
|
224
|
+
return initializeState(idPath);
|
|
225
|
+
};
|
|
226
|
+
var initializeState = async (idPath) => {
|
|
227
|
+
const observabilityState = {
|
|
228
|
+
installationId: uuid(),
|
|
229
|
+
group: process.env.DX_TELEMETRY_GROUP ?? void 0,
|
|
230
|
+
mode: process.env.DX_DISABLE_TELEMETRY ? "disabled" : process.env.DX_TELEMETRY_MODE ?? "basic"
|
|
231
|
+
};
|
|
232
|
+
await writeFile(idPath, "# This file is automatically generated by the @dxos/cli.\n" + yaml.dump(observabilityState), "utf-8");
|
|
233
|
+
return observabilityState;
|
|
234
|
+
};
|
|
235
|
+
var validate = (contextString) => {
|
|
236
|
+
const context = yaml.load(contextString);
|
|
237
|
+
if (Boolean(context.installationId) && validateUuid(context.installationId)) {
|
|
238
|
+
return {
|
|
239
|
+
...context,
|
|
240
|
+
mode: process.env.DX_DISABLE_TELEMETRY ? "disabled" : context.mode ?? "basic"
|
|
241
|
+
};
|
|
242
|
+
}
|
|
243
|
+
};
|
|
244
|
+
var initializeNodeObservability = async ({ namespace, config, installationId, group, mode = "basic", tracingEnable = true, replayEnable = true }) => {
|
|
245
|
+
log2("initializeCliObservability", {
|
|
246
|
+
config
|
|
247
|
+
}, {
|
|
248
|
+
F: __dxlog_file2,
|
|
249
|
+
L: 120,
|
|
250
|
+
S: void 0,
|
|
251
|
+
C: (f, a) => f(...a)
|
|
252
|
+
});
|
|
253
|
+
const release = `${namespace}@${config.get("runtime.app.build.version")}`;
|
|
254
|
+
const environment = config.get("runtime.app.env.DX_ENVIRONMENT");
|
|
255
|
+
const observability = new Observability({
|
|
256
|
+
namespace,
|
|
257
|
+
group,
|
|
258
|
+
mode,
|
|
259
|
+
errorLog: {
|
|
260
|
+
sentryInitOptions: {
|
|
261
|
+
environment,
|
|
262
|
+
release,
|
|
263
|
+
// TODO(wittjosiah): Configure this.
|
|
264
|
+
sampleRate: 1
|
|
265
|
+
},
|
|
266
|
+
logProcessor: true
|
|
267
|
+
}
|
|
268
|
+
});
|
|
269
|
+
observability.setTag("installationId", installationId);
|
|
270
|
+
const IPDATA_API_KEY = config.get("runtime.app.env.DX_IPDATA_API_KEY");
|
|
271
|
+
try {
|
|
272
|
+
const res = await fetch(`https://api.ipdata.co/?api-key=${IPDATA_API_KEY}`);
|
|
273
|
+
const ipData = await res.json();
|
|
274
|
+
ipData && observability.addIPDataTelemetryTags(ipData);
|
|
275
|
+
} catch (err) {
|
|
276
|
+
observability?.captureException(err);
|
|
277
|
+
}
|
|
278
|
+
return observability;
|
|
279
|
+
};
|
|
280
|
+
|
|
198
281
|
// packages/sdk/observability/src/helpers/map-spaces.ts
|
|
199
282
|
var mapSpaces = (spaces, options = {
|
|
200
283
|
verbose: false,
|
|
@@ -231,14 +314,13 @@ var lastFocusEvent = /* @__PURE__ */ new Date();
|
|
|
231
314
|
var totalTime = 0;
|
|
232
315
|
var setupTelemetryListeners = (namespace, client, observability) => {
|
|
233
316
|
const clickCallback = (event) => {
|
|
234
|
-
if (
|
|
317
|
+
if (observability.group === "dxos" && event.target && !event.target.id) {
|
|
235
318
|
console.warn("Click event on element without id:", event.target);
|
|
236
319
|
}
|
|
237
320
|
setTimeout(() => observability.event({
|
|
238
321
|
identityId: getTelemetryIdentifier(client),
|
|
239
322
|
name: `${namespace}.window.click`,
|
|
240
323
|
properties: {
|
|
241
|
-
...BASE_TELEMETRY_PROPERTIES,
|
|
242
324
|
href: window.location.href,
|
|
243
325
|
id: event.target?.id,
|
|
244
326
|
path: event.path?.filter((el) => Boolean(el.tagName)).map((el) => `${el.tagName.toLowerCase()}${el.id ? `#${el.id}` : ""}`).reverse().join(">")
|
|
@@ -251,7 +333,6 @@ var setupTelemetryListeners = (namespace, client, observability) => {
|
|
|
251
333
|
identityId: getTelemetryIdentifier(client),
|
|
252
334
|
name: `${namespace}.window.focus`,
|
|
253
335
|
properties: {
|
|
254
|
-
...BASE_TELEMETRY_PROPERTIES,
|
|
255
336
|
href: window.location.href,
|
|
256
337
|
timeAway: now.getTime() - lastFocusEvent.getTime()
|
|
257
338
|
}
|
|
@@ -265,7 +346,6 @@ var setupTelemetryListeners = (namespace, client, observability) => {
|
|
|
265
346
|
identityId: getTelemetryIdentifier(client),
|
|
266
347
|
name: `${namespace}.window.blur`,
|
|
267
348
|
properties: {
|
|
268
|
-
...BASE_TELEMETRY_PROPERTIES,
|
|
269
349
|
href: window.location.href,
|
|
270
350
|
timeSpent
|
|
271
351
|
}
|
|
@@ -278,7 +358,6 @@ var setupTelemetryListeners = (namespace, client, observability) => {
|
|
|
278
358
|
identityId: getTelemetryIdentifier(client),
|
|
279
359
|
name: `${namespace}.page.unload`,
|
|
280
360
|
properties: {
|
|
281
|
-
...BASE_TELEMETRY_PROPERTIES,
|
|
282
361
|
href: window.location.href,
|
|
283
362
|
timeSpent: totalTime
|
|
284
363
|
}
|
|
@@ -289,7 +368,6 @@ var setupTelemetryListeners = (namespace, client, observability) => {
|
|
|
289
368
|
identityId: getTelemetryIdentifier(client),
|
|
290
369
|
name: `${namespace}.window.error`,
|
|
291
370
|
properties: {
|
|
292
|
-
...BASE_TELEMETRY_PROPERTIES,
|
|
293
371
|
href: window.location.href,
|
|
294
372
|
message: event.message,
|
|
295
373
|
filename: event.filename,
|
|
@@ -312,15 +390,9 @@ var setupTelemetryListeners = (namespace, client, observability) => {
|
|
|
312
390
|
};
|
|
313
391
|
|
|
314
392
|
// packages/sdk/observability/src/observability.ts
|
|
315
|
-
var
|
|
393
|
+
var __dxlog_file3 = "/home/runner/work/dxos/dxos/packages/sdk/observability/src/observability.ts";
|
|
316
394
|
var SPACE_METRICS_MIN_INTERVAL = 1e3 * 60;
|
|
317
395
|
var DATADOG_IDLE_INTERVAL = 1e3 * 60 * 1;
|
|
318
|
-
var ERROR_TAGS = [
|
|
319
|
-
"identityKey",
|
|
320
|
-
"username",
|
|
321
|
-
"deviceKey",
|
|
322
|
-
"group"
|
|
323
|
-
];
|
|
324
396
|
var Observability = class {
|
|
325
397
|
// TODO(nf): make platform a required extension?
|
|
326
398
|
constructor({ namespace, config, secrets, group, mode, telemetry, errorLog }) {
|
|
@@ -328,6 +400,13 @@ var Observability = class {
|
|
|
328
400
|
// TODO(nf): accept upstream context?
|
|
329
401
|
this._ctx = new Context();
|
|
330
402
|
this._tags = /* @__PURE__ */ new Map();
|
|
403
|
+
this.addIPDataTelemetryTags = (ipData) => {
|
|
404
|
+
this.setTag("city", ipData.city, "telemetry");
|
|
405
|
+
this.setTag("region", ipData.region, "telemetry");
|
|
406
|
+
this.setTag("country", ipData.country, "telemetry");
|
|
407
|
+
ipData.latitude && this.setTag("latitude", ipData.latitude.toString(), "telemetry");
|
|
408
|
+
ipData.longitude && this.setTag("longitude", ipData.longitude.toString(), "telemetry");
|
|
409
|
+
};
|
|
331
410
|
this._namespace = namespace;
|
|
332
411
|
this._config = config;
|
|
333
412
|
this._mode = mode ?? "disabled";
|
|
@@ -348,20 +427,20 @@ var Observability = class {
|
|
|
348
427
|
return cli_observability_secrets_default;
|
|
349
428
|
} else {
|
|
350
429
|
invariant(config, "runtime config is required", {
|
|
351
|
-
F:
|
|
352
|
-
L:
|
|
430
|
+
F: __dxlog_file3,
|
|
431
|
+
L: 115,
|
|
353
432
|
S: this,
|
|
354
433
|
A: [
|
|
355
434
|
"config",
|
|
356
435
|
"'runtime config is required'"
|
|
357
436
|
]
|
|
358
437
|
});
|
|
359
|
-
|
|
438
|
+
log3("config", {
|
|
360
439
|
rtc: this._secrets,
|
|
361
440
|
config
|
|
362
441
|
}, {
|
|
363
|
-
F:
|
|
364
|
-
L:
|
|
442
|
+
F: __dxlog_file3,
|
|
443
|
+
L: 116,
|
|
365
444
|
S: this,
|
|
366
445
|
C: (f, a) => f(...a)
|
|
367
446
|
});
|
|
@@ -391,30 +470,36 @@ var Observability = class {
|
|
|
391
470
|
get mode() {
|
|
392
471
|
return this._mode;
|
|
393
472
|
}
|
|
473
|
+
get group() {
|
|
474
|
+
return this._group;
|
|
475
|
+
}
|
|
394
476
|
get enabled() {
|
|
395
477
|
return this._mode !== "disabled";
|
|
396
478
|
}
|
|
397
479
|
//
|
|
398
480
|
// Tags
|
|
399
481
|
//
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
*/
|
|
403
|
-
setTag(key, value) {
|
|
404
|
-
if (this.enabled && ERROR_TAGS.includes(key)) {
|
|
482
|
+
setTag(key, value, scope) {
|
|
483
|
+
if (this.enabled && (scope === void 0 || scope === "all" || scope === "errors")) {
|
|
405
484
|
setTag(key, value);
|
|
406
485
|
}
|
|
407
|
-
|
|
486
|
+
if (!scope) {
|
|
487
|
+
scope = "all";
|
|
488
|
+
}
|
|
489
|
+
this._tags.set(key, {
|
|
490
|
+
value,
|
|
491
|
+
scope
|
|
492
|
+
});
|
|
408
493
|
}
|
|
409
494
|
// TODO(wittjosiah): Improve privacy of telemetry identifiers. See `getTelemetryIdentifier`.
|
|
410
495
|
async setIdentityTags(client) {
|
|
411
496
|
client.services.services.IdentityService.queryIdentity().subscribe((idqr) => {
|
|
412
497
|
if (!idqr?.identity?.identityKey) {
|
|
413
|
-
|
|
498
|
+
log3("empty response from identity service", {
|
|
414
499
|
idqr
|
|
415
500
|
}, {
|
|
416
|
-
F:
|
|
417
|
-
L:
|
|
501
|
+
F: __dxlog_file3,
|
|
502
|
+
L: 184,
|
|
418
503
|
S: this,
|
|
419
504
|
C: (f, a) => f(...a)
|
|
420
505
|
});
|
|
@@ -424,19 +509,19 @@ var Observability = class {
|
|
|
424
509
|
});
|
|
425
510
|
client.services.services.DevicesService.queryDevices().subscribe((dqr) => {
|
|
426
511
|
if (!dqr || !dqr.devices || dqr.devices.length === 0) {
|
|
427
|
-
|
|
512
|
+
log3("empty response from device service", {
|
|
428
513
|
device: dqr
|
|
429
514
|
}, {
|
|
430
|
-
F:
|
|
431
|
-
L:
|
|
515
|
+
F: __dxlog_file3,
|
|
516
|
+
L: 193,
|
|
432
517
|
S: this,
|
|
433
518
|
C: (f, a) => f(...a)
|
|
434
519
|
});
|
|
435
520
|
return;
|
|
436
521
|
}
|
|
437
522
|
invariant(dqr, "empty response from device service", {
|
|
438
|
-
F:
|
|
439
|
-
L:
|
|
523
|
+
F: __dxlog_file3,
|
|
524
|
+
L: 196,
|
|
440
525
|
S: this,
|
|
441
526
|
A: [
|
|
442
527
|
"dqr",
|
|
@@ -445,11 +530,11 @@ var Observability = class {
|
|
|
445
530
|
});
|
|
446
531
|
const thisDevice = dqr.devices.find((device) => device.kind === DeviceKind.CURRENT);
|
|
447
532
|
if (!thisDevice) {
|
|
448
|
-
|
|
533
|
+
log3("no current device", {
|
|
449
534
|
device: dqr
|
|
450
535
|
}, {
|
|
451
|
-
F:
|
|
452
|
-
L:
|
|
536
|
+
F: __dxlog_file3,
|
|
537
|
+
L: 200,
|
|
453
538
|
S: this,
|
|
454
539
|
C: (f, a) => f(...a)
|
|
455
540
|
});
|
|
@@ -468,14 +553,19 @@ var Observability = class {
|
|
|
468
553
|
if (this.enabled && this._secrets.DATADOG_API_KEY) {
|
|
469
554
|
this._metrics = new DatadogMetrics({
|
|
470
555
|
apiKey: this._secrets.DATADOG_API_KEY,
|
|
471
|
-
getTags: () => this._tags,
|
|
556
|
+
getTags: () => Object.fromEntries(Array.from(this._tags).filter(([key, value]) => {
|
|
557
|
+
return value.scope === "all" || value.scope === "metrics";
|
|
558
|
+
}).map(([key, value]) => [
|
|
559
|
+
key,
|
|
560
|
+
value.value
|
|
561
|
+
])),
|
|
472
562
|
// TODO(nf): move/refactor from telementryContext, needed to read CORS proxy
|
|
473
563
|
config: this._config
|
|
474
564
|
});
|
|
475
565
|
} else {
|
|
476
|
-
|
|
477
|
-
F:
|
|
478
|
-
L:
|
|
566
|
+
log3("datadog disabled", void 0, {
|
|
567
|
+
F: __dxlog_file3,
|
|
568
|
+
L: 230,
|
|
479
569
|
S: this,
|
|
480
570
|
C: (f, a) => f(...a)
|
|
481
571
|
});
|
|
@@ -493,9 +583,9 @@ var Observability = class {
|
|
|
493
583
|
startNetworkMetrics(client) {
|
|
494
584
|
const updateSignalMetrics = new Event();
|
|
495
585
|
updateSignalMetrics.on(this._ctx, async (networkStatus) => {
|
|
496
|
-
|
|
497
|
-
F:
|
|
498
|
-
L:
|
|
586
|
+
log3("send signal metrics", void 0, {
|
|
587
|
+
F: __dxlog_file3,
|
|
588
|
+
L: 250,
|
|
499
589
|
S: this,
|
|
500
590
|
C: (f, a) => f(...a)
|
|
501
591
|
});
|
|
@@ -543,9 +633,9 @@ var Observability = class {
|
|
|
543
633
|
this._ctx.onDispose(() => subscriptions.forEach((subscription) => subscription.unsubscribe()));
|
|
544
634
|
const updateSpaceMetrics = new Event().debounce(SPACE_METRICS_MIN_INTERVAL);
|
|
545
635
|
updateSpaceMetrics.on(this._ctx, async () => {
|
|
546
|
-
|
|
547
|
-
F:
|
|
548
|
-
L:
|
|
636
|
+
log3("send space update", void 0, {
|
|
637
|
+
F: __dxlog_file3,
|
|
638
|
+
L: 302,
|
|
549
639
|
S: this,
|
|
550
640
|
C: (f, a) => f(...a)
|
|
551
641
|
});
|
|
@@ -567,10 +657,7 @@ var Observability = class {
|
|
|
567
657
|
this.event({
|
|
568
658
|
identityId: getTelemetryIdentifier(client),
|
|
569
659
|
name: `${namespace}.space.update`,
|
|
570
|
-
properties:
|
|
571
|
-
...BASE_TELEMETRY_PROPERTIES,
|
|
572
|
-
...data
|
|
573
|
-
}
|
|
660
|
+
properties: data
|
|
574
661
|
});
|
|
575
662
|
}
|
|
576
663
|
});
|
|
@@ -594,8 +681,8 @@ var Observability = class {
|
|
|
594
681
|
async startRuntimeMetrics(client, frequency = DATADOG_IDLE_INTERVAL) {
|
|
595
682
|
const platform = await client.services.services.SystemService?.getPlatform();
|
|
596
683
|
invariant(platform, "platform is required", {
|
|
597
|
-
F:
|
|
598
|
-
L:
|
|
684
|
+
F: __dxlog_file3,
|
|
685
|
+
L: 345,
|
|
599
686
|
S: this,
|
|
600
687
|
A: [
|
|
601
688
|
"platform",
|
|
@@ -615,18 +702,18 @@ var Observability = class {
|
|
|
615
702
|
}
|
|
616
703
|
}
|
|
617
704
|
scheduleTaskInterval(this._ctx, async () => {
|
|
618
|
-
|
|
619
|
-
F:
|
|
620
|
-
L:
|
|
705
|
+
log3("platform", void 0, {
|
|
706
|
+
F: __dxlog_file3,
|
|
707
|
+
L: 363,
|
|
621
708
|
S: this,
|
|
622
709
|
C: (f, a) => f(...a)
|
|
623
710
|
});
|
|
624
711
|
client.services.services.SystemService?.getPlatform().then((platform2) => {
|
|
625
|
-
|
|
712
|
+
log3("platform", {
|
|
626
713
|
platform: platform2
|
|
627
714
|
}, {
|
|
628
|
-
F:
|
|
629
|
-
L:
|
|
715
|
+
F: __dxlog_file3,
|
|
716
|
+
L: 366,
|
|
630
717
|
S: this,
|
|
631
718
|
C: (f, a) => f(...a)
|
|
632
719
|
});
|
|
@@ -635,11 +722,11 @@ var Observability = class {
|
|
|
635
722
|
this.gauge("dxos.client.runtime.heapTotal", platform2.memory.heapTotal);
|
|
636
723
|
this.gauge("dxos.client.runtime.heapUsed", platform2.memory.heapUsed);
|
|
637
724
|
}
|
|
638
|
-
}).catch((error) =>
|
|
725
|
+
}).catch((error) => log3("platform error", {
|
|
639
726
|
error
|
|
640
727
|
}, {
|
|
641
|
-
F:
|
|
642
|
-
L:
|
|
728
|
+
F: __dxlog_file3,
|
|
729
|
+
L: 373,
|
|
643
730
|
S: this,
|
|
644
731
|
C: (f, a) => f(...a)
|
|
645
732
|
}));
|
|
@@ -653,12 +740,17 @@ var Observability = class {
|
|
|
653
740
|
this._telemetry = new SegmentTelemetry({
|
|
654
741
|
apiKey: this._secrets.TELEMETRY_API_KEY,
|
|
655
742
|
batchSize: this._telemetryBatchSize,
|
|
656
|
-
getTags: () => this._tags
|
|
743
|
+
getTags: () => Object.fromEntries(Array.from(this._tags).filter(([key, value]) => {
|
|
744
|
+
return value.scope === "all" || value.scope === "telemetry";
|
|
745
|
+
}).map(([key, value]) => [
|
|
746
|
+
key,
|
|
747
|
+
value.value
|
|
748
|
+
]))
|
|
657
749
|
});
|
|
658
750
|
} else {
|
|
659
|
-
|
|
660
|
-
F:
|
|
661
|
-
L:
|
|
751
|
+
log3("segment disabled", void 0, {
|
|
752
|
+
F: __dxlog_file3,
|
|
753
|
+
L: 398,
|
|
662
754
|
S: this,
|
|
663
755
|
C: (f, a) => f(...a)
|
|
664
756
|
});
|
|
@@ -685,12 +777,12 @@ var Observability = class {
|
|
|
685
777
|
//
|
|
686
778
|
_initErrorLogs() {
|
|
687
779
|
if (this._secrets.SENTRY_DESTINATION && this._mode !== "disabled") {
|
|
688
|
-
|
|
780
|
+
log3.info("Initializing Sentry", {
|
|
689
781
|
dest: this._secrets.SENTRY_DESTINATION,
|
|
690
782
|
options: this._errorReportingOptions
|
|
691
783
|
}, {
|
|
692
|
-
F:
|
|
693
|
-
L:
|
|
784
|
+
F: __dxlog_file3,
|
|
785
|
+
L: 427,
|
|
694
786
|
S: this,
|
|
695
787
|
C: (f, a) => f(...a)
|
|
696
788
|
});
|
|
@@ -706,14 +798,14 @@ var Observability = class {
|
|
|
706
798
|
enableSentryLogProcessor();
|
|
707
799
|
}
|
|
708
800
|
this._tags.forEach((v, k) => {
|
|
709
|
-
if (
|
|
710
|
-
setTag(k, v);
|
|
801
|
+
if (v.scope === "all" || v.scope === "errors") {
|
|
802
|
+
setTag(k, v.value);
|
|
711
803
|
}
|
|
712
804
|
});
|
|
713
805
|
} else {
|
|
714
|
-
|
|
715
|
-
F:
|
|
716
|
-
L:
|
|
806
|
+
log3("sentry disabled", void 0, {
|
|
807
|
+
F: __dxlog_file3,
|
|
808
|
+
L: 450,
|
|
717
809
|
S: this,
|
|
718
810
|
C: (f, a) => f(...a)
|
|
719
811
|
});
|
|
@@ -733,16 +825,18 @@ var Observability = class {
|
|
|
733
825
|
|
|
734
826
|
export {
|
|
735
827
|
Observability,
|
|
736
|
-
BASE_TELEMETRY_PROPERTIES,
|
|
737
828
|
OBSERVABILITY_DISABLED_KEY,
|
|
738
829
|
OBSERVABILITY_GROUP_KEY,
|
|
739
|
-
getTelemetryIdentifier,
|
|
740
830
|
isObservabilityDisabled,
|
|
741
831
|
storeObservabilityDisabled,
|
|
742
832
|
getObservabilityGroup,
|
|
743
833
|
storeObservabilityGroup,
|
|
744
834
|
initializeAppObservability,
|
|
835
|
+
getTelemetryIdentifier,
|
|
836
|
+
showObservabilityBanner,
|
|
837
|
+
getObservabilityState,
|
|
838
|
+
initializeNodeObservability,
|
|
745
839
|
mapSpaces,
|
|
746
840
|
setupTelemetryListeners
|
|
747
841
|
};
|
|
748
|
-
//# sourceMappingURL=chunk-
|
|
842
|
+
//# sourceMappingURL=chunk-OCQVYNE3.mjs.map
|