@sentry/google-cloud-serverless 11.11.0 → 11.13.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 +9 -5
- package/build/cjs/debug-build.js.map +1 -1
- package/build/cjs/gcpfunction/cloud_events.js +56 -67
- package/build/cjs/gcpfunction/cloud_events.js.map +1 -1
- package/build/cjs/gcpfunction/events.js +57 -67
- package/build/cjs/gcpfunction/events.js.map +1 -1
- package/build/cjs/gcpfunction/http.js +66 -67
- package/build/cjs/gcpfunction/http.js.map +1 -1
- package/build/cjs/index.js +213 -217
- package/build/cjs/integrations/gcp-context.js +28 -34
- package/build/cjs/integrations/gcp-context.js.map +1 -1
- package/build/cjs/integrations/google-cloud-grpc.js +61 -77
- package/build/cjs/integrations/google-cloud-grpc.js.map +1 -1
- package/build/cjs/integrations/google-cloud-http.js +52 -51
- package/build/cjs/integrations/google-cloud-http.js.map +1 -1
- package/build/cjs/sdk.js +25 -24
- package/build/cjs/sdk.js.map +1 -1
- package/build/cjs/utils.js +44 -28
- package/build/cjs/utils.js.map +1 -1
- package/build/esm/_virtual/_rolldown/runtime.js +6 -0
- package/build/esm/debug-build.js +9 -3
- package/build/esm/debug-build.js.map +1 -1
- package/build/esm/gcpfunction/cloud_events.js +56 -65
- package/build/esm/gcpfunction/cloud_events.js.map +1 -1
- package/build/esm/gcpfunction/events.js +57 -65
- package/build/esm/gcpfunction/events.js.map +1 -1
- package/build/esm/gcpfunction/http.js +66 -65
- package/build/esm/gcpfunction/http.js.map +1 -1
- package/build/esm/index.js +9 -9
- package/build/esm/integrations/gcp-context.js +27 -31
- package/build/esm/integrations/gcp-context.js.map +1 -1
- package/build/esm/integrations/google-cloud-grpc.js +61 -74
- package/build/esm/integrations/google-cloud-grpc.js.map +1 -1
- package/build/esm/integrations/google-cloud-http.js +52 -48
- package/build/esm/integrations/google-cloud-http.js.map +1 -1
- package/build/esm/package.json +1 -1
- package/build/esm/sdk.js +22 -16
- package/build/esm/sdk.js.map +1 -1
- package/build/esm/utils.js +44 -26
- package/build/esm/utils.js.map +1 -1
- package/build/import-hook.mjs +1 -1
- package/build/types/index.d.ts +1 -1
- package/build/types/index.d.ts.map +1 -1
- package/package.json +27 -28
- package/build/cjs/index.js.map +0 -1
- package/build/esm/index.js.map +0 -1
|
@@ -1,90 +1,74 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
const node = require('@sentry/node');
|
|
7
|
-
|
|
1
|
+
let _sentry_node = require("@sentry/node");
|
|
2
|
+
let _sentry_core = require("@sentry/core");
|
|
3
|
+
let _sentry_conventions_attributes = require("@sentry/conventions/attributes");
|
|
4
|
+
let _sentry_conventions_op = require("@sentry/conventions/op");
|
|
5
|
+
// src/integrations/google-cloud-grpc.ts
|
|
8
6
|
const SERVICE_PATH_REGEX = /^(\w+)\.googleapis.com$/;
|
|
9
7
|
const INTEGRATION_NAME = "GoogleCloudGrpc";
|
|
10
8
|
const SETUP_CLIENTS = /* @__PURE__ */ new WeakMap();
|
|
11
9
|
const _googleCloudGrpcIntegration = ((options = {}) => {
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
}
|
|
28
|
-
}
|
|
29
|
-
},
|
|
30
|
-
setup(client) {
|
|
31
|
-
SETUP_CLIENTS.set(client, true);
|
|
32
|
-
}
|
|
33
|
-
};
|
|
10
|
+
const optional = options.optional || false;
|
|
11
|
+
return {
|
|
12
|
+
name: INTEGRATION_NAME,
|
|
13
|
+
setupOnce() {
|
|
14
|
+
try {
|
|
15
|
+
const gaxModule = require("google-gax");
|
|
16
|
+
(0, _sentry_core.fill)(gaxModule.GrpcClient.prototype, "createStub", wrapCreateStub);
|
|
17
|
+
} catch (e) {
|
|
18
|
+
if (!optional) throw e;
|
|
19
|
+
}
|
|
20
|
+
},
|
|
21
|
+
setup(client) {
|
|
22
|
+
SETUP_CLIENTS.set(client, true);
|
|
23
|
+
}
|
|
24
|
+
};
|
|
34
25
|
});
|
|
35
|
-
|
|
26
|
+
/**
|
|
27
|
+
* Google Cloud Platform service requests tracking for GRPC APIs.
|
|
28
|
+
*/
|
|
29
|
+
const googleCloudGrpcIntegration = (0, _sentry_core.defineIntegration)(_googleCloudGrpcIntegration);
|
|
30
|
+
/** Returns a wrapped function that returns a stub with tracing enabled */
|
|
36
31
|
function wrapCreateStub(origCreate) {
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
fillGrpcFunction(stub, serviceIdentifier, methodName);
|
|
46
|
-
}
|
|
47
|
-
return stub;
|
|
48
|
-
};
|
|
32
|
+
return async function(...args) {
|
|
33
|
+
const servicePath = args[1]?.servicePath;
|
|
34
|
+
if (servicePath == null || servicePath == void 0) return origCreate.apply(this, args);
|
|
35
|
+
const serviceIdentifier = identifyService(servicePath);
|
|
36
|
+
const stub = await origCreate.apply(this, args);
|
|
37
|
+
for (const methodName of Object.keys(Object.getPrototypeOf(stub))) fillGrpcFunction(stub, serviceIdentifier, methodName);
|
|
38
|
+
return stub;
|
|
39
|
+
};
|
|
49
40
|
}
|
|
41
|
+
/** Patches the function in grpc stub to enable tracing */
|
|
50
42
|
function fillGrpcFunction(stub, serviceIdentifier, methodName) {
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
});
|
|
75
|
-
ret.on("status", () => {
|
|
76
|
-
if (span) {
|
|
77
|
-
span.end();
|
|
78
|
-
}
|
|
79
|
-
});
|
|
80
|
-
return ret;
|
|
81
|
-
});
|
|
43
|
+
const funcObj = stub[methodName];
|
|
44
|
+
if (typeof funcObj !== "function") return;
|
|
45
|
+
const callType = !funcObj.requestStream && !funcObj.responseStream ? "unary call" : funcObj.requestStream && !funcObj.responseStream ? "client stream" : !funcObj.requestStream && funcObj.responseStream ? "server stream" : "bidi stream";
|
|
46
|
+
if (callType != "unary call") return;
|
|
47
|
+
(0, _sentry_core.fill)(stub, methodName, (orig) => (...args) => {
|
|
48
|
+
const ret = orig.apply(stub, args);
|
|
49
|
+
if (typeof ret?.on !== "function" || !SETUP_CLIENTS.has((0, _sentry_core.getClient)())) return ret;
|
|
50
|
+
const span = (0, _sentry_node.startInactiveSpan)({
|
|
51
|
+
name: `${callType} ${methodName}`,
|
|
52
|
+
onlyIfParent: true,
|
|
53
|
+
attributes: {
|
|
54
|
+
[_sentry_conventions_attributes.SENTRY_OP]: _sentry_conventions_op.GRPC,
|
|
55
|
+
[_sentry_conventions_attributes.SENTRY_ORIGIN]: "auto.grpc.google_cloud",
|
|
56
|
+
[_sentry_conventions_attributes.RPC_SYSTEM_NAME]: "grpc",
|
|
57
|
+
[_sentry_conventions_attributes.RPC_SERVICE]: serviceIdentifier,
|
|
58
|
+
[_sentry_conventions_attributes.RPC_METHOD]: methodName
|
|
59
|
+
}
|
|
60
|
+
});
|
|
61
|
+
ret.on("status", () => {
|
|
62
|
+
if (span) span.end();
|
|
63
|
+
});
|
|
64
|
+
return ret;
|
|
65
|
+
});
|
|
82
66
|
}
|
|
67
|
+
/** Identifies service by its address */
|
|
83
68
|
function identifyService(servicePath) {
|
|
84
|
-
|
|
85
|
-
return match?.[1] || servicePath;
|
|
69
|
+
return servicePath.match(SERVICE_PATH_REGEX)?.[1] || servicePath;
|
|
86
70
|
}
|
|
87
|
-
|
|
88
71
|
exports.fillGrpcFunction = fillGrpcFunction;
|
|
89
72
|
exports.googleCloudGrpcIntegration = googleCloudGrpcIntegration;
|
|
90
|
-
|
|
73
|
+
|
|
74
|
+
//# sourceMappingURL=google-cloud-grpc.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"google-cloud-grpc.js","sources":["../../../src/integrations/google-cloud-grpc.ts"],"sourcesContent":["import { RPC_METHOD, RPC_SERVICE, RPC_SYSTEM_NAME, SENTRY_OP, SENTRY_ORIGIN } from '@sentry/conventions/attributes';\nimport { GRPC } from '@sentry/conventions/op';\nimport type { Client, IntegrationFn } from '@sentry/core';\nimport { defineIntegration, fill, getClient } from '@sentry/core';\nimport { startInactiveSpan } from '@sentry/node';\nimport type { EventEmitter } from 'events';\n\nexport interface GrpcFunction extends CallableFunction {\n (...args: unknown[]): EventEmitter;\n}\n\nexport interface 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\nexport interface Stub {\n [key: string]: GrpcFunctionObject;\n}\n\nconst SERVICE_PATH_REGEX = /^(\\w+)\\.googleapis.com$/;\n\nconst INTEGRATION_NAME = 'GoogleCloudGrpc' as const;\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 */\nexport function 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(stub, methodName, (orig: GrpcFunction): GrpcFunction => (...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 attributes: {\n [SENTRY_OP]: GRPC,\n [SENTRY_ORIGIN]: 'auto.grpc.google_cloud',\n [RPC_SYSTEM_NAME]: 'grpc',\n [RPC_SERVICE]: serviceIdentifier,\n [RPC_METHOD]: methodName,\n },\n });\n ret.on('status', () => {\n if (span) {\n span.end();\n }\n });\n return ret;\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"],"
|
|
1
|
+
{"version":3,"file":"google-cloud-grpc.js","names":["fill","defineIntegration","getClient","startInactiveSpan","SENTRY_OP","GRPC","SENTRY_ORIGIN","RPC_SYSTEM_NAME","RPC_SERVICE","RPC_METHOD"],"sources":["../../../src/integrations/google-cloud-grpc.ts"],"sourcesContent":["import { RPC_METHOD, RPC_SERVICE, RPC_SYSTEM_NAME, SENTRY_OP, SENTRY_ORIGIN } from '@sentry/conventions/attributes';\nimport { GRPC } from '@sentry/conventions/op';\nimport type { Client, IntegrationFn } from '@sentry/core';\nimport { defineIntegration, fill, getClient } from '@sentry/core';\nimport { startInactiveSpan } from '@sentry/node';\nimport type { EventEmitter } from 'events';\n\nexport interface GrpcFunction extends CallableFunction {\n (...args: unknown[]): EventEmitter;\n}\n\nexport interface 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\nexport interface Stub {\n [key: string]: GrpcFunctionObject;\n}\n\nconst SERVICE_PATH_REGEX = /^(\\w+)\\.googleapis.com$/;\n\nconst INTEGRATION_NAME = 'GoogleCloudGrpc' as const;\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 */\nexport function 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(stub, methodName, (orig: GrpcFunction): GrpcFunction => (...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 attributes: {\n [SENTRY_OP]: GRPC,\n [SENTRY_ORIGIN]: 'auto.grpc.google_cloud',\n [RPC_SYSTEM_NAME]: 'grpc',\n [RPC_SERVICE]: serviceIdentifier,\n [RPC_METHOD]: methodName,\n },\n });\n ret.on('status', () => {\n if (span) {\n span.end();\n }\n });\n return ret;\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"],"mappings":";;;;;AA6BA,MAAM,qBAAqB;AAE3B,MAAM,mBAAmB;AAEzB,MAAM,gCAAgB,IAAI,QAAyB;AAEnD,MAAM,gCAAgC,UAAkC,CAAC,MAAM;CAC7E,MAAM,WAAW,QAAQ,YAAY;CACrC,OAAO;EACL,MAAM;EACN,YAAY;GACV,IAAI;IAEF,MAAM,YAAY,QAAQ,YAAY;IACtCA,CAAAA,GAAAA,aAAAA,KAAAA,CACE,UAAU,WAAW,WACrB,cACA,cACF;GACF,SAAS,GAAG;IACV,IAAI,CAAC,UACH,MAAM;GAEV;EACF;EACA,MAAM,QAAQ;GACZ,cAAc,IAAI,QAAQ,IAAI;EAChC;CACF;AACF;;;;AAKA,MAAa,8BAAA,GAA6BC,aAAAA,kBAAAA,CAAkB,2BAA2B;;AAGvF,SAAS,eAAe,YAA4C;CAClE,OAAO,eAA+B,GAAG,MAAkC;EACzE,MAAM,cAAc,KAAK,EAAE,EAAE;EAC7B,IAAI,eAAe,QAAQ,eAAe,KAAA,GACxC,OAAO,WAAW,MAAM,MAAM,IAAI;EAEpC,MAAM,oBAAoB,gBAAgB,WAAW;EACrD,MAAM,OAAO,MAAM,WAAW,MAAM,MAAM,IAAI;EAC9C,KAAK,MAAM,cAAc,OAAO,KAAK,OAAO,eAAe,IAAI,CAAC,GAC9D,iBAAiB,MAAM,mBAAmB,UAAU;EAEtD,OAAO;CACT;AACF;;AAGA,SAAgB,iBAAiB,MAAY,mBAA2B,YAA0B;CAChG,MAAM,UAAU,KAAK;CACrB,IAAI,OAAO,YAAY,YACrB;CAEF,MAAM,WACJ,CAAC,QAAQ,iBAAiB,CAAC,QAAQ,iBAC/B,eACA,QAAQ,iBAAiB,CAAC,QAAQ,iBAChC,kBACA,CAAC,QAAQ,iBAAiB,QAAQ,iBAChC,kBACA;CACV,IAAI,YAAY,cACd;CAEFD,CAAAA,GAAAA,aAAAA,KAAAA,CAAK,MAAM,aAAa,UAAsC,GAAG,SAAS;EACxE,MAAM,MAAM,KAAK,MAAM,MAAM,IAAI;EACjC,IAAI,OAAO,KAAK,OAAO,cAAc,CAAC,cAAc,KAAA,GAAIE,aAAAA,UAAAA,CAAU,CAAW,GAC3E,OAAO;EAET,MAAM,QAAA,GAAOC,aAAAA,kBAAAA,CAAkB;GAC7B,MAAM,GAAG,SAAS,GAAG;GACrB,cAAc;GACd,YAAY;KACTC,+BAAAA,YAAYC,uBAAAA;KACZC,+BAAAA,gBAAgB;KAChBC,+BAAAA,kBAAkB;KAClBC,+BAAAA,cAAc;KACdC,+BAAAA,aAAa;GAChB;EACF,CAAC;EACD,IAAI,GAAG,gBAAgB;GACrB,IAAI,MACF,KAAK,IAAI;EAEb,CAAC;EACD,OAAO;CACT,CAAC;AACH;;AAGA,SAAS,gBAAgB,aAA6B;CAEpD,OADc,YAAY,MAAM,kBACrB,CAAC,GAAG,MAAM;AACvB"}
|
|
@@ -1,60 +1,61 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
const node = require('@sentry/node');
|
|
7
|
-
|
|
1
|
+
let _sentry_node = require("@sentry/node");
|
|
2
|
+
let _sentry_core = require("@sentry/core");
|
|
3
|
+
let _sentry_conventions_attributes = require("@sentry/conventions/attributes");
|
|
4
|
+
let _sentry_conventions_op = require("@sentry/conventions/op");
|
|
5
|
+
// src/integrations/google-cloud-http.ts
|
|
8
6
|
const INTEGRATION_NAME = "GoogleCloudHttp";
|
|
9
7
|
const SETUP_CLIENTS = /* @__PURE__ */ new WeakMap();
|
|
10
8
|
const _googleCloudHttpIntegration = ((options = {}) => {
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
}
|
|
27
|
-
};
|
|
9
|
+
const optional = options.optional || false;
|
|
10
|
+
return {
|
|
11
|
+
name: INTEGRATION_NAME,
|
|
12
|
+
setupOnce() {
|
|
13
|
+
try {
|
|
14
|
+
const commonModule = require("@google-cloud/common");
|
|
15
|
+
(0, _sentry_core.fill)(commonModule.Service.prototype, "request", wrapRequestFunction);
|
|
16
|
+
} catch (e) {
|
|
17
|
+
if (!optional) throw e;
|
|
18
|
+
}
|
|
19
|
+
},
|
|
20
|
+
setup(client) {
|
|
21
|
+
SETUP_CLIENTS.set(client, true);
|
|
22
|
+
}
|
|
23
|
+
};
|
|
28
24
|
});
|
|
29
|
-
|
|
25
|
+
/**
|
|
26
|
+
* Google Cloud Platform service requests tracking for RESTful APIs.
|
|
27
|
+
*/
|
|
28
|
+
const googleCloudHttpIntegration = (0, _sentry_core.defineIntegration)(_googleCloudHttpIntegration);
|
|
29
|
+
/** Returns a wrapped function that makes a request with tracing enabled */
|
|
30
30
|
function wrapRequestFunction(orig) {
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
31
|
+
return function(reqOpts, callback) {
|
|
32
|
+
const httpMethod = reqOpts.method || "GET";
|
|
33
|
+
const client = (0, _sentry_core.getClient)();
|
|
34
|
+
const serverAddress = getServerAddress(this.apiEndpoint);
|
|
35
|
+
const streamedName = serverAddress ? `${httpMethod} ${serverAddress}` : httpMethod;
|
|
36
|
+
const span = SETUP_CLIENTS.has(client) ? (0, _sentry_node.startInactiveSpan)({
|
|
37
|
+
name: !!client && (0, _sentry_core.hasSpanStreamingEnabled)(client) ? streamedName : `${httpMethod} ${(0, _sentry_core.stripUrlQueryAndFragment)(reqOpts.uri)}`,
|
|
38
|
+
onlyIfParent: true,
|
|
39
|
+
attributes: {
|
|
40
|
+
[_sentry_conventions_attributes.SENTRY_OP]: _sentry_conventions_op.HTTP_CLIENT,
|
|
41
|
+
[_sentry_conventions_attributes.SENTRY_ORIGIN]: "auto.http.serverless",
|
|
42
|
+
[_sentry_conventions_attributes.HTTP_REQUEST_METHOD]: httpMethod,
|
|
43
|
+
[_sentry_conventions_attributes.SERVER_ADDRESS]: serverAddress,
|
|
44
|
+
[_sentry_conventions_attributes.URL_DOMAIN]: serverAddress,
|
|
45
|
+
[_sentry_conventions_attributes.URL_FULL]: (0, _sentry_core.filterCollectedUrl)(reqOpts.uri)
|
|
46
|
+
}
|
|
47
|
+
}) : new _sentry_core.SentryNonRecordingSpan();
|
|
48
|
+
orig.call(this, reqOpts, (...args) => {
|
|
49
|
+
span.end();
|
|
50
|
+
callback(...args);
|
|
51
|
+
});
|
|
52
|
+
};
|
|
53
53
|
}
|
|
54
|
+
/** Extracts the host of the API endpoint the request is sent to */
|
|
54
55
|
function getServerAddress(apiEndpoint) {
|
|
55
|
-
|
|
56
|
-
|
|
56
|
+
const url = (0, _sentry_core.parseStringToURLObject)(apiEndpoint);
|
|
57
|
+
return url && !(0, _sentry_core.isURLObjectRelative)(url) ? url.host : apiEndpoint;
|
|
57
58
|
}
|
|
58
|
-
|
|
59
59
|
exports.googleCloudHttpIntegration = googleCloudHttpIntegration;
|
|
60
|
-
|
|
60
|
+
|
|
61
|
+
//# sourceMappingURL=google-cloud-http.js.map
|
|
@@ -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 {\n HTTP_REQUEST_METHOD,\n SENTRY_OP,\n SERVER_ADDRESS,\n URL_DOMAIN,\n URL_FULL,\n SENTRY_ORIGIN,\n} from '@sentry/conventions/attributes';\nimport { HTTP_CLIENT } from '@sentry/conventions/op';\nimport type { Client, IntegrationFn } from '@sentry/core';\nimport {\n defineIntegration,\n fill,\n getClient,\n hasSpanStreamingEnabled,\n isURLObjectRelative,\n parseStringToURLObject,\n SentryNonRecordingSpan,\n filterCollectedUrl,\n stripUrlQueryAndFragment,\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' as const;\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 client = getClient();\n const serverAddress = getServerAddress(this.apiEndpoint);\n // Span names must not contain a query string, and callers can pass any URI they want. With span\n // streaming they have to be low cardinality on top of that, so the URI is dropped entirely and only\n // the API endpoint is kept — `reqOpts.uri` is a path with no route to parameterize.\n const streamedName = serverAddress ? `${httpMethod} ${serverAddress}` : httpMethod;\n const span = SETUP_CLIENTS.has(client as Client)\n ? startInactiveSpan({\n name:\n !!client && hasSpanStreamingEnabled(client)\n ? streamedName\n : `${httpMethod} ${stripUrlQueryAndFragment(reqOpts.uri)}`,\n onlyIfParent: true,\n attributes: {\n [SENTRY_OP]: HTTP_CLIENT,\n [SENTRY_ORIGIN]: 'auto.http.serverless',\n [HTTP_REQUEST_METHOD]: httpMethod,\n [SERVER_ADDRESS]: serverAddress,\n [URL_DOMAIN]: serverAddress,\n [URL_FULL]: filterCollectedUrl(reqOpts.uri),\n },\n })\n : new SentryNonRecordingSpan();\n orig.call(this, reqOpts, (...args: Parameters<ResponseCallback>) => {\n span.end();\n callback(...args);\n });\n };\n}\n\n/** Extracts the host of the API endpoint the request is sent to */\nfunction getServerAddress(apiEndpoint: string): string {\n const url = parseStringToURLObject(apiEndpoint);\n return url && !isURLObjectRelative(url) ? url.host : apiEndpoint;\n}\n"],"
|
|
1
|
+
{"version":3,"file":"google-cloud-http.js","names":["fill","defineIntegration","getClient","startInactiveSpan","hasSpanStreamingEnabled","stripUrlQueryAndFragment","SENTRY_OP","HTTP_CLIENT","SENTRY_ORIGIN","HTTP_REQUEST_METHOD","SERVER_ADDRESS","URL_DOMAIN","URL_FULL","filterCollectedUrl","SentryNonRecordingSpan","parseStringToURLObject","isURLObjectRelative"],"sources":["../../../src/integrations/google-cloud-http.ts"],"sourcesContent":["import type * as common from '@google-cloud/common';\nimport {\n HTTP_REQUEST_METHOD,\n SENTRY_OP,\n SERVER_ADDRESS,\n URL_DOMAIN,\n URL_FULL,\n SENTRY_ORIGIN,\n} from '@sentry/conventions/attributes';\nimport { HTTP_CLIENT } from '@sentry/conventions/op';\nimport type { Client, IntegrationFn } from '@sentry/core';\nimport {\n defineIntegration,\n fill,\n getClient,\n hasSpanStreamingEnabled,\n isURLObjectRelative,\n parseStringToURLObject,\n SentryNonRecordingSpan,\n filterCollectedUrl,\n stripUrlQueryAndFragment,\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' as const;\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 client = getClient();\n const serverAddress = getServerAddress(this.apiEndpoint);\n // Span names must not contain a query string, and callers can pass any URI they want. With span\n // streaming they have to be low cardinality on top of that, so the URI is dropped entirely and only\n // the API endpoint is kept — `reqOpts.uri` is a path with no route to parameterize.\n const streamedName = serverAddress ? `${httpMethod} ${serverAddress}` : httpMethod;\n const span = SETUP_CLIENTS.has(client as Client)\n ? startInactiveSpan({\n name:\n !!client && hasSpanStreamingEnabled(client)\n ? streamedName\n : `${httpMethod} ${stripUrlQueryAndFragment(reqOpts.uri)}`,\n onlyIfParent: true,\n attributes: {\n [SENTRY_OP]: HTTP_CLIENT,\n [SENTRY_ORIGIN]: 'auto.http.serverless',\n [HTTP_REQUEST_METHOD]: httpMethod,\n [SERVER_ADDRESS]: serverAddress,\n [URL_DOMAIN]: serverAddress,\n [URL_FULL]: filterCollectedUrl(reqOpts.uri),\n },\n })\n : new SentryNonRecordingSpan();\n orig.call(this, reqOpts, (...args: Parameters<ResponseCallback>) => {\n span.end();\n callback(...args);\n });\n };\n}\n\n/** Extracts the host of the API endpoint the request is sent to */\nfunction getServerAddress(apiEndpoint: string): string {\n const url = parseStringToURLObject(apiEndpoint);\n return url && !isURLObjectRelative(url) ? url.host : apiEndpoint;\n}\n"],"mappings":";;;;;AA+BA,MAAM,mBAAmB;AAEzB,MAAM,gCAAgB,IAAI,QAAyB;AAEnD,MAAM,gCAAgC,UAAkC,CAAC,MAAM;CAC7E,MAAM,WAAW,QAAQ,YAAY;CACrC,OAAO;EACL,MAAM;EACN,YAAY;GACV,IAAI;IAEF,MAAM,eAAe,QAAQ,sBAAsB;IACnDA,CAAAA,GAAAA,aAAAA,KAAAA,CAAK,aAAa,QAAQ,WAAW,WAAW,mBAAmB;GACrE,SAAS,GAAG;IACV,IAAI,CAAC,UACH,MAAM;GAEV;EACF;EACA,MAAM,QAAQ;GACZ,cAAc,IAAI,QAAQ,IAAI;EAChC;CACF;AACF;;;;AAKA,MAAa,8BAAA,GAA6BC,aAAAA,kBAAAA,CAAkB,2BAA2B;;AAGvF,SAAS,oBAAoB,MAAwC;CACnE,OAAO,SAAgC,SAAyB,UAAkC;EAChG,MAAM,aAAa,QAAQ,UAAU;EACrC,MAAM,UAAA,GAASC,aAAAA,UAAAA,CAAU;EACzB,MAAM,gBAAgB,iBAAiB,KAAK,WAAW;EAIvD,MAAM,eAAe,gBAAgB,GAAG,WAAW,GAAG,kBAAkB;EACxE,MAAM,OAAO,cAAc,IAAI,MAAgB,KAAA,GAC3CC,aAAAA,kBAAAA,CAAkB;GAChB,MACE,CAAC,CAAC,WAAA,GAAUC,aAAAA,wBAAAA,CAAwB,MAAM,IACtC,eACA,GAAG,WAAW,IAAA,GAAGC,aAAAA,yBAAAA,CAAyB,QAAQ,GAAG;GAC3D,cAAc;GACd,YAAY;KACTC,+BAAAA,YAAYC,uBAAAA;KACZC,+BAAAA,gBAAgB;KAChBC,+BAAAA,sBAAsB;KACtBC,+BAAAA,iBAAiB;KACjBC,+BAAAA,aAAa;KACbC,+BAAAA,YAAAA,GAAWC,aAAAA,mBAAAA,CAAmB,QAAQ,GAAG;GAC5C;EACF,CAAC,IACD,IAAIC,aAAAA,uBAAuB;EAC/B,KAAK,KAAK,MAAM,UAAU,GAAG,SAAuC;GAClE,KAAK,IAAI;GACT,SAAS,GAAG,IAAI;EAClB,CAAC;CACH;AACF;;AAGA,SAAS,iBAAiB,aAA6B;CACrD,MAAM,OAAA,GAAMC,aAAAA,uBAAAA,CAAuB,WAAW;CAC9C,OAAO,OAAO,EAAA,GAACC,aAAAA,oBAAAA,CAAoB,GAAG,IAAI,IAAI,OAAO;AACvD"}
|
package/build/cjs/sdk.js
CHANGED
|
@@ -1,31 +1,32 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
const
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
const googleCloudHttp = require('./integrations/google-cloud-http.js');
|
|
8
|
-
|
|
1
|
+
const require_gcp_context = require("./integrations/gcp-context.js");
|
|
2
|
+
const require_google_cloud_grpc = require("./integrations/google-cloud-grpc.js");
|
|
3
|
+
const require_google_cloud_http = require("./integrations/google-cloud-http.js");
|
|
4
|
+
let _sentry_node = require("@sentry/node");
|
|
5
|
+
let _sentry_core = require("@sentry/core");
|
|
6
|
+
// src/sdk.ts
|
|
9
7
|
function getCjsOnlyIntegrations() {
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
googleCloudGrpc.googleCloudGrpcIntegration({ optional: true })
|
|
14
|
-
// We mark this integration optional since 'google-gax' module could be missing.
|
|
15
|
-
];
|
|
16
|
-
}
|
|
8
|
+
return [require_google_cloud_http.googleCloudHttpIntegration({ optional: true }), require_google_cloud_grpc.googleCloudGrpcIntegration({ optional: true })];
|
|
9
|
+
}
|
|
10
|
+
/** Get the default integrations for the GCP SDK. */
|
|
17
11
|
function getDefaultIntegrations(_options) {
|
|
18
|
-
|
|
12
|
+
return [
|
|
13
|
+
...(0, _sentry_node.getDefaultIntegrationsWithoutPerformance)(),
|
|
14
|
+
require_gcp_context.gcpContextIntegration(),
|
|
15
|
+
...getCjsOnlyIntegrations()
|
|
16
|
+
];
|
|
19
17
|
}
|
|
18
|
+
/**
|
|
19
|
+
* @see {@link Sentry.init}
|
|
20
|
+
*/
|
|
20
21
|
function init(options = {}) {
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
22
|
+
const opts = {
|
|
23
|
+
defaultIntegrations: getDefaultIntegrations(options),
|
|
24
|
+
...options
|
|
25
|
+
};
|
|
26
|
+
(0, _sentry_core.applySdkMetadata)(opts, "google-cloud-serverless", ["google-cloud-serverless", "node"]);
|
|
27
|
+
return (0, _sentry_node.init)(opts);
|
|
27
28
|
}
|
|
28
|
-
|
|
29
29
|
exports.getDefaultIntegrations = getDefaultIntegrations;
|
|
30
30
|
exports.init = init;
|
|
31
|
-
|
|
31
|
+
|
|
32
|
+
//# sourceMappingURL=sdk.js.map
|
package/build/cjs/sdk.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sdk.js","sources":["../../src/sdk.ts"],"sourcesContent":["import type { Integration, Options } from '@sentry/core';\nimport { applySdkMetadata } from '@sentry/core';\nimport type { NodeClient, NodeOptions } from '@sentry/node';\nimport { getDefaultIntegrationsWithoutPerformance, init as initNode } from '@sentry/node';\nimport { gcpContextIntegration } from './integrations/gcp-context';\nimport { googleCloudGrpcIntegration } from './integrations/google-cloud-grpc';\nimport { googleCloudHttpIntegration } from './integrations/google-cloud-http';\n\nfunction getCjsOnlyIntegrations(): Integration[] {\n /*! rollup-include-cjs-only */\n return [\n googleCloudHttpIntegration({ optional: true }), // We mark this integration optional since '@google-cloud/common' module could be missing.\n googleCloudGrpcIntegration({ optional: true }), // We mark this integration optional since 'google-gax' module could be missing.\n ];\n /*! rollup-include-cjs-only-end */\n /*! rollup-include-esm-only */\n // oxlint-disable-next-line no-unreachable -- reachable only in the ESM build; rollup strips the CJS return above\n return [];\n /*! rollup-include-esm-only-end */\n}\n\n/** Get the default integrations for the GCP SDK. */\nexport function getDefaultIntegrations(_options: Options): Integration[] {\n return [...getDefaultIntegrationsWithoutPerformance(), gcpContextIntegration(), ...getCjsOnlyIntegrations()];\n}\n\n/**\n * @see {@link Sentry.init}\n */\nexport function init(options: NodeOptions = {}): NodeClient | undefined {\n const opts = {\n defaultIntegrations: getDefaultIntegrations(options),\n ...options,\n };\n\n applySdkMetadata(opts, 'google-cloud-serverless', ['google-cloud-serverless', 'node']);\n\n return initNode(opts);\n}\n"],"
|
|
1
|
+
{"version":3,"file":"sdk.js","names":["googleCloudHttpIntegration","googleCloudGrpcIntegration","getDefaultIntegrationsWithoutPerformance","gcpContextIntegration","applySdkMetadata","initNode"],"sources":["../../src/sdk.ts"],"sourcesContent":["import type { Integration, Options } from '@sentry/core';\nimport { applySdkMetadata } from '@sentry/core';\nimport type { NodeClient, NodeOptions } from '@sentry/node';\nimport { getDefaultIntegrationsWithoutPerformance, init as initNode } from '@sentry/node';\nimport { gcpContextIntegration } from './integrations/gcp-context';\nimport { googleCloudGrpcIntegration } from './integrations/google-cloud-grpc';\nimport { googleCloudHttpIntegration } from './integrations/google-cloud-http';\n\nfunction getCjsOnlyIntegrations(): Integration[] {\n /*! rollup-include-cjs-only */\n return [\n googleCloudHttpIntegration({ optional: true }), // We mark this integration optional since '@google-cloud/common' module could be missing.\n googleCloudGrpcIntegration({ optional: true }), // We mark this integration optional since 'google-gax' module could be missing.\n ];\n /*! rollup-include-cjs-only-end */\n /*! rollup-include-esm-only */\n // oxlint-disable-next-line no-unreachable -- reachable only in the ESM build; rollup strips the CJS return above\n return [];\n /*! rollup-include-esm-only-end */\n}\n\n/** Get the default integrations for the GCP SDK. */\nexport function getDefaultIntegrations(_options: Options): Integration[] {\n return [...getDefaultIntegrationsWithoutPerformance(), gcpContextIntegration(), ...getCjsOnlyIntegrations()];\n}\n\n/**\n * @see {@link Sentry.init}\n */\nexport function init(options: NodeOptions = {}): NodeClient | undefined {\n const opts = {\n defaultIntegrations: getDefaultIntegrations(options),\n ...options,\n };\n\n applySdkMetadata(opts, 'google-cloud-serverless', ['google-cloud-serverless', 'node']);\n\n return initNode(opts);\n}\n"],"mappings":";;;;;;AAQA,SAAS,yBAAwC;CAC/C,OAAO,CACLA,0BAAAA,2BAA2B,EAAE,UAAU,KAAK,CAAC,GAC7CC,0BAAAA,2BAA2B,EAAE,UAAU,KAAK,CAAC,CAC/C;AACA;;AAGF,SAAgB,uBAAuB,UAAkC;CACvE,OAAO;EAAC,IAAA,GAAGC,aAAAA,yCAAAA,CAAyC;EAAGC,oBAAAA,sBAAsB;EAAG,GAAG,uBAAuB;CAAC;AAC7G;;;;AAKA,SAAgB,KAAK,UAAuB,CAAC,GAA2B;CACtE,MAAM,OAAO;EACX,qBAAqB,uBAAuB,OAAO;EACnD,GAAG;CACL;CAEAC,CAAAA,GAAAA,aAAAA,iBAAAA,CAAiB,MAAM,2BAA2B,CAAC,2BAA2B,MAAM,CAAC;CAErF,QAAA,GAAOC,aAAAA,KAAAA,CAAS,IAAI;AACtB"}
|
package/build/cjs/utils.js
CHANGED
|
@@ -1,40 +1,56 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
let _sentry_core = require("@sentry/core");
|
|
2
|
+
// src/utils.ts
|
|
3
|
+
/**
|
|
4
|
+
* @param fn function to run
|
|
5
|
+
* @returns function which runs in the newly created domain or in the existing one
|
|
6
|
+
*/
|
|
5
7
|
function domainify(fn) {
|
|
6
|
-
|
|
8
|
+
return (...args) => (0, _sentry_core.withIsolationScope)(() => fn(...args));
|
|
7
9
|
}
|
|
10
|
+
/**
|
|
11
|
+
* @param source function to be wrapped
|
|
12
|
+
* @param wrap wrapping function that takes source and returns a wrapper
|
|
13
|
+
* @param overrides properties to override in the source
|
|
14
|
+
* @returns wrapped function
|
|
15
|
+
*/
|
|
8
16
|
function proxyFunction(source, wrap, overrides) {
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
return overrides[prop];
|
|
19
|
-
}
|
|
20
|
-
return target[prop];
|
|
21
|
-
};
|
|
22
|
-
}
|
|
23
|
-
return new Proxy(source, handler);
|
|
17
|
+
const wrapper = wrap(source);
|
|
18
|
+
const handler = { apply: (_target, thisArg, args) => {
|
|
19
|
+
return wrapper.apply(thisArg, args);
|
|
20
|
+
} };
|
|
21
|
+
if (overrides) handler.get = (target, prop) => {
|
|
22
|
+
if (Object.prototype.hasOwnProperty.call(overrides, prop)) return overrides[prop];
|
|
23
|
+
return target[prop];
|
|
24
|
+
};
|
|
25
|
+
return new Proxy(source, handler);
|
|
24
26
|
}
|
|
27
|
+
/**
|
|
28
|
+
* Marks an event as unhandled by adding a span processor to the passed scope.
|
|
29
|
+
*/
|
|
25
30
|
function markEventUnhandled(scope, type) {
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
+
scope.addEventProcessor((event) => {
|
|
32
|
+
(0, _sentry_core.addExceptionMechanism)(event, {
|
|
33
|
+
handled: false,
|
|
34
|
+
type
|
|
35
|
+
});
|
|
36
|
+
return event;
|
|
37
|
+
});
|
|
38
|
+
return scope;
|
|
31
39
|
}
|
|
40
|
+
/**
|
|
41
|
+
* Resolves the name of the currently executing cloud function.
|
|
42
|
+
*
|
|
43
|
+
* `FUNCTION_TARGET` ("the function to be executed") is set by GCP for every deployed function, and
|
|
44
|
+
* by the functions-framework when running locally, where `K_SERVICE` is absent. `K_SERVICE` is the
|
|
45
|
+
* Cloud Run service the function runs as; the two differ whenever the entry point is named
|
|
46
|
+
* separately from the service, as in `gcloud run deploy my-service --function myHandler`.
|
|
47
|
+
*/
|
|
32
48
|
function getFunctionName() {
|
|
33
|
-
|
|
49
|
+
return process.env.FUNCTION_TARGET || process.env.K_SERVICE || void 0;
|
|
34
50
|
}
|
|
35
|
-
|
|
36
51
|
exports.domainify = domainify;
|
|
37
52
|
exports.getFunctionName = getFunctionName;
|
|
38
53
|
exports.markEventUnhandled = markEventUnhandled;
|
|
39
54
|
exports.proxyFunction = proxyFunction;
|
|
40
|
-
|
|
55
|
+
|
|
56
|
+
//# sourceMappingURL=utils.js.map
|
package/build/cjs/utils.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.js","sources":["../../src/utils.ts"],"sourcesContent":["import type { Scope } from '@sentry/core';\nimport { addExceptionMechanism, withIsolationScope } from '@sentry/core';\n\n/**\n * @param fn function to run\n * @returns function which runs in the newly created domain or in the existing one\n */\nexport function domainify<A extends unknown[], R>(fn: (...args: A) => R): (...args: A) => R | void {\n return (...args) => withIsolationScope(() => fn(...args));\n}\n\n/**\n * @param source function to be wrapped\n * @param wrap wrapping function that takes source and returns a wrapper\n * @param overrides properties to override in the source\n * @returns wrapped function\n */\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport function proxyFunction<A extends any[], R, F extends (...args: A) => R>(\n source: F,\n wrap: (source: F) => F,\n overrides?: Record<PropertyKey, unknown>,\n): F {\n const wrapper = wrap(source);\n const handler: ProxyHandler<F> = {\n apply: <T>(_target: F, thisArg: T, args: A) => {\n return wrapper.apply(thisArg, args);\n },\n };\n\n if (overrides) {\n handler.get = (target, prop) => {\n if (Object.prototype.hasOwnProperty.call(overrides, prop)) {\n return overrides[prop as string];\n }\n return (target as Record<PropertyKey, unknown>)[prop as string];\n };\n }\n\n return new Proxy(source, handler);\n}\n\n/**\n * Marks an event as unhandled by adding a span processor to the passed scope.\n */\nexport function markEventUnhandled(scope: Scope, type: string): Scope {\n scope.addEventProcessor(event => {\n addExceptionMechanism(event, { handled: false, type });\n return event;\n });\n\n return scope;\n}\n\n/**\n * Resolves the name of the currently executing cloud function.\n *\n * `FUNCTION_TARGET` (\"the function to be executed\") is set by GCP for every deployed function, and\n * by the functions-framework when running locally, where `K_SERVICE` is absent. `K_SERVICE` is the\n * Cloud Run service the function runs as; the two differ whenever the entry point is named\n * separately from the service, as in `gcloud run deploy my-service --function myHandler`.\n */\nexport function getFunctionName(): string | undefined {\n return process.env.FUNCTION_TARGET || process.env.K_SERVICE || undefined;\n}\n"],"
|
|
1
|
+
{"version":3,"file":"utils.js","names":["withIsolationScope","addExceptionMechanism"],"sources":["../../src/utils.ts"],"sourcesContent":["import type { Scope } from '@sentry/core';\nimport { addExceptionMechanism, withIsolationScope } from '@sentry/core';\n\n/**\n * @param fn function to run\n * @returns function which runs in the newly created domain or in the existing one\n */\nexport function domainify<A extends unknown[], R>(fn: (...args: A) => R): (...args: A) => R | void {\n return (...args) => withIsolationScope(() => fn(...args));\n}\n\n/**\n * @param source function to be wrapped\n * @param wrap wrapping function that takes source and returns a wrapper\n * @param overrides properties to override in the source\n * @returns wrapped function\n */\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport function proxyFunction<A extends any[], R, F extends (...args: A) => R>(\n source: F,\n wrap: (source: F) => F,\n overrides?: Record<PropertyKey, unknown>,\n): F {\n const wrapper = wrap(source);\n const handler: ProxyHandler<F> = {\n apply: <T>(_target: F, thisArg: T, args: A) => {\n return wrapper.apply(thisArg, args);\n },\n };\n\n if (overrides) {\n handler.get = (target, prop) => {\n if (Object.prototype.hasOwnProperty.call(overrides, prop)) {\n return overrides[prop as string];\n }\n return (target as Record<PropertyKey, unknown>)[prop as string];\n };\n }\n\n return new Proxy(source, handler);\n}\n\n/**\n * Marks an event as unhandled by adding a span processor to the passed scope.\n */\nexport function markEventUnhandled(scope: Scope, type: string): Scope {\n scope.addEventProcessor(event => {\n addExceptionMechanism(event, { handled: false, type });\n return event;\n });\n\n return scope;\n}\n\n/**\n * Resolves the name of the currently executing cloud function.\n *\n * `FUNCTION_TARGET` (\"the function to be executed\") is set by GCP for every deployed function, and\n * by the functions-framework when running locally, where `K_SERVICE` is absent. `K_SERVICE` is the\n * Cloud Run service the function runs as; the two differ whenever the entry point is named\n * separately from the service, as in `gcloud run deploy my-service --function myHandler`.\n */\nexport function getFunctionName(): string | undefined {\n return process.env.FUNCTION_TARGET || process.env.K_SERVICE || undefined;\n}\n"],"mappings":";;;;;;AAOA,SAAgB,UAAkC,IAAiD;CACjG,QAAQ,GAAG,UAAA,GAASA,aAAAA,mBAAAA,OAAyB,GAAG,GAAG,IAAI,CAAC;AAC1D;;;;;;;AASA,SAAgB,cACd,QACA,MACA,WACG;CACH,MAAM,UAAU,KAAK,MAAM;CAC3B,MAAM,UAA2B,EAC/B,QAAW,SAAY,SAAY,SAAY;EAC7C,OAAO,QAAQ,MAAM,SAAS,IAAI;CACpC,EACF;CAEA,IAAI,WACF,QAAQ,OAAO,QAAQ,SAAS;EAC9B,IAAI,OAAO,UAAU,eAAe,KAAK,WAAW,IAAI,GACtD,OAAO,UAAU;EAEnB,OAAQ,OAAwC;CAClD;CAGF,OAAO,IAAI,MAAM,QAAQ,OAAO;AAClC;;;;AAKA,SAAgB,mBAAmB,OAAc,MAAqB;CACpE,MAAM,mBAAkB,UAAS;EAC/BC,CAAAA,GAAAA,aAAAA,sBAAAA,CAAsB,OAAO;GAAE,SAAS;GAAO;EAAK,CAAC;EACrD,OAAO;CACT,CAAC;CAED,OAAO;AACT;;;;;;;;;AAUA,SAAgB,kBAAsC;CACpD,OAAO,QAAQ,IAAI,mBAAmB,QAAQ,IAAI,aAAa,KAAA;AACjE"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
// \0rolldown/runtime.js
|
|
2
|
+
var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, { get: (a, b) => (typeof require !== "undefined" ? require : a)[b] }) : x)(function(x) {
|
|
3
|
+
if (typeof require !== "undefined") return require.apply(this, arguments);
|
|
4
|
+
throw Error("Calling `require` for \"" + x + "\" in an environment that doesn't expose the `require` function. See https://rolldown.rs/in-depth/bundling-cjs#require-external-modules for more details.");
|
|
5
|
+
});
|
|
6
|
+
export { __require };
|
package/build/esm/debug-build.js
CHANGED
|
@@ -1,4 +1,10 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
// src/debug-build.ts
|
|
2
|
+
/**
|
|
3
|
+
* 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.
|
|
4
|
+
*
|
|
5
|
+
* ATTENTION: This constant must never cross package boundaries (i.e. be exported) to guarantee that it can be used for tree shaking.
|
|
6
|
+
*/
|
|
7
|
+
const DEBUG_BUILD = typeof __SENTRY_DEBUG__ === "undefined" || __SENTRY_DEBUG__;
|
|
3
8
|
export { DEBUG_BUILD };
|
|
4
|
-
|
|
9
|
+
|
|
10
|
+
//# sourceMappingURL=debug-build.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"debug-build.js","sources":["../../src/debug-build.ts"],"sourcesContent":["declare const __DEBUG_BUILD__: boolean;\n\n/**\n * 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.\n *\n * ATTENTION: This constant must never cross package boundaries (i.e. be exported) to guarantee that it can be used for tree shaking.\n */\nexport const DEBUG_BUILD = __DEBUG_BUILD__;\n"],"
|
|
1
|
+
{"version":3,"file":"debug-build.js","names":[],"sources":["../../src/debug-build.ts"],"sourcesContent":["declare const __DEBUG_BUILD__: boolean;\n\n/**\n * 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.\n *\n * ATTENTION: This constant must never cross package boundaries (i.e. be exported) to guarantee that it can be used for tree shaking.\n */\nexport const DEBUG_BUILD = __DEBUG_BUILD__;\n"],"mappings":";;;;;;AAOA,MAAa,cAAe,OAAO,qBAAqB,eAAe"}
|