@sentry/google-cloud-serverless 8.53.0 → 9.0.0-alpha.0
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/build/cjs/debug-build.js +1 -1
- package/build/cjs/gcpfunction/cloud_events.js +1 -1
- package/build/cjs/gcpfunction/events.js +1 -1
- package/build/cjs/gcpfunction/http.js +2 -6
- package/build/cjs/gcpfunction/http.js.map +1 -1
- package/build/cjs/index.js +1 -12
- package/build/cjs/index.js.map +1 -1
- package/build/cjs/integrations/google-cloud-grpc.js +4 -8
- package/build/cjs/integrations/google-cloud-grpc.js.map +1 -1
- package/build/cjs/integrations/google-cloud-http.js +2 -2
- package/build/cjs/integrations/google-cloud-http.js.map +1 -1
- package/build/cjs/sdk.js +1 -1
- package/build/cjs/utils.js +1 -1
- package/build/esm/gcpfunction/http.js +1 -2
- package/build/esm/gcpfunction/http.js.map +1 -1
- package/build/esm/index.js +2 -2
- package/build/esm/integrations/google-cloud-grpc.js +3 -4
- package/build/esm/integrations/google-cloud-grpc.js.map +1 -1
- package/build/esm/integrations/google-cloud-http.js +1 -1
- package/build/esm/integrations/google-cloud-http.js.map +1 -1
- package/build/esm/package.json +1 -1
- package/build/types/index.d.ts +2 -2
- package/build/types/index.d.ts.map +1 -1
- package/build/types-ts3.8/index.d.ts +2 -2
- package/package.json +6 -6
package/build/cjs/debug-build.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
Object.defineProperty(exports,
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
4
|
* This serves as a build time flag that will be true by default, but false in non-debug builds or if users replace `__SENTRY_DEBUG__` in their generated code.
|
|
@@ -1,8 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
_optionalChain
|
|
3
|
-
} = require('@sentry/core');
|
|
4
|
-
|
|
5
|
-
Object.defineProperty(exports, '__esModule', { value: true });
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
6
2
|
|
|
7
3
|
const core = require('@sentry/core');
|
|
8
4
|
const node = require('@sentry/node');
|
|
@@ -38,7 +34,7 @@ function _wrapHttpFunction(fn, options) {
|
|
|
38
34
|
const reqUrl = core.stripUrlQueryAndFragment(req.originalUrl || req.url || '');
|
|
39
35
|
|
|
40
36
|
const sentryTrace = req.headers && core.isString(req.headers['sentry-trace']) ? req.headers['sentry-trace'] : undefined;
|
|
41
|
-
const baggage =
|
|
37
|
+
const baggage = req.headers?.baggage;
|
|
42
38
|
|
|
43
39
|
return node.continueTrace({ sentryTrace, baggage }, () => {
|
|
44
40
|
const normalizedRequest = core.httpRequestToRequestData(req);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"http.js","sources":["../../../src/gcpfunction/http.ts"],"sourcesContent":["import {\n SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN,\n SEMANTIC_ATTRIBUTE_SENTRY_SOURCE,\n handleCallbackErrors,\n httpRequestToRequestData,\n isString,\n logger,\n setHttpStatus,\n stripUrlQueryAndFragment,\n} from '@sentry/core';\nimport { captureException, continueTrace, flush, getCurrentScope, startSpanManual } from '@sentry/node';\nimport { DEBUG_BUILD } from '../debug-build';\nimport { domainify, markEventUnhandled, proxyFunction } from '../utils';\nimport type { HttpFunction, WrapperOptions } from './general';\n\n/**\n * Wraps an HTTP function handler adding it error capture and tracing capabilities.\n *\n * @param fn HTTP Handler\n * @param options Options\n * @returns HTTP handler\n */\nexport function wrapHttpFunction(fn: HttpFunction, wrapOptions: Partial<WrapperOptions> = {}): HttpFunction {\n const wrap = (f: HttpFunction): HttpFunction => domainify(_wrapHttpFunction(f, wrapOptions));\n\n let overrides: Record<PropertyKey, unknown> | undefined;\n\n // Functions emulator from firebase-tools has a hack-ish workaround that saves the actual function\n // passed to `onRequest(...)` and in fact runs it so we need to wrap it too.\n const emulatorFunc = (fn as HttpFunction & { __emulator_func?: HttpFunction }).__emulator_func;\n if (emulatorFunc) {\n overrides = { __emulator_func: proxyFunction(emulatorFunc, wrap) };\n }\n return proxyFunction(fn, wrap, overrides);\n}\n\n/** */\nfunction _wrapHttpFunction(fn: HttpFunction, options: Partial<WrapperOptions>): HttpFunction {\n const flushTimeout = options.flushTimeout || 2000;\n return (req, res) => {\n const reqMethod = (req.method || '').toUpperCase();\n const reqUrl = stripUrlQueryAndFragment(req.originalUrl || req.url || '');\n\n const sentryTrace = req.headers && isString(req.headers['sentry-trace']) ? req.headers['sentry-trace'] : undefined;\n const baggage = req.headers?.baggage;\n\n return continueTrace({ sentryTrace, baggage }, () => {\n const normalizedRequest = httpRequestToRequestData(req);\n getCurrentScope().setSDKProcessingMetadata({ normalizedRequest });\n\n return startSpanManual(\n {\n name: `${reqMethod} ${reqUrl}`,\n op: 'function.gcp.http',\n attributes: {\n [SEMANTIC_ATTRIBUTE_SENTRY_SOURCE]: 'route',\n [SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN]: 'auto.function.serverless.gcp_http',\n },\n },\n span => {\n // eslint-disable-next-line @typescript-eslint/unbound-method\n const _end = res.end;\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n res.end = function (chunk?: any | (() => void), encoding?: string | (() => void), cb?: () => void): any {\n setHttpStatus(span, res.statusCode);\n span.end();\n\n // eslint-disable-next-line @typescript-eslint/no-floating-promises\n flush(flushTimeout)\n .then(null, e => {\n DEBUG_BUILD && logger.error(e);\n })\n .then(() => {\n _end.call(this, chunk, encoding, cb);\n });\n };\n\n return handleCallbackErrors(\n () => fn(req, res),\n err => {\n captureException(err, scope => markEventUnhandled(scope));\n },\n );\n },\n );\n });\n };\n}\n"],"names":["domainify","proxyFunction","stripUrlQueryAndFragment","isString","continueTrace","httpRequestToRequestData","getCurrentScope","startSpanManual","SEMANTIC_ATTRIBUTE_SENTRY_SOURCE","SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN","setHttpStatus","flush","DEBUG_BUILD","logger","handleCallbackErrors","captureException","mark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UAEA,OAAAC,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA;YACA,MAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,EAAA,GAAA,CAAA;YACA,IAAA,CAAA,EAAA;cACAC,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAA,CAAA,CAAA,CAAA,CAAA,EAAA,CAAA,CAAA,CAAA,CAAA,KAAAC,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA;YACA,CAAA;UACA,CAAA;QACA,CAAA;MACA,CAAA;IACA,CAAA,CAAA;EACA,CAAA;AACA;;"}
|
|
1
|
+
{"version":3,"file":"http.js","sources":["../../../src/gcpfunction/http.ts"],"sourcesContent":["import {\n SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN,\n SEMANTIC_ATTRIBUTE_SENTRY_SOURCE,\n handleCallbackErrors,\n httpRequestToRequestData,\n isString,\n logger,\n setHttpStatus,\n stripUrlQueryAndFragment,\n} from '@sentry/core';\nimport { captureException, continueTrace, flush, getCurrentScope, startSpanManual } from '@sentry/node';\nimport { DEBUG_BUILD } from '../debug-build';\nimport { domainify, markEventUnhandled, proxyFunction } from '../utils';\nimport type { HttpFunction, WrapperOptions } from './general';\n\n/**\n * Wraps an HTTP function handler adding it error capture and tracing capabilities.\n *\n * @param fn HTTP Handler\n * @param options Options\n * @returns HTTP handler\n */\nexport function wrapHttpFunction(fn: HttpFunction, wrapOptions: Partial<WrapperOptions> = {}): HttpFunction {\n const wrap = (f: HttpFunction): HttpFunction => domainify(_wrapHttpFunction(f, wrapOptions));\n\n let overrides: Record<PropertyKey, unknown> | undefined;\n\n // Functions emulator from firebase-tools has a hack-ish workaround that saves the actual function\n // passed to `onRequest(...)` and in fact runs it so we need to wrap it too.\n const emulatorFunc = (fn as HttpFunction & { __emulator_func?: HttpFunction }).__emulator_func;\n if (emulatorFunc) {\n overrides = { __emulator_func: proxyFunction(emulatorFunc, wrap) };\n }\n return proxyFunction(fn, wrap, overrides);\n}\n\n/** */\nfunction _wrapHttpFunction(fn: HttpFunction, options: Partial<WrapperOptions>): HttpFunction {\n const flushTimeout = options.flushTimeout || 2000;\n return (req, res) => {\n const reqMethod = (req.method || '').toUpperCase();\n const reqUrl = stripUrlQueryAndFragment(req.originalUrl || req.url || '');\n\n const sentryTrace = req.headers && isString(req.headers['sentry-trace']) ? req.headers['sentry-trace'] : undefined;\n const baggage = req.headers?.baggage;\n\n return continueTrace({ sentryTrace, baggage }, () => {\n const normalizedRequest = httpRequestToRequestData(req);\n getCurrentScope().setSDKProcessingMetadata({ normalizedRequest });\n\n return startSpanManual(\n {\n name: `${reqMethod} ${reqUrl}`,\n op: 'function.gcp.http',\n attributes: {\n [SEMANTIC_ATTRIBUTE_SENTRY_SOURCE]: 'route',\n [SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN]: 'auto.function.serverless.gcp_http',\n },\n },\n span => {\n // eslint-disable-next-line @typescript-eslint/unbound-method\n const _end = res.end;\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n res.end = function (chunk?: any | (() => void), encoding?: string | (() => void), cb?: () => void): any {\n setHttpStatus(span, res.statusCode);\n span.end();\n\n // eslint-disable-next-line @typescript-eslint/no-floating-promises\n flush(flushTimeout)\n .then(null, e => {\n DEBUG_BUILD && logger.error(e);\n })\n .then(() => {\n _end.call(this, chunk, encoding, cb);\n });\n };\n\n return handleCallbackErrors(\n () => fn(req, res),\n err => {\n captureException(err, scope => markEventUnhandled(scope));\n },\n );\n },\n );\n });\n };\n}\n"],"names":["domainify","proxyFunction","stripUrlQueryAndFragment","isString","continueTrace","httpRequestToRequestData","getCurrentScope","startSpanManual","SEMANTIC_ATTRIBUTE_SENTRY_SOURCE","SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN","setHttpStatus","flush","DEBUG_BUILD","logger","handleCallbackErrors","captureException","markEventUnhandled"],"mappings":";;;;;;;AAeA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAAS,gBAAgB,CAAC,EAAE,EAAgB,WAAW,GAA4B,EAAE,EAAgB;AAC5G,EAAE,MAAM,IAAA,GAAO,CAAC,CAAC,KAAiCA,eAAS,CAAC,iBAAiB,CAAC,CAAC,EAAE,WAAW,CAAC,CAAC;;AAE9F,EAAE,IAAI,SAAS;;AAEf;AACA;AACA,EAAE,MAAM,YAAa,GAAE,CAAC,EAAG,GAAsD,eAAe;AAChG,EAAE,IAAI,YAAY,EAAE;AACpB,IAAI,SAAA,GAAY,EAAE,eAAe,EAAEC,mBAAa,CAAC,YAAY,EAAE,IAAI,CAAA,EAAG;AACtE;AACA,EAAE,OAAOA,mBAAa,CAAC,EAAE,EAAE,IAAI,EAAE,SAAS,CAAC;AAC3C;;AAEA;AACA,SAAS,iBAAiB,CAAC,EAAE,EAAgB,OAAO,EAAyC;AAC7F,EAAE,MAAM,YAAa,GAAE,OAAO,CAAC,YAAA,IAAgB,IAAI;AACnD,EAAE,OAAO,CAAC,GAAG,EAAE,GAAG,KAAK;AACvB,IAAI,MAAM,SAAA,GAAY,CAAC,GAAG,CAAC,MAAO,IAAG,EAAE,EAAE,WAAW,EAAE;AACtD,IAAI,MAAM,MAAA,GAASC,6BAAwB,CAAC,GAAG,CAAC,WAAY,IAAG,GAAG,CAAC,GAAI,IAAG,EAAE,CAAC;;AAE7E,IAAI,MAAM,WAAY,GAAE,GAAG,CAAC,WAAWC,aAAQ,CAAC,GAAG,CAAC,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AA,GAAA,EAAA,GAAA,CAAA;AACA,YAAA,GAAA,IAAA;AACA,cAAAC,qBAAA,CAAA,GAAA,EAAA,KAAA,IAAAC,wBAAA,CAAA,KAAA,CAAA,CAAA;AACA,aAAA;AACA,WAAA;AACA,SAAA;AACA,OAAA;AACA,KAAA,CAAA;AACA,GAAA;AACA;;;;"}
|
package/build/cjs/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
Object.defineProperty(exports,
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
2
2
|
|
|
3
3
|
const node = require('@sentry/node');
|
|
4
4
|
const core = require('@sentry/core');
|
|
@@ -11,7 +11,6 @@ const events = require('./gcpfunction/events.js');
|
|
|
11
11
|
|
|
12
12
|
|
|
13
13
|
|
|
14
|
-
exports.DEFAULT_USER_INCLUDES = node.DEFAULT_USER_INCLUDES;
|
|
15
14
|
exports.NodeClient = node.NodeClient;
|
|
16
15
|
exports.SDK_VERSION = node.SDK_VERSION;
|
|
17
16
|
exports.SEMANTIC_ATTRIBUTE_SENTRY_OP = node.SEMANTIC_ATTRIBUTE_SENTRY_OP;
|
|
@@ -22,8 +21,6 @@ exports.Scope = node.Scope;
|
|
|
22
21
|
exports.addBreadcrumb = node.addBreadcrumb;
|
|
23
22
|
exports.addEventProcessor = node.addEventProcessor;
|
|
24
23
|
exports.addIntegration = node.addIntegration;
|
|
25
|
-
exports.addOpenTelemetryInstrumentation = node.addOpenTelemetryInstrumentation;
|
|
26
|
-
exports.addRequestDataToEvent = node.addRequestDataToEvent;
|
|
27
24
|
exports.amqplibIntegration = node.amqplibIntegration;
|
|
28
25
|
exports.anrIntegration = node.anrIntegration;
|
|
29
26
|
exports.captureCheckIn = node.captureCheckIn;
|
|
@@ -47,7 +44,6 @@ exports.disableAnrDetectionForCallback = node.disableAnrDetectionForCallback;
|
|
|
47
44
|
exports.endSession = node.endSession;
|
|
48
45
|
exports.expressErrorHandler = node.expressErrorHandler;
|
|
49
46
|
exports.expressIntegration = node.expressIntegration;
|
|
50
|
-
exports.extractRequestData = node.extractRequestData;
|
|
51
47
|
exports.fastifyIntegration = node.fastifyIntegration;
|
|
52
48
|
exports.flush = node.flush;
|
|
53
49
|
exports.fsIntegration = node.fsIntegration;
|
|
@@ -57,7 +53,6 @@ exports.genericPoolIntegration = node.genericPoolIntegration;
|
|
|
57
53
|
exports.getActiveSpan = node.getActiveSpan;
|
|
58
54
|
exports.getAutoPerformanceIntegrations = node.getAutoPerformanceIntegrations;
|
|
59
55
|
exports.getClient = node.getClient;
|
|
60
|
-
exports.getCurrentHub = node.getCurrentHub;
|
|
61
56
|
exports.getCurrentScope = node.getCurrentScope;
|
|
62
57
|
exports.getGlobalScope = node.getGlobalScope;
|
|
63
58
|
exports.getIsolationScope = node.getIsolationScope;
|
|
@@ -81,21 +76,18 @@ exports.linkedErrorsIntegration = node.linkedErrorsIntegration;
|
|
|
81
76
|
exports.localVariablesIntegration = node.localVariablesIntegration;
|
|
82
77
|
exports.lruMemoizerIntegration = node.lruMemoizerIntegration;
|
|
83
78
|
exports.makeNodeTransport = node.makeNodeTransport;
|
|
84
|
-
exports.metrics = node.metrics;
|
|
85
79
|
exports.modulesIntegration = node.modulesIntegration;
|
|
86
80
|
exports.mongoIntegration = node.mongoIntegration;
|
|
87
81
|
exports.mongooseIntegration = node.mongooseIntegration;
|
|
88
82
|
exports.mysql2Integration = node.mysql2Integration;
|
|
89
83
|
exports.mysqlIntegration = node.mysqlIntegration;
|
|
90
84
|
exports.nativeNodeFetchIntegration = node.nativeNodeFetchIntegration;
|
|
91
|
-
exports.nestIntegration = node.nestIntegration;
|
|
92
85
|
exports.nodeContextIntegration = node.nodeContextIntegration;
|
|
93
86
|
exports.onUncaughtExceptionIntegration = node.onUncaughtExceptionIntegration;
|
|
94
87
|
exports.onUnhandledRejectionIntegration = node.onUnhandledRejectionIntegration;
|
|
95
88
|
exports.parameterize = node.parameterize;
|
|
96
89
|
exports.postgresIntegration = node.postgresIntegration;
|
|
97
90
|
exports.prismaIntegration = node.prismaIntegration;
|
|
98
|
-
exports.processThreadBreadcrumbIntegration = node.processThreadBreadcrumbIntegration;
|
|
99
91
|
exports.profiler = node.profiler;
|
|
100
92
|
exports.redisIntegration = node.redisIntegration;
|
|
101
93
|
exports.requestDataIntegration = node.requestDataIntegration;
|
|
@@ -112,7 +104,6 @@ exports.setupConnectErrorHandler = node.setupConnectErrorHandler;
|
|
|
112
104
|
exports.setupExpressErrorHandler = node.setupExpressErrorHandler;
|
|
113
105
|
exports.setupHapiErrorHandler = node.setupHapiErrorHandler;
|
|
114
106
|
exports.setupKoaErrorHandler = node.setupKoaErrorHandler;
|
|
115
|
-
exports.setupNestErrorHandler = node.setupNestErrorHandler;
|
|
116
107
|
exports.spanToBaggageHeader = node.spanToBaggageHeader;
|
|
117
108
|
exports.spanToJSON = node.spanToJSON;
|
|
118
109
|
exports.spanToTraceHeader = node.spanToTraceHeader;
|
|
@@ -132,11 +123,9 @@ exports.withMonitor = node.withMonitor;
|
|
|
132
123
|
exports.withScope = node.withScope;
|
|
133
124
|
exports.zodErrorsIntegration = node.zodErrorsIntegration;
|
|
134
125
|
exports.captureConsoleIntegration = core.captureConsoleIntegration;
|
|
135
|
-
exports.debugIntegration = core.debugIntegration;
|
|
136
126
|
exports.dedupeIntegration = core.dedupeIntegration;
|
|
137
127
|
exports.extraErrorDataIntegration = core.extraErrorDataIntegration;
|
|
138
128
|
exports.rewriteFramesIntegration = core.rewriteFramesIntegration;
|
|
139
|
-
exports.sessionTimingIntegration = core.sessionTimingIntegration;
|
|
140
129
|
exports.getDefaultIntegrations = sdk.getDefaultIntegrations;
|
|
141
130
|
exports.init = sdk.init;
|
|
142
131
|
exports.googleCloudHttpIntegration = googleCloudHttp.googleCloudHttpIntegration;
|
package/build/cjs/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
|
@@ -1,8 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
_optionalChain
|
|
3
|
-
} = require('@sentry/core');
|
|
4
|
-
|
|
5
|
-
Object.defineProperty(exports, '__esModule', { value: true });
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
6
2
|
|
|
7
3
|
const core = require('@sentry/core');
|
|
8
4
|
const node = require('@sentry/node');
|
|
@@ -46,7 +42,7 @@ const googleCloudGrpcIntegration = core.defineIntegration(_googleCloudGrpcIntegr
|
|
|
46
42
|
/** Returns a wrapped function that returns a stub with tracing enabled */
|
|
47
43
|
function wrapCreateStub(origCreate) {
|
|
48
44
|
return async function ( ...args) {
|
|
49
|
-
const servicePath =
|
|
45
|
+
const servicePath = args[1]?.servicePath;
|
|
50
46
|
if (servicePath == null || servicePath == undefined) {
|
|
51
47
|
return origCreate.apply(this, args);
|
|
52
48
|
}
|
|
@@ -82,7 +78,7 @@ function fillGrpcFunction(stub, serviceIdentifier, methodName) {
|
|
|
82
78
|
(orig) =>
|
|
83
79
|
(...args) => {
|
|
84
80
|
const ret = orig.apply(stub, args);
|
|
85
|
-
if (typeof
|
|
81
|
+
if (typeof ret?.on !== 'function' || !SETUP_CLIENTS.has(core.getClient() )) {
|
|
86
82
|
return ret;
|
|
87
83
|
}
|
|
88
84
|
const span = node.startInactiveSpan({
|
|
@@ -106,7 +102,7 @@ function fillGrpcFunction(stub, serviceIdentifier, methodName) {
|
|
|
106
102
|
/** Identifies service by its address */
|
|
107
103
|
function identifyService(servicePath) {
|
|
108
104
|
const match = servicePath.match(SERVICE_PATH_REGEX);
|
|
109
|
-
return match
|
|
105
|
+
return match?.[1] || servicePath;
|
|
110
106
|
}
|
|
111
107
|
|
|
112
108
|
exports.googleCloudGrpcIntegration = googleCloudGrpcIntegration;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"google-cloud-grpc.js","sources":["../../../src/integrations/google-cloud-grpc.ts"],"sourcesContent":["import type { EventEmitter } from 'events';\nimport type { Client, IntegrationFn } from '@sentry/core';\nimport { SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN, defineIntegration, fill, getClient } from '@sentry/core';\nimport { startInactiveSpan } from '@sentry/node';\n\ninterface GrpcFunction extends CallableFunction {\n (...args: unknown[]): EventEmitter;\n}\n\ninterface GrpcFunctionObject extends GrpcFunction {\n requestStream: boolean;\n responseStream: boolean;\n originalName: string;\n}\n\ninterface StubOptions {\n servicePath?: string;\n}\n\ninterface CreateStubFunc extends CallableFunction {\n (createStub: unknown, options: StubOptions): PromiseLike<Stub>;\n}\n\ninterface Stub {\n [key: string]: GrpcFunctionObject;\n}\n\nconst SERVICE_PATH_REGEX = /^(\\w+)\\.googleapis.com$/;\n\nconst INTEGRATION_NAME = 'GoogleCloudGrpc';\n\nconst SETUP_CLIENTS = new WeakMap<Client, boolean>();\n\nconst _googleCloudGrpcIntegration = ((options: { optional?: boolean } = {}) => {\n const optional = options.optional || false;\n return {\n name: INTEGRATION_NAME,\n setupOnce() {\n try {\n // eslint-disable-next-line @typescript-eslint/no-var-requires\n const gaxModule = require('google-gax');\n fill(\n gaxModule.GrpcClient.prototype, // eslint-disable-line @typescript-eslint/no-unsafe-member-access\n 'createStub',\n wrapCreateStub,\n );\n } catch (e) {\n if (!optional) {\n throw e;\n }\n }\n },\n setup(client) {\n SETUP_CLIENTS.set(client, true);\n },\n };\n}) satisfies IntegrationFn;\n\n/**\n * Google Cloud Platform service requests tracking for GRPC APIs.\n */\nexport const googleCloudGrpcIntegration = defineIntegration(_googleCloudGrpcIntegration);\n\n/** Returns a wrapped function that returns a stub with tracing enabled */\nfunction wrapCreateStub(origCreate: CreateStubFunc): CreateStubFunc {\n return async function (this: unknown, ...args: Parameters<CreateStubFunc>) {\n const servicePath = args[1]?.servicePath;\n if (servicePath == null || servicePath == undefined) {\n return origCreate.apply(this, args);\n }\n const serviceIdentifier = identifyService(servicePath);\n const stub = await origCreate.apply(this, args);\n for (const methodName of Object.keys(Object.getPrototypeOf(stub))) {\n fillGrpcFunction(stub, serviceIdentifier, methodName);\n }\n return stub;\n };\n}\n\n/** Patches the function in grpc stub to enable tracing */\nfunction fillGrpcFunction(stub: Stub, serviceIdentifier: string, methodName: string): void {\n const funcObj = stub[methodName];\n if (typeof funcObj !== 'function') {\n return;\n }\n const callType =\n !funcObj.requestStream && !funcObj.responseStream\n ? 'unary call'\n : funcObj.requestStream && !funcObj.responseStream\n ? 'client stream'\n : !funcObj.requestStream && funcObj.responseStream\n ? 'server stream'\n : 'bidi stream';\n if (callType != 'unary call') {\n return;\n }\n fill(\n stub,\n methodName,\n (orig: GrpcFunction): GrpcFunction =>\n (...args) => {\n const ret = orig.apply(stub, args);\n if (typeof ret?.on !== 'function' || !SETUP_CLIENTS.has(getClient() as Client)) {\n return ret;\n }\n const span = startInactiveSpan({\n name: `${callType} ${methodName}`,\n onlyIfParent: true,\n op: `grpc.${serviceIdentifier}`,\n attributes: {\n [SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN]: 'auto.grpc.serverless',\n },\n });\n ret.on('status', () => {\n if (span) {\n span.end();\n }\n });\n return ret;\n },\n );\n}\n\n/** Identifies service by its address */\nfunction identifyService(servicePath: string): string {\n const match = servicePath.match(SERVICE_PATH_REGEX);\n return match && match[1] ? match[1] : servicePath;\n}\n"],"names":["fill","defineIntegration","getClient","startInactiveSpan","SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN"],"mappings":";;;;;;;;;AA2BA,CAAM,CAAA,CAAA,CAAA,EAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,C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AAA,CAAA,EAAA,MAAA,EAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,kBAAA,CAAA;EACA,CAAA,CAAA,CAAA,CAAA,CAAA,EAAA,CAAA,CAAA,CAAA,CAAA,EAAA,CAAA,EAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,EAAA,EAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,IAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA;AACA;;"}
|
|
1
|
+
{"version":3,"file":"google-cloud-grpc.js","sources":["../../../src/integrations/google-cloud-grpc.ts"],"sourcesContent":["import type { EventEmitter } from 'events';\nimport type { Client, IntegrationFn } from '@sentry/core';\nimport { SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN, defineIntegration, fill, getClient } from '@sentry/core';\nimport { startInactiveSpan } from '@sentry/node';\n\ninterface GrpcFunction extends CallableFunction {\n (...args: unknown[]): EventEmitter;\n}\n\ninterface GrpcFunctionObject extends GrpcFunction {\n requestStream: boolean;\n responseStream: boolean;\n originalName: string;\n}\n\ninterface StubOptions {\n servicePath?: string;\n}\n\ninterface CreateStubFunc extends CallableFunction {\n (createStub: unknown, options: StubOptions): PromiseLike<Stub>;\n}\n\ninterface Stub {\n [key: string]: GrpcFunctionObject;\n}\n\nconst SERVICE_PATH_REGEX = /^(\\w+)\\.googleapis.com$/;\n\nconst INTEGRATION_NAME = 'GoogleCloudGrpc';\n\nconst SETUP_CLIENTS = new WeakMap<Client, boolean>();\n\nconst _googleCloudGrpcIntegration = ((options: { optional?: boolean } = {}) => {\n const optional = options.optional || false;\n return {\n name: INTEGRATION_NAME,\n setupOnce() {\n try {\n // eslint-disable-next-line @typescript-eslint/no-var-requires\n const gaxModule = require('google-gax');\n fill(\n gaxModule.GrpcClient.prototype, // eslint-disable-line @typescript-eslint/no-unsafe-member-access\n 'createStub',\n wrapCreateStub,\n );\n } catch (e) {\n if (!optional) {\n throw e;\n }\n }\n },\n setup(client) {\n SETUP_CLIENTS.set(client, true);\n },\n };\n}) satisfies IntegrationFn;\n\n/**\n * Google Cloud Platform service requests tracking for GRPC APIs.\n */\nexport const googleCloudGrpcIntegration = defineIntegration(_googleCloudGrpcIntegration);\n\n/** Returns a wrapped function that returns a stub with tracing enabled */\nfunction wrapCreateStub(origCreate: CreateStubFunc): CreateStubFunc {\n return async function (this: unknown, ...args: Parameters<CreateStubFunc>) {\n const servicePath = args[1]?.servicePath;\n if (servicePath == null || servicePath == undefined) {\n return origCreate.apply(this, args);\n }\n const serviceIdentifier = identifyService(servicePath);\n const stub = await origCreate.apply(this, args);\n for (const methodName of Object.keys(Object.getPrototypeOf(stub))) {\n fillGrpcFunction(stub, serviceIdentifier, methodName);\n }\n return stub;\n };\n}\n\n/** Patches the function in grpc stub to enable tracing */\nfunction fillGrpcFunction(stub: Stub, serviceIdentifier: string, methodName: string): void {\n const funcObj = stub[methodName];\n if (typeof funcObj !== 'function') {\n return;\n }\n const callType =\n !funcObj.requestStream && !funcObj.responseStream\n ? 'unary call'\n : funcObj.requestStream && !funcObj.responseStream\n ? 'client stream'\n : !funcObj.requestStream && funcObj.responseStream\n ? 'server stream'\n : 'bidi stream';\n if (callType != 'unary call') {\n return;\n }\n fill(\n stub,\n methodName,\n (orig: GrpcFunction): GrpcFunction =>\n (...args) => {\n const ret = orig.apply(stub, args);\n if (typeof ret?.on !== 'function' || !SETUP_CLIENTS.has(getClient() as Client)) {\n return ret;\n }\n const span = startInactiveSpan({\n name: `${callType} ${methodName}`,\n onlyIfParent: true,\n op: `grpc.${serviceIdentifier}`,\n attributes: {\n [SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN]: 'auto.grpc.serverless',\n },\n });\n ret.on('status', () => {\n if (span) {\n span.end();\n }\n });\n return ret;\n },\n );\n}\n\n/** Identifies service by its address */\nfunction identifyService(servicePath: string): string {\n const match = servicePath.match(SERVICE_PATH_REGEX);\n return match?.[1] || servicePath;\n}\n"],"names":["fill","defineIntegration","getClient","startInactiveSpan","SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN"],"mappings":";;;;;AA2BA,MAAM,kBAAA,GAAqB,yBAAyB;;AAEpD,MAAM,gBAAA,GAAmB,iBAAiB;;AAE1C,MAAM,aAAc,GAAE,IAAI,OAAO,EAAmB;;AAEpD,MAAM,2BAAA,IAA+B,CAAC,OAAO,GAA2B,EAAE,KAAK;AAC/E,EAAE,MAAM,QAAS,GAAE,OAAO,CAAC,QAAA,IAAY,KAAK;AAC5C,EAAE,OAAO;AACT,IAAI,IAAI,EAAE,gBAAgB;AAC1B,IAAI,SAAS,GAAG;AAChB,MAAM,IAAI;AACV;AACA,QAAQ,MAAM,SAAU,GAAE,OAAO,CAAC,YAAY,CAAC;AAC/C,QAAQA,SAAI;AACZ,UAAU,SAAS,CAAC,UAAU,CAAC,SAAS;AACxC,UAAU,YAAY;AACtB,UAAU,cAAc;AACxB,SAAS;AACT,OAAQ,CAAA,OAAO,CAAC,EAAE;AAClB,QAAQ,IAAI,CAAC,QAAQ,EAAE;AACvB,UAAU,MAAM,CAAC;AACjB;AACA;AACA,KAAK;AACL,IAAI,KAAK,CAAC,MAAM,EAAE;AAClB,MAAM,aAAa,CAAC,GAAG,CAAC,MAAM,EAAE,IAAI,CAAC;AACrC,KAAK;AACL,GAAG;AACH,CAAC,CAAE;;AAEH;AACA;AACA;MACa,0BAA2B,GAAEC,sBAAiB,CAAC,2BAA2B;;AAEvF;AACA,SAAS,cAAc,CAAC,UAAU,EAAkC;AACpE,EAAE,OAAO,iBAA+B,GAAG,IAAI,EAA8B;AAC7E,IAAI,MAAM,cAAc,IAAI,CAAC,CAAC,CAAC,EAAE,WAAW;AAC5C,IAAI,IAAI,WAAY,IAAG,QAAQ,WAAA,IAAe,SAAS,EAAE;AACzD,MAAM,OAAO,UAAU,CAAC,KAAK,CAAC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Q,MAAM,IAAA,GAAOC,sBAAiB,CAAC;AACvC,UAAU,IAAI,EAAE,CAAC,EAAA,QAAA,CAAA,CAAA,EAAA,UAAA,CAAA,CAAA;AACA,UAAA,YAAA,EAAA,IAAA;AACA,UAAA,EAAA,EAAA,CAAA,KAAA,EAAA,iBAAA,CAAA,CAAA;AACA,UAAA,UAAA,EAAA;AACA,YAAA,CAAAC,qCAAA,GAAA,sBAAA;AACA,WAAA;AACA,SAAA,CAAA;AACA,QAAA,GAAA,CAAA,EAAA,CAAA,QAAA,EAAA,MAAA;AACA,UAAA,IAAA,IAAA,EAAA;AACA,YAAA,IAAA,CAAA,GAAA,EAAA;AACA;AACA,SAAA,CAAA;AACA,QAAA,OAAA,GAAA;AACA,OAAA;AACA,GAAA;AACA;;AAEA;AACA,SAAA,eAAA,CAAA,WAAA,EAAA;AACA,EAAA,MAAA,KAAA,GAAA,WAAA,CAAA,KAAA,CAAA,kBAAA,CAAA;AACA,EAAA,OAAA,KAAA,GAAA,CAAA,CAAA,IAAA,WAAA;AACA;;;;"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
Object.defineProperty(exports,
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
2
2
|
|
|
3
3
|
const core = require('@sentry/core');
|
|
4
4
|
const node = require('@sentry/node');
|
|
@@ -57,7 +57,7 @@ function wrapRequestFunction(orig) {
|
|
|
57
57
|
/** Identifies service by its base url */
|
|
58
58
|
function identifyService(apiEndpoint) {
|
|
59
59
|
const match = apiEndpoint.match(/^https:\/\/(\w+)\.googleapis.com$/);
|
|
60
|
-
return match
|
|
60
|
+
return match?.[1] || apiEndpoint.replace(/^(http|https)?:\/\//, '');
|
|
61
61
|
}
|
|
62
62
|
|
|
63
63
|
exports.googleCloudHttpIntegration = googleCloudHttpIntegration;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"google-cloud-http.js","sources":["../../../src/integrations/google-cloud-http.ts"],"sourcesContent":["import type * as common from '@google-cloud/common';\nimport type { Client, IntegrationFn } from '@sentry/core';\nimport {\n SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN,\n SentryNonRecordingSpan,\n defineIntegration,\n fill,\n getClient,\n} from '@sentry/core';\nimport { startInactiveSpan } from '@sentry/node';\n\ntype RequestOptions = common.DecorateRequestOptions;\ntype ResponseCallback = common.BodyResponseCallback;\n// This interace could be replaced with just type alias once the `strictBindCallApply` mode is enabled.\ninterface RequestFunction extends CallableFunction {\n (reqOpts: RequestOptions, callback: ResponseCallback): void;\n}\n\nconst INTEGRATION_NAME = 'GoogleCloudHttp';\n\nconst SETUP_CLIENTS = new WeakMap<Client, boolean>();\n\nconst _googleCloudHttpIntegration = ((options: { optional?: boolean } = {}) => {\n const optional = options.optional || false;\n return {\n name: INTEGRATION_NAME,\n setupOnce() {\n try {\n // eslint-disable-next-line @typescript-eslint/no-var-requires\n const commonModule = require('@google-cloud/common') as typeof common;\n fill(commonModule.Service.prototype, 'request', wrapRequestFunction);\n } catch (e) {\n if (!optional) {\n throw e;\n }\n }\n },\n setup(client) {\n SETUP_CLIENTS.set(client, true);\n },\n };\n}) satisfies IntegrationFn;\n\n/**\n * Google Cloud Platform service requests tracking for RESTful APIs.\n */\nexport const googleCloudHttpIntegration = defineIntegration(_googleCloudHttpIntegration);\n\n/** Returns a wrapped function that makes a request with tracing enabled */\nfunction wrapRequestFunction(orig: RequestFunction): RequestFunction {\n return function (this: common.Service, reqOpts: RequestOptions, callback: ResponseCallback): void {\n const httpMethod = reqOpts.method || 'GET';\n const span = SETUP_CLIENTS.has(getClient() as Client)\n ? startInactiveSpan({\n name: `${httpMethod} ${reqOpts.uri}`,\n onlyIfParent: true,\n op: `http.client.${identifyService(this.apiEndpoint)}`,\n attributes: {\n [SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN]: 'auto.http.serverless',\n },\n })\n : new SentryNonRecordingSpan();\n orig.call(this, reqOpts, (...args: Parameters<ResponseCallback>) => {\n span.end();\n callback(...args);\n });\n };\n}\n\n/** Identifies service by its base url */\nfunction identifyService(apiEndpoint: string): string {\n const match = apiEndpoint.match(/^https:\\/\\/(\\w+)\\.googleapis.com$/);\n return match
|
|
1
|
+
{"version":3,"file":"google-cloud-http.js","sources":["../../../src/integrations/google-cloud-http.ts"],"sourcesContent":["import type * as common from '@google-cloud/common';\nimport type { Client, IntegrationFn } from '@sentry/core';\nimport {\n SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN,\n SentryNonRecordingSpan,\n defineIntegration,\n fill,\n getClient,\n} from '@sentry/core';\nimport { startInactiveSpan } from '@sentry/node';\n\ntype RequestOptions = common.DecorateRequestOptions;\ntype ResponseCallback = common.BodyResponseCallback;\n// This interace could be replaced with just type alias once the `strictBindCallApply` mode is enabled.\ninterface RequestFunction extends CallableFunction {\n (reqOpts: RequestOptions, callback: ResponseCallback): void;\n}\n\nconst INTEGRATION_NAME = 'GoogleCloudHttp';\n\nconst SETUP_CLIENTS = new WeakMap<Client, boolean>();\n\nconst _googleCloudHttpIntegration = ((options: { optional?: boolean } = {}) => {\n const optional = options.optional || false;\n return {\n name: INTEGRATION_NAME,\n setupOnce() {\n try {\n // eslint-disable-next-line @typescript-eslint/no-var-requires\n const commonModule = require('@google-cloud/common') as typeof common;\n fill(commonModule.Service.prototype, 'request', wrapRequestFunction);\n } catch (e) {\n if (!optional) {\n throw e;\n }\n }\n },\n setup(client) {\n SETUP_CLIENTS.set(client, true);\n },\n };\n}) satisfies IntegrationFn;\n\n/**\n * Google Cloud Platform service requests tracking for RESTful APIs.\n */\nexport const googleCloudHttpIntegration = defineIntegration(_googleCloudHttpIntegration);\n\n/** Returns a wrapped function that makes a request with tracing enabled */\nfunction wrapRequestFunction(orig: RequestFunction): RequestFunction {\n return function (this: common.Service, reqOpts: RequestOptions, callback: ResponseCallback): void {\n const httpMethod = reqOpts.method || 'GET';\n const span = SETUP_CLIENTS.has(getClient() as Client)\n ? startInactiveSpan({\n name: `${httpMethod} ${reqOpts.uri}`,\n onlyIfParent: true,\n op: `http.client.${identifyService(this.apiEndpoint)}`,\n attributes: {\n [SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN]: 'auto.http.serverless',\n },\n })\n : new SentryNonRecordingSpan();\n orig.call(this, reqOpts, (...args: Parameters<ResponseCallback>) => {\n span.end();\n callback(...args);\n });\n };\n}\n\n/** Identifies service by its base url */\nfunction identifyService(apiEndpoint: string): string {\n const match = apiEndpoint.match(/^https:\\/\\/(\\w+)\\.googleapis.com$/);\n return match?.[1] || apiEndpoint.replace(/^(http|https)?:\\/\\//, '');\n}\n"],"names":["fill","defineIntegration","getClient","startInactiveSpan","SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN","SentryNonRecordingSpan"],"mappings":";;;;;AAkBA,MAAM,gBAAA,GAAmB,iBAAiB;;AAE1C,MAAM,aAAc,GAAE,IAAI,OAAO,EAAmB;;AAEpD,MAAM,2BAAA,IAA+B,CAAC,OAAO,GAA2B,EAAE,KAAK;AAC/E,EAAE,MAAM,QAAS,GAAE,OAAO,CAAC,QAAA,IAAY,KAAK;AAC5C,EAAE,OAAO;AACT,IAAI,IAAI,EAAE,gBAAgB;AAC1B,IAAI,SAAS,GAAG;AAChB,MAAM,IAAI;AACV;AACA,QAAQ,MAAM,YAAa,GAAE,OAAO,CAAC,sBAAsB,CAAE;AAC7D,QAAQA,SAAI,CAAC,YAAY,CAAC,OAAO,CAAC,SAAS,EAAE,SAAS,EAAE,mBAAmB,CAAC;AAC5E,OAAQ,CAAA,OAAO,CAAC,EAAE;AAClB,QAAQ,IAAI,CAAC,QAAQ,EAAE;AACvB,UAAU,MAAM,CAAC;AACjB;AACA;AACA,KAAK;AACL,IAAI,KAAK,CAAC,MAAM,EAAE;AAClB,MAAM,aAAa,CAAC,GAAG,CAAC,MAAM,EAAE,IAAI,CAAC;AACrC,KAAK;AACL,GAAG;AACH,CAAC,CAAE;;AAEH;AACA;AACA;MACa,0BAA2B,GAAEC,sBAAiB,CAAC,2BAA2B;;AAEvF;AACA,SAAS,mBAAmB,CAAC,IAAI,EAAoC;AACrE,EAAE,OAAO,WAAgC,OAAO,EAAkB,QAAQ,EAA0B;AACpG,IAAI,MAAM,UAAW,GAAE,OAAO,CAAC,MAAA,IAAU,KAAK;AAC9C,IAAI,MAAM,OAAO,aAAa,CAAC,GAAG,CAACC,cAAS,EAAG;AAC/C,QAAQC,sBAAiB,CAAC;AAC1B,UAAU,IAAI,EAAE,CAAC,EAAA,UAAA,CAAA,CAAA,EAAA,OAAA,CAAA,GAAA,CAAA,CAAA;AACA,UAAA,YAAA,EAAA,IAAA;AACA,UAAA,EAAA,EAAA,CAAA,YAAA,EAAA,eAAA,CAAA,IAAA,CAAA,WAAA,CAAA,CAAA,CAAA;AACA,UAAA,UAAA,EAAA;AACA,YAAA,CAAAC,qCAAA,GAAA,sBAAA;AACA,WAAA;AACA,SAAA;AACA,QAAA,IAAAC,2BAAA,EAAA;AACA,IAAA,IAAA,CAAA,IAAA,CAAA,IAAA,EAAA,OAAA,EAAA,CAAA,GAAA,IAAA,KAAA;AACA,MAAA,IAAA,CAAA,GAAA,EAAA;AACA,MAAA,QAAA,CAAA,GAAA,IAAA,CAAA;AACA,KAAA,CAAA;AACA,GAAA;AACA;;AAEA;AACA,SAAA,eAAA,CAAA,WAAA,EAAA;AACA,EAAA,MAAA,KAAA,GAAA,WAAA,CAAA,KAAA,CAAA,mCAAA,CAAA;AACA,EAAA,OAAA,KAAA,GAAA,CAAA,CAAA,IAAA,WAAA,CAAA,OAAA,CAAA,qBAAA,EAAA,EAAA,CAAA;AACA;;;;"}
|
package/build/cjs/sdk.js
CHANGED
package/build/cjs/utils.js
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { _optionalChain } from '@sentry/core';
|
|
2
1
|
import { stripUrlQueryAndFragment, isString, httpRequestToRequestData, SEMANTIC_ATTRIBUTE_SENTRY_SOURCE, SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN, setHttpStatus, logger, handleCallbackErrors } from '@sentry/core';
|
|
3
2
|
import { continueTrace, getCurrentScope, startSpanManual, flush, captureException } from '@sentry/node';
|
|
4
3
|
import { DEBUG_BUILD } from '../debug-build.js';
|
|
@@ -33,7 +32,7 @@ function _wrapHttpFunction(fn, options) {
|
|
|
33
32
|
const reqUrl = stripUrlQueryAndFragment(req.originalUrl || req.url || '');
|
|
34
33
|
|
|
35
34
|
const sentryTrace = req.headers && isString(req.headers['sentry-trace']) ? req.headers['sentry-trace'] : undefined;
|
|
36
|
-
const baggage =
|
|
35
|
+
const baggage = req.headers?.baggage;
|
|
37
36
|
|
|
38
37
|
return continueTrace({ sentryTrace, baggage }, () => {
|
|
39
38
|
const normalizedRequest = httpRequestToRequestData(req);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"http.js","sources":["../../../src/gcpfunction/http.ts"],"sourcesContent":["import {\n SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN,\n SEMANTIC_ATTRIBUTE_SENTRY_SOURCE,\n handleCallbackErrors,\n httpRequestToRequestData,\n isString,\n logger,\n setHttpStatus,\n stripUrlQueryAndFragment,\n} from '@sentry/core';\nimport { captureException, continueTrace, flush, getCurrentScope, startSpanManual } from '@sentry/node';\nimport { DEBUG_BUILD } from '../debug-build';\nimport { domainify, markEventUnhandled, proxyFunction } from '../utils';\nimport type { HttpFunction, WrapperOptions } from './general';\n\n/**\n * Wraps an HTTP function handler adding it error capture and tracing capabilities.\n *\n * @param fn HTTP Handler\n * @param options Options\n * @returns HTTP handler\n */\nexport function wrapHttpFunction(fn: HttpFunction, wrapOptions: Partial<WrapperOptions> = {}): HttpFunction {\n const wrap = (f: HttpFunction): HttpFunction => domainify(_wrapHttpFunction(f, wrapOptions));\n\n let overrides: Record<PropertyKey, unknown> | undefined;\n\n // Functions emulator from firebase-tools has a hack-ish workaround that saves the actual function\n // passed to `onRequest(...)` and in fact runs it so we need to wrap it too.\n const emulatorFunc = (fn as HttpFunction & { __emulator_func?: HttpFunction }).__emulator_func;\n if (emulatorFunc) {\n overrides = { __emulator_func: proxyFunction(emulatorFunc, wrap) };\n }\n return proxyFunction(fn, wrap, overrides);\n}\n\n/** */\nfunction _wrapHttpFunction(fn: HttpFunction, options: Partial<WrapperOptions>): HttpFunction {\n const flushTimeout = options.flushTimeout || 2000;\n return (req, res) => {\n const reqMethod = (req.method || '').toUpperCase();\n const reqUrl = stripUrlQueryAndFragment(req.originalUrl || req.url || '');\n\n const sentryTrace = req.headers && isString(req.headers['sentry-trace']) ? req.headers['sentry-trace'] : undefined;\n const baggage = req.headers?.baggage;\n\n return continueTrace({ sentryTrace, baggage }, () => {\n const normalizedRequest = httpRequestToRequestData(req);\n getCurrentScope().setSDKProcessingMetadata({ normalizedRequest });\n\n return startSpanManual(\n {\n name: `${reqMethod} ${reqUrl}`,\n op: 'function.gcp.http',\n attributes: {\n [SEMANTIC_ATTRIBUTE_SENTRY_SOURCE]: 'route',\n [SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN]: 'auto.function.serverless.gcp_http',\n },\n },\n span => {\n // eslint-disable-next-line @typescript-eslint/unbound-method\n const _end = res.end;\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n res.end = function (chunk?: any | (() => void), encoding?: string | (() => void), cb?: () => void): any {\n setHttpStatus(span, res.statusCode);\n span.end();\n\n // eslint-disable-next-line @typescript-eslint/no-floating-promises\n flush(flushTimeout)\n .then(null, e => {\n DEBUG_BUILD && logger.error(e);\n })\n .then(() => {\n _end.call(this, chunk, encoding, cb);\n });\n };\n\n return handleCallbackErrors(\n () => fn(req, res),\n err => {\n captureException(err, scope => markEventUnhandled(scope));\n },\n );\n },\n );\n });\n };\n}\n"],"names":[],"mappings":";;;;;;AAeA,CAAA,CAAA;CACA,EAAA,CAAA,CAAA,CAAA,CAAA,EAAA,CAAA,EAAA,CAAA,CAAA,CAAA,EAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,EAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA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MANTIC_ATTRIBUTE_SENTRY_ORIGIN,\n SEMANTIC_ATTRIBUTE_SENTRY_SOURCE,\n handleCallbackErrors,\n httpRequestToRequestData,\n isString,\n logger,\n setHttpStatus,\n stripUrlQueryAndFragment,\n} from '@sentry/core';\nimport { captureException, continueTrace, flush, getCurrentScope, startSpanManual } from '@sentry/node';\nimport { DEBUG_BUILD } from '../debug-build';\nimport { domainify, markEventUnhandled, proxyFunction } from '../utils';\nimport type { HttpFunction, WrapperOptions } from './general';\n\n/**\n * Wraps an HTTP function handler adding it error capture and tracing capabilities.\n *\n * @param fn HTTP Handler\n * @param options Options\n * @returns HTTP handler\n */\nexport function wrapHttpFunction(fn: HttpFunction, wrapOptions: Partial<WrapperOptions> = {}): HttpFunction {\n const wrap = (f: HttpFunction): HttpFunction => domainify(_wrapHttpFunction(f, wrapOptions));\n\n let overrides: Record<PropertyKey, unknown> | undefined;\n\n // Functions emulator from firebase-tools has a hack-ish workaround that saves the actual function\n // passed to `onRequest(...)` and in fact runs it so we need to wrap it too.\n const emulatorFunc = (fn as HttpFunction & { __emulator_func?: HttpFunction }).__emulator_func;\n if (emulatorFunc) {\n overrides = { __emulator_func: proxyFunction(emulatorFunc, wrap) };\n }\n return proxyFunction(fn, wrap, overrides);\n}\n\n/** */\nfunction _wrapHttpFunction(fn: HttpFunction, options: Partial<WrapperOptions>): HttpFunction {\n const flushTimeout = options.flushTimeout || 2000;\n return (req, res) => {\n const reqMethod = (req.method || '').toUpperCase();\n const reqUrl = stripUrlQueryAndFragment(req.originalUrl || req.url || '');\n\n const sentryTrace = req.headers && isString(req.headers['sentry-trace']) ? req.headers['sentry-trace'] : undefined;\n const baggage = req.headers?.baggage;\n\n return continueTrace({ sentryTrace, baggage }, () => {\n const normalizedRequest = httpRequestToRequestData(req);\n getCurrentScope().setSDKProcessingMetadata({ normalizedRequest });\n\n return startSpanManual(\n {\n name: `${reqMethod} ${reqUrl}`,\n op: 'function.gcp.http',\n attributes: {\n [SEMANTIC_ATTRIBUTE_SENTRY_SOURCE]: 'route',\n [SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN]: 'auto.function.serverless.gcp_http',\n },\n },\n span => {\n // eslint-disable-next-line @typescript-eslint/unbound-method\n const _end = res.end;\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n res.end = function (chunk?: any | (() => void), encoding?: string | (() => void), cb?: () => void): any {\n setHttpStatus(span, res.statusCode);\n span.end();\n\n // eslint-disable-next-line @typescript-eslint/no-floating-promises\n flush(flushTimeout)\n .then(null, e => {\n DEBUG_BUILD && logger.error(e);\n })\n .then(() => {\n _end.call(this, chunk, encoding, cb);\n });\n };\n\n return handleCallbackErrors(\n () => fn(req, res),\n err => {\n captureException(err, scope => markEventUnhandled(scope));\n },\n );\n },\n );\n });\n };\n}\n"],"names":[],"mappings":";;;;;AAeA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAAS,gBAAgB,CAAC,EAAE,EAAgB,WAAW,GAA4B,EAAE,EAAgB;AAC5G,EAAE,MAAM,IAAA,GAAO,CAAC,CAAC,KAAiC,SAAS,CAAC,iBAAiB,CAAC,CAAC,EAAE,WAAW,CAAC,CAAC;;AAE9F,EAAE,IAAI,SAAS;;AAEf;AACA;AACA,EAAE,MAAM,YAAa,GAAE,CAAC,EAAG,GAAsD,eAAe;AAChG,EAAE,IAAI,YAAY,EAAE;AACpB,IAAI,SAAA,GAAY,EAAE,eAAe,EAAE,aAAa,CAAC,YAAY,EAAE,IAAI,CAAA,EAAG;AACtE;AACA,EAAE,OAAO,aAAa,CAAC,EAAE,EAAE,IAAI,EAAE,SAAS,CAAC;AAC3C;;AAEA;AACA,SAAS,iBAAiB,CAAC,EAAE,EAAgB,OAAO,EAAyC;AAC7F,EAAE,MAAM,YAAa,GAAE,OAAO,CAAC,YAAA,IAAgB,IAAI;AACnD,EAAE,OAAO,CAAC,GAAG,EAAE,GAAG,KAAK;AACvB,IAAI,MAAM,SAAA,GAAY,CAAC,GAAG,CAAC,MAAO,IAAG,E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A,IAAA,CAAA,MAAA;AACA,gBAAA,IAAA,CAAA,IAAA,CAAA,IAAA,EAAA,KAAA,EAAA,QAAA,EAAA,EAAA,CAAA;AACA,eAAA,CAAA;AACA,WAAA;;AAEA,UAAA,OAAA,oBAAA;AACA,YAAA,MAAA,EAAA,CAAA,GAAA,EAAA,GAAA,CAAA;AACA,YAAA,GAAA,IAAA;AACA,cAAA,gBAAA,CAAA,GAAA,EAAA,KAAA,IAAA,kBAAA,CAAA,KAAA,CAAA,CAAA;AACA,aAAA;AACA,WAAA;AACA,SAAA;AACA,OAAA;AACA,KAAA,CAAA;AACA,GAAA;AACA;;;;"}
|
package/build/esm/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
export {
|
|
2
|
-
export { captureConsoleIntegration,
|
|
1
|
+
export { NodeClient, SDK_VERSION, SEMANTIC_ATTRIBUTE_SENTRY_OP, SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN, SEMANTIC_ATTRIBUTE_SENTRY_SAMPLE_RATE, SEMANTIC_ATTRIBUTE_SENTRY_SOURCE, Scope, addBreadcrumb, addEventProcessor, addIntegration, amqplibIntegration, anrIntegration, captureCheckIn, captureEvent, captureException, captureFeedback, captureMessage, captureSession, childProcessIntegration, close, connectIntegration, consoleIntegration, contextLinesIntegration, continueTrace, createGetModuleFromFilename, createTransport, cron, dataloaderIntegration, defaultStackParser, disableAnrDetectionForCallback, endSession, expressErrorHandler, expressIntegration, fastifyIntegration, flush, fsIntegration, functionToStringIntegration, generateInstrumentOnce, genericPoolIntegration, getActiveSpan, getAutoPerformanceIntegrations, getClient, getCurrentScope, getGlobalScope, getIsolationScope, getRootSpan, getSentryRelease, getSpanDescendants, getSpanStatusFromHttpCode, getTraceData, getTraceMetaTags, graphqlIntegration, hapiIntegration, httpIntegration, inboundFiltersIntegration, initOpenTelemetry, isInitialized, kafkaIntegration, knexIntegration, koaIntegration, lastEventId, linkedErrorsIntegration, localVariablesIntegration, lruMemoizerIntegration, makeNodeTransport, modulesIntegration, mongoIntegration, mongooseIntegration, mysql2Integration, mysqlIntegration, nativeNodeFetchIntegration, nodeContextIntegration, onUncaughtExceptionIntegration, onUnhandledRejectionIntegration, parameterize, postgresIntegration, prismaIntegration, profiler, redisIntegration, requestDataIntegration, setContext, setCurrentClient, setExtra, setExtras, setHttpStatus, setMeasurement, setTag, setTags, setUser, setupConnectErrorHandler, setupExpressErrorHandler, setupHapiErrorHandler, setupKoaErrorHandler, spanToBaggageHeader, spanToJSON, spanToTraceHeader, spotlightIntegration, startInactiveSpan, startNewTrace, startSession, startSpan, startSpanManual, suppressTracing, tediousIntegration, trpcMiddleware, updateSpanName, withActiveSpan, withIsolationScope, withMonitor, withScope, zodErrorsIntegration } from '@sentry/node';
|
|
2
|
+
export { captureConsoleIntegration, dedupeIntegration, extraErrorDataIntegration, rewriteFramesIntegration } from '@sentry/core';
|
|
3
3
|
export { getDefaultIntegrations, init } from './sdk.js';
|
|
4
4
|
export { googleCloudHttpIntegration } from './integrations/google-cloud-http.js';
|
|
5
5
|
export { googleCloudGrpcIntegration } from './integrations/google-cloud-grpc.js';
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { _optionalChain } from '@sentry/core';
|
|
2
1
|
import { defineIntegration, fill, getClient, SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN } from '@sentry/core';
|
|
3
2
|
import { startInactiveSpan } from '@sentry/node';
|
|
4
3
|
|
|
@@ -41,7 +40,7 @@ const googleCloudGrpcIntegration = defineIntegration(_googleCloudGrpcIntegration
|
|
|
41
40
|
/** Returns a wrapped function that returns a stub with tracing enabled */
|
|
42
41
|
function wrapCreateStub(origCreate) {
|
|
43
42
|
return async function ( ...args) {
|
|
44
|
-
const servicePath =
|
|
43
|
+
const servicePath = args[1]?.servicePath;
|
|
45
44
|
if (servicePath == null || servicePath == undefined) {
|
|
46
45
|
return origCreate.apply(this, args);
|
|
47
46
|
}
|
|
@@ -77,7 +76,7 @@ function fillGrpcFunction(stub, serviceIdentifier, methodName) {
|
|
|
77
76
|
(orig) =>
|
|
78
77
|
(...args) => {
|
|
79
78
|
const ret = orig.apply(stub, args);
|
|
80
|
-
if (typeof
|
|
79
|
+
if (typeof ret?.on !== 'function' || !SETUP_CLIENTS.has(getClient() )) {
|
|
81
80
|
return ret;
|
|
82
81
|
}
|
|
83
82
|
const span = startInactiveSpan({
|
|
@@ -101,7 +100,7 @@ function fillGrpcFunction(stub, serviceIdentifier, methodName) {
|
|
|
101
100
|
/** Identifies service by its address */
|
|
102
101
|
function identifyService(servicePath) {
|
|
103
102
|
const match = servicePath.match(SERVICE_PATH_REGEX);
|
|
104
|
-
return match
|
|
103
|
+
return match?.[1] || servicePath;
|
|
105
104
|
}
|
|
106
105
|
|
|
107
106
|
export { googleCloudGrpcIntegration };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"google-cloud-grpc.js","sources":["../../../src/integrations/google-cloud-grpc.ts"],"sourcesContent":["import type { EventEmitter } from 'events';\nimport type { Client, IntegrationFn } from '@sentry/core';\nimport { SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN, defineIntegration, fill, getClient } from '@sentry/core';\nimport { startInactiveSpan } from '@sentry/node';\n\ninterface GrpcFunction extends CallableFunction {\n (...args: unknown[]): EventEmitter;\n}\n\ninterface GrpcFunctionObject extends GrpcFunction {\n requestStream: boolean;\n responseStream: boolean;\n originalName: string;\n}\n\ninterface StubOptions {\n servicePath?: string;\n}\n\ninterface CreateStubFunc extends CallableFunction {\n (createStub: unknown, options: StubOptions): PromiseLike<Stub>;\n}\n\ninterface Stub {\n [key: string]: GrpcFunctionObject;\n}\n\nconst SERVICE_PATH_REGEX = /^(\\w+)\\.googleapis.com$/;\n\nconst INTEGRATION_NAME = 'GoogleCloudGrpc';\n\nconst SETUP_CLIENTS = new WeakMap<Client, boolean>();\n\nconst _googleCloudGrpcIntegration = ((options: { optional?: boolean } = {}) => {\n const optional = options.optional || false;\n return {\n name: INTEGRATION_NAME,\n setupOnce() {\n try {\n // eslint-disable-next-line @typescript-eslint/no-var-requires\n const gaxModule = require('google-gax');\n fill(\n gaxModule.GrpcClient.prototype, // eslint-disable-line @typescript-eslint/no-unsafe-member-access\n 'createStub',\n wrapCreateStub,\n );\n } catch (e) {\n if (!optional) {\n throw e;\n }\n }\n },\n setup(client) {\n SETUP_CLIENTS.set(client, true);\n },\n };\n}) satisfies IntegrationFn;\n\n/**\n * Google Cloud Platform service requests tracking for GRPC APIs.\n */\nexport const googleCloudGrpcIntegration = defineIntegration(_googleCloudGrpcIntegration);\n\n/** Returns a wrapped function that returns a stub with tracing enabled */\nfunction wrapCreateStub(origCreate: CreateStubFunc): CreateStubFunc {\n return async function (this: unknown, ...args: Parameters<CreateStubFunc>) {\n const servicePath = args[1]?.servicePath;\n if (servicePath == null || servicePath == undefined) {\n return origCreate.apply(this, args);\n }\n const serviceIdentifier = identifyService(servicePath);\n const stub = await origCreate.apply(this, args);\n for (const methodName of Object.keys(Object.getPrototypeOf(stub))) {\n fillGrpcFunction(stub, serviceIdentifier, methodName);\n }\n return stub;\n };\n}\n\n/** Patches the function in grpc stub to enable tracing */\nfunction fillGrpcFunction(stub: Stub, serviceIdentifier: string, methodName: string): void {\n const funcObj = stub[methodName];\n if (typeof funcObj !== 'function') {\n return;\n }\n const callType =\n !funcObj.requestStream && !funcObj.responseStream\n ? 'unary call'\n : funcObj.requestStream && !funcObj.responseStream\n ? 'client stream'\n : !funcObj.requestStream && funcObj.responseStream\n ? 'server stream'\n : 'bidi stream';\n if (callType != 'unary call') {\n return;\n }\n fill(\n stub,\n methodName,\n (orig: GrpcFunction): GrpcFunction =>\n (...args) => {\n const ret = orig.apply(stub, args);\n if (typeof ret?.on !== 'function' || !SETUP_CLIENTS.has(getClient() as Client)) {\n return ret;\n }\n const span = startInactiveSpan({\n name: `${callType} ${methodName}`,\n onlyIfParent: true,\n op: `grpc.${serviceIdentifier}`,\n attributes: {\n [SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN]: 'auto.grpc.serverless',\n },\n });\n ret.on('status', () => {\n if (span) {\n span.end();\n }\n });\n return ret;\n },\n );\n}\n\n/** Identifies service by its address */\nfunction identifyService(servicePath: string): string {\n const match = servicePath.match(SERVICE_PATH_REGEX);\n return match && match[1] ? match[1] : servicePath;\n}\n"],"names":[],"mappings":";;;;AA2BA,CAAM,CAAA,CAAA,CAAA,EAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,IAAqB,CAAyB,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA;;AAEpD,CAAM,CAAA,CAAA,CAAA,EAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,IAAmB,CAAiB,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA;;AAE1C,CAAA,CAAA,CAAA,CAAA,EAAM,CAAc,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,EAAA,EAAE,CAAI,CAAA,EAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAO,CAAmB,CAAA;;AAEpD,CAAA,CAAA,CAAA,CAAA,EAAM,4BAA+B,EAAA,CAAA,CAAC,CAAO,CAAA,CAAA,CAAA,CAAA,CAAA,EAAA,EAA2B,EAAE,EAAK,CAAA,EAAA;EAC7E,MAAM,CAAS,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,EAAA,EAAE,OAAO,CAAC,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,KAAY,CAAK,CAAA,CAAA,CAAA,CAAA;EAC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AA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,EAAA;EACA,CAAA,CAAA,CAAA,CAAA,EAAA,MAAA,EAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,kBAAA,CAAA;EACA,CAAA,CAAA,CAAA,CAAA,CAAA,EAAA,CAAA,CAAA,CAAA,CAAA,EAAA,CAAA,EAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,EAAA,EAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,IAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA;AACA;;"}
|
|
1
|
+
{"version":3,"file":"google-cloud-grpc.js","sources":["../../../src/integrations/google-cloud-grpc.ts"],"sourcesContent":["import type { EventEmitter } from 'events';\nimport type { Client, IntegrationFn } from '@sentry/core';\nimport { SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN, defineIntegration, fill, getClient } from '@sentry/core';\nimport { startInactiveSpan } from '@sentry/node';\n\ninterface GrpcFunction extends CallableFunction {\n (...args: unknown[]): EventEmitter;\n}\n\ninterface GrpcFunctionObject extends GrpcFunction {\n requestStream: boolean;\n responseStream: boolean;\n originalName: string;\n}\n\ninterface StubOptions {\n servicePath?: string;\n}\n\ninterface CreateStubFunc extends CallableFunction {\n (createStub: unknown, options: StubOptions): PromiseLike<Stub>;\n}\n\ninterface Stub {\n [key: string]: GrpcFunctionObject;\n}\n\nconst SERVICE_PATH_REGEX = /^(\\w+)\\.googleapis.com$/;\n\nconst INTEGRATION_NAME = 'GoogleCloudGrpc';\n\nconst SETUP_CLIENTS = new WeakMap<Client, boolean>();\n\nconst _googleCloudGrpcIntegration = ((options: { optional?: boolean } = {}) => {\n const optional = options.optional || false;\n return {\n name: INTEGRATION_NAME,\n setupOnce() {\n try {\n // eslint-disable-next-line @typescript-eslint/no-var-requires\n const gaxModule = require('google-gax');\n fill(\n gaxModule.GrpcClient.prototype, // eslint-disable-line @typescript-eslint/no-unsafe-member-access\n 'createStub',\n wrapCreateStub,\n );\n } catch (e) {\n if (!optional) {\n throw e;\n }\n }\n },\n setup(client) {\n SETUP_CLIENTS.set(client, true);\n },\n };\n}) satisfies IntegrationFn;\n\n/**\n * Google Cloud Platform service requests tracking for GRPC APIs.\n */\nexport const googleCloudGrpcIntegration = defineIntegration(_googleCloudGrpcIntegration);\n\n/** Returns a wrapped function that returns a stub with tracing enabled */\nfunction wrapCreateStub(origCreate: CreateStubFunc): CreateStubFunc {\n return async function (this: unknown, ...args: Parameters<CreateStubFunc>) {\n const servicePath = args[1]?.servicePath;\n if (servicePath == null || servicePath == undefined) {\n return origCreate.apply(this, args);\n }\n const serviceIdentifier = identifyService(servicePath);\n const stub = await origCreate.apply(this, args);\n for (const methodName of Object.keys(Object.getPrototypeOf(stub))) {\n fillGrpcFunction(stub, serviceIdentifier, methodName);\n }\n return stub;\n };\n}\n\n/** Patches the function in grpc stub to enable tracing */\nfunction fillGrpcFunction(stub: Stub, serviceIdentifier: string, methodName: string): void {\n const funcObj = stub[methodName];\n if (typeof funcObj !== 'function') {\n return;\n }\n const callType =\n !funcObj.requestStream && !funcObj.responseStream\n ? 'unary call'\n : funcObj.requestStream && !funcObj.responseStream\n ? 'client stream'\n : !funcObj.requestStream && funcObj.responseStream\n ? 'server stream'\n : 'bidi stream';\n if (callType != 'unary call') {\n return;\n }\n fill(\n stub,\n methodName,\n (orig: GrpcFunction): GrpcFunction =>\n (...args) => {\n const ret = orig.apply(stub, args);\n if (typeof ret?.on !== 'function' || !SETUP_CLIENTS.has(getClient() as Client)) {\n return ret;\n }\n const span = startInactiveSpan({\n name: `${callType} ${methodName}`,\n onlyIfParent: true,\n op: `grpc.${serviceIdentifier}`,\n attributes: {\n [SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN]: 'auto.grpc.serverless',\n },\n });\n ret.on('status', () => {\n if (span) {\n span.end();\n }\n });\n return ret;\n },\n );\n}\n\n/** Identifies service by its address */\nfunction identifyService(servicePath: string): string {\n const match = servicePath.match(SERVICE_PATH_REGEX);\n return match?.[1] || servicePath;\n}\n"],"names":[],"mappings":";;;AA2BA,MAAM,kBAAA,GAAqB,yBAAyB;;AAEpD,MAAM,gBAAA,GAAmB,iBAAiB;;AAE1C,MAAM,aAAc,GAAE,IAAI,OAAO,EAAmB;;AAEpD,MAAM,2BAAA,IAA+B,CAAC,OAAO,GAA2B,EAAE,KAAK;AAC/E,EAAE,MAAM,QAAS,GAAE,OAAO,CAAC,QAAA,IAAY,KAAK;AAC5C,EAAE,OAAO;AACT,IAAI,IAAI,EAAE,gBAAgB;AAC1B,IAAI,SAAS,GAAG;AAChB,MAAM,IAAI;AACV;AACA,QAAQ,MAAM,SAAU,GAAE,OAAO,CAAC,YAAY,CAAC;AAC/C,QAAQ,IAAI;AACZ,UAAU,SAAS,CAAC,UAAU,CAAC,SAAS;AACxC,UAAU,YAAY;AACtB,UAAU,cAAc;AACxB,SAAS;AACT,OAAQ,CAAA,OAAO,CAAC,EAAE;AAClB,QAAQ,IAAI,CAAC,QAAQ,EAAE;AACvB,UAAU,MAAM,CAAC;AACjB;AACA;AACA,KAAK;AACL,IAAI,KAAK,CAAC,MAAM,EAAE;AAClB,MAAM,aAAa,CAAC,GAAG,CAAC,MAAM,EAAE,IAAI,CAAC;AACrC,KAAK;AACL,GAAG;AACH,CAAC,CAAE;;AAEH;AACA;AACA;MACa,0BAA2B,GAAE,iBAAiB,CAAC,2BAA2B;;AAEvF;AACA,SAAS,cAAc,CAAC,UAAU,EAAkC;AACpE,EAAE,OAAO,iBAA+B,GAAG,IAAI,EAA8B;AAC7E,IAAI,MAAM,cAAc,IAAI,CAAC,CAAC,CAAC,EAAE,WAAW;AAC5C,IAAI,IAAI,WAAY,IAAG,QAAQ,WAAA,IAAe,SAAS,EAAE;AACzD,MAAM,OAA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AAO,GAAG;AACpB;AACA,QAAQ,MAAM,IAAA,GAAO,iBAAiB,CAAC;AACvC,UAAU,IAAI,EAAE,CAAC,EAAA,QAAA,CAAA,CAAA,EAAA,UAAA,CAAA,CAAA;AACA,UAAA,YAAA,EAAA,IAAA;AACA,UAAA,EAAA,EAAA,CAAA,KAAA,EAAA,iBAAA,CAAA,CAAA;AACA,UAAA,UAAA,EAAA;AACA,YAAA,CAAA,gCAAA,GAAA,sBAAA;AACA,WAAA;AACA,SAAA,CAAA;AACA,QAAA,GAAA,CAAA,EAAA,CAAA,QAAA,EAAA,MAAA;AACA,UAAA,IAAA,IAAA,EAAA;AACA,YAAA,IAAA,CAAA,GAAA,EAAA;AACA;AACA,SAAA,CAAA;AACA,QAAA,OAAA,GAAA;AACA,OAAA;AACA,GAAA;AACA;;AAEA;AACA,SAAA,eAAA,CAAA,WAAA,EAAA;AACA,EAAA,MAAA,KAAA,GAAA,WAAA,CAAA,KAAA,CAAA,kBAAA,CAAA;AACA,EAAA,OAAA,KAAA,GAAA,CAAA,CAAA,IAAA,WAAA;AACA;;;;"}
|
|
@@ -55,7 +55,7 @@ function wrapRequestFunction(orig) {
|
|
|
55
55
|
/** Identifies service by its base url */
|
|
56
56
|
function identifyService(apiEndpoint) {
|
|
57
57
|
const match = apiEndpoint.match(/^https:\/\/(\w+)\.googleapis.com$/);
|
|
58
|
-
return match
|
|
58
|
+
return match?.[1] || apiEndpoint.replace(/^(http|https)?:\/\//, '');
|
|
59
59
|
}
|
|
60
60
|
|
|
61
61
|
export { googleCloudHttpIntegration };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"google-cloud-http.js","sources":["../../../src/integrations/google-cloud-http.ts"],"sourcesContent":["import type * as common from '@google-cloud/common';\nimport type { Client, IntegrationFn } from '@sentry/core';\nimport {\n SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN,\n SentryNonRecordingSpan,\n defineIntegration,\n fill,\n getClient,\n} from '@sentry/core';\nimport { startInactiveSpan } from '@sentry/node';\n\ntype RequestOptions = common.DecorateRequestOptions;\ntype ResponseCallback = common.BodyResponseCallback;\n// This interace could be replaced with just type alias once the `strictBindCallApply` mode is enabled.\ninterface RequestFunction extends CallableFunction {\n (reqOpts: RequestOptions, callback: ResponseCallback): void;\n}\n\nconst INTEGRATION_NAME = 'GoogleCloudHttp';\n\nconst SETUP_CLIENTS = new WeakMap<Client, boolean>();\n\nconst _googleCloudHttpIntegration = ((options: { optional?: boolean } = {}) => {\n const optional = options.optional || false;\n return {\n name: INTEGRATION_NAME,\n setupOnce() {\n try {\n // eslint-disable-next-line @typescript-eslint/no-var-requires\n const commonModule = require('@google-cloud/common') as typeof common;\n fill(commonModule.Service.prototype, 'request', wrapRequestFunction);\n } catch (e) {\n if (!optional) {\n throw e;\n }\n }\n },\n setup(client) {\n SETUP_CLIENTS.set(client, true);\n },\n };\n}) satisfies IntegrationFn;\n\n/**\n * Google Cloud Platform service requests tracking for RESTful APIs.\n */\nexport const googleCloudHttpIntegration = defineIntegration(_googleCloudHttpIntegration);\n\n/** Returns a wrapped function that makes a request with tracing enabled */\nfunction wrapRequestFunction(orig: RequestFunction): RequestFunction {\n return function (this: common.Service, reqOpts: RequestOptions, callback: ResponseCallback): void {\n const httpMethod = reqOpts.method || 'GET';\n const span = SETUP_CLIENTS.has(getClient() as Client)\n ? startInactiveSpan({\n name: `${httpMethod} ${reqOpts.uri}`,\n onlyIfParent: true,\n op: `http.client.${identifyService(this.apiEndpoint)}`,\n attributes: {\n [SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN]: 'auto.http.serverless',\n },\n })\n : new SentryNonRecordingSpan();\n orig.call(this, reqOpts, (...args: Parameters<ResponseCallback>) => {\n span.end();\n callback(...args);\n });\n };\n}\n\n/** Identifies service by its base url */\nfunction identifyService(apiEndpoint: string): string {\n const match = apiEndpoint.match(/^https:\\/\\/(\\w+)\\.googleapis.com$/);\n return match
|
|
1
|
+
{"version":3,"file":"google-cloud-http.js","sources":["../../../src/integrations/google-cloud-http.ts"],"sourcesContent":["import type * as common from '@google-cloud/common';\nimport type { Client, IntegrationFn } from '@sentry/core';\nimport {\n SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN,\n SentryNonRecordingSpan,\n defineIntegration,\n fill,\n getClient,\n} from '@sentry/core';\nimport { startInactiveSpan } from '@sentry/node';\n\ntype RequestOptions = common.DecorateRequestOptions;\ntype ResponseCallback = common.BodyResponseCallback;\n// This interace could be replaced with just type alias once the `strictBindCallApply` mode is enabled.\ninterface RequestFunction extends CallableFunction {\n (reqOpts: RequestOptions, callback: ResponseCallback): void;\n}\n\nconst INTEGRATION_NAME = 'GoogleCloudHttp';\n\nconst SETUP_CLIENTS = new WeakMap<Client, boolean>();\n\nconst _googleCloudHttpIntegration = ((options: { optional?: boolean } = {}) => {\n const optional = options.optional || false;\n return {\n name: INTEGRATION_NAME,\n setupOnce() {\n try {\n // eslint-disable-next-line @typescript-eslint/no-var-requires\n const commonModule = require('@google-cloud/common') as typeof common;\n fill(commonModule.Service.prototype, 'request', wrapRequestFunction);\n } catch (e) {\n if (!optional) {\n throw e;\n }\n }\n },\n setup(client) {\n SETUP_CLIENTS.set(client, true);\n },\n };\n}) satisfies IntegrationFn;\n\n/**\n * Google Cloud Platform service requests tracking for RESTful APIs.\n */\nexport const googleCloudHttpIntegration = defineIntegration(_googleCloudHttpIntegration);\n\n/** Returns a wrapped function that makes a request with tracing enabled */\nfunction wrapRequestFunction(orig: RequestFunction): RequestFunction {\n return function (this: common.Service, reqOpts: RequestOptions, callback: ResponseCallback): void {\n const httpMethod = reqOpts.method || 'GET';\n const span = SETUP_CLIENTS.has(getClient() as Client)\n ? startInactiveSpan({\n name: `${httpMethod} ${reqOpts.uri}`,\n onlyIfParent: true,\n op: `http.client.${identifyService(this.apiEndpoint)}`,\n attributes: {\n [SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN]: 'auto.http.serverless',\n },\n })\n : new SentryNonRecordingSpan();\n orig.call(this, reqOpts, (...args: Parameters<ResponseCallback>) => {\n span.end();\n callback(...args);\n });\n };\n}\n\n/** Identifies service by its base url */\nfunction identifyService(apiEndpoint: string): string {\n const match = apiEndpoint.match(/^https:\\/\\/(\\w+)\\.googleapis.com$/);\n return match?.[1] || apiEndpoint.replace(/^(http|https)?:\\/\\//, '');\n}\n"],"names":[],"mappings":";;;AAkBA,MAAM,gBAAA,GAAmB,iBAAiB;;AAE1C,MAAM,aAAc,GAAE,IAAI,OAAO,EAAmB;;AAEpD,MAAM,2BAAA,IAA+B,CAAC,OAAO,GAA2B,EAAE,KAAK;AAC/E,EAAE,MAAM,QAAS,GAAE,OAAO,CAAC,QAAA,IAAY,KAAK;AAC5C,EAAE,OAAO;AACT,IAAI,IAAI,EAAE,gBAAgB;AAC1B,IAAI,SAAS,GAAG;AAChB,MAAM,IAAI;AACV;AACA,QAAQ,MAAM,YAAa,GAAE,OAAO,CAAC,sBAAsB,CAAE;AAC7D,QAAQ,IAAI,CAAC,YAAY,CAAC,OAAO,CAAC,SAAS,EAAE,SAAS,EAAE,mBAAmB,CAAC;AAC5E,OAAQ,CAAA,OAAO,CAAC,EAAE;AAClB,QAAQ,IAAI,CAAC,QAAQ,EAAE;AACvB,UAAU,MAAM,CAAC;AACjB;AACA;AACA,KAAK;AACL,IAAI,KAAK,CAAC,MAAM,EAAE;AAClB,MAAM,aAAa,CAAC,GAAG,CAAC,MAAM,EAAE,IAAI,CAAC;AACrC,KAAK;AACL,GAAG;AACH,CAAC,CAAE;;AAEH;AACA;AACA;MACa,0BAA2B,GAAE,iBAAiB,CAAC,2BAA2B;;AAEvF;AACA,SAAS,mBAAmB,CAAC,IAAI,EAAoC;AACrE,EAAE,OAAO,WAAgC,OAAO,EAAkB,QAAQ,EAA0B;AACpG,IAAI,MAAM,UAAW,GAAE,OAAO,CAAC,MAAA,IAAU,KAAK;AAC9C,IAAI,MAAM,OAAO,aAAa,CAAC,GAAG,CAAC,SAAS,EAAG;AAC/C,QAAQ,iBAAiB,CAAC;AAC1B,UAAU,IAAI,EAAE,CAAC,EAAA,UAAA,CAAA,CAAA,EAAA,OAAA,CAAA,GAAA,CAAA,CAAA;AACA,UAAA,YAAA,EAAA,IAAA;AACA,UAAA,EAAA,EAAA,CAAA,YAAA,EAAA,eAAA,CAAA,IAAA,CAAA,WAAA,CAAA,CAAA,CAAA;AACA,UAAA,UAAA,EAAA;AACA,YAAA,CAAA,gCAAA,GAAA,sBAAA;AACA,WAAA;AACA,SAAA;AACA,QAAA,IAAA,sBAAA,EAAA;AACA,IAAA,IAAA,CAAA,IAAA,CAAA,IAAA,EAAA,OAAA,EAAA,CAAA,GAAA,IAAA,KAAA;AACA,MAAA,IAAA,CAAA,GAAA,EAAA;AACA,MAAA,QAAA,CAAA,GAAA,IAAA,CAAA;AACA,KAAA,CAAA;AACA,GAAA;AACA;;AAEA;AACA,SAAA,eAAA,CAAA,WAAA,EAAA;AACA,EAAA,MAAA,KAAA,GAAA,WAAA,CAAA,KAAA,CAAA,mCAAA,CAAA;AACA,EAAA,OAAA,KAAA,GAAA,CAAA,CAAA,IAAA,WAAA,CAAA,OAAA,CAAA,qBAAA,EAAA,EAAA,CAAA;AACA;;;;"}
|
package/build/esm/package.json
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"type":"module","version":"
|
|
1
|
+
{"type":"module","version":"9.0.0-alpha.0","sideEffects":false}
|
package/build/types/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
export { addEventProcessor, addBreadcrumb, addIntegration, captureException, captureEvent, captureMessage, captureCheckIn, captureFeedback, startSession, captureSession, endSession, withMonitor, createTransport,
|
|
2
|
-
export { captureConsoleIntegration,
|
|
1
|
+
export { addEventProcessor, addBreadcrumb, addIntegration, captureException, captureEvent, captureMessage, captureCheckIn, captureFeedback, startSession, captureSession, endSession, withMonitor, createTransport, getClient, isInitialized, generateInstrumentOnce, getCurrentScope, getGlobalScope, getIsolationScope, getTraceData, getTraceMetaTags, setCurrentClient, Scope, SDK_VERSION, setContext, setExtra, setExtras, setTag, setTags, setUser, getSpanStatusFromHttpCode, setHttpStatus, withScope, withIsolationScope, makeNodeTransport, NodeClient, defaultStackParser, lastEventId, flush, close, getSentryRelease, createGetModuleFromFilename, anrIntegration, disableAnrDetectionForCallback, consoleIntegration, httpIntegration, nativeNodeFetchIntegration, onUncaughtExceptionIntegration, onUnhandledRejectionIntegration, modulesIntegration, contextLinesIntegration, nodeContextIntegration, localVariablesIntegration, requestDataIntegration, fsIntegration, functionToStringIntegration, inboundFiltersIntegration, linkedErrorsIntegration, setMeasurement, getActiveSpan, startSpan, startInactiveSpan, startSpanManual, startNewTrace, suppressTracing, withActiveSpan, getRootSpan, getSpanDescendants, continueTrace, getAutoPerformanceIntegrations, cron, parameterize, SEMANTIC_ATTRIBUTE_SENTRY_OP, SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN, SEMANTIC_ATTRIBUTE_SENTRY_SOURCE, SEMANTIC_ATTRIBUTE_SENTRY_SAMPLE_RATE, dataloaderIntegration, expressIntegration, expressErrorHandler, setupExpressErrorHandler, koaIntegration, setupKoaErrorHandler, connectIntegration, setupConnectErrorHandler, fastifyIntegration, genericPoolIntegration, graphqlIntegration, knexIntegration, kafkaIntegration, lruMemoizerIntegration, mongoIntegration, mongooseIntegration, mysqlIntegration, mysql2Integration, redisIntegration, tediousIntegration, postgresIntegration, prismaIntegration, hapiIntegration, setupHapiErrorHandler, spotlightIntegration, initOpenTelemetry, spanToJSON, spanToTraceHeader, spanToBaggageHeader, trpcMiddleware, updateSpanName, zodErrorsIntegration, profiler, amqplibIntegration, childProcessIntegration, } from '@sentry/node';
|
|
2
|
+
export { captureConsoleIntegration, dedupeIntegration, extraErrorDataIntegration, rewriteFramesIntegration, } from '@sentry/core';
|
|
3
3
|
export { getDefaultIntegrations, init } from './sdk';
|
|
4
4
|
export { googleCloudHttpIntegration } from './integrations/google-cloud-http';
|
|
5
5
|
export { googleCloudGrpcIntegration } from './integrations/google-cloud-grpc';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,iBAAiB,EACjB,aAAa,EACb,cAAc,EACd,gBAAgB,EAChB,YAAY,EACZ,cAAc,EACd,cAAc,EACd,eAAe,EACf,YAAY,EACZ,cAAc,EACd,UAAU,EACV,WAAW,EACX,eAAe,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,iBAAiB,EACjB,aAAa,EACb,cAAc,EACd,gBAAgB,EAChB,YAAY,EACZ,cAAc,EACd,cAAc,EACd,eAAe,EACf,YAAY,EACZ,cAAc,EACd,UAAU,EACV,WAAW,EACX,eAAe,EACf,SAAS,EACT,aAAa,EACb,sBAAsB,EACtB,eAAe,EACf,cAAc,EACd,iBAAiB,EACjB,YAAY,EACZ,gBAAgB,EAChB,gBAAgB,EAChB,KAAK,EACL,WAAW,EACX,UAAU,EACV,QAAQ,EACR,SAAS,EACT,MAAM,EACN,OAAO,EACP,OAAO,EACP,yBAAyB,EACzB,aAAa,EACb,SAAS,EACT,kBAAkB,EAClB,iBAAiB,EACjB,UAAU,EACV,kBAAkB,EAClB,WAAW,EACX,KAAK,EACL,KAAK,EACL,gBAAgB,EAChB,2BAA2B,EAC3B,cAAc,EACd,8BAA8B,EAC9B,kBAAkB,EAClB,eAAe,EACf,0BAA0B,EAC1B,8BAA8B,EAC9B,+BAA+B,EAC/B,kBAAkB,EAClB,uBAAuB,EACvB,sBAAsB,EACtB,yBAAyB,EACzB,sBAAsB,EACtB,aAAa,EACb,2BAA2B,EAC3B,yBAAyB,EACzB,uBAAuB,EACvB,cAAc,EACd,aAAa,EACb,SAAS,EACT,iBAAiB,EACjB,eAAe,EACf,aAAa,EACb,eAAe,EACf,cAAc,EACd,WAAW,EACX,kBAAkB,EAClB,aAAa,EACb,8BAA8B,EAC9B,IAAI,EACJ,YAAY,EACZ,4BAA4B,EAC5B,gCAAgC,EAChC,gCAAgC,EAChC,qCAAqC,EACrC,qBAAqB,EACrB,kBAAkB,EAClB,mBAAmB,EACnB,wBAAwB,EACxB,cAAc,EACd,oBAAoB,EACpB,kBAAkB,EAClB,wBAAwB,EACxB,kBAAkB,EAClB,sBAAsB,EACtB,kBAAkB,EAClB,eAAe,EACf,gBAAgB,EAChB,sBAAsB,EACtB,gBAAgB,EAChB,mBAAmB,EACnB,gBAAgB,EAChB,iBAAiB,EACjB,gBAAgB,EAChB,kBAAkB,EAClB,mBAAmB,EACnB,iBAAiB,EACjB,eAAe,EACf,qBAAqB,EACrB,oBAAoB,EACpB,iBAAiB,EACjB,UAAU,EACV,iBAAiB,EACjB,mBAAmB,EACnB,cAAc,EACd,cAAc,EACd,oBAAoB,EACpB,QAAQ,EACR,kBAAkB,EAClB,uBAAuB,GACxB,MAAM,cAAc,CAAC;AAEtB,OAAO,EACL,yBAAyB,EACzB,iBAAiB,EACjB,yBAAyB,EACzB,wBAAwB,GACzB,MAAM,cAAc,CAAC;AAEtB,OAAO,EAAE,sBAAsB,EAAE,IAAI,EAAE,MAAM,OAAO,CAAC;AAErD,OAAO,EAAE,0BAA0B,EAAE,MAAM,kCAAkC,CAAC;AAC9E,OAAO,EAAE,0BAA0B,EAAE,MAAM,kCAAkC,CAAC;AAE9E,OAAO,EAAE,sBAAsB,EAAE,MAAM,4BAA4B,CAAC;AACpE,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AACtD,OAAO,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAC"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
export { addEventProcessor, addBreadcrumb, addIntegration, captureException, captureEvent, captureMessage, captureCheckIn, captureFeedback, startSession, captureSession, endSession, withMonitor, createTransport,
|
|
2
|
-
export { captureConsoleIntegration,
|
|
1
|
+
export { addEventProcessor, addBreadcrumb, addIntegration, captureException, captureEvent, captureMessage, captureCheckIn, captureFeedback, startSession, captureSession, endSession, withMonitor, createTransport, getClient, isInitialized, generateInstrumentOnce, getCurrentScope, getGlobalScope, getIsolationScope, getTraceData, getTraceMetaTags, setCurrentClient, Scope, SDK_VERSION, setContext, setExtra, setExtras, setTag, setTags, setUser, getSpanStatusFromHttpCode, setHttpStatus, withScope, withIsolationScope, makeNodeTransport, NodeClient, defaultStackParser, lastEventId, flush, close, getSentryRelease, createGetModuleFromFilename, anrIntegration, disableAnrDetectionForCallback, consoleIntegration, httpIntegration, nativeNodeFetchIntegration, onUncaughtExceptionIntegration, onUnhandledRejectionIntegration, modulesIntegration, contextLinesIntegration, nodeContextIntegration, localVariablesIntegration, requestDataIntegration, fsIntegration, functionToStringIntegration, inboundFiltersIntegration, linkedErrorsIntegration, setMeasurement, getActiveSpan, startSpan, startInactiveSpan, startSpanManual, startNewTrace, suppressTracing, withActiveSpan, getRootSpan, getSpanDescendants, continueTrace, getAutoPerformanceIntegrations, cron, parameterize, SEMANTIC_ATTRIBUTE_SENTRY_OP, SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN, SEMANTIC_ATTRIBUTE_SENTRY_SOURCE, SEMANTIC_ATTRIBUTE_SENTRY_SAMPLE_RATE, dataloaderIntegration, expressIntegration, expressErrorHandler, setupExpressErrorHandler, koaIntegration, setupKoaErrorHandler, connectIntegration, setupConnectErrorHandler, fastifyIntegration, genericPoolIntegration, graphqlIntegration, knexIntegration, kafkaIntegration, lruMemoizerIntegration, mongoIntegration, mongooseIntegration, mysqlIntegration, mysql2Integration, redisIntegration, tediousIntegration, postgresIntegration, prismaIntegration, hapiIntegration, setupHapiErrorHandler, spotlightIntegration, initOpenTelemetry, spanToJSON, spanToTraceHeader, spanToBaggageHeader, trpcMiddleware, updateSpanName, zodErrorsIntegration, profiler, amqplibIntegration, childProcessIntegration, } from '@sentry/node';
|
|
2
|
+
export { captureConsoleIntegration, dedupeIntegration, extraErrorDataIntegration, rewriteFramesIntegration, } from '@sentry/core';
|
|
3
3
|
export { getDefaultIntegrations, init } from './sdk';
|
|
4
4
|
export { googleCloudHttpIntegration } from './integrations/google-cloud-http';
|
|
5
5
|
export { googleCloudGrpcIntegration } from './integrations/google-cloud-grpc';
|
package/package.json
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sentry/google-cloud-serverless",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "9.0.0-alpha.0",
|
|
4
4
|
"description": "Official Sentry SDK for Google Cloud Functions",
|
|
5
5
|
"repository": "git://github.com/getsentry/sentry-javascript.git",
|
|
6
6
|
"homepage": "https://github.com/getsentry/sentry-javascript/tree/master/packages/google-cloud-serverless",
|
|
7
7
|
"author": "Sentry",
|
|
8
8
|
"license": "MIT",
|
|
9
9
|
"engines": {
|
|
10
|
-
"node": ">=
|
|
10
|
+
"node": ">=18"
|
|
11
11
|
},
|
|
12
12
|
"files": [
|
|
13
13
|
"/build"
|
|
@@ -38,7 +38,7 @@
|
|
|
38
38
|
}
|
|
39
39
|
},
|
|
40
40
|
"typesVersions": {
|
|
41
|
-
"<
|
|
41
|
+
"<5.0": {
|
|
42
42
|
"build/types/index.d.ts": [
|
|
43
43
|
"build/types-ts3.8/index.d.ts"
|
|
44
44
|
]
|
|
@@ -48,8 +48,8 @@
|
|
|
48
48
|
"access": "public"
|
|
49
49
|
},
|
|
50
50
|
"dependencies": {
|
|
51
|
-
"@sentry/core": "
|
|
52
|
-
"@sentry/node": "
|
|
51
|
+
"@sentry/core": "9.0.0-alpha.0",
|
|
52
|
+
"@sentry/node": "9.0.0-alpha.0",
|
|
53
53
|
"@types/express": "^4.17.14"
|
|
54
54
|
},
|
|
55
55
|
"devDependencies": {
|
|
@@ -57,7 +57,7 @@
|
|
|
57
57
|
"@google-cloud/common": "^3.4.1",
|
|
58
58
|
"@google-cloud/functions-framework": "^1.7.1",
|
|
59
59
|
"@google-cloud/pubsub": "^2.5.0",
|
|
60
|
-
"@types/node": "^
|
|
60
|
+
"@types/node": "^18.19.1",
|
|
61
61
|
"google-gax": "^2.9.0",
|
|
62
62
|
"nock": "^13.5.5"
|
|
63
63
|
},
|