@dxos/observability 0.8.4-main.a4bbb77 → 0.8.4-main.ae835ea
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-YTRUOREY.mjs → chunk-USIB5JOP.mjs} +58 -64
- package/dist/lib/browser/{chunk-YTRUOREY.mjs.map → chunk-USIB5JOP.mjs.map} +2 -2
- package/dist/lib/browser/{chunk-ICKR6U3G.mjs → chunk-XNAF22QM.mjs} +25 -38
- package/dist/lib/browser/{chunk-ICKR6U3G.mjs.map → chunk-XNAF22QM.mjs.map} +2 -2
- package/dist/lib/browser/{chunk-LJO63BXO.mjs → chunk-ZI3ZS3PA.mjs} +1 -1
- package/dist/lib/browser/{chunk-LJO63BXO.mjs.map → chunk-ZI3ZS3PA.mjs.map} +1 -1
- package/dist/lib/browser/index.mjs +3 -3
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/browser/observability-AOZNUWZS.mjs +10 -0
- package/dist/lib/browser/{otel-6FVBNA5F.mjs → otel-UH7ZRWC2.mjs} +96 -136
- package/dist/lib/browser/{otel-6FVBNA5F.mjs.map → otel-UH7ZRWC2.mjs.map} +2 -2
- package/dist/lib/browser/segment/index.mjs +2 -2
- package/dist/lib/browser/sentry/index.mjs +1 -1
- package/dist/lib/browser/{sentry-log-processor-RG4CFVGL.mjs → sentry-log-processor-5LSQJMIO.mjs} +56 -72
- package/dist/lib/browser/{sentry-log-processor-RG4CFVGL.mjs.map → sentry-log-processor-5LSQJMIO.mjs.map} +2 -2
- package/dist/lib/node-esm/{chunk-4EWQFQ2F.mjs → chunk-JJS4CBLT.mjs} +58 -64
- package/dist/lib/node-esm/{chunk-4EWQFQ2F.mjs.map → chunk-JJS4CBLT.mjs.map} +2 -2
- package/dist/lib/node-esm/{chunk-24NMRR4E.mjs → chunk-OJV247NY.mjs} +31 -56
- package/dist/lib/node-esm/{chunk-24NMRR4E.mjs.map → chunk-OJV247NY.mjs.map} +2 -2
- package/dist/lib/node-esm/index.mjs +2 -2
- package/dist/lib/node-esm/meta.json +1 -1
- package/dist/lib/node-esm/{observability-DHNVVRC7.mjs → observability-UWX2LAYX.mjs} +3 -3
- package/dist/lib/node-esm/{otel-KHSGBROB.mjs → otel-7PUCFSTY.mjs} +85 -125
- package/dist/lib/node-esm/{otel-KHSGBROB.mjs.map → otel-7PUCFSTY.mjs.map} +2 -2
- package/dist/lib/node-esm/segment/index.mjs +1 -1
- package/dist/lib/node-esm/{sentry-log-processor-3BDS4BB4.mjs → sentry-log-processor-C4UGMAMV.mjs} +55 -71
- package/dist/lib/node-esm/{sentry-log-processor-3BDS4BB4.mjs.map → sentry-log-processor-C4UGMAMV.mjs.map} +2 -2
- package/dist/types/src/sentry/browser.js +1 -1
- package/dist/types/src/sentry/browser.js.map +1 -1
- package/dist/types/tsconfig.tsbuildinfo +1 -1
- package/package.json +15 -18
- package/src/sentry/browser.ts +1 -1
- package/dist/lib/browser/observability-CQGG3MID.mjs +0 -10
- /package/dist/lib/browser/{observability-CQGG3MID.mjs.map → observability-AOZNUWZS.mjs.map} +0 -0
- /package/dist/lib/node-esm/{observability-DHNVVRC7.mjs.map → observability-UWX2LAYX.mjs.map} +0 -0
package/dist/lib/browser/{sentry-log-processor-RG4CFVGL.mjs → sentry-log-processor-5LSQJMIO.mjs}
RENAMED
|
@@ -2,30 +2,69 @@ import {
|
|
|
2
2
|
captureException,
|
|
3
3
|
captureMessage,
|
|
4
4
|
withScope
|
|
5
|
-
} from "./chunk-
|
|
5
|
+
} from "./chunk-ZI3ZS3PA.mjs";
|
|
6
6
|
|
|
7
7
|
// src/sentry/sentry-log-processor.ts
|
|
8
8
|
import { InvariantViolation } from "@dxos/invariant";
|
|
9
9
|
import { LogLevel, shouldLog } from "@dxos/log";
|
|
10
10
|
import { CircularBuffer, getDebugName } from "@dxos/util";
|
|
11
|
-
function _define_property(obj, key, value) {
|
|
12
|
-
if (key in obj) {
|
|
13
|
-
Object.defineProperty(obj, key, {
|
|
14
|
-
value,
|
|
15
|
-
enumerable: true,
|
|
16
|
-
configurable: true,
|
|
17
|
-
writable: true
|
|
18
|
-
});
|
|
19
|
-
} else {
|
|
20
|
-
obj[key] = value;
|
|
21
|
-
}
|
|
22
|
-
return obj;
|
|
23
|
-
}
|
|
24
11
|
var MAX_LOG_BREADCRUMBS = 150;
|
|
25
12
|
var SentryLogProcessor = class {
|
|
13
|
+
_breadcrumbs = new CircularBuffer(MAX_LOG_BREADCRUMBS);
|
|
14
|
+
logProcessor = (config, entry) => {
|
|
15
|
+
const { level, meta, error } = entry;
|
|
16
|
+
if (!shouldLog(entry, config.captureFilters) || meta?.S?.remoteSessionId) {
|
|
17
|
+
if (entry.level > LogLevel.DEBUG) {
|
|
18
|
+
this._addBreadcrumb(void 0, entry.message ?? (entry.error ? entry.error.message ?? String(entry.error) : ""), convertLevel(entry.level), void 0);
|
|
19
|
+
}
|
|
20
|
+
return;
|
|
21
|
+
}
|
|
22
|
+
if (entry.level !== LogLevel.WARN && entry.level !== LogLevel.ERROR) {
|
|
23
|
+
return;
|
|
24
|
+
}
|
|
25
|
+
withScope((scope) => {
|
|
26
|
+
const severity = convertLevel(level);
|
|
27
|
+
scope.setLevel(severity);
|
|
28
|
+
scope.setContext("dxoslog", entry.context ?? null);
|
|
29
|
+
if (meta) {
|
|
30
|
+
scope.setTag("transaction", `${getRelativeFilename(meta.F)}:${meta.L}`);
|
|
31
|
+
if (meta.S?.hostSessionId) {
|
|
32
|
+
scope.setTags({
|
|
33
|
+
service_host_issue: true,
|
|
34
|
+
service_host_session: meta.S?.hostSessionId
|
|
35
|
+
});
|
|
36
|
+
}
|
|
37
|
+
if (!Number.isNaN(meta.S?.uptimeSeconds)) {
|
|
38
|
+
scope.setExtra("uptime_seconds", meta.S?.uptimeSeconds);
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
const extendedMessage = formatMessageForSentry(entry);
|
|
42
|
+
let capturedError = error;
|
|
43
|
+
if (capturedError == null && entry.level === LogLevel.ERROR) {
|
|
44
|
+
capturedError = Object.values(entry.context ?? {}).find((v) => v instanceof Error);
|
|
45
|
+
}
|
|
46
|
+
if (capturedError) {
|
|
47
|
+
if (capturedError instanceof InvariantViolation) {
|
|
48
|
+
scope.setExtra("invariant_violation", true);
|
|
49
|
+
}
|
|
50
|
+
const isMessageDifferentFromStackTrace = error == null;
|
|
51
|
+
if (isMessageDifferentFromStackTrace) {
|
|
52
|
+
scope.setExtra("message", extendedMessage);
|
|
53
|
+
}
|
|
54
|
+
const eventId2 = captureException(capturedError);
|
|
55
|
+
this._addBreadcrumb(eventId2, extendedMessage, severity, entry.context);
|
|
56
|
+
return;
|
|
57
|
+
}
|
|
58
|
+
const message = entry.message ?? (entry.error ? entry.error.message ?? String(entry.error) : "");
|
|
59
|
+
scope.setFingerprint([
|
|
60
|
+
message
|
|
61
|
+
]);
|
|
62
|
+
const eventId = captureMessage(extendedMessage);
|
|
63
|
+
this._addBreadcrumb(eventId, extendedMessage, severity, entry.context);
|
|
64
|
+
});
|
|
65
|
+
};
|
|
26
66
|
addLogBreadcrumbsTo(event) {
|
|
27
|
-
|
|
28
|
-
(_event = event).breadcrumbs ?? (_event.breadcrumbs = []);
|
|
67
|
+
event.breadcrumbs ??= [];
|
|
29
68
|
for (const breadcrumb of this._breadcrumbs) {
|
|
30
69
|
event.breadcrumbs.push(breadcrumb);
|
|
31
70
|
}
|
|
@@ -59,61 +98,6 @@ var SentryLogProcessor = class {
|
|
|
59
98
|
}
|
|
60
99
|
this._breadcrumbs.push(breadcrumb);
|
|
61
100
|
}
|
|
62
|
-
constructor() {
|
|
63
|
-
_define_property(this, "_breadcrumbs", new CircularBuffer(MAX_LOG_BREADCRUMBS));
|
|
64
|
-
_define_property(this, "logProcessor", (config, entry) => {
|
|
65
|
-
const { level, meta, error } = entry;
|
|
66
|
-
if (!shouldLog(entry, config.captureFilters) || meta?.S?.remoteSessionId) {
|
|
67
|
-
if (entry.level > LogLevel.DEBUG) {
|
|
68
|
-
this._addBreadcrumb(void 0, entry.message ?? (entry.error ? entry.error.message ?? String(entry.error) : ""), convertLevel(entry.level), void 0);
|
|
69
|
-
}
|
|
70
|
-
return;
|
|
71
|
-
}
|
|
72
|
-
if (entry.level !== LogLevel.WARN && entry.level !== LogLevel.ERROR) {
|
|
73
|
-
return;
|
|
74
|
-
}
|
|
75
|
-
withScope((scope) => {
|
|
76
|
-
const severity = convertLevel(level);
|
|
77
|
-
scope.setLevel(severity);
|
|
78
|
-
scope.setContext("dxoslog", entry.context ?? null);
|
|
79
|
-
if (meta) {
|
|
80
|
-
scope.setTag("transaction", `${getRelativeFilename(meta.F)}:${meta.L}`);
|
|
81
|
-
if (meta.S?.hostSessionId) {
|
|
82
|
-
scope.setTags({
|
|
83
|
-
service_host_issue: true,
|
|
84
|
-
service_host_session: meta.S?.hostSessionId
|
|
85
|
-
});
|
|
86
|
-
}
|
|
87
|
-
if (!Number.isNaN(meta.S?.uptimeSeconds)) {
|
|
88
|
-
scope.setExtra("uptime_seconds", meta.S?.uptimeSeconds);
|
|
89
|
-
}
|
|
90
|
-
}
|
|
91
|
-
const extendedMessage = formatMessageForSentry(entry);
|
|
92
|
-
let capturedError = error;
|
|
93
|
-
if (capturedError == null && entry.level === LogLevel.ERROR) {
|
|
94
|
-
capturedError = Object.values(entry.context ?? {}).find((v) => v instanceof Error);
|
|
95
|
-
}
|
|
96
|
-
if (capturedError) {
|
|
97
|
-
if (capturedError instanceof InvariantViolation) {
|
|
98
|
-
scope.setExtra("invariant_violation", true);
|
|
99
|
-
}
|
|
100
|
-
const isMessageDifferentFromStackTrace = error == null;
|
|
101
|
-
if (isMessageDifferentFromStackTrace) {
|
|
102
|
-
scope.setExtra("message", extendedMessage);
|
|
103
|
-
}
|
|
104
|
-
const eventId2 = captureException(capturedError);
|
|
105
|
-
this._addBreadcrumb(eventId2, extendedMessage, severity, entry.context);
|
|
106
|
-
return;
|
|
107
|
-
}
|
|
108
|
-
const message = entry.message ?? (entry.error ? entry.error.message ?? String(entry.error) : "");
|
|
109
|
-
scope.setFingerprint([
|
|
110
|
-
message
|
|
111
|
-
]);
|
|
112
|
-
const eventId = captureMessage(extendedMessage);
|
|
113
|
-
this._addBreadcrumb(eventId, extendedMessage, severity, entry.context);
|
|
114
|
-
});
|
|
115
|
-
});
|
|
116
|
-
}
|
|
117
101
|
};
|
|
118
102
|
var formatMessageForSentry = (entry) => {
|
|
119
103
|
const message = entry.message ?? (entry.error ? entry.error.message ?? String(entry.error) : "");
|
|
@@ -159,4 +143,4 @@ var getRelativeFilename = (filename) => {
|
|
|
159
143
|
export {
|
|
160
144
|
SentryLogProcessor
|
|
161
145
|
};
|
|
162
|
-
//# sourceMappingURL=sentry-log-processor-
|
|
146
|
+
//# sourceMappingURL=sentry-log-processor-5LSQJMIO.mjs.map
|
|
@@ -2,6 +2,6 @@
|
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/sentry/sentry-log-processor.ts"],
|
|
4
4
|
"sourcesContent": ["//\n// Copyright 2024 DXOS.org\n//\n\nimport type { Breadcrumb, Event, SeverityLevel } from '@sentry/types';\n\nimport { InvariantViolation } from '@dxos/invariant';\nimport { type LogConfig, type LogEntry, LogLevel, type LogProcessor, shouldLog } from '@dxos/log';\nimport { CircularBuffer, getDebugName } from '@dxos/util';\n\nimport { captureException, captureMessage, withScope } from './node';\n\nconst MAX_LOG_BREADCRUMBS = 150;\n\nexport class SentryLogProcessor {\n private _breadcrumbs = new CircularBuffer<Breadcrumb>(MAX_LOG_BREADCRUMBS);\n\n public readonly logProcessor: LogProcessor = (config: LogConfig, entry: LogEntry) => {\n const { level, meta, error } = entry;\n // Don't forward logs from remote sessions.\n if (!shouldLog(entry, config.captureFilters) || meta?.S?.remoteSessionId) {\n if (entry.level > LogLevel.DEBUG) {\n this._addBreadcrumb(\n undefined,\n entry.message ?? (entry.error ? (entry.error.message ?? String(entry.error)) : ''),\n convertLevel(entry.level),\n undefined,\n );\n }\n return;\n }\n if (entry.level !== LogLevel.WARN && entry.level !== LogLevel.ERROR) {\n return;\n }\n\n // TODO(nf): add rate limiting to avoid spamming Sentry/consuming excessive quota.\n withScope((scope) => {\n const severity = convertLevel(level);\n scope.setLevel(severity);\n scope.setContext('dxoslog', entry.context ?? null);\n if (meta) {\n scope.setTag('transaction', `${getRelativeFilename(meta.F)}:${meta.L}`);\n\n if (meta.S?.hostSessionId) {\n scope.setTags({\n service_host_issue: true,\n service_host_session: meta.S?.hostSessionId,\n });\n }\n\n if (!Number.isNaN(meta.S?.uptimeSeconds)) {\n scope.setExtra('uptime_seconds', meta.S?.uptimeSeconds);\n }\n }\n\n const extendedMessage = formatMessageForSentry(entry);\n let capturedError = error;\n if (capturedError == null && entry.level === LogLevel.ERROR) {\n capturedError = Object.values(entry.context ?? {}).find((v): v is Error => v instanceof Error);\n }\n if (capturedError) {\n if (capturedError instanceof InvariantViolation) {\n scope.setExtra('invariant_violation', true);\n }\n const isMessageDifferentFromStackTrace = error == null;\n if (isMessageDifferentFromStackTrace) {\n scope.setExtra('message', extendedMessage);\n }\n const eventId = captureException(capturedError);\n this._addBreadcrumb(eventId, extendedMessage, severity, entry.context);\n return;\n }\n\n const message = entry.message ?? (entry.error ? (entry.error.message ?? String(entry.error)) : '');\n scope.setFingerprint([message]);\n const eventId = captureMessage(extendedMessage);\n this._addBreadcrumb(eventId, extendedMessage, severity, entry.context);\n });\n };\n\n public addLogBreadcrumbsTo(event: Event): void {\n event.breadcrumbs ??= [];\n for (const breadcrumb of this._breadcrumbs) {\n event.breadcrumbs.push(breadcrumb);\n }\n event.breadcrumbs.sort((b1, b2) => {\n if (b1.timestamp === undefined || b2.timestamp === undefined) {\n return b1.timestamp === b2.timestamp ? 0 : b1.timestamp === undefined ? -1 : 1;\n }\n return b1.timestamp - b2.timestamp;\n });\n }\n\n private _addBreadcrumb(\n eventId: string | undefined,\n message: string,\n severity: SeverityLevel,\n context: { [key: string]: any } | undefined,\n ): void {\n const breadcrumb: Breadcrumb = {\n type: 'console',\n level: severity,\n event_id: eventId,\n category: 'log',\n message,\n data: context,\n timestamp: Math.floor(Date.now() / 1000),\n };\n const lastRecorded = this._breadcrumbs.getLast();\n if (lastRecorded && lastRecorded.message === breadcrumb.message) {\n const firstBreadcrumbData = lastRecorded.data?.firstBreadcrumbData ?? lastRecorded.data ?? {};\n const mergedBreadcrumbCount = Number.isNaN(lastRecorded.data?.mergedBreadcrumbCount)\n ? 1\n : Number(lastRecorded.data?.mergedBreadcrumbCount);\n lastRecorded.data = {\n mergedBreadcrumbCount: mergedBreadcrumbCount + 1,\n firstBreadcrumbData,\n lastBreadcrumbData: breadcrumb.data,\n };\n return;\n }\n this._breadcrumbs.push(breadcrumb);\n }\n}\n\nconst formatMessageForSentry = (entry: LogEntry): string => {\n const message = entry.message ?? (entry.error ? (entry.error.message ?? String(entry.error)) : '');\n\n let scopePrefix: string | undefined;\n if (entry.meta?.S) {\n const scope = entry.meta?.S;\n scopePrefix = scope.name || getDebugName(scope);\n }\n if (scopePrefix == null) {\n return message;\n }\n\n const workerPrefix = entry.meta?.S?.hostSessionId ? '[worker] ' : '';\n return `${workerPrefix}${scopePrefix} ${message}`;\n};\n\nconst convertLevel = (level: LogLevel): SeverityLevel => {\n switch (level) {\n case LogLevel.ERROR:\n return 'error';\n case LogLevel.VERBOSE:\n return 'info';\n case LogLevel.INFO:\n return 'info';\n case LogLevel.WARN:\n return 'warning';\n case LogLevel.DEBUG:\n case LogLevel.TRACE:\n return 'debug';\n default:\n throw never(level);\n }\n};\n\nconst never = (_: never) => {\n return new Error('unhandled value');\n};\n\nconst getRelativeFilename = (filename: string) => {\n // TODO(burdon): Hack uses \"packages\" as an anchor (pre-parse NX?)\n // Including `packages/` part of the path so that excluded paths (e.g. from dist) are clickable in vscode.\n const match = filename.match(/.+\\/(packages\\/.+\\/.+)/);\n if (match) {\n const [, filePath] = match;\n return filePath;\n }\n\n return filename;\n};\n"],
|
|
5
|
-
"mappings": ";;;;;;;AAMA,SAASA,0BAA0B;AACnC,SAAwCC,UAA6BC,iBAAiB;AACtF,SAASC,gBAAgBC,oBAAoB;
|
|
6
|
-
"names": ["InvariantViolation", "LogLevel", "shouldLog", "CircularBuffer", "getDebugName", "MAX_LOG_BREADCRUMBS", "SentryLogProcessor", "
|
|
5
|
+
"mappings": ";;;;;;;AAMA,SAASA,0BAA0B;AACnC,SAAwCC,UAA6BC,iBAAiB;AACtF,SAASC,gBAAgBC,oBAAoB;AAI7C,IAAMC,sBAAsB;AAErB,IAAMC,qBAAN,MAAMA;EACHC,eAAe,IAAIC,eAA2BH,mBAAAA;EAEtCI,eAA6B,CAACC,QAAmBC,UAAAA;AAC/D,UAAM,EAAEC,OAAOC,MAAMC,MAAK,IAAKH;AAE/B,QAAI,CAACI,UAAUJ,OAAOD,OAAOM,cAAc,KAAKH,MAAMI,GAAGC,iBAAiB;AACxE,UAAIP,MAAMC,QAAQO,SAASC,OAAO;AAChC,aAAKC,eACHC,QACAX,MAAMY,YAAYZ,MAAMG,QAASH,MAAMG,MAAMS,WAAWC,OAAOb,MAAMG,KAAK,IAAK,KAC/EW,aAAad,MAAMC,KAAK,GACxBU,MAAAA;MAEJ;AACA;IACF;AACA,QAAIX,MAAMC,UAAUO,SAASO,QAAQf,MAAMC,UAAUO,SAASQ,OAAO;AACnE;IACF;AAGAC,cAAU,CAACC,UAAAA;AACT,YAAMC,WAAWL,aAAab,KAAAA;AAC9BiB,YAAME,SAASD,QAAAA;AACfD,YAAMG,WAAW,WAAWrB,MAAMsB,WAAW,IAAA;AAC7C,UAAIpB,MAAM;AACRgB,cAAMK,OAAO,eAAe,GAAGC,oBAAoBtB,KAAKuB,CAAC,CAAA,IAAKvB,KAAKwB,CAAC,EAAE;AAEtE,YAAIxB,KAAKI,GAAGqB,eAAe;AACzBT,gBAAMU,QAAQ;YACZC,oBAAoB;YACpBC,sBAAsB5B,KAAKI,GAAGqB;UAChC,CAAA;QACF;AAEA,YAAI,CAACI,OAAOC,MAAM9B,KAAKI,GAAG2B,aAAAA,G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AKpE,SAASO;AACZ,aAAO;IACT,KAAKP,SAASC;IACd,KAAKD,SAASqE;AACZ,aAAO;IACT;AACE,YAAMC,MAAM7E,KAAAA;EAChB;AACF;AAEA,IAAM6E,QAAQ,CAACC,MAAAA;AACb,SAAO,IAAIrC,MAAM,iBAAA;AACnB;AAEA,IAAMlB,sBAAsB,CAACwD,aAAAA;AAG3B,QAAMC,QAAQD,SAASC,MAAM,wBAAA;AAC7B,MAAIA,OAAO;AACT,UAAM,CAAA,EAAGC,QAAAA,IAAYD;AACrB,WAAOC;EACT;AAEA,SAAOF;AACT;",
|
|
6
|
+
"names": ["InvariantViolation", "LogLevel", "shouldLog", "CircularBuffer", "getDebugName", "MAX_LOG_BREADCRUMBS", "SentryLogProcessor", "_breadcrumbs", "CircularBuffer", "logProcessor", "config", "entry", "level", "meta", "error", "shouldLog", "captureFilters", "S", "remoteSessionId", "LogLevel", "DEBUG", "_addBreadcrumb", "undefined", "message", "String", "convertLevel", "WARN", "ERROR", "withScope", "scope", "severity", "setLevel", "setContext", "context", "setTag", "getRelativeFilename", "F", "L", "hostSessionId", "setTags", "service_host_issue", "service_host_session", "Number", "isNaN", "uptimeSeconds", "setExtra", "extendedMessage", "formatMessageForSentry", "capturedError", "Object", "values", "find", "v", "Error", "InvariantViolation", "isMessageDifferentFromStackTrace", "eventId", "captureException", "setFingerprint", "captureMessage", "addLogBreadcrumbsTo", "event", "breadcrumbs", "breadcrumb", "push", "sort", "b1", "b2", "timestamp", "type", "event_id", "category", "data", "Math", "floor", "Date", "now", "lastRecorded", "getLast", "firstBreadcrumbData", "mergedBreadcrumbCount", "lastBreadcrumbData", "scopePrefix", "name", "getDebugName", "workerPrefix", "VERBOSE", "INFO", "TRACE", "never", "_", "filename", "match", "filePath"]
|
|
7
7
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { createRequire } from 'node:module';const require = createRequire(import.meta.url);
|
|
2
2
|
import {
|
|
3
3
|
TelemetryEvent
|
|
4
|
-
} from "./chunk-
|
|
4
|
+
} from "./chunk-OJV247NY.mjs";
|
|
5
5
|
|
|
6
6
|
// src/observability.ts
|
|
7
7
|
import { Event, scheduleTaskInterval } from "@dxos/async";
|
|
@@ -96,7 +96,7 @@ var initializeAppObservability = async ({
|
|
|
96
96
|
const group = await getObservabilityGroup(namespace) ?? void 0;
|
|
97
97
|
const release = `${namespace}@${config.get("runtime.app.build.version")}`;
|
|
98
98
|
const environment = config.get("runtime.app.env.DX_ENVIRONMENT");
|
|
99
|
-
const { Observability: Observability2 } = await import("./observability-
|
|
99
|
+
const { Observability: Observability2 } = await import("./observability-UWX2LAYX.mjs");
|
|
100
100
|
const observability = new Observability2({
|
|
101
101
|
namespace,
|
|
102
102
|
release,
|
|
@@ -408,24 +408,50 @@ var setupTelemetryListeners = (namespace, client, observability) => {
|
|
|
408
408
|
};
|
|
409
409
|
|
|
410
410
|
// src/observability.ts
|
|
411
|
-
function _define_property(obj, key, value) {
|
|
412
|
-
if (key in obj) {
|
|
413
|
-
Object.defineProperty(obj, key, {
|
|
414
|
-
value,
|
|
415
|
-
enumerable: true,
|
|
416
|
-
configurable: true,
|
|
417
|
-
writable: true
|
|
418
|
-
});
|
|
419
|
-
} else {
|
|
420
|
-
obj[key] = value;
|
|
421
|
-
}
|
|
422
|
-
return obj;
|
|
423
|
-
}
|
|
424
411
|
var __dxlog_file3 = "/__w/dxos/dxos/packages/sdk/observability/src/observability.ts";
|
|
425
412
|
var SPACE_METRICS_MIN_INTERVAL = 1e3 * 60;
|
|
426
413
|
var SPACE_TELEMETRY_MIN_INTERVAL = 1e3 * 60 * 60;
|
|
427
414
|
var NETWORK_METRICS_MIN_INTERVAL = 1e3 * 60 * 5;
|
|
428
415
|
var Observability = class {
|
|
416
|
+
_mode;
|
|
417
|
+
_namespace;
|
|
418
|
+
_config;
|
|
419
|
+
_group;
|
|
420
|
+
_secrets;
|
|
421
|
+
_tags = /* @__PURE__ */ new Map();
|
|
422
|
+
// TODO(wittjosiah): Generic metrics interface.
|
|
423
|
+
_otelMetrics;
|
|
424
|
+
_otelTraces;
|
|
425
|
+
// TODO(wittjosiah): Generic telemetry interface.
|
|
426
|
+
_telemetryBatchSize;
|
|
427
|
+
_telemetry;
|
|
428
|
+
// TODO(wittjosiah): Generic error logging interface.
|
|
429
|
+
_sentryLogProcessor;
|
|
430
|
+
_otelLogs;
|
|
431
|
+
_errorReportingOptions;
|
|
432
|
+
_captureException;
|
|
433
|
+
_captureUserFeedback;
|
|
434
|
+
_lastNetworkStatus;
|
|
435
|
+
_ctx = new Context(void 0, {
|
|
436
|
+
F: __dxlog_file3,
|
|
437
|
+
L: 115
|
|
438
|
+
});
|
|
439
|
+
// TODO(nf): make platform a required extension?
|
|
440
|
+
constructor({ mode, namespace, environment, release, config, group, secrets, telemetry, errorLog }) {
|
|
441
|
+
this._mode = mode;
|
|
442
|
+
this._namespace = namespace;
|
|
443
|
+
this._config = config;
|
|
444
|
+
this._group = group;
|
|
445
|
+
this._secrets = this._loadSecrets(config, secrets);
|
|
446
|
+
this._telemetryBatchSize = telemetry?.batchSize ?? 30;
|
|
447
|
+
this._errorReportingOptions = errorLog?.sentryInitOptions;
|
|
448
|
+
this.setTag("mode", this._mode);
|
|
449
|
+
this.setTag("namespace", this._namespace);
|
|
450
|
+
this.setTag("environment", environment);
|
|
451
|
+
this.setTag("release", release);
|
|
452
|
+
this.setTag("session", PublicKey.random().toHex());
|
|
453
|
+
this.setTag("group", this._group);
|
|
454
|
+
}
|
|
429
455
|
get mode() {
|
|
430
456
|
return this._mode;
|
|
431
457
|
}
|
|
@@ -501,6 +527,11 @@ var Observability = class {
|
|
|
501
527
|
setMode(mode) {
|
|
502
528
|
this._mode = mode;
|
|
503
529
|
}
|
|
530
|
+
//
|
|
531
|
+
// Tags
|
|
532
|
+
//
|
|
533
|
+
/** Callback (e.g., to share tags with Sentry.) */
|
|
534
|
+
_setTag;
|
|
504
535
|
/**
|
|
505
536
|
* camelCase keys are converted to snake_case in Segment.
|
|
506
537
|
*/
|
|
@@ -584,12 +615,19 @@ var Observability = class {
|
|
|
584
615
|
});
|
|
585
616
|
}
|
|
586
617
|
}
|
|
618
|
+
setIPDataTelemetryTags = (ipData) => {
|
|
619
|
+
this.setTag("city", ipData.city, "telemetry");
|
|
620
|
+
this.setTag("region", ipData.region, "telemetry");
|
|
621
|
+
this.setTag("country", ipData.country, "telemetry");
|
|
622
|
+
ipData.latitude && this.setTag("latitude", ipData.latitude.toString(), "telemetry");
|
|
623
|
+
ipData.longitude && this.setTag("longitude", ipData.longitude.toString(), "telemetry");
|
|
624
|
+
};
|
|
587
625
|
//
|
|
588
626
|
// Logs
|
|
589
627
|
//
|
|
590
628
|
async _initLogs() {
|
|
591
629
|
if (this._secrets.OTEL_ENDPOINT && this._secrets.OTEL_AUTHORIZATION && this._mode !== "disabled") {
|
|
592
|
-
const { OtelLogs } = await import("./otel-
|
|
630
|
+
const { OtelLogs } = await import("./otel-7PUCFSTY.mjs");
|
|
593
631
|
this._otelLogs = new OtelLogs({
|
|
594
632
|
endpoint: this._secrets.OTEL_ENDPOINT,
|
|
595
633
|
authorizationHeader: this._secrets.OTEL_AUTHORIZATION,
|
|
@@ -627,7 +665,7 @@ var Observability = class {
|
|
|
627
665
|
//
|
|
628
666
|
async _initMetrics() {
|
|
629
667
|
if (this.enabled && this._secrets.OTEL_ENDPOINT && this._secrets.OTEL_AUTHORIZATION) {
|
|
630
|
-
const { OtelMetrics } = await import("./otel-
|
|
668
|
+
const { OtelMetrics } = await import("./otel-7PUCFSTY.mjs");
|
|
631
669
|
this._otelMetrics = new OtelMetrics({
|
|
632
670
|
endpoint: this._secrets.OTEL_ENDPOINT,
|
|
633
671
|
authorizationHeader: this._secrets.OTEL_AUTHORIZATION,
|
|
@@ -875,7 +913,7 @@ var Observability = class {
|
|
|
875
913
|
async _initErrorLogs() {
|
|
876
914
|
if (this._secrets.SENTRY_DESTINATION && this._mode !== "disabled") {
|
|
877
915
|
const { captureException, captureUserFeedback, init, setTag } = await import("./sentry/index.mjs");
|
|
878
|
-
const { SentryLogProcessor } = await import("./sentry-log-processor-
|
|
916
|
+
const { SentryLogProcessor } = await import("./sentry-log-processor-C4UGMAMV.mjs");
|
|
879
917
|
this._captureException = captureException;
|
|
880
918
|
this._captureUserFeedback = captureUserFeedback;
|
|
881
919
|
this._setTag = setTag;
|
|
@@ -918,7 +956,7 @@ var Observability = class {
|
|
|
918
956
|
// TODO(nf): Refactor init based on providers and their capabilities.
|
|
919
957
|
async _initTraces() {
|
|
920
958
|
if (this._secrets.OTEL_ENDPOINT && this._secrets.OTEL_AUTHORIZATION && this._mode !== "disabled") {
|
|
921
|
-
const { OtelTraces } = await import("./otel-
|
|
959
|
+
const { OtelTraces } = await import("./otel-7PUCFSTY.mjs");
|
|
922
960
|
this._otelTraces = new OtelTraces({
|
|
923
961
|
endpoint: this._secrets.OTEL_ENDPOINT,
|
|
924
962
|
authorizationHeader: this._secrets.OTEL_AUTHORIZATION,
|
|
@@ -960,50 +998,6 @@ var Observability = class {
|
|
|
960
998
|
}
|
|
961
999
|
void this._captureUserFeedback?.(message);
|
|
962
1000
|
}
|
|
963
|
-
// TODO(nf): make platform a required extension?
|
|
964
|
-
constructor({ mode, namespace, environment, release, config, group, secrets, telemetry, errorLog }) {
|
|
965
|
-
_define_property(this, "_mode", void 0);
|
|
966
|
-
_define_property(this, "_namespace", void 0);
|
|
967
|
-
_define_property(this, "_config", void 0);
|
|
968
|
-
_define_property(this, "_group", void 0);
|
|
969
|
-
_define_property(this, "_secrets", void 0);
|
|
970
|
-
_define_property(this, "_tags", /* @__PURE__ */ new Map());
|
|
971
|
-
_define_property(this, "_otelMetrics", void 0);
|
|
972
|
-
_define_property(this, "_otelTraces", void 0);
|
|
973
|
-
_define_property(this, "_telemetryBatchSize", void 0);
|
|
974
|
-
_define_property(this, "_telemetry", void 0);
|
|
975
|
-
_define_property(this, "_sentryLogProcessor", void 0);
|
|
976
|
-
_define_property(this, "_otelLogs", void 0);
|
|
977
|
-
_define_property(this, "_errorReportingOptions", void 0);
|
|
978
|
-
_define_property(this, "_captureException", void 0);
|
|
979
|
-
_define_property(this, "_captureUserFeedback", void 0);
|
|
980
|
-
_define_property(this, "_lastNetworkStatus", void 0);
|
|
981
|
-
_define_property(this, "_ctx", new Context(void 0, {
|
|
982
|
-
F: __dxlog_file3,
|
|
983
|
-
L: 115
|
|
984
|
-
}));
|
|
985
|
-
_define_property(this, "_setTag", void 0);
|
|
986
|
-
_define_property(this, "setIPDataTelemetryTags", (ipData) => {
|
|
987
|
-
this.setTag("city", ipData.city, "telemetry");
|
|
988
|
-
this.setTag("region", ipData.region, "telemetry");
|
|
989
|
-
this.setTag("country", ipData.country, "telemetry");
|
|
990
|
-
ipData.latitude && this.setTag("latitude", ipData.latitude.toString(), "telemetry");
|
|
991
|
-
ipData.longitude && this.setTag("longitude", ipData.longitude.toString(), "telemetry");
|
|
992
|
-
});
|
|
993
|
-
this._mode = mode;
|
|
994
|
-
this._namespace = namespace;
|
|
995
|
-
this._config = config;
|
|
996
|
-
this._group = group;
|
|
997
|
-
this._secrets = this._loadSecrets(config, secrets);
|
|
998
|
-
this._telemetryBatchSize = telemetry?.batchSize ?? 30;
|
|
999
|
-
this._errorReportingOptions = errorLog?.sentryInitOptions;
|
|
1000
|
-
this.setTag("mode", this._mode);
|
|
1001
|
-
this.setTag("namespace", this._namespace);
|
|
1002
|
-
this.setTag("environment", environment);
|
|
1003
|
-
this.setTag("release", release);
|
|
1004
|
-
this.setTag("session", PublicKey.random().toHex());
|
|
1005
|
-
this.setTag("group", this._group);
|
|
1006
|
-
}
|
|
1007
1001
|
};
|
|
1008
1002
|
|
|
1009
1003
|
export {
|
|
@@ -1023,4 +1017,4 @@ export {
|
|
|
1023
1017
|
mapSpaces,
|
|
1024
1018
|
setupTelemetryListeners
|
|
1025
1019
|
};
|
|
1026
|
-
//# sourceMappingURL=chunk-
|
|
1020
|
+
//# sourceMappingURL=chunk-JJS4CBLT.mjs.map
|