@contember/engine-http 2.2.0-alpha.16 → 2.2.0-alpha.17
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/development/index.cjs +1 -0
- package/dist/development/index.cjs.map +1 -1
- package/dist/development/index.js +2 -1
- package/dist/development/src/utils/sentry.cjs +3 -3
- package/dist/development/src/utils/sentry.cjs.map +1 -1
- package/dist/development/src/utils/sentry.js +4 -4
- package/dist/development/src/utils/sentry.js.map +1 -1
- package/dist/production/index.cjs +1 -0
- package/dist/production/index.cjs.map +1 -1
- package/dist/production/index.js +2 -1
- package/dist/production/src/utils/sentry.cjs +3 -3
- package/dist/production/src/utils/sentry.cjs.map +1 -1
- package/dist/production/src/utils/sentry.js +4 -4
- package/dist/production/src/utils/sentry.js.map +1 -1
- package/dist/tests/cases/unit/sentryIntegrations.test.d.ts +2 -0
- package/dist/tests/cases/unit/sentryIntegrations.test.d.ts.map +1 -0
- package/dist/tests/tsconfig.tsbuildinfo +1 -1
- package/dist/types/tsconfig.tsbuildinfo +1 -1
- package/dist/types/utils/sentry.d.ts +4 -0
- package/dist/types/utils/sentry.d.ts.map +1 -1
- package/package.json +16 -16
- package/src/utils/sentry.ts +8 -3
- package/tests/cases/unit/sentryIntegrations.test.ts +15 -0
|
@@ -123,6 +123,7 @@ exports.executeTerminationJobs = serverTermination.executeTerminationJobs;
|
|
|
123
123
|
exports.listenOnProcessTermination = serverTermination.listenOnProcessTermination;
|
|
124
124
|
exports.SentryLoggerHandler = sentry.SentryLoggerHandler;
|
|
125
125
|
exports.createSentryLoggerHandler = sentry.createSentryLoggerHandler;
|
|
126
|
+
exports.filterSentryIntegrations = sentry.filterSentryIntegrations;
|
|
126
127
|
exports.createFastSqlSpanFilter = FilteringSpanProcessor.createFastSqlSpanFilter;
|
|
127
128
|
exports.createFilteringSpanProcessor = FilteringSpanProcessor.createFilteringSpanProcessor;
|
|
128
129
|
exports.isIncomingTraceTrusted = incomingTrace.isIncomingTraceTrusted;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.cjs","sources":["../../../packages/engine-http/src/index.ts"],"sourcesContent":["import { MasterContainerArgs, MasterContainerFactory } from './MasterContainer.js'\nimport Koa from 'koa'\n\nexport * from './config/config.js'\nexport * from './config/ConfigProcessor.js'\nexport { projectNameToEnvName } from './config/projectConfigResolver.js'\nexport * from './config/tenantConfigResolver.js'\nexport * from './common/index.js'\nexport * from './content/index.js'\nexport * from './plugin/Plugin.js'\nexport * from './misc/index.js'\nexport * from './project-common/index.js'\nexport * from './system/index.js'\nexport * from './tenant/index.js'\nexport * from './transfer/index.js'\nexport * from './application/index.js'\nexport * from './providers.js'\nexport * from './graphql/index.js'\nexport * from './project/config.js'\nexport * from './utils/CryptoWrapper.js'\nexport * from './project/ProjectContainer.js'\nexport * from './project/ProjectContainerResolver.js'\nexport * from './projectGroup/ProjectGroupContainer.js'\nexport * from './projectGroup/ProjectGroupResolver.js'\nexport type { ProjectGroupContainerResolver } from './projectGroup/ProjectGroupContainerResolver.js'\n\nexport * from './testing/index.js'\nexport * from './utils/serverStartup.js'\nexport * from './utils/serverTermination.js'\nexport * from './utils/sentry.js'\nexport * from './telemetry/index.js'\nexport * from './MasterContainer.js'\nexport { serverConfigSchema } from './config/configSchema.js'\n\nexport const createContainer = (args: MasterContainerArgs) => {\n\treturn new MasterContainerFactory().create(args)\n}\n\nexport { Koa }\n"],"names":["MasterContainerFactory"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAkCO,MAAM,kBAAkB,CAAC,SAA8B;AAC7D,SAAO,IAAIA,gBAAAA,uBAAA,EAAyB,OAAO,IAAI;AAChD
|
|
1
|
+
{"version":3,"file":"index.cjs","sources":["../../../packages/engine-http/src/index.ts"],"sourcesContent":["import { MasterContainerArgs, MasterContainerFactory } from './MasterContainer.js'\nimport Koa from 'koa'\n\nexport * from './config/config.js'\nexport * from './config/ConfigProcessor.js'\nexport { projectNameToEnvName } from './config/projectConfigResolver.js'\nexport * from './config/tenantConfigResolver.js'\nexport * from './common/index.js'\nexport * from './content/index.js'\nexport * from './plugin/Plugin.js'\nexport * from './misc/index.js'\nexport * from './project-common/index.js'\nexport * from './system/index.js'\nexport * from './tenant/index.js'\nexport * from './transfer/index.js'\nexport * from './application/index.js'\nexport * from './providers.js'\nexport * from './graphql/index.js'\nexport * from './project/config.js'\nexport * from './utils/CryptoWrapper.js'\nexport * from './project/ProjectContainer.js'\nexport * from './project/ProjectContainerResolver.js'\nexport * from './projectGroup/ProjectGroupContainer.js'\nexport * from './projectGroup/ProjectGroupResolver.js'\nexport type { ProjectGroupContainerResolver } from './projectGroup/ProjectGroupContainerResolver.js'\n\nexport * from './testing/index.js'\nexport * from './utils/serverStartup.js'\nexport * from './utils/serverTermination.js'\nexport * from './utils/sentry.js'\nexport * from './telemetry/index.js'\nexport * from './MasterContainer.js'\nexport { serverConfigSchema } from './config/configSchema.js'\n\nexport const createContainer = (args: MasterContainerArgs) => {\n\treturn new MasterContainerFactory().create(args)\n}\n\nexport { Koa }\n"],"names":["MasterContainerFactory"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAkCO,MAAM,kBAAkB,CAAC,SAA8B;AAC7D,SAAO,IAAIA,gBAAAA,uBAAA,EAAyB,OAAO,IAAI;AAChD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
|
@@ -43,7 +43,7 @@ import { ProjectGroupResolver } from "./src/projectGroup/ProjectGroupResolver.js
|
|
|
43
43
|
import { TestTransactionService } from "./src/testing/TestTransactions.js";
|
|
44
44
|
import { createDefaultLogger, getServerVersion, isDebugMode, printStartInfo, resolveServerConfig } from "./src/utils/serverStartup.js";
|
|
45
45
|
import { createTerminationExecutor, executeTerminationJobs, listenOnProcessTermination } from "./src/utils/serverTermination.js";
|
|
46
|
-
import { SentryLoggerHandler, createSentryLoggerHandler } from "./src/utils/sentry.js";
|
|
46
|
+
import { SentryLoggerHandler, createSentryLoggerHandler, filterSentryIntegrations } from "./src/utils/sentry.js";
|
|
47
47
|
import { createFastSqlSpanFilter, createFilteringSpanProcessor } from "./src/telemetry/FilteringSpanProcessor.js";
|
|
48
48
|
import { isIncomingTraceTrusted, resolveIncomingSpanContext } from "./src/telemetry/incomingTrace.js";
|
|
49
49
|
import { ProjectGroupContainerTelemetryHook } from "./src/telemetry/ProjectGroupContainerTelemetryHook.js";
|
|
@@ -113,6 +113,7 @@ export {
|
|
|
113
113
|
defaultServiceName,
|
|
114
114
|
executeTerminationJobs,
|
|
115
115
|
extractOriginalError,
|
|
116
|
+
filterSentryIntegrations,
|
|
116
117
|
forceHttpOkHeader,
|
|
117
118
|
getServerVersion,
|
|
118
119
|
homepageController,
|
|
@@ -65,18 +65,18 @@ class SentryLoggerHandler {
|
|
|
65
65
|
close() {
|
|
66
66
|
}
|
|
67
67
|
}
|
|
68
|
+
const filterSentryIntegrations = (integrations) => integrations.filter((integration) => !["Console", "Http", "Undici"].includes(integration.name));
|
|
68
69
|
const createSentryLoggerHandler = (dsn) => {
|
|
69
70
|
if (!dsn) {
|
|
70
71
|
return null;
|
|
71
72
|
}
|
|
72
73
|
Sentry__namespace.init({
|
|
73
74
|
dsn,
|
|
74
|
-
integrations:
|
|
75
|
-
return integrations.filter((integration) => integration.name !== "Console" && integration.name !== "Http");
|
|
76
|
-
}
|
|
75
|
+
integrations: filterSentryIntegrations
|
|
77
76
|
});
|
|
78
77
|
return new SentryLoggerHandler(logger.LogLevels.warn);
|
|
79
78
|
};
|
|
80
79
|
exports.SentryLoggerHandler = SentryLoggerHandler;
|
|
81
80
|
exports.createSentryLoggerHandler = createSentryLoggerHandler;
|
|
81
|
+
exports.filterSentryIntegrations = filterSentryIntegrations;
|
|
82
82
|
//# sourceMappingURL=sentry.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sentry.cjs","sources":["../../../../../packages/engine-http/src/utils/sentry.ts"],"sourcesContent":["import * as Sentry from '@sentry/node'\nimport { LogEntry, LoggerHandler, LogLevel, LogLevelName, LogLevels } from '@contember/logger'\nimport { LoggerRequestBody } from '../application/index.js'\n\nconst logLevelMapping: Record<LogLevelName, Sentry.SeverityLevel> = {\n\tcrit: 'fatal',\n\terror: 'error',\n\twarn: 'warning',\n\tdebug: 'debug',\n\tinfo: 'info',\n}\n\nexport class SentryLoggerHandler implements LoggerHandler {\n\tconstructor(\n\t\tprivate readonly logLevel: LogLevel,\n\t) {\n\t}\n\n\tgetMinLevel(): number {\n\t\treturn this.logLevel.value\n\t}\n\n\thandle(entry: LogEntry) {\n\t\tif (!entry.error || entry.level.value < this.logLevel.value) {\n\t\t\treturn\n\t\t}\n\t\tSentry.captureException(entry.error, scope => {\n\t\t\tscope.setTag('project', entry.loggerAttributes.project ?? entry.ownAttributes.project)\n\t\t\tscope.setTag('projectGroup', entry.loggerAttributes.projectGroup ?? entry.ownAttributes.projectGroup)\n\t\t\tscope.setTag('module', entry.loggerAttributes.module ?? entry.ownAttributes.module)\n\t\t\tscope.setLevel(logLevelMapping[entry.level.name])\n\t\t\tscope.setUser({\n\t\t\t\tid: entry.loggerAttributes.user ?? entry.ownAttributes.user,\n\t\t\t})\n\t\t\tscope.setExtra('requestId', entry.loggerAttributes.requestId)\n\n\t\t\tscope.addEventProcessor(event => {\n\t\t\t\tconst traceId = entry.loggerAttributes.traceId\n\t\t\t\tconst spanId = entry.loggerAttributes.spanId\n\t\t\t\treturn {\n\t\t\t\t\t...event,\n\t\t\t\t\trequest: {\n\t\t\t\t\t\turl: entry.loggerAttributes.url ?? entry.ownAttributes.url,\n\t\t\t\t\t\tdata: entry.loggerAttributes[LoggerRequestBody],\n\t\t\t\t\t},\n\t\t\t\t\t...(typeof traceId === 'string' && typeof spanId === 'string'\n\t\t\t\t\t\t? { contexts: { ...event.contexts, trace: { trace_id: traceId, span_id: spanId } } }\n\t\t\t\t\t\t: {}),\n\t\t\t\t}\n\t\t\t})\n\t\t\treturn scope\n\t\t})\n\t}\n\n\tclose(): void {\n\t}\n}\n\nexport const createSentryLoggerHandler = (dsn?: string): null | LoggerHandler => {\n\tif (!dsn) {\n\t\treturn null\n\t}\n\tSentry.init({\n\t\tdsn: dsn,\n\t\tintegrations:
|
|
1
|
+
{"version":3,"file":"sentry.cjs","sources":["../../../../../packages/engine-http/src/utils/sentry.ts"],"sourcesContent":["import * as Sentry from '@sentry/node'\nimport { LogEntry, LoggerHandler, LogLevel, LogLevelName, LogLevels } from '@contember/logger'\nimport { LoggerRequestBody } from '../application/index.js'\n\nconst logLevelMapping: Record<LogLevelName, Sentry.SeverityLevel> = {\n\tcrit: 'fatal',\n\terror: 'error',\n\twarn: 'warning',\n\tdebug: 'debug',\n\tinfo: 'info',\n}\n\nexport class SentryLoggerHandler implements LoggerHandler {\n\tconstructor(\n\t\tprivate readonly logLevel: LogLevel,\n\t) {\n\t}\n\n\tgetMinLevel(): number {\n\t\treturn this.logLevel.value\n\t}\n\n\thandle(entry: LogEntry) {\n\t\tif (!entry.error || entry.level.value < this.logLevel.value) {\n\t\t\treturn\n\t\t}\n\t\tSentry.captureException(entry.error, scope => {\n\t\t\tscope.setTag('project', entry.loggerAttributes.project ?? entry.ownAttributes.project)\n\t\t\tscope.setTag('projectGroup', entry.loggerAttributes.projectGroup ?? entry.ownAttributes.projectGroup)\n\t\t\tscope.setTag('module', entry.loggerAttributes.module ?? entry.ownAttributes.module)\n\t\t\tscope.setLevel(logLevelMapping[entry.level.name])\n\t\t\tscope.setUser({\n\t\t\t\tid: entry.loggerAttributes.user ?? entry.ownAttributes.user,\n\t\t\t})\n\t\t\tscope.setExtra('requestId', entry.loggerAttributes.requestId)\n\n\t\t\tscope.addEventProcessor(event => {\n\t\t\t\tconst traceId = entry.loggerAttributes.traceId\n\t\t\t\tconst spanId = entry.loggerAttributes.spanId\n\t\t\t\treturn {\n\t\t\t\t\t...event,\n\t\t\t\t\trequest: {\n\t\t\t\t\t\turl: entry.loggerAttributes.url ?? entry.ownAttributes.url,\n\t\t\t\t\t\tdata: entry.loggerAttributes[LoggerRequestBody],\n\t\t\t\t\t},\n\t\t\t\t\t...(typeof traceId === 'string' && typeof spanId === 'string'\n\t\t\t\t\t\t? { contexts: { ...event.contexts, trace: { trace_id: traceId, span_id: spanId } } }\n\t\t\t\t\t\t: {}),\n\t\t\t\t}\n\t\t\t})\n\t\t\treturn scope\n\t\t})\n\t}\n\n\tclose(): void {\n\t}\n}\n\ntype SentryIntegration = ReturnType<typeof Sentry.getDefaultIntegrations>[number]\n\n// Undici (fetch) would record outgoing request URLs, which may carry a webhook credential in the path or query,\n// in breadcrumbs and spans, and add Sentry trace headers to every webhook request.\nexport const filterSentryIntegrations = (integrations: SentryIntegration[]): SentryIntegration[] =>\n\tintegrations.filter(integration => !['Console', 'Http', 'Undici'].includes(integration.name))\n\nexport const createSentryLoggerHandler = (dsn?: string): null | LoggerHandler => {\n\tif (!dsn) {\n\t\treturn null\n\t}\n\tSentry.init({\n\t\tdsn: dsn,\n\t\tintegrations: filterSentryIntegrations,\n\t})\n\treturn new SentryLoggerHandler(LogLevels.warn)\n}\n"],"names":["Sentry","LoggerRequestBody","LogLevels"],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAIA,MAAM,kBAA8D;AAAA,EACnE,MAAM;AAAA,EACN,OAAO;AAAA,EACP,MAAM;AAAA,EACN,OAAO;AAAA,EACP,MAAM;AACP;AAEO,MAAM,oBAA6C;AAAA,EACzD,YACkB,UAChB;AADgB,SAAA,WAAA;AAAA,EAElB;AAAA,EAEA,cAAsB;AACrB,WAAO,KAAK,SAAS;AAAA,EACtB;AAAA,EAEA,OAAO,OAAiB;AACvB,QAAI,CAAC,MAAM,SAAS,MAAM,MAAM,QAAQ,KAAK,SAAS,OAAO;AAC5D;AAAA,IACD;AACAA,sBAAO,iBAAiB,MAAM,OAAO,CAAA,UAAS;AAC7C,YAAM,OAAO,WAAW,MAAM,iBAAiB,WAAW,MAAM,cAAc,OAAO;AACrF,YAAM,OAAO,gBAAgB,MAAM,iBAAiB,gBAAgB,MAAM,cAAc,YAAY;AACpG,YAAM,OAAO,UAAU,MAAM,iBAAiB,UAAU,MAAM,cAAc,MAAM;AAClF,YAAM,SAAS,gBAAgB,MAAM,MAAM,IAAI,CAAC;AAChD,YAAM,QAAQ;AAAA,QACb,IAAI,MAAM,iBAAiB,QAAQ,MAAM,cAAc;AAAA,MAAA,CACvD;AACD,YAAM,SAAS,aAAa,MAAM,iBAAiB,SAAS;AAE5D,YAAM,kBAAkB,CAAA,UAAS;AAChC,cAAM,UAAU,MAAM,iBAAiB;AACvC,cAAM,SAAS,MAAM,iBAAiB;AACtC,eAAO;AAAA,UACN,GAAG;AAAA,UACH,SAAS;AAAA,YACR,KAAK,MAAM,iBAAiB,OAAO,MAAM,cAAc;AAAA,YACvD,MAAM,MAAM,iBAAiBC,YAAAA,iBAAiB;AAAA,UAAA;AAAA,UAE/C,GAAI,OAAO,YAAY,YAAY,OAAO,WAAW,WAClD,EAAE,UAAU,EAAE,GAAG,MAAM,UAAU,OAAO,EAAE,UAAU,SAAS,SAAS,OAAA,EAAO,MAC7E,CAAA;AAAA,QAAC;AAAA,MAEN,CAAC;AACD,aAAO;AAAA,IACR,CAAC;AAAA,EACF;AAAA,EAEA,QAAc;AAAA,EACd;AACD;AAMO,MAAM,2BAA2B,CAAC,iBACxC,aAAa,OAAO,CAAA,gBAAe,CAAC,CAAC,WAAW,QAAQ,QAAQ,EAAE,SAAS,YAAY,IAAI,CAAC;AAEtF,MAAM,4BAA4B,CAAC,QAAuC;AAChF,MAAI,CAAC,KAAK;AACT,WAAO;AAAA,EACR;AACAD,oBAAO,KAAK;AAAA,IACX;AAAA,IACA,cAAc;AAAA,EAAA,CACd;AACD,SAAO,IAAI,oBAAoBE,OAAAA,UAAU,IAAI;AAC9C;;;;"}
|
|
@@ -46,20 +46,20 @@ class SentryLoggerHandler {
|
|
|
46
46
|
close() {
|
|
47
47
|
}
|
|
48
48
|
}
|
|
49
|
+
const filterSentryIntegrations = (integrations) => integrations.filter((integration) => !["Console", "Http", "Undici"].includes(integration.name));
|
|
49
50
|
const createSentryLoggerHandler = (dsn) => {
|
|
50
51
|
if (!dsn) {
|
|
51
52
|
return null;
|
|
52
53
|
}
|
|
53
54
|
Sentry.init({
|
|
54
55
|
dsn,
|
|
55
|
-
integrations:
|
|
56
|
-
return integrations.filter((integration) => integration.name !== "Console" && integration.name !== "Http");
|
|
57
|
-
}
|
|
56
|
+
integrations: filterSentryIntegrations
|
|
58
57
|
});
|
|
59
58
|
return new SentryLoggerHandler(LogLevels.warn);
|
|
60
59
|
};
|
|
61
60
|
export {
|
|
62
61
|
SentryLoggerHandler,
|
|
63
|
-
createSentryLoggerHandler
|
|
62
|
+
createSentryLoggerHandler,
|
|
63
|
+
filterSentryIntegrations
|
|
64
64
|
};
|
|
65
65
|
//# sourceMappingURL=sentry.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sentry.js","sources":["../../../../../packages/engine-http/src/utils/sentry.ts"],"sourcesContent":["import * as Sentry from '@sentry/node'\nimport { LogEntry, LoggerHandler, LogLevel, LogLevelName, LogLevels } from '@contember/logger'\nimport { LoggerRequestBody } from '../application/index.js'\n\nconst logLevelMapping: Record<LogLevelName, Sentry.SeverityLevel> = {\n\tcrit: 'fatal',\n\terror: 'error',\n\twarn: 'warning',\n\tdebug: 'debug',\n\tinfo: 'info',\n}\n\nexport class SentryLoggerHandler implements LoggerHandler {\n\tconstructor(\n\t\tprivate readonly logLevel: LogLevel,\n\t) {\n\t}\n\n\tgetMinLevel(): number {\n\t\treturn this.logLevel.value\n\t}\n\n\thandle(entry: LogEntry) {\n\t\tif (!entry.error || entry.level.value < this.logLevel.value) {\n\t\t\treturn\n\t\t}\n\t\tSentry.captureException(entry.error, scope => {\n\t\t\tscope.setTag('project', entry.loggerAttributes.project ?? entry.ownAttributes.project)\n\t\t\tscope.setTag('projectGroup', entry.loggerAttributes.projectGroup ?? entry.ownAttributes.projectGroup)\n\t\t\tscope.setTag('module', entry.loggerAttributes.module ?? entry.ownAttributes.module)\n\t\t\tscope.setLevel(logLevelMapping[entry.level.name])\n\t\t\tscope.setUser({\n\t\t\t\tid: entry.loggerAttributes.user ?? entry.ownAttributes.user,\n\t\t\t})\n\t\t\tscope.setExtra('requestId', entry.loggerAttributes.requestId)\n\n\t\t\tscope.addEventProcessor(event => {\n\t\t\t\tconst traceId = entry.loggerAttributes.traceId\n\t\t\t\tconst spanId = entry.loggerAttributes.spanId\n\t\t\t\treturn {\n\t\t\t\t\t...event,\n\t\t\t\t\trequest: {\n\t\t\t\t\t\turl: entry.loggerAttributes.url ?? entry.ownAttributes.url,\n\t\t\t\t\t\tdata: entry.loggerAttributes[LoggerRequestBody],\n\t\t\t\t\t},\n\t\t\t\t\t...(typeof traceId === 'string' && typeof spanId === 'string'\n\t\t\t\t\t\t? { contexts: { ...event.contexts, trace: { trace_id: traceId, span_id: spanId } } }\n\t\t\t\t\t\t: {}),\n\t\t\t\t}\n\t\t\t})\n\t\t\treturn scope\n\t\t})\n\t}\n\n\tclose(): void {\n\t}\n}\n\nexport const createSentryLoggerHandler = (dsn?: string): null | LoggerHandler => {\n\tif (!dsn) {\n\t\treturn null\n\t}\n\tSentry.init({\n\t\tdsn: dsn,\n\t\tintegrations:
|
|
1
|
+
{"version":3,"file":"sentry.js","sources":["../../../../../packages/engine-http/src/utils/sentry.ts"],"sourcesContent":["import * as Sentry from '@sentry/node'\nimport { LogEntry, LoggerHandler, LogLevel, LogLevelName, LogLevels } from '@contember/logger'\nimport { LoggerRequestBody } from '../application/index.js'\n\nconst logLevelMapping: Record<LogLevelName, Sentry.SeverityLevel> = {\n\tcrit: 'fatal',\n\terror: 'error',\n\twarn: 'warning',\n\tdebug: 'debug',\n\tinfo: 'info',\n}\n\nexport class SentryLoggerHandler implements LoggerHandler {\n\tconstructor(\n\t\tprivate readonly logLevel: LogLevel,\n\t) {\n\t}\n\n\tgetMinLevel(): number {\n\t\treturn this.logLevel.value\n\t}\n\n\thandle(entry: LogEntry) {\n\t\tif (!entry.error || entry.level.value < this.logLevel.value) {\n\t\t\treturn\n\t\t}\n\t\tSentry.captureException(entry.error, scope => {\n\t\t\tscope.setTag('project', entry.loggerAttributes.project ?? entry.ownAttributes.project)\n\t\t\tscope.setTag('projectGroup', entry.loggerAttributes.projectGroup ?? entry.ownAttributes.projectGroup)\n\t\t\tscope.setTag('module', entry.loggerAttributes.module ?? entry.ownAttributes.module)\n\t\t\tscope.setLevel(logLevelMapping[entry.level.name])\n\t\t\tscope.setUser({\n\t\t\t\tid: entry.loggerAttributes.user ?? entry.ownAttributes.user,\n\t\t\t})\n\t\t\tscope.setExtra('requestId', entry.loggerAttributes.requestId)\n\n\t\t\tscope.addEventProcessor(event => {\n\t\t\t\tconst traceId = entry.loggerAttributes.traceId\n\t\t\t\tconst spanId = entry.loggerAttributes.spanId\n\t\t\t\treturn {\n\t\t\t\t\t...event,\n\t\t\t\t\trequest: {\n\t\t\t\t\t\turl: entry.loggerAttributes.url ?? entry.ownAttributes.url,\n\t\t\t\t\t\tdata: entry.loggerAttributes[LoggerRequestBody],\n\t\t\t\t\t},\n\t\t\t\t\t...(typeof traceId === 'string' && typeof spanId === 'string'\n\t\t\t\t\t\t? { contexts: { ...event.contexts, trace: { trace_id: traceId, span_id: spanId } } }\n\t\t\t\t\t\t: {}),\n\t\t\t\t}\n\t\t\t})\n\t\t\treturn scope\n\t\t})\n\t}\n\n\tclose(): void {\n\t}\n}\n\ntype SentryIntegration = ReturnType<typeof Sentry.getDefaultIntegrations>[number]\n\n// Undici (fetch) would record outgoing request URLs, which may carry a webhook credential in the path or query,\n// in breadcrumbs and spans, and add Sentry trace headers to every webhook request.\nexport const filterSentryIntegrations = (integrations: SentryIntegration[]): SentryIntegration[] =>\n\tintegrations.filter(integration => !['Console', 'Http', 'Undici'].includes(integration.name))\n\nexport const createSentryLoggerHandler = (dsn?: string): null | LoggerHandler => {\n\tif (!dsn) {\n\t\treturn null\n\t}\n\tSentry.init({\n\t\tdsn: dsn,\n\t\tintegrations: filterSentryIntegrations,\n\t})\n\treturn new SentryLoggerHandler(LogLevels.warn)\n}\n"],"names":[],"mappings":";;;AAIA,MAAM,kBAA8D;AAAA,EACnE,MAAM;AAAA,EACN,OAAO;AAAA,EACP,MAAM;AAAA,EACN,OAAO;AAAA,EACP,MAAM;AACP;AAEO,MAAM,oBAA6C;AAAA,EACzD,YACkB,UAChB;AADgB,SAAA,WAAA;AAAA,EAElB;AAAA,EAEA,cAAsB;AACrB,WAAO,KAAK,SAAS;AAAA,EACtB;AAAA,EAEA,OAAO,OAAiB;AACvB,QAAI,CAAC,MAAM,SAAS,MAAM,MAAM,QAAQ,KAAK,SAAS,OAAO;AAC5D;AAAA,IACD;AACA,WAAO,iBAAiB,MAAM,OAAO,CAAA,UAAS;AAC7C,YAAM,OAAO,WAAW,MAAM,iBAAiB,WAAW,MAAM,cAAc,OAAO;AACrF,YAAM,OAAO,gBAAgB,MAAM,iBAAiB,gBAAgB,MAAM,cAAc,YAAY;AACpG,YAAM,OAAO,UAAU,MAAM,iBAAiB,UAAU,MAAM,cAAc,MAAM;AAClF,YAAM,SAAS,gBAAgB,MAAM,MAAM,IAAI,CAAC;AAChD,YAAM,QAAQ;AAAA,QACb,IAAI,MAAM,iBAAiB,QAAQ,MAAM,cAAc;AAAA,MAAA,CACvD;AACD,YAAM,SAAS,aAAa,MAAM,iBAAiB,SAAS;AAE5D,YAAM,kBAAkB,CAAA,UAAS;AAChC,cAAM,UAAU,MAAM,iBAAiB;AACvC,cAAM,SAAS,MAAM,iBAAiB;AACtC,eAAO;AAAA,UACN,GAAG;AAAA,UACH,SAAS;AAAA,YACR,KAAK,MAAM,iBAAiB,OAAO,MAAM,cAAc;AAAA,YACvD,MAAM,MAAM,iBAAiB,iBAAiB;AAAA,UAAA;AAAA,UAE/C,GAAI,OAAO,YAAY,YAAY,OAAO,WAAW,WAClD,EAAE,UAAU,EAAE,GAAG,MAAM,UAAU,OAAO,EAAE,UAAU,SAAS,SAAS,OAAA,EAAO,MAC7E,CAAA;AAAA,QAAC;AAAA,MAEN,CAAC;AACD,aAAO;AAAA,IACR,CAAC;AAAA,EACF;AAAA,EAEA,QAAc;AAAA,EACd;AACD;AAMO,MAAM,2BAA2B,CAAC,iBACxC,aAAa,OAAO,CAAA,gBAAe,CAAC,CAAC,WAAW,QAAQ,QAAQ,EAAE,SAAS,YAAY,IAAI,CAAC;AAEtF,MAAM,4BAA4B,CAAC,QAAuC;AAChF,MAAI,CAAC,KAAK;AACT,WAAO;AAAA,EACR;AACA,SAAO,KAAK;AAAA,IACX;AAAA,IACA,cAAc;AAAA,EAAA,CACd;AACD,SAAO,IAAI,oBAAoB,UAAU,IAAI;AAC9C;"}
|
|
@@ -123,6 +123,7 @@ exports.executeTerminationJobs = serverTermination.executeTerminationJobs;
|
|
|
123
123
|
exports.listenOnProcessTermination = serverTermination.listenOnProcessTermination;
|
|
124
124
|
exports.SentryLoggerHandler = sentry.SentryLoggerHandler;
|
|
125
125
|
exports.createSentryLoggerHandler = sentry.createSentryLoggerHandler;
|
|
126
|
+
exports.filterSentryIntegrations = sentry.filterSentryIntegrations;
|
|
126
127
|
exports.createFastSqlSpanFilter = FilteringSpanProcessor.createFastSqlSpanFilter;
|
|
127
128
|
exports.createFilteringSpanProcessor = FilteringSpanProcessor.createFilteringSpanProcessor;
|
|
128
129
|
exports.isIncomingTraceTrusted = incomingTrace.isIncomingTraceTrusted;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.cjs","sources":["../../../packages/engine-http/src/index.ts"],"sourcesContent":["import { MasterContainerArgs, MasterContainerFactory } from './MasterContainer.js'\nimport Koa from 'koa'\n\nexport * from './config/config.js'\nexport * from './config/ConfigProcessor.js'\nexport { projectNameToEnvName } from './config/projectConfigResolver.js'\nexport * from './config/tenantConfigResolver.js'\nexport * from './common/index.js'\nexport * from './content/index.js'\nexport * from './plugin/Plugin.js'\nexport * from './misc/index.js'\nexport * from './project-common/index.js'\nexport * from './system/index.js'\nexport * from './tenant/index.js'\nexport * from './transfer/index.js'\nexport * from './application/index.js'\nexport * from './providers.js'\nexport * from './graphql/index.js'\nexport * from './project/config.js'\nexport * from './utils/CryptoWrapper.js'\nexport * from './project/ProjectContainer.js'\nexport * from './project/ProjectContainerResolver.js'\nexport * from './projectGroup/ProjectGroupContainer.js'\nexport * from './projectGroup/ProjectGroupResolver.js'\nexport type { ProjectGroupContainerResolver } from './projectGroup/ProjectGroupContainerResolver.js'\n\nexport * from './testing/index.js'\nexport * from './utils/serverStartup.js'\nexport * from './utils/serverTermination.js'\nexport * from './utils/sentry.js'\nexport * from './telemetry/index.js'\nexport * from './MasterContainer.js'\nexport { serverConfigSchema } from './config/configSchema.js'\n\nexport const createContainer = (args: MasterContainerArgs) => {\n\treturn new MasterContainerFactory().create(args)\n}\n\nexport { Koa }\n"],"names":["MasterContainerFactory"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAkCO,MAAM,kBAAkB,CAAC,SAA8B;AAC7D,SAAO,IAAIA,gBAAAA,uBAAA,EAAyB,OAAO,IAAI;AAChD
|
|
1
|
+
{"version":3,"file":"index.cjs","sources":["../../../packages/engine-http/src/index.ts"],"sourcesContent":["import { MasterContainerArgs, MasterContainerFactory } from './MasterContainer.js'\nimport Koa from 'koa'\n\nexport * from './config/config.js'\nexport * from './config/ConfigProcessor.js'\nexport { projectNameToEnvName } from './config/projectConfigResolver.js'\nexport * from './config/tenantConfigResolver.js'\nexport * from './common/index.js'\nexport * from './content/index.js'\nexport * from './plugin/Plugin.js'\nexport * from './misc/index.js'\nexport * from './project-common/index.js'\nexport * from './system/index.js'\nexport * from './tenant/index.js'\nexport * from './transfer/index.js'\nexport * from './application/index.js'\nexport * from './providers.js'\nexport * from './graphql/index.js'\nexport * from './project/config.js'\nexport * from './utils/CryptoWrapper.js'\nexport * from './project/ProjectContainer.js'\nexport * from './project/ProjectContainerResolver.js'\nexport * from './projectGroup/ProjectGroupContainer.js'\nexport * from './projectGroup/ProjectGroupResolver.js'\nexport type { ProjectGroupContainerResolver } from './projectGroup/ProjectGroupContainerResolver.js'\n\nexport * from './testing/index.js'\nexport * from './utils/serverStartup.js'\nexport * from './utils/serverTermination.js'\nexport * from './utils/sentry.js'\nexport * from './telemetry/index.js'\nexport * from './MasterContainer.js'\nexport { serverConfigSchema } from './config/configSchema.js'\n\nexport const createContainer = (args: MasterContainerArgs) => {\n\treturn new MasterContainerFactory().create(args)\n}\n\nexport { Koa }\n"],"names":["MasterContainerFactory"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAkCO,MAAM,kBAAkB,CAAC,SAA8B;AAC7D,SAAO,IAAIA,gBAAAA,uBAAA,EAAyB,OAAO,IAAI;AAChD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
package/dist/production/index.js
CHANGED
|
@@ -43,7 +43,7 @@ import { ProjectGroupResolver } from "./src/projectGroup/ProjectGroupResolver.js
|
|
|
43
43
|
import { TestTransactionService } from "./src/testing/TestTransactions.js";
|
|
44
44
|
import { createDefaultLogger, getServerVersion, isDebugMode, printStartInfo, resolveServerConfig } from "./src/utils/serverStartup.js";
|
|
45
45
|
import { createTerminationExecutor, executeTerminationJobs, listenOnProcessTermination } from "./src/utils/serverTermination.js";
|
|
46
|
-
import { SentryLoggerHandler, createSentryLoggerHandler } from "./src/utils/sentry.js";
|
|
46
|
+
import { SentryLoggerHandler, createSentryLoggerHandler, filterSentryIntegrations } from "./src/utils/sentry.js";
|
|
47
47
|
import { createFastSqlSpanFilter, createFilteringSpanProcessor } from "./src/telemetry/FilteringSpanProcessor.js";
|
|
48
48
|
import { isIncomingTraceTrusted, resolveIncomingSpanContext } from "./src/telemetry/incomingTrace.js";
|
|
49
49
|
import { ProjectGroupContainerTelemetryHook } from "./src/telemetry/ProjectGroupContainerTelemetryHook.js";
|
|
@@ -113,6 +113,7 @@ export {
|
|
|
113
113
|
defaultServiceName,
|
|
114
114
|
executeTerminationJobs,
|
|
115
115
|
extractOriginalError,
|
|
116
|
+
filterSentryIntegrations,
|
|
116
117
|
forceHttpOkHeader,
|
|
117
118
|
getServerVersion,
|
|
118
119
|
homepageController,
|
|
@@ -65,18 +65,18 @@ class SentryLoggerHandler {
|
|
|
65
65
|
close() {
|
|
66
66
|
}
|
|
67
67
|
}
|
|
68
|
+
const filterSentryIntegrations = (integrations) => integrations.filter((integration) => !["Console", "Http", "Undici"].includes(integration.name));
|
|
68
69
|
const createSentryLoggerHandler = (dsn) => {
|
|
69
70
|
if (!dsn) {
|
|
70
71
|
return null;
|
|
71
72
|
}
|
|
72
73
|
Sentry__namespace.init({
|
|
73
74
|
dsn,
|
|
74
|
-
integrations:
|
|
75
|
-
return integrations.filter((integration) => integration.name !== "Console" && integration.name !== "Http");
|
|
76
|
-
}
|
|
75
|
+
integrations: filterSentryIntegrations
|
|
77
76
|
});
|
|
78
77
|
return new SentryLoggerHandler(logger.LogLevels.warn);
|
|
79
78
|
};
|
|
80
79
|
exports.SentryLoggerHandler = SentryLoggerHandler;
|
|
81
80
|
exports.createSentryLoggerHandler = createSentryLoggerHandler;
|
|
81
|
+
exports.filterSentryIntegrations = filterSentryIntegrations;
|
|
82
82
|
//# sourceMappingURL=sentry.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sentry.cjs","sources":["../../../../../packages/engine-http/src/utils/sentry.ts"],"sourcesContent":["import * as Sentry from '@sentry/node'\nimport { LogEntry, LoggerHandler, LogLevel, LogLevelName, LogLevels } from '@contember/logger'\nimport { LoggerRequestBody } from '../application/index.js'\n\nconst logLevelMapping: Record<LogLevelName, Sentry.SeverityLevel> = {\n\tcrit: 'fatal',\n\terror: 'error',\n\twarn: 'warning',\n\tdebug: 'debug',\n\tinfo: 'info',\n}\n\nexport class SentryLoggerHandler implements LoggerHandler {\n\tconstructor(\n\t\tprivate readonly logLevel: LogLevel,\n\t) {\n\t}\n\n\tgetMinLevel(): number {\n\t\treturn this.logLevel.value\n\t}\n\n\thandle(entry: LogEntry) {\n\t\tif (!entry.error || entry.level.value < this.logLevel.value) {\n\t\t\treturn\n\t\t}\n\t\tSentry.captureException(entry.error, scope => {\n\t\t\tscope.setTag('project', entry.loggerAttributes.project ?? entry.ownAttributes.project)\n\t\t\tscope.setTag('projectGroup', entry.loggerAttributes.projectGroup ?? entry.ownAttributes.projectGroup)\n\t\t\tscope.setTag('module', entry.loggerAttributes.module ?? entry.ownAttributes.module)\n\t\t\tscope.setLevel(logLevelMapping[entry.level.name])\n\t\t\tscope.setUser({\n\t\t\t\tid: entry.loggerAttributes.user ?? entry.ownAttributes.user,\n\t\t\t})\n\t\t\tscope.setExtra('requestId', entry.loggerAttributes.requestId)\n\n\t\t\tscope.addEventProcessor(event => {\n\t\t\t\tconst traceId = entry.loggerAttributes.traceId\n\t\t\t\tconst spanId = entry.loggerAttributes.spanId\n\t\t\t\treturn {\n\t\t\t\t\t...event,\n\t\t\t\t\trequest: {\n\t\t\t\t\t\turl: entry.loggerAttributes.url ?? entry.ownAttributes.url,\n\t\t\t\t\t\tdata: entry.loggerAttributes[LoggerRequestBody],\n\t\t\t\t\t},\n\t\t\t\t\t...(typeof traceId === 'string' && typeof spanId === 'string'\n\t\t\t\t\t\t? { contexts: { ...event.contexts, trace: { trace_id: traceId, span_id: spanId } } }\n\t\t\t\t\t\t: {}),\n\t\t\t\t}\n\t\t\t})\n\t\t\treturn scope\n\t\t})\n\t}\n\n\tclose(): void {\n\t}\n}\n\nexport const createSentryLoggerHandler = (dsn?: string): null | LoggerHandler => {\n\tif (!dsn) {\n\t\treturn null\n\t}\n\tSentry.init({\n\t\tdsn: dsn,\n\t\tintegrations:
|
|
1
|
+
{"version":3,"file":"sentry.cjs","sources":["../../../../../packages/engine-http/src/utils/sentry.ts"],"sourcesContent":["import * as Sentry from '@sentry/node'\nimport { LogEntry, LoggerHandler, LogLevel, LogLevelName, LogLevels } from '@contember/logger'\nimport { LoggerRequestBody } from '../application/index.js'\n\nconst logLevelMapping: Record<LogLevelName, Sentry.SeverityLevel> = {\n\tcrit: 'fatal',\n\terror: 'error',\n\twarn: 'warning',\n\tdebug: 'debug',\n\tinfo: 'info',\n}\n\nexport class SentryLoggerHandler implements LoggerHandler {\n\tconstructor(\n\t\tprivate readonly logLevel: LogLevel,\n\t) {\n\t}\n\n\tgetMinLevel(): number {\n\t\treturn this.logLevel.value\n\t}\n\n\thandle(entry: LogEntry) {\n\t\tif (!entry.error || entry.level.value < this.logLevel.value) {\n\t\t\treturn\n\t\t}\n\t\tSentry.captureException(entry.error, scope => {\n\t\t\tscope.setTag('project', entry.loggerAttributes.project ?? entry.ownAttributes.project)\n\t\t\tscope.setTag('projectGroup', entry.loggerAttributes.projectGroup ?? entry.ownAttributes.projectGroup)\n\t\t\tscope.setTag('module', entry.loggerAttributes.module ?? entry.ownAttributes.module)\n\t\t\tscope.setLevel(logLevelMapping[entry.level.name])\n\t\t\tscope.setUser({\n\t\t\t\tid: entry.loggerAttributes.user ?? entry.ownAttributes.user,\n\t\t\t})\n\t\t\tscope.setExtra('requestId', entry.loggerAttributes.requestId)\n\n\t\t\tscope.addEventProcessor(event => {\n\t\t\t\tconst traceId = entry.loggerAttributes.traceId\n\t\t\t\tconst spanId = entry.loggerAttributes.spanId\n\t\t\t\treturn {\n\t\t\t\t\t...event,\n\t\t\t\t\trequest: {\n\t\t\t\t\t\turl: entry.loggerAttributes.url ?? entry.ownAttributes.url,\n\t\t\t\t\t\tdata: entry.loggerAttributes[LoggerRequestBody],\n\t\t\t\t\t},\n\t\t\t\t\t...(typeof traceId === 'string' && typeof spanId === 'string'\n\t\t\t\t\t\t? { contexts: { ...event.contexts, trace: { trace_id: traceId, span_id: spanId } } }\n\t\t\t\t\t\t: {}),\n\t\t\t\t}\n\t\t\t})\n\t\t\treturn scope\n\t\t})\n\t}\n\n\tclose(): void {\n\t}\n}\n\ntype SentryIntegration = ReturnType<typeof Sentry.getDefaultIntegrations>[number]\n\n// Undici (fetch) would record outgoing request URLs, which may carry a webhook credential in the path or query,\n// in breadcrumbs and spans, and add Sentry trace headers to every webhook request.\nexport const filterSentryIntegrations = (integrations: SentryIntegration[]): SentryIntegration[] =>\n\tintegrations.filter(integration => !['Console', 'Http', 'Undici'].includes(integration.name))\n\nexport const createSentryLoggerHandler = (dsn?: string): null | LoggerHandler => {\n\tif (!dsn) {\n\t\treturn null\n\t}\n\tSentry.init({\n\t\tdsn: dsn,\n\t\tintegrations: filterSentryIntegrations,\n\t})\n\treturn new SentryLoggerHandler(LogLevels.warn)\n}\n"],"names":["Sentry","LoggerRequestBody","LogLevels"],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAIA,MAAM,kBAA8D;AAAA,EACnE,MAAM;AAAA,EACN,OAAO;AAAA,EACP,MAAM;AAAA,EACN,OAAO;AAAA,EACP,MAAM;AACP;AAEO,MAAM,oBAA6C;AAAA,EACzD,YACkB,UAChB;AADgB,SAAA,WAAA;AAAA,EAElB;AAAA,EAEA,cAAsB;AACrB,WAAO,KAAK,SAAS;AAAA,EACtB;AAAA,EAEA,OAAO,OAAiB;AACvB,QAAI,CAAC,MAAM,SAAS,MAAM,MAAM,QAAQ,KAAK,SAAS,OAAO;AAC5D;AAAA,IACD;AACAA,sBAAO,iBAAiB,MAAM,OAAO,CAAA,UAAS;AAC7C,YAAM,OAAO,WAAW,MAAM,iBAAiB,WAAW,MAAM,cAAc,OAAO;AACrF,YAAM,OAAO,gBAAgB,MAAM,iBAAiB,gBAAgB,MAAM,cAAc,YAAY;AACpG,YAAM,OAAO,UAAU,MAAM,iBAAiB,UAAU,MAAM,cAAc,MAAM;AAClF,YAAM,SAAS,gBAAgB,MAAM,MAAM,IAAI,CAAC;AAChD,YAAM,QAAQ;AAAA,QACb,IAAI,MAAM,iBAAiB,QAAQ,MAAM,cAAc;AAAA,MAAA,CACvD;AACD,YAAM,SAAS,aAAa,MAAM,iBAAiB,SAAS;AAE5D,YAAM,kBAAkB,CAAA,UAAS;AAChC,cAAM,UAAU,MAAM,iBAAiB;AACvC,cAAM,SAAS,MAAM,iBAAiB;AACtC,eAAO;AAAA,UACN,GAAG;AAAA,UACH,SAAS;AAAA,YACR,KAAK,MAAM,iBAAiB,OAAO,MAAM,cAAc;AAAA,YACvD,MAAM,MAAM,iBAAiBC,YAAAA,iBAAiB;AAAA,UAAA;AAAA,UAE/C,GAAI,OAAO,YAAY,YAAY,OAAO,WAAW,WAClD,EAAE,UAAU,EAAE,GAAG,MAAM,UAAU,OAAO,EAAE,UAAU,SAAS,SAAS,OAAA,EAAO,MAC7E,CAAA;AAAA,QAAC;AAAA,MAEN,CAAC;AACD,aAAO;AAAA,IACR,CAAC;AAAA,EACF;AAAA,EAEA,QAAc;AAAA,EACd;AACD;AAMO,MAAM,2BAA2B,CAAC,iBACxC,aAAa,OAAO,CAAA,gBAAe,CAAC,CAAC,WAAW,QAAQ,QAAQ,EAAE,SAAS,YAAY,IAAI,CAAC;AAEtF,MAAM,4BAA4B,CAAC,QAAuC;AAChF,MAAI,CAAC,KAAK;AACT,WAAO;AAAA,EACR;AACAD,oBAAO,KAAK;AAAA,IACX;AAAA,IACA,cAAc;AAAA,EAAA,CACd;AACD,SAAO,IAAI,oBAAoBE,OAAAA,UAAU,IAAI;AAC9C;;;;"}
|
|
@@ -46,20 +46,20 @@ class SentryLoggerHandler {
|
|
|
46
46
|
close() {
|
|
47
47
|
}
|
|
48
48
|
}
|
|
49
|
+
const filterSentryIntegrations = (integrations) => integrations.filter((integration) => !["Console", "Http", "Undici"].includes(integration.name));
|
|
49
50
|
const createSentryLoggerHandler = (dsn) => {
|
|
50
51
|
if (!dsn) {
|
|
51
52
|
return null;
|
|
52
53
|
}
|
|
53
54
|
Sentry.init({
|
|
54
55
|
dsn,
|
|
55
|
-
integrations:
|
|
56
|
-
return integrations.filter((integration) => integration.name !== "Console" && integration.name !== "Http");
|
|
57
|
-
}
|
|
56
|
+
integrations: filterSentryIntegrations
|
|
58
57
|
});
|
|
59
58
|
return new SentryLoggerHandler(LogLevels.warn);
|
|
60
59
|
};
|
|
61
60
|
export {
|
|
62
61
|
SentryLoggerHandler,
|
|
63
|
-
createSentryLoggerHandler
|
|
62
|
+
createSentryLoggerHandler,
|
|
63
|
+
filterSentryIntegrations
|
|
64
64
|
};
|
|
65
65
|
//# sourceMappingURL=sentry.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sentry.js","sources":["../../../../../packages/engine-http/src/utils/sentry.ts"],"sourcesContent":["import * as Sentry from '@sentry/node'\nimport { LogEntry, LoggerHandler, LogLevel, LogLevelName, LogLevels } from '@contember/logger'\nimport { LoggerRequestBody } from '../application/index.js'\n\nconst logLevelMapping: Record<LogLevelName, Sentry.SeverityLevel> = {\n\tcrit: 'fatal',\n\terror: 'error',\n\twarn: 'warning',\n\tdebug: 'debug',\n\tinfo: 'info',\n}\n\nexport class SentryLoggerHandler implements LoggerHandler {\n\tconstructor(\n\t\tprivate readonly logLevel: LogLevel,\n\t) {\n\t}\n\n\tgetMinLevel(): number {\n\t\treturn this.logLevel.value\n\t}\n\n\thandle(entry: LogEntry) {\n\t\tif (!entry.error || entry.level.value < this.logLevel.value) {\n\t\t\treturn\n\t\t}\n\t\tSentry.captureException(entry.error, scope => {\n\t\t\tscope.setTag('project', entry.loggerAttributes.project ?? entry.ownAttributes.project)\n\t\t\tscope.setTag('projectGroup', entry.loggerAttributes.projectGroup ?? entry.ownAttributes.projectGroup)\n\t\t\tscope.setTag('module', entry.loggerAttributes.module ?? entry.ownAttributes.module)\n\t\t\tscope.setLevel(logLevelMapping[entry.level.name])\n\t\t\tscope.setUser({\n\t\t\t\tid: entry.loggerAttributes.user ?? entry.ownAttributes.user,\n\t\t\t})\n\t\t\tscope.setExtra('requestId', entry.loggerAttributes.requestId)\n\n\t\t\tscope.addEventProcessor(event => {\n\t\t\t\tconst traceId = entry.loggerAttributes.traceId\n\t\t\t\tconst spanId = entry.loggerAttributes.spanId\n\t\t\t\treturn {\n\t\t\t\t\t...event,\n\t\t\t\t\trequest: {\n\t\t\t\t\t\turl: entry.loggerAttributes.url ?? entry.ownAttributes.url,\n\t\t\t\t\t\tdata: entry.loggerAttributes[LoggerRequestBody],\n\t\t\t\t\t},\n\t\t\t\t\t...(typeof traceId === 'string' && typeof spanId === 'string'\n\t\t\t\t\t\t? { contexts: { ...event.contexts, trace: { trace_id: traceId, span_id: spanId } } }\n\t\t\t\t\t\t: {}),\n\t\t\t\t}\n\t\t\t})\n\t\t\treturn scope\n\t\t})\n\t}\n\n\tclose(): void {\n\t}\n}\n\nexport const createSentryLoggerHandler = (dsn?: string): null | LoggerHandler => {\n\tif (!dsn) {\n\t\treturn null\n\t}\n\tSentry.init({\n\t\tdsn: dsn,\n\t\tintegrations:
|
|
1
|
+
{"version":3,"file":"sentry.js","sources":["../../../../../packages/engine-http/src/utils/sentry.ts"],"sourcesContent":["import * as Sentry from '@sentry/node'\nimport { LogEntry, LoggerHandler, LogLevel, LogLevelName, LogLevels } from '@contember/logger'\nimport { LoggerRequestBody } from '../application/index.js'\n\nconst logLevelMapping: Record<LogLevelName, Sentry.SeverityLevel> = {\n\tcrit: 'fatal',\n\terror: 'error',\n\twarn: 'warning',\n\tdebug: 'debug',\n\tinfo: 'info',\n}\n\nexport class SentryLoggerHandler implements LoggerHandler {\n\tconstructor(\n\t\tprivate readonly logLevel: LogLevel,\n\t) {\n\t}\n\n\tgetMinLevel(): number {\n\t\treturn this.logLevel.value\n\t}\n\n\thandle(entry: LogEntry) {\n\t\tif (!entry.error || entry.level.value < this.logLevel.value) {\n\t\t\treturn\n\t\t}\n\t\tSentry.captureException(entry.error, scope => {\n\t\t\tscope.setTag('project', entry.loggerAttributes.project ?? entry.ownAttributes.project)\n\t\t\tscope.setTag('projectGroup', entry.loggerAttributes.projectGroup ?? entry.ownAttributes.projectGroup)\n\t\t\tscope.setTag('module', entry.loggerAttributes.module ?? entry.ownAttributes.module)\n\t\t\tscope.setLevel(logLevelMapping[entry.level.name])\n\t\t\tscope.setUser({\n\t\t\t\tid: entry.loggerAttributes.user ?? entry.ownAttributes.user,\n\t\t\t})\n\t\t\tscope.setExtra('requestId', entry.loggerAttributes.requestId)\n\n\t\t\tscope.addEventProcessor(event => {\n\t\t\t\tconst traceId = entry.loggerAttributes.traceId\n\t\t\t\tconst spanId = entry.loggerAttributes.spanId\n\t\t\t\treturn {\n\t\t\t\t\t...event,\n\t\t\t\t\trequest: {\n\t\t\t\t\t\turl: entry.loggerAttributes.url ?? entry.ownAttributes.url,\n\t\t\t\t\t\tdata: entry.loggerAttributes[LoggerRequestBody],\n\t\t\t\t\t},\n\t\t\t\t\t...(typeof traceId === 'string' && typeof spanId === 'string'\n\t\t\t\t\t\t? { contexts: { ...event.contexts, trace: { trace_id: traceId, span_id: spanId } } }\n\t\t\t\t\t\t: {}),\n\t\t\t\t}\n\t\t\t})\n\t\t\treturn scope\n\t\t})\n\t}\n\n\tclose(): void {\n\t}\n}\n\ntype SentryIntegration = ReturnType<typeof Sentry.getDefaultIntegrations>[number]\n\n// Undici (fetch) would record outgoing request URLs, which may carry a webhook credential in the path or query,\n// in breadcrumbs and spans, and add Sentry trace headers to every webhook request.\nexport const filterSentryIntegrations = (integrations: SentryIntegration[]): SentryIntegration[] =>\n\tintegrations.filter(integration => !['Console', 'Http', 'Undici'].includes(integration.name))\n\nexport const createSentryLoggerHandler = (dsn?: string): null | LoggerHandler => {\n\tif (!dsn) {\n\t\treturn null\n\t}\n\tSentry.init({\n\t\tdsn: dsn,\n\t\tintegrations: filterSentryIntegrations,\n\t})\n\treturn new SentryLoggerHandler(LogLevels.warn)\n}\n"],"names":[],"mappings":";;;AAIA,MAAM,kBAA8D;AAAA,EACnE,MAAM;AAAA,EACN,OAAO;AAAA,EACP,MAAM;AAAA,EACN,OAAO;AAAA,EACP,MAAM;AACP;AAEO,MAAM,oBAA6C;AAAA,EACzD,YACkB,UAChB;AADgB,SAAA,WAAA;AAAA,EAElB;AAAA,EAEA,cAAsB;AACrB,WAAO,KAAK,SAAS;AAAA,EACtB;AAAA,EAEA,OAAO,OAAiB;AACvB,QAAI,CAAC,MAAM,SAAS,MAAM,MAAM,QAAQ,KAAK,SAAS,OAAO;AAC5D;AAAA,IACD;AACA,WAAO,iBAAiB,MAAM,OAAO,CAAA,UAAS;AAC7C,YAAM,OAAO,WAAW,MAAM,iBAAiB,WAAW,MAAM,cAAc,OAAO;AACrF,YAAM,OAAO,gBAAgB,MAAM,iBAAiB,gBAAgB,MAAM,cAAc,YAAY;AACpG,YAAM,OAAO,UAAU,MAAM,iBAAiB,UAAU,MAAM,cAAc,MAAM;AAClF,YAAM,SAAS,gBAAgB,MAAM,MAAM,IAAI,CAAC;AAChD,YAAM,QAAQ;AAAA,QACb,IAAI,MAAM,iBAAiB,QAAQ,MAAM,cAAc;AAAA,MAAA,CACvD;AACD,YAAM,SAAS,aAAa,MAAM,iBAAiB,SAAS;AAE5D,YAAM,kBAAkB,CAAA,UAAS;AAChC,cAAM,UAAU,MAAM,iBAAiB;AACvC,cAAM,SAAS,MAAM,iBAAiB;AACtC,eAAO;AAAA,UACN,GAAG;AAAA,UACH,SAAS;AAAA,YACR,KAAK,MAAM,iBAAiB,OAAO,MAAM,cAAc;AAAA,YACvD,MAAM,MAAM,iBAAiB,iBAAiB;AAAA,UAAA;AAAA,UAE/C,GAAI,OAAO,YAAY,YAAY,OAAO,WAAW,WAClD,EAAE,UAAU,EAAE,GAAG,MAAM,UAAU,OAAO,EAAE,UAAU,SAAS,SAAS,OAAA,EAAO,MAC7E,CAAA;AAAA,QAAC;AAAA,MAEN,CAAC;AACD,aAAO;AAAA,IACR,CAAC;AAAA,EACF;AAAA,EAEA,QAAc;AAAA,EACd;AACD;AAMO,MAAM,2BAA2B,CAAC,iBACxC,aAAa,OAAO,CAAA,gBAAe,CAAC,CAAC,WAAW,QAAQ,QAAQ,EAAE,SAAS,YAAY,IAAI,CAAC;AAEtF,MAAM,4BAA4B,CAAC,QAAuC;AAChF,MAAI,CAAC,KAAK;AACT,WAAO;AAAA,EACR;AACA,SAAO,KAAK;AAAA,IACX;AAAA,IACA,cAAc;AAAA,EAAA,CACd;AACD,SAAO,IAAI,oBAAoB,UAAU,IAAI;AAC9C;"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sentryIntegrations.test.d.ts","sourceRoot":"","sources":["../../../../tests/cases/unit/sentryIntegrations.test.ts"],"names":[],"mappings":""}
|