@sentry/google-cloud-serverless 11.0.0-beta.1 → 11.0.0-rc.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/gcpfunction/cloud_events.js +11 -2
- package/build/cjs/gcpfunction/cloud_events.js.map +1 -1
- package/build/cjs/gcpfunction/events.js +10 -2
- package/build/cjs/gcpfunction/events.js.map +1 -1
- package/build/cjs/gcpfunction/http.js +12 -3
- package/build/cjs/gcpfunction/http.js.map +1 -1
- package/build/cjs/index.js +7 -0
- package/build/cjs/index.js.map +1 -1
- package/build/cjs/utils.js +4 -0
- package/build/cjs/utils.js.map +1 -1
- package/build/esm/gcpfunction/cloud_events.js +14 -5
- package/build/esm/gcpfunction/cloud_events.js.map +1 -1
- package/build/esm/gcpfunction/events.js +13 -5
- package/build/esm/gcpfunction/events.js.map +1 -1
- package/build/esm/gcpfunction/http.js +15 -6
- package/build/esm/gcpfunction/http.js.map +1 -1
- package/build/esm/index.js +1 -1
- package/build/esm/package.json +1 -1
- package/build/esm/utils.js +4 -1
- package/build/esm/utils.js.map +1 -1
- package/build/types/gcpfunction/cloud_events.d.ts.map +1 -1
- package/build/types/gcpfunction/events.d.ts.map +1 -1
- package/build/types/gcpfunction/http.d.ts.map +1 -1
- package/build/types/index.d.ts +1 -1
- package/build/types/index.d.ts.map +1 -1
- package/build/types/utils.d.ts +9 -0
- package/build/types/utils.d.ts.map +1 -1
- package/package.json +6 -6
|
@@ -16,14 +16,23 @@ function _wrapCloudEventFunction(fn, wrapOptions = {}) {
|
|
|
16
16
|
...wrapOptions
|
|
17
17
|
};
|
|
18
18
|
return (context, callback) => {
|
|
19
|
+
const client = core.getClient();
|
|
20
|
+
const functionName = utils.getFunctionName();
|
|
21
|
+
const name = client && core.hasSpanStreamingEnabled(client) ? functionName || core.SERVERLESS_FUNCTION_SPAN_NAME_FALLBACK : context.type || "<unknown>";
|
|
19
22
|
return node.startSpanManual(
|
|
20
23
|
{
|
|
21
|
-
name
|
|
24
|
+
name,
|
|
22
25
|
attributes: {
|
|
23
26
|
[attributes.SENTRY_OP]: op.FUNCTION_GCP,
|
|
27
|
+
[attributes.FAAS_NAME]: functionName,
|
|
24
28
|
[attributes.FAAS_TRIGGER]: "cloud_event",
|
|
25
29
|
[attributes.SENTRY_SEGMENT_NAME_SOURCE]: "component",
|
|
26
|
-
[core.SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN]: "auto.function.serverless.gcp_cloud_event"
|
|
30
|
+
[core.SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN]: "auto.function.serverless.gcp_cloud_event",
|
|
31
|
+
[attributes.GCP_FUNCTION_CONTEXT_TYPE]: context.type,
|
|
32
|
+
[attributes.GCP_FUNCTION_CONTEXT_ID]: context.id,
|
|
33
|
+
[attributes.GCP_FUNCTION_CONTEXT_SOURCE]: context.source,
|
|
34
|
+
[attributes.GCP_FUNCTION_CONTEXT_SPECVERSION]: context.specversion,
|
|
35
|
+
[attributes.GCP_FUNCTION_CONTEXT_TIME]: context.time
|
|
27
36
|
}
|
|
28
37
|
},
|
|
29
38
|
(span) => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cloud_events.js","sources":["../../../src/gcpfunction/cloud_events.ts"],"sourcesContent":["import {
|
|
1
|
+
{"version":3,"file":"cloud_events.js","sources":["../../../src/gcpfunction/cloud_events.ts"],"sourcesContent":["import {\n SENTRY_SEGMENT_NAME_SOURCE,\n FAAS_NAME,\n FAAS_TRIGGER,\n SENTRY_OP,\n GCP_FUNCTION_CONTEXT_TYPE,\n GCP_FUNCTION_CONTEXT_ID,\n GCP_FUNCTION_CONTEXT_SOURCE,\n GCP_FUNCTION_CONTEXT_SPECVERSION,\n GCP_FUNCTION_CONTEXT_TIME,\n} from '@sentry/conventions/attributes';\nimport { FUNCTION_GCP } from '@sentry/conventions/op';\nimport {\n debug,\n getClient,\n handleCallbackErrors,\n hasSpanStreamingEnabled,\n SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN,\n SERVERLESS_FUNCTION_SPAN_NAME_FALLBACK,\n} from '@sentry/core';\nimport { captureException, flush, getCurrentScope, startSpanManual } from '@sentry/node';\nimport { DEBUG_BUILD } from '../debug-build';\nimport { domainify, getFunctionName, markEventUnhandled, proxyFunction } from '../utils';\nimport type { CloudEventFunction, CloudEventFunctionWithCallback, WrapperOptions } from './general';\n\nexport type CloudEventFunctionWrapperOptions = WrapperOptions;\n\n/**\n * Wraps an event function handler adding it error capture and tracing capabilities.\n *\n * @param fn Event handler\n * @param options Options\n * @returns Event handler\n */\nexport function wrapCloudEventFunction(\n fn: CloudEventFunction | CloudEventFunctionWithCallback,\n wrapOptions: Partial<CloudEventFunctionWrapperOptions> = {},\n): CloudEventFunctionWithCallback {\n return proxyFunction(fn, f => domainify(_wrapCloudEventFunction(f, wrapOptions)));\n}\n\nfunction _wrapCloudEventFunction(\n fn: CloudEventFunction | CloudEventFunctionWithCallback,\n wrapOptions: Partial<CloudEventFunctionWrapperOptions> = {},\n): CloudEventFunctionWithCallback {\n const options: CloudEventFunctionWrapperOptions = {\n flushTimeout: 2000,\n ...wrapOptions,\n };\n return (context, callback) => {\n const client = getClient();\n\n const functionName = getFunctionName();\n const name =\n client && hasSpanStreamingEnabled(client)\n ? functionName || SERVERLESS_FUNCTION_SPAN_NAME_FALLBACK\n : context.type || '<unknown>';\n\n return startSpanManual(\n {\n name,\n attributes: {\n [SENTRY_OP]: FUNCTION_GCP,\n [FAAS_NAME]: functionName,\n [FAAS_TRIGGER]: 'cloud_event',\n [SENTRY_SEGMENT_NAME_SOURCE]: 'component',\n [SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN]: 'auto.function.serverless.gcp_cloud_event',\n [GCP_FUNCTION_CONTEXT_TYPE]: context.type,\n [GCP_FUNCTION_CONTEXT_ID]: context.id,\n [GCP_FUNCTION_CONTEXT_SOURCE]: context.source,\n [GCP_FUNCTION_CONTEXT_SPECVERSION]: context.specversion,\n [GCP_FUNCTION_CONTEXT_TIME]: context.time,\n },\n },\n span => {\n const scope = getCurrentScope();\n scope.setContext('gcp.function.context', { ...context });\n\n const newCallback = domainify((...args: unknown[]) => {\n if (args[0] !== null && args[0] !== undefined) {\n captureException(args[0], scope => markEventUnhandled(scope, 'auto.function.serverless.gcp_cloud_event'));\n }\n span.end();\n\n // eslint-disable-next-line @typescript-eslint/no-floating-promises\n flush(options.flushTimeout)\n .then(null, e => {\n DEBUG_BUILD && debug.error(e);\n })\n .then(() => {\n if (typeof callback === 'function') {\n callback(...args);\n }\n });\n });\n\n if (fn.length > 1) {\n return handleCallbackErrors(\n () => (fn as CloudEventFunctionWithCallback)(context, newCallback),\n err => {\n captureException(err, scope => markEventUnhandled(scope, 'auto.function.serverless.gcp_cloud_event'));\n },\n );\n }\n\n return Promise.resolve()\n .then(() => (fn as CloudEventFunction)(context))\n .then(\n result => newCallback(null, result),\n err => newCallback(err, undefined),\n );\n },\n );\n };\n}\n"],"names":["proxyFunction","domainify","getClient","getFunctionName","hasSpanStreamingEnabled","SERVERLESS_FUNCTION_SPAN_NAME_FALLBACK","startSpanManual","SENTRY_OP","FUNCTION_GCP","FAAS_NAME","FAAS_TRIGGER","SENTRY_SEGMENT_NAME_SOURCE","SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN","GCP_FUNCTION_CONTEXT_TYPE","GCP_FUNCTION_CONTEXT_ID","GCP_FUNCTION_CONTEXT_SOURCE","GCP_FUNCTION_CONTEXT_SPECVERSION","GCP_FUNCTION_CONTEXT_TIME","getCurrentScope","captureException","scope","markEventUnhandled","flush","DEBUG_BUILD","debug","handleCallbackErrors"],"mappings":";;;;;;;;;AAkCO,SAAS,sBAAA,CACd,EAAA,EACA,WAAA,GAAyD,EAAC,EAC1B;AAChC,EAAA,OAAOA,mBAAA,CAAc,IAAI,CAAA,CAAA,KAAKC,eAAA,CAAU,wBAAwB,CAAA,EAAG,WAAW,CAAC,CAAC,CAAA;AAClF;AAEA,SAAS,uBAAA,CACP,E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AAA,CAAK,CAAC,CAAA,EAAG,CAAAC,WAASC,wBAAA,CAAmBD,MAAAA,EAAO,0CAA0C,CAAC,CAAA;AAAA,UAC1G;AACA,UAAA,IAAA,CAAK,GAAA,EAAI;AAGT,UAAAE,UAAA,CAAM,OAAA,CAAQ,YAAY,CAAA,CACvB,IAAA,CAAK,MAAM,CAAA,CAAA,KAAK;AACf,YAAAC,sBAAA,IAAeC,UAAA,CAAM,MAAM,CAAC,CAAA;AAAA,UAC9B,CAAC,CAAA,CACA,IAAA,CAAK,MAAM;AACV,YAAA,IAAI,OAAO,aAAa,UAAA,EAAY;AAClC,cAAA,QAAA,CAAS,GAAG,IAAI,CAAA;AAAA,YAClB;AAAA,UACF,CAAC,CAAA;AAAA,QACL,CAAC,CAAA;AAED,QAAA,IAAI,EAAA,CAAG,SAAS,CAAA,EAAG;AACjB,UAAA,OAAOC,yBAAA;AAAA,YACL,MAAO,EAAA,CAAsC,OAAA,EAAS,WAAW,CAAA;AAAA,YACjE,CAAA,GAAA,KAAO;AACL,cAAAN,qBAAA,CAAiB,KAAK,CAAAC,MAAAA,KAASC,wBAAA,CAAmBD,MAAAA,EAAO,0CAA0C,CAAC,CAAA;AAAA,YACtG;AAAA,WACF;AAAA,QACF;AAEA,QAAA,OAAO,OAAA,CAAQ,SAAQ,CACpB,IAAA,CAAK,MAAO,EAAA,CAA0B,OAAO,CAAC,CAAA,CAC9C,IAAA;AAAA,UACC,CAAA,MAAA,KAAU,WAAA,CAAY,IAAA,EAAM,MAAM,CAAA;AAAA,UAClC,CAAA,GAAA,KAAO,WAAA,CAAY,GAAA,EAAK,MAAS;AAAA,SACnC;AAAA,MACJ;AAAA,KACF;AAAA,EACF,CAAA;AACF;;;;"}
|
|
@@ -17,14 +17,22 @@ function _wrapEventFunction(fn, wrapOptions = {}) {
|
|
|
17
17
|
};
|
|
18
18
|
return (...eventFunctionArguments) => {
|
|
19
19
|
const [data, context, callback] = eventFunctionArguments;
|
|
20
|
+
const client = core.getClient();
|
|
21
|
+
const functionName = utils.getFunctionName();
|
|
22
|
+
const name = client && core.hasSpanStreamingEnabled(client) ? functionName || core.SERVERLESS_FUNCTION_SPAN_NAME_FALLBACK : context.eventType;
|
|
20
23
|
return node.startSpanManual(
|
|
21
24
|
{
|
|
22
|
-
name
|
|
25
|
+
name,
|
|
23
26
|
attributes: {
|
|
24
27
|
[attributes.SENTRY_OP]: op.FUNCTION_GCP,
|
|
28
|
+
[attributes.FAAS_NAME]: functionName,
|
|
25
29
|
[attributes.FAAS_TRIGGER]: "event",
|
|
26
30
|
[attributes.SENTRY_SEGMENT_NAME_SOURCE]: "component",
|
|
27
|
-
[
|
|
31
|
+
[attributes.SENTRY_ORIGIN]: "auto.function.serverless.gcp_event",
|
|
32
|
+
[attributes.GCP_FUNCTION_CONTEXT_EVENT_TYPE]: context.eventType,
|
|
33
|
+
[attributes.GCP_FUNCTION_CONTEXT_EVENT_ID]: context.eventId,
|
|
34
|
+
[attributes.GCP_FUNCTION_CONTEXT_RESOURCE]: context.resource,
|
|
35
|
+
[attributes.GCP_FUNCTION_CONTEXT_TIMESTAMP]: context.timestamp
|
|
28
36
|
}
|
|
29
37
|
},
|
|
30
38
|
(span) => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"events.js","sources":["../../../src/gcpfunction/events.ts"],"sourcesContent":["import {
|
|
1
|
+
{"version":3,"file":"events.js","sources":["../../../src/gcpfunction/events.ts"],"sourcesContent":["import {\n SENTRY_SEGMENT_NAME_SOURCE,\n FAAS_NAME,\n FAAS_TRIGGER,\n SENTRY_OP,\n GCP_FUNCTION_CONTEXT_EVENT_TYPE,\n GCP_FUNCTION_CONTEXT_EVENT_ID,\n GCP_FUNCTION_CONTEXT_RESOURCE,\n GCP_FUNCTION_CONTEXT_TIMESTAMP,\n SENTRY_ORIGIN,\n} from '@sentry/conventions/attributes';\nimport { FUNCTION_GCP } from '@sentry/conventions/op';\nimport {\n debug,\n getClient,\n handleCallbackErrors,\n hasSpanStreamingEnabled,\n SERVERLESS_FUNCTION_SPAN_NAME_FALLBACK,\n} from '@sentry/core';\nimport { captureException, flush, getCurrentScope, startSpanManual } from '@sentry/node';\nimport { DEBUG_BUILD } from '../debug-build';\nimport { domainify, getFunctionName, markEventUnhandled, proxyFunction } from '../utils';\nimport type { EventFunction, EventFunctionWithCallback, WrapperOptions } from './general';\n\nexport type EventFunctionWrapperOptions = WrapperOptions;\n\n/**\n * Wraps an event function handler adding it error capture and tracing capabilities.\n *\n * @param fn Event handler\n * @param options Options\n * @returns Event handler\n */\nexport function wrapEventFunction(\n fn: EventFunction | EventFunctionWithCallback,\n wrapOptions: Partial<EventFunctionWrapperOptions> = {},\n): EventFunctionWithCallback {\n return proxyFunction(fn, f => domainify(_wrapEventFunction(f, wrapOptions)));\n}\n\n/** */\nfunction _wrapEventFunction<F extends EventFunction | EventFunctionWithCallback>(\n fn: F,\n wrapOptions: Partial<EventFunctionWrapperOptions> = {},\n): (...args: Parameters<F>) => ReturnType<F> | Promise<void> {\n const options: EventFunctionWrapperOptions = {\n flushTimeout: 2000,\n ...wrapOptions,\n };\n return (...eventFunctionArguments: Parameters<F>): ReturnType<F> | Promise<void> => {\n const [data, context, callback] = eventFunctionArguments;\n\n const client = getClient();\n\n const functionName = getFunctionName();\n const name =\n client && hasSpanStreamingEnabled(client)\n ? functionName || SERVERLESS_FUNCTION_SPAN_NAME_FALLBACK\n : context.eventType;\n\n return startSpanManual(\n {\n name,\n attributes: {\n [SENTRY_OP]: FUNCTION_GCP,\n [FAAS_NAME]: functionName,\n [FAAS_TRIGGER]: 'event',\n [SENTRY_SEGMENT_NAME_SOURCE]: 'component',\n [SENTRY_ORIGIN]: 'auto.function.serverless.gcp_event',\n [GCP_FUNCTION_CONTEXT_EVENT_TYPE]: context.eventType,\n [GCP_FUNCTION_CONTEXT_EVENT_ID]: context.eventId,\n [GCP_FUNCTION_CONTEXT_RESOURCE]: context.resource,\n [GCP_FUNCTION_CONTEXT_TIMESTAMP]: context.timestamp,\n },\n },\n span => {\n const scope = getCurrentScope();\n scope.setContext('gcp.function.context', { ...context });\n\n const newCallback = domainify((...args: unknown[]) => {\n if (args[0] !== null && args[0] !== undefined) {\n captureException(args[0], scope => markEventUnhandled(scope, 'auto.function.serverless.gcp_event'));\n }\n span.end();\n\n // eslint-disable-next-line @typescript-eslint/no-floating-promises\n flush(options.flushTimeout)\n .then(null, e => {\n DEBUG_BUILD && debug.error(e);\n })\n .then(() => {\n if (typeof callback === 'function') {\n callback(...args);\n }\n });\n });\n\n if (fn.length > 2) {\n return handleCallbackErrors(\n () => (fn as EventFunctionWithCallback)(data, context, newCallback),\n err => {\n captureException(err, scope => markEventUnhandled(scope, 'auto.function.serverless.gcp_event'));\n },\n );\n }\n\n return Promise.resolve()\n .then(() => (fn as EventFunction)(data, context))\n .then(\n result => newCallback(null, result),\n err => newCallback(err, undefined),\n );\n },\n );\n };\n}\n"],"names":["proxyFunction","domainify","getClient","getFunctionName","hasSpanStreamingEnabled","SERVERLESS_FUNCTION_SPAN_NAME_FALLBACK","startSpanManual","SENTRY_OP","FUNCTION_GCP","FAAS_NAME","FAAS_TRIGGER","SENTRY_SEGMENT_NAME_SOURCE","SENTRY_ORIGIN","GCP_FUNCTION_CONTEXT_EVENT_TYPE","GCP_FUNCTION_CONTEXT_EVENT_ID","GCP_FUNCTION_CONTEXT_RESOURCE","GCP_FUNCTION_CONTEXT_TIMESTAMP","getCurrentScope","captureException","scope","markEventUnhandled","flush","DEBUG_BUILD","debug","handleCallbackErrors"],"mappings":";;;;;;;;;AAiCO,SAAS,iBAAA,CACd,EAAA,EACA,WAAA,GAAoD,EAAC,EAC1B;AAC3B,EAAA,OAAOA,mBAAA,CAAc,IAAI,CAAA,CAAA,KAAKC,eAAA,CAAU,mBAAmB,CAAA,EAAG,WAAW,CAAC,CAAC,CAAA;AAC7E;AAGA,SAAS,kBAAA,CACP,EAAA,EACA,WAAA,GAAoD,EAAC,EACM;AAC3D,EAAA,MAAM,OAAA,GAAuC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,MAAAA,EAAO,oCAAoC,CAAC,CAAA;AAAA,UACpG;AACA,UAAA,IAAA,CAAK,GAAA,EAAI;AAGT,UAAAE,UAAA,CAAM,OAAA,CAAQ,YAAY,CAAA,CACvB,IAAA,CAAK,MAAM,CAAA,CAAA,KAAK;AACf,YAAAC,sBAAA,IAAeC,UAAA,CAAM,MAAM,CAAC,CAAA;AAAA,UAC9B,CAAC,CAAA,CACA,IAAA,CAAK,MAAM;AACV,YAAA,IAAI,OAAO,aAAa,UAAA,EAAY;AAClC,cAAA,QAAA,CAAS,GAAG,IAAI,CAAA;AAAA,YAClB;AAAA,UACF,CAAC,CAAA;AAAA,QACL,CAAC,CAAA;AAED,QAAA,IAAI,EAAA,CAAG,SAAS,CAAA,EAAG;AACjB,UAAA,OAAOC,yBAAA;AAAA,YACL,MAAO,EAAA,CAAiC,IAAA,EAAM,OAAA,EAAS,WAAW,CAAA;AAAA,YAClE,CAAA,GAAA,KAAO;AACL,cAAAN,qBAAA,CAAiB,KAAK,CAAAC,MAAAA,KAASC,wBAAA,CAAmBD,MAAAA,EAAO,oCAAoC,CAAC,CAAA;AAAA,YAChG;AAAA,WACF;AAAA,QACF;AAEA,QAAA,OAAO,OAAA,CAAQ,SAAQ,CACpB,IAAA,CAAK,MAAO,EAAA,CAAqB,IAAA,EAAM,OAAO,CAAC,CAAA,CAC/C,IAAA;AAAA,UACC,CAAA,MAAA,KAAU,WAAA,CAAY,IAAA,EAAM,MAAM,CAAA;AAAA,UAClC,CAAA,GAAA,KAAO,WAAA,CAAY,GAAA,EAAK,MAAS;AAAA,SACnC;AAAA,MACJ;AAAA,KACF;AAAA,EACF,CAAA;AACF;;;;"}
|
|
@@ -26,14 +26,23 @@ function _wrapHttpFunction(fn, options) {
|
|
|
26
26
|
return node.continueTrace({ sentryTrace, baggage }, () => {
|
|
27
27
|
const normalizedRequest = core.httpRequestToRequestData(req);
|
|
28
28
|
node.getCurrentScope().setSDKProcessingMetadata({ normalizedRequest });
|
|
29
|
+
const functionName = utils.getFunctionName();
|
|
30
|
+
const client = core.getClient();
|
|
31
|
+
const hasSpanStreaming = client && core.hasSpanStreamingEnabled(client);
|
|
32
|
+
const name = hasSpanStreaming ? functionName || core.SERVERLESS_FUNCTION_SPAN_NAME_FALLBACK : `${reqMethod} ${reqUrl}`;
|
|
29
33
|
return node.startSpanManual(
|
|
30
34
|
{
|
|
31
|
-
name
|
|
35
|
+
name,
|
|
32
36
|
attributes: {
|
|
33
37
|
[attributes.SENTRY_OP]: op.FUNCTION_GCP,
|
|
38
|
+
[attributes.FAAS_NAME]: functionName,
|
|
34
39
|
[attributes.FAAS_TRIGGER]: "http",
|
|
35
|
-
[attributes.SENTRY_SEGMENT_NAME_SOURCE]: "route",
|
|
36
|
-
[core.SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN]: "auto.function.serverless.gcp_http"
|
|
40
|
+
[attributes.SENTRY_SEGMENT_NAME_SOURCE]: hasSpanStreaming ? "component" : "route",
|
|
41
|
+
[core.SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN]: "auto.function.serverless.gcp_http",
|
|
42
|
+
// The method and path used to be the span name; they stay on the span so that
|
|
43
|
+
// information survives the low-cardinality rename.
|
|
44
|
+
[attributes.HTTP_REQUEST_METHOD]: reqMethod || void 0,
|
|
45
|
+
[attributes.URL_PATH]: reqUrl || void 0
|
|
37
46
|
}
|
|
38
47
|
},
|
|
39
48
|
(span) => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"http.js","sources":["../../../src/gcpfunction/http.ts"],"sourcesContent":["import {
|
|
1
|
+
{"version":3,"file":"http.js","sources":["../../../src/gcpfunction/http.ts"],"sourcesContent":["import {\n SENTRY_SEGMENT_NAME_SOURCE,\n FAAS_NAME,\n FAAS_TRIGGER,\n HTTP_REQUEST_METHOD,\n SENTRY_OP,\n URL_PATH,\n} from '@sentry/conventions/attributes';\nimport { FUNCTION_GCP } from '@sentry/conventions/op';\nimport {\n debug,\n getClient,\n handleCallbackErrors,\n hasSpanStreamingEnabled,\n httpRequestToRequestData,\n isString,\n SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN,\n SERVERLESS_FUNCTION_SPAN_NAME_FALLBACK,\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, getFunctionName, 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 const functionName = getFunctionName();\n\n const client = getClient();\n const hasSpanStreaming = client && hasSpanStreamingEnabled(client);\n const name = hasSpanStreaming ? functionName || SERVERLESS_FUNCTION_SPAN_NAME_FALLBACK : `${reqMethod} ${reqUrl}`;\n\n return startSpanManual(\n {\n name,\n attributes: {\n [SENTRY_OP]: FUNCTION_GCP,\n [FAAS_NAME]: functionName,\n [FAAS_TRIGGER]: 'http',\n [SENTRY_SEGMENT_NAME_SOURCE]: hasSpanStreaming ? 'component' : 'route',\n [SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN]: 'auto.function.serverless.gcp_http',\n // The method and path used to be the span name; they stay on the span so that\n // information survives the low-cardinality rename.\n [HTTP_REQUEST_METHOD]: reqMethod || undefined,\n [URL_PATH]: reqUrl || undefined,\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 && debug.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, 'auto.function.serverless.gcp_http'));\n },\n );\n },\n );\n });\n };\n}\n"],"names":["domainify","proxyFunction","stripUrlQueryAndFragment","isString","continueTrace","httpRequestToRequestData","getCurrentScope","getFunctionName","getClient","hasSpanStreamingEnabled","SERVERLESS_FUNCTION_SPAN_NAME_FALLBACK","startSpanManual","SENTRY_OP","FUNCTION_GCP","FAAS_NAME","FAAS_TRIGGER","SENTRY_SEGMENT_NAME_SOURCE","SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN","HTTP_REQUEST_METHOD","URL_PATH","setHttpStatus","flush","DEBUG_BUILD","debug","handleCallbackErrors","captureException","markEventUnhandled"],"mappings":";;;;;;;;;AAiCO,SAAS,gBAAA,CAAiB,EAAA,EA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AA,YACjB,CAAA,GAAA,KAAO;AACL,cAAAC,qBAAA,CAAiB,GAAA,EAAK,CAAA,KAAA,KAASC,wBAAA,CAAmB,KAAA,EAAO,mCAAmC,CAAC,CAAA;AAAA,YAC/F;AAAA,WACF;AAAA,QACF;AAAA,OACF;AAAA,IACF,CAAC,CAAA;AAAA,EACH,CAAA;AACF;;;;"}
|
package/build/cjs/index.js
CHANGED
|
@@ -20,6 +20,7 @@ exports.SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN = node.SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN
|
|
|
20
20
|
exports.SEMANTIC_ATTRIBUTE_SENTRY_SAMPLE_RATE = node.SEMANTIC_ATTRIBUTE_SENTRY_SAMPLE_RATE;
|
|
21
21
|
exports.SENTRY_SEGMENT_NAME_SOURCE = node.SENTRY_SEGMENT_NAME_SOURCE;
|
|
22
22
|
exports.Scope = node.Scope;
|
|
23
|
+
exports.SentryMastraExporter = node.SentryMastraExporter;
|
|
23
24
|
exports.addBreadcrumb = node.addBreadcrumb;
|
|
24
25
|
exports.addEventProcessor = node.addEventProcessor;
|
|
25
26
|
exports.addIntegration = node.addIntegration;
|
|
@@ -41,6 +42,7 @@ exports.consoleLoggingIntegration = node.consoleLoggingIntegration;
|
|
|
41
42
|
exports.contextLinesIntegration = node.contextLinesIntegration;
|
|
42
43
|
exports.continueTrace = node.continueTrace;
|
|
43
44
|
exports.createConsolaReporter = node.createConsolaReporter;
|
|
45
|
+
exports.createFlueInstrumentation = node.createFlueInstrumentation;
|
|
44
46
|
exports.createGetModuleFromFilename = node.createGetModuleFromFilename;
|
|
45
47
|
exports.createLangChainCallbackHandler = node.createLangChainCallbackHandler;
|
|
46
48
|
exports.createSentryWinstonTransport = node.createSentryWinstonTransport;
|
|
@@ -50,6 +52,7 @@ exports.dataloaderIntegration = node.dataloaderIntegration;
|
|
|
50
52
|
exports.defaultStackParser = node.defaultStackParser;
|
|
51
53
|
exports.disableAnrDetectionForCallback = node.disableAnrDetectionForCallback;
|
|
52
54
|
exports.endSession = node.endSession;
|
|
55
|
+
exports.eveConversationHook = node.eveConversationHook;
|
|
53
56
|
exports.eventFiltersIntegration = node.eventFiltersIntegration;
|
|
54
57
|
exports.expressErrorHandler = node.expressErrorHandler;
|
|
55
58
|
exports.expressIntegration = node.expressIntegration;
|
|
@@ -65,6 +68,7 @@ exports.getAutoPerformanceIntegrations = node.getAutoPerformanceIntegrations;
|
|
|
65
68
|
exports.getClient = node.getClient;
|
|
66
69
|
exports.getCurrentScope = node.getCurrentScope;
|
|
67
70
|
exports.getGlobalScope = node.getGlobalScope;
|
|
71
|
+
exports.getInstrumentedModuleNames = node.getInstrumentedModuleNames;
|
|
68
72
|
exports.getIsolationScope = node.getIsolationScope;
|
|
69
73
|
exports.getOtlpTracesEndpoint = node.getOtlpTracesEndpoint;
|
|
70
74
|
exports.getRootSpan = node.getRootSpan;
|
|
@@ -85,6 +89,7 @@ exports.initOpenTelemetry = node.initOpenTelemetry;
|
|
|
85
89
|
exports.instrumentAnthropicAiClient = node.instrumentAnthropicAiClient;
|
|
86
90
|
exports.instrumentGoogleGenAIClient = node.instrumentGoogleGenAIClient;
|
|
87
91
|
exports.instrumentLangChainEmbeddings = node.instrumentLangChainEmbeddings;
|
|
92
|
+
exports.instrumentMistralAiClient = node.instrumentMistralAiClient;
|
|
88
93
|
exports.instrumentOpenAiClient = node.instrumentOpenAiClient;
|
|
89
94
|
exports.instrumentStateGraph = node.instrumentStateGraph;
|
|
90
95
|
exports.instrumentStateGraphCompile = node.instrumentStateGraphCompile;
|
|
@@ -103,7 +108,9 @@ exports.localVariablesIntegration = node.localVariablesIntegration;
|
|
|
103
108
|
exports.logger = node.logger;
|
|
104
109
|
exports.lruMemoizerIntegration = node.lruMemoizerIntegration;
|
|
105
110
|
exports.makeNodeTransport = node.makeNodeTransport;
|
|
111
|
+
exports.mastraIntegration = node.mastraIntegration;
|
|
106
112
|
exports.metrics = node.metrics;
|
|
113
|
+
exports.mistralAIIntegration = node.mistralAIIntegration;
|
|
107
114
|
exports.modulesIntegration = node.modulesIntegration;
|
|
108
115
|
exports.mongoIntegration = node.mongoIntegration;
|
|
109
116
|
exports.mongooseIntegration = node.mongooseIntegration;
|
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":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
package/build/cjs/utils.js
CHANGED
|
@@ -29,8 +29,12 @@ function markEventUnhandled(scope, type) {
|
|
|
29
29
|
});
|
|
30
30
|
return scope;
|
|
31
31
|
}
|
|
32
|
+
function getFunctionName() {
|
|
33
|
+
return process.env.FUNCTION_TARGET || process.env.K_SERVICE || void 0;
|
|
34
|
+
}
|
|
32
35
|
|
|
33
36
|
exports.domainify = domainify;
|
|
37
|
+
exports.getFunctionName = getFunctionName;
|
|
34
38
|
exports.markEventUnhandled = markEventUnhandled;
|
|
35
39
|
exports.proxyFunction = proxyFunction;
|
|
36
40
|
//# 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"],"names":["withIsolationScope","addExceptionMechanism"],"mappings":";;;;AAOO,SAAS,UAAkC,EAAA,EAAiD;AACjG,EAAA,OAAO,IAAI,IAAA,KAASA,uBAAA,CAAmB,MAAM,EAAA,CAAG,GAAG,IAAI,CAAC,CAAA;AAC1D;AASO,SAAS,aAAA,CACd,MAAA,EACA,IAAA,EACA,SAAA,EACG;AACH,EAAA,MAAM,OAAA,GAAU,KAAK,MAAM,CAAA;AAC3B,EAAA,MAAM,OAAA,GAA2B;AAAA,IAC/B,KAAA,EAAO,CAAI,OAAA,EAAY,OAAA,EAAY,IAAA,KAAY;AAC7C,MAAA,OAAO,OAAA,CAAQ,KAAA,CAAM,OAAA,EAAS,IAAI,CAAA;AAAA,IACpC;AAAA,GACF;AAEA,EAAA,IAAI,SAAA,EAAW;AACb,IAAA,OAAA,CAAQ,GAAA,GAAM,CAAC,MAAA,EAAQ,IAAA,KAAS;AAC9B,MAAA,IAAI,OAAO,SAAA,CAAU,cAAA,CAAe,IAAA,CAAK,SAAA,EAAW,IAAI,CAAA,EAAG;AACzD,QAAA,OAAO,UAAU,IAAc,CAAA;AAAA,MACjC;AACA,MAAA,OAAQ,OAAwC,IAAc,CAAA;AAAA,IAChE,CAAA;AAAA,EACF;AAEA,EAAA,OAAO,IAAI,KAAA,CAAM,MAAA,EAAQ,OAAO,CAAA;AAClC;AAKO,SAAS,kBAAA,CAAmB,OAAc,IAAA,EAAqB;AACpE,EAAA,KAAA,CAAM,kBAAkB,CAAA,KAAA,KAAS;AAC/B,IAAAC,0BAAA,CAAsB,KAAA,EAAO,EAAE,OAAA,EAAS,KAAA,EAAO,MAAM,CAAA;AACrD,IAAA,OAAO,KAAA;AAAA,EACT,CAAC,CAAA;AAED,EAAA,OAAO,KAAA;AACT
|
|
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"],"names":["withIsolationScope","addExceptionMechanism"],"mappings":";;;;AAOO,SAAS,UAAkC,EAAA,EAAiD;AACjG,EAAA,OAAO,IAAI,IAAA,KAASA,uBAAA,CAAmB,MAAM,EAAA,CAAG,GAAG,IAAI,CAAC,CAAA;AAC1D;AASO,SAAS,aAAA,CACd,MAAA,EACA,IAAA,EACA,SAAA,EACG;AACH,EAAA,MAAM,OAAA,GAAU,KAAK,MAAM,CAAA;AAC3B,EAAA,MAAM,OAAA,GAA2B;AAAA,IAC/B,KAAA,EAAO,CAAI,OAAA,EAAY,OAAA,EAAY,IAAA,KAAY;AAC7C,MAAA,OAAO,OAAA,CAAQ,KAAA,CAAM,OAAA,EAAS,IAAI,CAAA;AAAA,IACpC;AAAA,GACF;AAEA,EAAA,IAAI,SAAA,EAAW;AACb,IAAA,OAAA,CAAQ,GAAA,GAAM,CAAC,MAAA,EAAQ,IAAA,KAAS;AAC9B,MAAA,IAAI,OAAO,SAAA,CAAU,cAAA,CAAe,IAAA,CAAK,SAAA,EAAW,IAAI,CAAA,EAAG;AACzD,QAAA,OAAO,UAAU,IAAc,CAAA;AAAA,MACjC;AACA,MAAA,OAAQ,OAAwC,IAAc,CAAA;AAAA,IAChE,CAAA;AAAA,EACF;AAEA,EAAA,OAAO,IAAI,KAAA,CAAM,MAAA,EAAQ,OAAO,CAAA;AAClC;AAKO,SAAS,kBAAA,CAAmB,OAAc,IAAA,EAAqB;AACpE,EAAA,KAAA,CAAM,kBAAkB,CAAA,KAAA,KAAS;AAC/B,IAAAC,0BAAA,CAAsB,KAAA,EAAO,EAAE,OAAA,EAAS,KAAA,EAAO,MAAM,CAAA;AACrD,IAAA,OAAO,KAAA;AAAA,EACT,CAAC,CAAA;AAED,EAAA,OAAO,KAAA;AACT;AAUO,SAAS,eAAA,GAAsC;AACpD,EAAA,OAAO,OAAA,CAAQ,GAAA,CAAI,eAAA,IAAmB,OAAA,CAAQ,IAAI,SAAA,IAAa,MAAA;AACjE;;;;;;;"}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { SENTRY_SEGMENT_NAME_SOURCE, FAAS_TRIGGER, SENTRY_OP } from '@sentry/conventions/attributes';
|
|
1
|
+
import { GCP_FUNCTION_CONTEXT_TIME, GCP_FUNCTION_CONTEXT_SPECVERSION, GCP_FUNCTION_CONTEXT_SOURCE, GCP_FUNCTION_CONTEXT_ID, GCP_FUNCTION_CONTEXT_TYPE, SENTRY_SEGMENT_NAME_SOURCE, FAAS_TRIGGER, FAAS_NAME, SENTRY_OP } from '@sentry/conventions/attributes';
|
|
2
2
|
import { FUNCTION_GCP } from '@sentry/conventions/op';
|
|
3
|
-
import { SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN, handleCallbackErrors, debug } from '@sentry/core';
|
|
3
|
+
import { getClient, hasSpanStreamingEnabled, SERVERLESS_FUNCTION_SPAN_NAME_FALLBACK, SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN, handleCallbackErrors, debug } from '@sentry/core';
|
|
4
4
|
import { startSpanManual, getCurrentScope, captureException, flush } from '@sentry/node';
|
|
5
5
|
import { DEBUG_BUILD } from '../debug-build.js';
|
|
6
|
-
import { proxyFunction, domainify, markEventUnhandled } from '../utils.js';
|
|
6
|
+
import { proxyFunction, domainify, getFunctionName, markEventUnhandled } from '../utils.js';
|
|
7
7
|
|
|
8
8
|
function wrapCloudEventFunction(fn, wrapOptions = {}) {
|
|
9
9
|
return proxyFunction(fn, (f) => domainify(_wrapCloudEventFunction(f, wrapOptions)));
|
|
@@ -14,14 +14,23 @@ function _wrapCloudEventFunction(fn, wrapOptions = {}) {
|
|
|
14
14
|
...wrapOptions
|
|
15
15
|
};
|
|
16
16
|
return (context, callback) => {
|
|
17
|
+
const client = getClient();
|
|
18
|
+
const functionName = getFunctionName();
|
|
19
|
+
const name = client && hasSpanStreamingEnabled(client) ? functionName || SERVERLESS_FUNCTION_SPAN_NAME_FALLBACK : context.type || "<unknown>";
|
|
17
20
|
return startSpanManual(
|
|
18
21
|
{
|
|
19
|
-
name
|
|
22
|
+
name,
|
|
20
23
|
attributes: {
|
|
21
24
|
[SENTRY_OP]: FUNCTION_GCP,
|
|
25
|
+
[FAAS_NAME]: functionName,
|
|
22
26
|
[FAAS_TRIGGER]: "cloud_event",
|
|
23
27
|
[SENTRY_SEGMENT_NAME_SOURCE]: "component",
|
|
24
|
-
[SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN]: "auto.function.serverless.gcp_cloud_event"
|
|
28
|
+
[SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN]: "auto.function.serverless.gcp_cloud_event",
|
|
29
|
+
[GCP_FUNCTION_CONTEXT_TYPE]: context.type,
|
|
30
|
+
[GCP_FUNCTION_CONTEXT_ID]: context.id,
|
|
31
|
+
[GCP_FUNCTION_CONTEXT_SOURCE]: context.source,
|
|
32
|
+
[GCP_FUNCTION_CONTEXT_SPECVERSION]: context.specversion,
|
|
33
|
+
[GCP_FUNCTION_CONTEXT_TIME]: context.time
|
|
25
34
|
}
|
|
26
35
|
},
|
|
27
36
|
(span) => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cloud_events.js","sources":["../../../src/gcpfunction/cloud_events.ts"],"sourcesContent":["import {
|
|
1
|
+
{"version":3,"file":"cloud_events.js","sources":["../../../src/gcpfunction/cloud_events.ts"],"sourcesContent":["import {\n SENTRY_SEGMENT_NAME_SOURCE,\n FAAS_NAME,\n FAAS_TRIGGER,\n SENTRY_OP,\n GCP_FUNCTION_CONTEXT_TYPE,\n GCP_FUNCTION_CONTEXT_ID,\n GCP_FUNCTION_CONTEXT_SOURCE,\n GCP_FUNCTION_CONTEXT_SPECVERSION,\n GCP_FUNCTION_CONTEXT_TIME,\n} from '@sentry/conventions/attributes';\nimport { FUNCTION_GCP } from '@sentry/conventions/op';\nimport {\n debug,\n getClient,\n handleCallbackErrors,\n hasSpanStreamingEnabled,\n SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN,\n SERVERLESS_FUNCTION_SPAN_NAME_FALLBACK,\n} from '@sentry/core';\nimport { captureException, flush, getCurrentScope, startSpanManual } from '@sentry/node';\nimport { DEBUG_BUILD } from '../debug-build';\nimport { domainify, getFunctionName, markEventUnhandled, proxyFunction } from '../utils';\nimport type { CloudEventFunction, CloudEventFunctionWithCallback, WrapperOptions } from './general';\n\nexport type CloudEventFunctionWrapperOptions = WrapperOptions;\n\n/**\n * Wraps an event function handler adding it error capture and tracing capabilities.\n *\n * @param fn Event handler\n * @param options Options\n * @returns Event handler\n */\nexport function wrapCloudEventFunction(\n fn: CloudEventFunction | CloudEventFunctionWithCallback,\n wrapOptions: Partial<CloudEventFunctionWrapperOptions> = {},\n): CloudEventFunctionWithCallback {\n return proxyFunction(fn, f => domainify(_wrapCloudEventFunction(f, wrapOptions)));\n}\n\nfunction _wrapCloudEventFunction(\n fn: CloudEventFunction | CloudEventFunctionWithCallback,\n wrapOptions: Partial<CloudEventFunctionWrapperOptions> = {},\n): CloudEventFunctionWithCallback {\n const options: CloudEventFunctionWrapperOptions = {\n flushTimeout: 2000,\n ...wrapOptions,\n };\n return (context, callback) => {\n const client = getClient();\n\n const functionName = getFunctionName();\n const name =\n client && hasSpanStreamingEnabled(client)\n ? functionName || SERVERLESS_FUNCTION_SPAN_NAME_FALLBACK\n : context.type || '<unknown>';\n\n return startSpanManual(\n {\n name,\n attributes: {\n [SENTRY_OP]: FUNCTION_GCP,\n [FAAS_NAME]: functionName,\n [FAAS_TRIGGER]: 'cloud_event',\n [SENTRY_SEGMENT_NAME_SOURCE]: 'component',\n [SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN]: 'auto.function.serverless.gcp_cloud_event',\n [GCP_FUNCTION_CONTEXT_TYPE]: context.type,\n [GCP_FUNCTION_CONTEXT_ID]: context.id,\n [GCP_FUNCTION_CONTEXT_SOURCE]: context.source,\n [GCP_FUNCTION_CONTEXT_SPECVERSION]: context.specversion,\n [GCP_FUNCTION_CONTEXT_TIME]: context.time,\n },\n },\n span => {\n const scope = getCurrentScope();\n scope.setContext('gcp.function.context', { ...context });\n\n const newCallback = domainify((...args: unknown[]) => {\n if (args[0] !== null && args[0] !== undefined) {\n captureException(args[0], scope => markEventUnhandled(scope, 'auto.function.serverless.gcp_cloud_event'));\n }\n span.end();\n\n // eslint-disable-next-line @typescript-eslint/no-floating-promises\n flush(options.flushTimeout)\n .then(null, e => {\n DEBUG_BUILD && debug.error(e);\n })\n .then(() => {\n if (typeof callback === 'function') {\n callback(...args);\n }\n });\n });\n\n if (fn.length > 1) {\n return handleCallbackErrors(\n () => (fn as CloudEventFunctionWithCallback)(context, newCallback),\n err => {\n captureException(err, scope => markEventUnhandled(scope, 'auto.function.serverless.gcp_cloud_event'));\n },\n );\n }\n\n return Promise.resolve()\n .then(() => (fn as CloudEventFunction)(context))\n .then(\n result => newCallback(null, result),\n err => newCallback(err, undefined),\n );\n },\n );\n };\n}\n"],"names":["scope"],"mappings":";;;;;;;AAkCO,SAAS,sBAAA,CACd,EAAA,EACA,WAAA,GAAyD,EAAC,EAC1B;AAChC,EAAA,OAAO,aAAA,CAAc,IAAI,CAAA,CAAA,KAAK,SAAA,CAAU,wBAAwB,CAAA,EAAG,WAAW,CAAC,CAAC,CAAA;AAClF;AAEA,SAAS,uBAAA,CACP,EAAA,EACA,WAAA,GAAyD,EAAC,EAC1B;AAChC,EAAA,MAAM,OAAA,GAA4C;AAAA,IAChD,Y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SENTRY_SEGMENT_NAME_SOURCE, FAAS_TRIGGER, FAAS_NAME, SENTRY_OP } from '@sentry/conventions/attributes';
|
|
2
2
|
import { FUNCTION_GCP } from '@sentry/conventions/op';
|
|
3
|
-
import {
|
|
3
|
+
import { getClient, hasSpanStreamingEnabled, SERVERLESS_FUNCTION_SPAN_NAME_FALLBACK, handleCallbackErrors, debug } from '@sentry/core';
|
|
4
4
|
import { startSpanManual, getCurrentScope, captureException, flush } from '@sentry/node';
|
|
5
5
|
import { DEBUG_BUILD } from '../debug-build.js';
|
|
6
|
-
import { proxyFunction, domainify, markEventUnhandled } from '../utils.js';
|
|
6
|
+
import { proxyFunction, domainify, getFunctionName, markEventUnhandled } from '../utils.js';
|
|
7
7
|
|
|
8
8
|
function wrapEventFunction(fn, wrapOptions = {}) {
|
|
9
9
|
return proxyFunction(fn, (f) => domainify(_wrapEventFunction(f, wrapOptions)));
|
|
@@ -15,14 +15,22 @@ function _wrapEventFunction(fn, wrapOptions = {}) {
|
|
|
15
15
|
};
|
|
16
16
|
return (...eventFunctionArguments) => {
|
|
17
17
|
const [data, context, callback] = eventFunctionArguments;
|
|
18
|
+
const client = getClient();
|
|
19
|
+
const functionName = getFunctionName();
|
|
20
|
+
const name = client && hasSpanStreamingEnabled(client) ? functionName || SERVERLESS_FUNCTION_SPAN_NAME_FALLBACK : context.eventType;
|
|
18
21
|
return startSpanManual(
|
|
19
22
|
{
|
|
20
|
-
name
|
|
23
|
+
name,
|
|
21
24
|
attributes: {
|
|
22
25
|
[SENTRY_OP]: FUNCTION_GCP,
|
|
26
|
+
[FAAS_NAME]: functionName,
|
|
23
27
|
[FAAS_TRIGGER]: "event",
|
|
24
28
|
[SENTRY_SEGMENT_NAME_SOURCE]: "component",
|
|
25
|
-
[
|
|
29
|
+
[SENTRY_ORIGIN]: "auto.function.serverless.gcp_event",
|
|
30
|
+
[GCP_FUNCTION_CONTEXT_EVENT_TYPE]: context.eventType,
|
|
31
|
+
[GCP_FUNCTION_CONTEXT_EVENT_ID]: context.eventId,
|
|
32
|
+
[GCP_FUNCTION_CONTEXT_RESOURCE]: context.resource,
|
|
33
|
+
[GCP_FUNCTION_CONTEXT_TIMESTAMP]: context.timestamp
|
|
26
34
|
}
|
|
27
35
|
},
|
|
28
36
|
(span) => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"events.js","sources":["../../../src/gcpfunction/events.ts"],"sourcesContent":["import {
|
|
1
|
+
{"version":3,"file":"events.js","sources":["../../../src/gcpfunction/events.ts"],"sourcesContent":["import {\n SENTRY_SEGMENT_NAME_SOURCE,\n FAAS_NAME,\n FAAS_TRIGGER,\n SENTRY_OP,\n GCP_FUNCTION_CONTEXT_EVENT_TYPE,\n GCP_FUNCTION_CONTEXT_EVENT_ID,\n GCP_FUNCTION_CONTEXT_RESOURCE,\n GCP_FUNCTION_CONTEXT_TIMESTAMP,\n SENTRY_ORIGIN,\n} from '@sentry/conventions/attributes';\nimport { FUNCTION_GCP } from '@sentry/conventions/op';\nimport {\n debug,\n getClient,\n handleCallbackErrors,\n hasSpanStreamingEnabled,\n SERVERLESS_FUNCTION_SPAN_NAME_FALLBACK,\n} from '@sentry/core';\nimport { captureException, flush, getCurrentScope, startSpanManual } from '@sentry/node';\nimport { DEBUG_BUILD } from '../debug-build';\nimport { domainify, getFunctionName, markEventUnhandled, proxyFunction } from '../utils';\nimport type { EventFunction, EventFunctionWithCallback, WrapperOptions } from './general';\n\nexport type EventFunctionWrapperOptions = WrapperOptions;\n\n/**\n * Wraps an event function handler adding it error capture and tracing capabilities.\n *\n * @param fn Event handler\n * @param options Options\n * @returns Event handler\n */\nexport function wrapEventFunction(\n fn: EventFunction | EventFunctionWithCallback,\n wrapOptions: Partial<EventFunctionWrapperOptions> = {},\n): EventFunctionWithCallback {\n return proxyFunction(fn, f => domainify(_wrapEventFunction(f, wrapOptions)));\n}\n\n/** */\nfunction _wrapEventFunction<F extends EventFunction | EventFunctionWithCallback>(\n fn: F,\n wrapOptions: Partial<EventFunctionWrapperOptions> = {},\n): (...args: Parameters<F>) => ReturnType<F> | Promise<void> {\n const options: EventFunctionWrapperOptions = {\n flushTimeout: 2000,\n ...wrapOptions,\n };\n return (...eventFunctionArguments: Parameters<F>): ReturnType<F> | Promise<void> => {\n const [data, context, callback] = eventFunctionArguments;\n\n const client = getClient();\n\n const functionName = getFunctionName();\n const name =\n client && hasSpanStreamingEnabled(client)\n ? functionName || SERVERLESS_FUNCTION_SPAN_NAME_FALLBACK\n : context.eventType;\n\n return startSpanManual(\n {\n name,\n attributes: {\n [SENTRY_OP]: FUNCTION_GCP,\n [FAAS_NAME]: functionName,\n [FAAS_TRIGGER]: 'event',\n [SENTRY_SEGMENT_NAME_SOURCE]: 'component',\n [SENTRY_ORIGIN]: 'auto.function.serverless.gcp_event',\n [GCP_FUNCTION_CONTEXT_EVENT_TYPE]: context.eventType,\n [GCP_FUNCTION_CONTEXT_EVENT_ID]: context.eventId,\n [GCP_FUNCTION_CONTEXT_RESOURCE]: context.resource,\n [GCP_FUNCTION_CONTEXT_TIMESTAMP]: context.timestamp,\n },\n },\n span => {\n const scope = getCurrentScope();\n scope.setContext('gcp.function.context', { ...context });\n\n const newCallback = domainify((...args: unknown[]) => {\n if (args[0] !== null && args[0] !== undefined) {\n captureException(args[0], scope => markEventUnhandled(scope, 'auto.function.serverless.gcp_event'));\n }\n span.end();\n\n // eslint-disable-next-line @typescript-eslint/no-floating-promises\n flush(options.flushTimeout)\n .then(null, e => {\n DEBUG_BUILD && debug.error(e);\n })\n .then(() => {\n if (typeof callback === 'function') {\n callback(...args);\n }\n });\n });\n\n if (fn.length > 2) {\n return handleCallbackErrors(\n () => (fn as EventFunctionWithCallback)(data, context, newCallback),\n err => {\n captureException(err, scope => markEventUnhandled(scope, 'auto.function.serverless.gcp_event'));\n },\n );\n }\n\n return Promise.resolve()\n .then(() => (fn as EventFunction)(data, context))\n .then(\n result => newCallback(null, result),\n err => newCallback(err, undefined),\n );\n },\n );\n };\n}\n"],"names":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AAS;AAAA,SACnC;AAAA,MACJ;AAAA,KACF;AAAA,EACF,CAAA;AACF;;;;"}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { SENTRY_SEGMENT_NAME_SOURCE, FAAS_TRIGGER, SENTRY_OP } from '@sentry/conventions/attributes';
|
|
1
|
+
import { URL_PATH, HTTP_REQUEST_METHOD, SENTRY_SEGMENT_NAME_SOURCE, FAAS_TRIGGER, FAAS_NAME, SENTRY_OP } from '@sentry/conventions/attributes';
|
|
2
2
|
import { FUNCTION_GCP } from '@sentry/conventions/op';
|
|
3
|
-
import { stripUrlQueryAndFragment, isString, httpRequestToRequestData, SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN, setHttpStatus, debug, handleCallbackErrors } from '@sentry/core';
|
|
3
|
+
import { stripUrlQueryAndFragment, isString, httpRequestToRequestData, getClient, hasSpanStreamingEnabled, SERVERLESS_FUNCTION_SPAN_NAME_FALLBACK, SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN, setHttpStatus, debug, handleCallbackErrors } from '@sentry/core';
|
|
4
4
|
import { continueTrace, getCurrentScope, startSpanManual, flush, captureException } from '@sentry/node';
|
|
5
5
|
import { DEBUG_BUILD } from '../debug-build.js';
|
|
6
|
-
import { proxyFunction, domainify, markEventUnhandled } from '../utils.js';
|
|
6
|
+
import { proxyFunction, domainify, getFunctionName, markEventUnhandled } from '../utils.js';
|
|
7
7
|
|
|
8
8
|
function wrapHttpFunction(fn, wrapOptions = {}) {
|
|
9
9
|
const wrap = (f) => domainify(_wrapHttpFunction(f, wrapOptions));
|
|
@@ -24,14 +24,23 @@ function _wrapHttpFunction(fn, options) {
|
|
|
24
24
|
return continueTrace({ sentryTrace, baggage }, () => {
|
|
25
25
|
const normalizedRequest = httpRequestToRequestData(req);
|
|
26
26
|
getCurrentScope().setSDKProcessingMetadata({ normalizedRequest });
|
|
27
|
+
const functionName = getFunctionName();
|
|
28
|
+
const client = getClient();
|
|
29
|
+
const hasSpanStreaming = client && hasSpanStreamingEnabled(client);
|
|
30
|
+
const name = hasSpanStreaming ? functionName || SERVERLESS_FUNCTION_SPAN_NAME_FALLBACK : `${reqMethod} ${reqUrl}`;
|
|
27
31
|
return startSpanManual(
|
|
28
32
|
{
|
|
29
|
-
name
|
|
33
|
+
name,
|
|
30
34
|
attributes: {
|
|
31
35
|
[SENTRY_OP]: FUNCTION_GCP,
|
|
36
|
+
[FAAS_NAME]: functionName,
|
|
32
37
|
[FAAS_TRIGGER]: "http",
|
|
33
|
-
[SENTRY_SEGMENT_NAME_SOURCE]: "route",
|
|
34
|
-
[SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN]: "auto.function.serverless.gcp_http"
|
|
38
|
+
[SENTRY_SEGMENT_NAME_SOURCE]: hasSpanStreaming ? "component" : "route",
|
|
39
|
+
[SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN]: "auto.function.serverless.gcp_http",
|
|
40
|
+
// The method and path used to be the span name; they stay on the span so that
|
|
41
|
+
// information survives the low-cardinality rename.
|
|
42
|
+
[HTTP_REQUEST_METHOD]: reqMethod || void 0,
|
|
43
|
+
[URL_PATH]: reqUrl || void 0
|
|
35
44
|
}
|
|
36
45
|
},
|
|
37
46
|
(span) => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"http.js","sources":["../../../src/gcpfunction/http.ts"],"sourcesContent":["import {
|
|
1
|
+
{"version":3,"file":"http.js","sources":["../../../src/gcpfunction/http.ts"],"sourcesContent":["import {\n SENTRY_SEGMENT_NAME_SOURCE,\n FAAS_NAME,\n FAAS_TRIGGER,\n HTTP_REQUEST_METHOD,\n SENTRY_OP,\n URL_PATH,\n} from '@sentry/conventions/attributes';\nimport { FUNCTION_GCP } from '@sentry/conventions/op';\nimport {\n debug,\n getClient,\n handleCallbackErrors,\n hasSpanStreamingEnabled,\n httpRequestToRequestData,\n isString,\n SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN,\n SERVERLESS_FUNCTION_SPAN_NAME_FALLBACK,\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, getFunctionName, 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 const functionName = getFunctionName();\n\n const client = getClient();\n const hasSpanStreaming = client && hasSpanStreamingEnabled(client);\n const name = hasSpanStreaming ? functionName || SERVERLESS_FUNCTION_SPAN_NAME_FALLBACK : `${reqMethod} ${reqUrl}`;\n\n return startSpanManual(\n {\n name,\n attributes: {\n [SENTRY_OP]: FUNCTION_GCP,\n [FAAS_NAME]: functionName,\n [FAAS_TRIGGER]: 'http',\n [SENTRY_SEGMENT_NAME_SOURCE]: hasSpanStreaming ? 'component' : 'route',\n [SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN]: 'auto.function.serverless.gcp_http',\n // The method and path used to be the span name; they stay on the span so that\n // information survives the low-cardinality rename.\n [HTTP_REQUEST_METHOD]: reqMethod || undefined,\n [URL_PATH]: reqUrl || undefined,\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 && debug.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, 'auto.function.serverless.gcp_http'));\n },\n );\n },\n );\n });\n };\n}\n"],"names":[],"mappings":";;;;;;;AAiCO,SAAS,gBAAA,CAAiB,EAAA,EAAkB,WAAA,GAAuC,EAAC,EAAiB;AAC1G,EAAA,MAAM,OAAO,CAAC,CAAA,KAAkC,UAAU,iBAAA,CAAkB,CAAA,EAAG,WAAW,CAAC,CAAA;AAE3F,EAAA,IAAI,SAAA;AAIJ,EAAA,MAAM,eAAgB,EAAA,CAAyD,eAAA;AAC/E,EAAA,IAAI,YAAA,EAAc;AAChB,IAAA,SAAA,GAAY,EAAE,eAAA,EAAiB,aAAA,CAAc,YAAA,EAAc,IAAI,CAAA,EAAE;AAAA,EACnE;AACA,EAAA,OAAO,aAAA,CAAc,EAAA,EAAI,IAAA,EAAM,SAAS,CAAA;AAC1C;AAGA,SAAS,iBAAA,CAAkB,IAAkB,OAAA,EAAgD;AAC3F,EAAA,MAAM,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AAC,mBAAmB,GAAG,SAAA,IAAa,MAAA;AAAA,YACpC,CAAC,QAAQ,GAAG,MAAA,IAAU;AAAA;AACxB,SACF;AAAA,QACA,CAAA,IAAA,KAAQ;AAEN,UAAA,MAAM,OAAO,GAAA,CAAI,GAAA;AAEjB,UAAA,GAAA,CAAI,GAAA,GAAM,SAAU,KAAA,EAA4B,QAAA,EAAkC,EAAA,EAAsB;AACtG,YAAA,aAAA,CAAc,IAAA,EAAM,IAAI,UAAU,CAAA;AAClC,YAAA,IAAA,CAAK,GAAA,EAAI;AAGT,YAAA,KAAA,CAAM,YAAY,CAAA,CACf,IAAA,CAAK,IAAA,EAAM,CAAA,CAAA,KAAK;AACf,cAAA,WAAA,IAAe,KAAA,CAAM,MAAM,CAAC,CAAA;AAAA,YAC9B,CAAC,CAAA,CACA,IAAA,CAAK,MAAM;AACV,cAAA,IAAA,CAAK,IAAA,CAAK,IAAA,EAAM,KAAA,EAAO,QAAA,EAAU,EAAE,CAAA;AAAA,YACrC,CAAC,CAAA;AAAA,UACL,CAAA;AAEA,UAAA,OAAO,oBAAA;AAAA,YACL,MAAM,EAAA,CAAG,GAAA,EAAK,GAAG,CAAA;AAAA,YACjB,CAAA,GAAA,KAAO;AACL,cAAA,gBAAA,CAAiB,GAAA,EAAK,CAAA,KAAA,KAAS,kBAAA,CAAmB,KAAA,EAAO,mCAAmC,CAAC,CAAA;AAAA,YAC/F;AAAA,WACF;AAAA,QACF;AAAA,OACF;AAAA,IACF,CAAC,CAAA;AAAA,EACH,CAAA;AACF;;;;"}
|
package/build/esm/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { NODE_VERSION, NodeClient, OpenFeatureIntegrationHook, SDK_VERSION, SEMANTIC_ATTRIBUTE_SENTRY_OP, SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN, SEMANTIC_ATTRIBUTE_SENTRY_SAMPLE_RATE, SENTRY_SEGMENT_NAME_SOURCE, Scope, addBreadcrumb, addEventProcessor, addIntegration, amqplibIntegration, anrIntegration, anthropicAIIntegration, bindScopeToEmitter, buildLaunchDarklyFlagUsedHandler, captureCheckIn, captureEvent, captureException, captureFeedback, captureMessage, captureSession, childProcessIntegration, close, consoleIntegration, consoleLoggingIntegration, contextLinesIntegration, continueTrace, createConsolaReporter, createGetModuleFromFilename, createLangChainCallbackHandler, createSentryWinstonTransport, createTransport, cron, dataloaderIntegration, defaultStackParser, disableAnrDetectionForCallback, endSession, eventFiltersIntegration, expressErrorHandler, expressIntegration, fastifyIntegration, featureFlagsIntegration, firebaseIntegration, flush, fsIntegration, functionToStringIntegration, genericPoolIntegration, getActiveSpan, getAutoPerformanceIntegrations, getClient, getCurrentScope, getGlobalScope, getIsolationScope, getOtlpTracesEndpoint, getRootSpan, getSentryRelease, getSpanDescendants, getSpanStatusFromHttpCode, getTraceData, getTraceMetaTags, googleGenAIIntegration, graphqlIntegration, growthbookIntegration, hapiIntegration, httpHeadersToSpanAttributes, httpIntegration, httpServerIntegration, httpServerSpansIntegration, initOpenTelemetry, instrumentAnthropicAiClient, instrumentGoogleGenAIClient, instrumentLangChainEmbeddings, instrumentOpenAiClient, instrumentStateGraph, instrumentStateGraphCompile, instrumentSupabaseClient, isEnabled, isInitialized, kafkaIntegration, knexIntegration, koaIntegration, langChainIntegration, langGraphIntegration, lastEventId, launchDarklyIntegration, linkedErrorsIntegration, localVariablesIntegration, logger, lruMemoizerIntegration, makeNodeTransport, metrics, modulesIntegration, mongoIntegration, mongooseIntegration, mysql2Integration, mysqlIntegration, nativeNodeFetchIntegration, nodeContextIntegration, nodeRuntimeMetricsIntegration, onUncaughtExceptionIntegration, onUnhandledRejectionIntegration, openAIIntegration, openFeatureIntegration, openTelemetryIntegration, parameterize, pinoIntegration, postgresIntegration, postgresJsIntegration, prismaIntegration, processSessionIntegration, profiler, redisIntegration, requestDataIntegration, setAttribute, setAttributes, setContext, setConversationId, setCurrentClient, setExtra, setExtras, setHttpStatus, setMeasurement, setTag, setTags, setUser, setupExpressErrorHandler, setupHapiErrorHandler, setupKoaErrorHandler, spanStreamingIntegration, spanToBaggageHeader, spanToJSON, spanToStaticSpanJSON, spanToTraceHeader, spotlightIntegration, startInactiveSpan, startNewTrace, startSession, startSpan, startSpanManual, statsigIntegration, supabaseIntegration, suppressTracing, systemErrorIntegration, tediousIntegration, trpcMiddleware, unleashIntegration, updateSpanName, vercelAIIntegration, winterCGHeadersToDict, withActiveSpan, withIsolationScope, withMonitor, withScope, withStaticSpan, withStreamedSpan, workerThreadsIntegration, wrapMcpServerWithSentry, zodErrorsIntegration } from '@sentry/node';
|
|
1
|
+
export { NODE_VERSION, NodeClient, OpenFeatureIntegrationHook, SDK_VERSION, SEMANTIC_ATTRIBUTE_SENTRY_OP, SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN, SEMANTIC_ATTRIBUTE_SENTRY_SAMPLE_RATE, SENTRY_SEGMENT_NAME_SOURCE, Scope, SentryMastraExporter, addBreadcrumb, addEventProcessor, addIntegration, amqplibIntegration, anrIntegration, anthropicAIIntegration, bindScopeToEmitter, buildLaunchDarklyFlagUsedHandler, captureCheckIn, captureEvent, captureException, captureFeedback, captureMessage, captureSession, childProcessIntegration, close, consoleIntegration, consoleLoggingIntegration, contextLinesIntegration, continueTrace, createConsolaReporter, createFlueInstrumentation, createGetModuleFromFilename, createLangChainCallbackHandler, createSentryWinstonTransport, createTransport, cron, dataloaderIntegration, defaultStackParser, disableAnrDetectionForCallback, endSession, eveConversationHook, eventFiltersIntegration, expressErrorHandler, expressIntegration, fastifyIntegration, featureFlagsIntegration, firebaseIntegration, flush, fsIntegration, functionToStringIntegration, genericPoolIntegration, getActiveSpan, getAutoPerformanceIntegrations, getClient, getCurrentScope, getGlobalScope, getInstrumentedModuleNames, getIsolationScope, getOtlpTracesEndpoint, getRootSpan, getSentryRelease, getSpanDescendants, getSpanStatusFromHttpCode, getTraceData, getTraceMetaTags, googleGenAIIntegration, graphqlIntegration, growthbookIntegration, hapiIntegration, httpHeadersToSpanAttributes, httpIntegration, httpServerIntegration, httpServerSpansIntegration, initOpenTelemetry, instrumentAnthropicAiClient, instrumentGoogleGenAIClient, instrumentLangChainEmbeddings, instrumentMistralAiClient, instrumentOpenAiClient, instrumentStateGraph, instrumentStateGraphCompile, instrumentSupabaseClient, isEnabled, isInitialized, kafkaIntegration, knexIntegration, koaIntegration, langChainIntegration, langGraphIntegration, lastEventId, launchDarklyIntegration, linkedErrorsIntegration, localVariablesIntegration, logger, lruMemoizerIntegration, makeNodeTransport, mastraIntegration, metrics, mistralAIIntegration, modulesIntegration, mongoIntegration, mongooseIntegration, mysql2Integration, mysqlIntegration, nativeNodeFetchIntegration, nodeContextIntegration, nodeRuntimeMetricsIntegration, onUncaughtExceptionIntegration, onUnhandledRejectionIntegration, openAIIntegration, openFeatureIntegration, openTelemetryIntegration, parameterize, pinoIntegration, postgresIntegration, postgresJsIntegration, prismaIntegration, processSessionIntegration, profiler, redisIntegration, requestDataIntegration, setAttribute, setAttributes, setContext, setConversationId, setCurrentClient, setExtra, setExtras, setHttpStatus, setMeasurement, setTag, setTags, setUser, setupExpressErrorHandler, setupHapiErrorHandler, setupKoaErrorHandler, spanStreamingIntegration, spanToBaggageHeader, spanToJSON, spanToStaticSpanJSON, spanToTraceHeader, spotlightIntegration, startInactiveSpan, startNewTrace, startSession, startSpan, startSpanManual, statsigIntegration, supabaseIntegration, suppressTracing, systemErrorIntegration, tediousIntegration, trpcMiddleware, unleashIntegration, updateSpanName, vercelAIIntegration, winterCGHeadersToDict, withActiveSpan, withIsolationScope, withMonitor, withScope, withStaticSpan, withStreamedSpan, workerThreadsIntegration, wrapMcpServerWithSentry, zodErrorsIntegration } from '@sentry/node';
|
|
2
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';
|
package/build/esm/package.json
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"type":"module","version":"11.0.0-
|
|
1
|
+
{"type":"module","version":"11.0.0-rc.0","sideEffects":false}
|
package/build/esm/utils.js
CHANGED
|
@@ -27,6 +27,9 @@ function markEventUnhandled(scope, type) {
|
|
|
27
27
|
});
|
|
28
28
|
return scope;
|
|
29
29
|
}
|
|
30
|
+
function getFunctionName() {
|
|
31
|
+
return process.env.FUNCTION_TARGET || process.env.K_SERVICE || void 0;
|
|
32
|
+
}
|
|
30
33
|
|
|
31
|
-
export { domainify, markEventUnhandled, proxyFunction };
|
|
34
|
+
export { domainify, getFunctionName, markEventUnhandled, proxyFunction };
|
|
32
35
|
//# sourceMappingURL=utils.js.map
|
package/build/esm/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"],"names":[],"mappings":";;AAOO,SAAS,UAAkC,EAAA,EAAiD;AACjG,EAAA,OAAO,IAAI,IAAA,KAAS,kBAAA,CAAmB,MAAM,EAAA,CAAG,GAAG,IAAI,CAAC,CAAA;AAC1D;AASO,SAAS,aAAA,CACd,MAAA,EACA,IAAA,EACA,SAAA,EACG;AACH,EAAA,MAAM,OAAA,GAAU,KAAK,MAAM,CAAA;AAC3B,EAAA,MAAM,OAAA,GAA2B;AAAA,IAC/B,KAAA,EAAO,CAAI,OAAA,EAAY,OAAA,EAAY,IAAA,KAAY;AAC7C,MAAA,OAAO,OAAA,CAAQ,KAAA,CAAM,OAAA,EAAS,IAAI,CAAA;AAAA,IACpC;AAAA,GACF;AAEA,EAAA,IAAI,SAAA,EAAW;AACb,IAAA,OAAA,CAAQ,GAAA,GAAM,CAAC,MAAA,EAAQ,IAAA,KAAS;AAC9B,MAAA,IAAI,OAAO,SAAA,CAAU,cAAA,CAAe,IAAA,CAAK,SAAA,EAAW,IAAI,CAAA,EAAG;AACzD,QAAA,OAAO,UAAU,IAAc,CAAA;AAAA,MACjC;AACA,MAAA,OAAQ,OAAwC,IAAc,CAAA;AAAA,IAChE,CAAA;AAAA,EACF;AAEA,EAAA,OAAO,IAAI,KAAA,CAAM,MAAA,EAAQ,OAAO,CAAA;AAClC;AAKO,SAAS,kBAAA,CAAmB,OAAc,IAAA,EAAqB;AACpE,EAAA,KAAA,CAAM,kBAAkB,CAAA,KAAA,KAAS;AAC/B,IAAA,qBAAA,CAAsB,KAAA,EAAO,EAAE,OAAA,EAAS,KAAA,EAAO,MAAM,CAAA;AACrD,IAAA,OAAO,KAAA;AAAA,EACT,CAAC,CAAA;AAED,EAAA,OAAO,KAAA;AACT;;;;"}
|
|
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"],"names":[],"mappings":";;AAOO,SAAS,UAAkC,EAAA,EAAiD;AACjG,EAAA,OAAO,IAAI,IAAA,KAAS,kBAAA,CAAmB,MAAM,EAAA,CAAG,GAAG,IAAI,CAAC,CAAA;AAC1D;AASO,SAAS,aAAA,CACd,MAAA,EACA,IAAA,EACA,SAAA,EACG;AACH,EAAA,MAAM,OAAA,GAAU,KAAK,MAAM,CAAA;AAC3B,EAAA,MAAM,OAAA,GAA2B;AAAA,IAC/B,KAAA,EAAO,CAAI,OAAA,EAAY,OAAA,EAAY,IAAA,KAAY;AAC7C,MAAA,OAAO,OAAA,CAAQ,KAAA,CAAM,OAAA,EAAS,IAAI,CAAA;AAAA,IACpC;AAAA,GACF;AAEA,EAAA,IAAI,SAAA,EAAW;AACb,IAAA,OAAA,CAAQ,GAAA,GAAM,CAAC,MAAA,EAAQ,IAAA,KAAS;AAC9B,MAAA,IAAI,OAAO,SAAA,CAAU,cAAA,CAAe,IAAA,CAAK,SAAA,EAAW,IAAI,CAAA,EAAG;AACzD,QAAA,OAAO,UAAU,IAAc,CAAA;AAAA,MACjC;AACA,MAAA,OAAQ,OAAwC,IAAc,CAAA;AAAA,IAChE,CAAA;AAAA,EACF;AAEA,EAAA,OAAO,IAAI,KAAA,CAAM,MAAA,EAAQ,OAAO,CAAA;AAClC;AAKO,SAAS,kBAAA,CAAmB,OAAc,IAAA,EAAqB;AACpE,EAAA,KAAA,CAAM,kBAAkB,CAAA,KAAA,KAAS;AAC/B,IAAA,qBAAA,CAAsB,KAAA,EAAO,EAAE,OAAA,EAAS,KAAA,EAAO,MAAM,CAAA;AACrD,IAAA,OAAO,KAAA;AAAA,EACT,CAAC,CAAA;AAED,EAAA,OAAO,KAAA;AACT;AAUO,SAAS,eAAA,GAAsC;AACpD,EAAA,OAAO,OAAA,CAAQ,GAAA,CAAI,eAAA,IAAmB,OAAA,CAAQ,IAAI,SAAA,IAAa,MAAA;AACjE;;;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cloud_events.d.ts","sourceRoot":"","sources":["../../../src/gcpfunction/cloud_events.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"cloud_events.d.ts","sourceRoot":"","sources":["../../../src/gcpfunction/cloud_events.ts"],"names":[],"mappings":"AAuBA,OAAO,KAAK,EAAE,kBAAkB,EAAE,8BAA8B,EAAE,cAAc,EAAE,MAAM,WAAW,CAAC;AAEpG,MAAM,MAAM,gCAAgC,GAAG,cAAc,CAAC;AAE9D;;;;;;GAMG;AACH,wBAAgB,sBAAsB,CACpC,EAAE,EAAE,kBAAkB,GAAG,8BAA8B,EACvD,WAAW,GAAE,OAAO,CAAC,gCAAgC,CAAM,GAC1D,8BAA8B,CAEhC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"events.d.ts","sourceRoot":"","sources":["../../../src/gcpfunction/events.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"events.d.ts","sourceRoot":"","sources":["../../../src/gcpfunction/events.ts"],"names":[],"mappings":"AAsBA,OAAO,KAAK,EAAE,aAAa,EAAE,yBAAyB,EAAE,cAAc,EAAE,MAAM,WAAW,CAAC;AAE1F,MAAM,MAAM,2BAA2B,GAAG,cAAc,CAAC;AAEzD;;;;;;GAMG;AACH,wBAAgB,iBAAiB,CAC/B,EAAE,EAAE,aAAa,GAAG,yBAAyB,EAC7C,WAAW,GAAE,OAAO,CAAC,2BAA2B,CAAM,GACrD,yBAAyB,CAE3B"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"http.d.ts","sourceRoot":"","sources":["../../../src/gcpfunction/http.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"http.d.ts","sourceRoot":"","sources":["../../../src/gcpfunction/http.ts"],"names":[],"mappings":"AAwBA,OAAO,KAAK,EAAE,YAAY,EAAE,cAAc,EAAE,MAAM,WAAW,CAAC;AAE9D;;;;;;GAMG;AACH,wBAAgB,gBAAgB,CAAC,EAAE,EAAE,YAAY,EAAE,WAAW,GAAE,OAAO,CAAC,cAAc,CAAM,GAAG,YAAY,CAY1G"}
|
package/build/types/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { addEventProcessor, addBreadcrumb, addIntegration, captureException, captureEvent, captureMessage, captureCheckIn, captureFeedback, startSession, captureSession, endSession, withMonitor, createTransport, getClient, isInitialized, isEnabled, getCurrentScope, getGlobalScope, getIsolationScope, getTraceData, getTraceMetaTags, setCurrentClient, Scope, SDK_VERSION, setContext, setConversationId, setExtra, setExtras, setTag, setTags, setAttribute, setAttributes, setUser, getSpanStatusFromHttpCode, setHttpStatus, withScope, withIsolationScope, makeNodeTransport, NodeClient, defaultStackParser, lastEventId, flush, close, getSentryRelease, createGetModuleFromFilename, createLangChainCallbackHandler, instrumentLangChainEmbeddings, httpHeadersToSpanAttributes, winterCGHeadersToDict, anrIntegration, disableAnrDetectionForCallback, consoleIntegration, httpIntegration, httpServerIntegration, httpServerSpansIntegration, nativeNodeFetchIntegration, onUncaughtExceptionIntegration, onUnhandledRejectionIntegration, openAIIntegration, langChainIntegration, langGraphIntegration, modulesIntegration, nodeRuntimeMetricsIntegration, type NodeRuntimeMetricsOptions, contextLinesIntegration, nodeContextIntegration, localVariablesIntegration, requestDataIntegration, fsIntegration, functionToStringIntegration, eventFiltersIntegration, linkedErrorsIntegration, setMeasurement, getActiveSpan, startSpan, startInactiveSpan, startSpanManual, startNewTrace, bindScopeToEmitter, suppressTracing, withActiveSpan, getRootSpan, getSpanDescendants, continueTrace, getAutoPerformanceIntegrations, cron, parameterize, SEMANTIC_ATTRIBUTE_SENTRY_OP, SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN, SENTRY_SEGMENT_NAME_SOURCE, SEMANTIC_ATTRIBUTE_SENTRY_SAMPLE_RATE, dataloaderIntegration, expressIntegration, expressErrorHandler, setupExpressErrorHandler, koaIntegration, setupKoaErrorHandler, fastifyIntegration, firebaseIntegration, genericPoolIntegration, graphqlIntegration, knexIntegration, kafkaIntegration, lruMemoizerIntegration, mongoIntegration, mongooseIntegration, mysqlIntegration, mysql2Integration, redisIntegration, tediousIntegration, pinoIntegration, postgresIntegration, postgresJsIntegration, prismaIntegration, openTelemetryIntegration, getOtlpTracesEndpoint, processSessionIntegration, hapiIntegration, setupHapiErrorHandler, spotlightIntegration, initOpenTelemetry, spanToStaticSpanJSON, spanToJSON, spanToTraceHeader, spanToBaggageHeader, trpcMiddleware, updateSpanName, supabaseIntegration, systemErrorIntegration, instrumentSupabaseClient, instrumentOpenAiClient, instrumentAnthropicAiClient, instrumentGoogleGenAIClient, instrumentStateGraph, instrumentStateGraphCompile, zodErrorsIntegration, profiler, amqplibIntegration, anthropicAIIntegration, googleGenAIIntegration, childProcessIntegration, workerThreadsIntegration, createSentryWinstonTransport, vercelAIIntegration, logger, consoleLoggingIntegration, createConsolaReporter, wrapMcpServerWithSentry, NODE_VERSION, featureFlagsIntegration, type FeatureFlagsIntegration, launchDarklyIntegration, growthbookIntegration, buildLaunchDarklyFlagUsedHandler, openFeatureIntegration, OpenFeatureIntegrationHook, statsigIntegration, unleashIntegration, metrics, spanStreamingIntegration, withStaticSpan, withStreamedSpan, } from '@sentry/node';
|
|
1
|
+
export { addEventProcessor, addBreadcrumb, addIntegration, captureException, captureEvent, captureMessage, captureCheckIn, captureFeedback, startSession, captureSession, endSession, withMonitor, createTransport, getClient, isInitialized, isEnabled, getCurrentScope, getGlobalScope, getIsolationScope, getTraceData, getTraceMetaTags, setCurrentClient, Scope, SDK_VERSION, setContext, setConversationId, setExtra, setExtras, setTag, setTags, setAttribute, setAttributes, setUser, getSpanStatusFromHttpCode, setHttpStatus, withScope, withIsolationScope, makeNodeTransport, NodeClient, defaultStackParser, lastEventId, flush, close, getSentryRelease, createGetModuleFromFilename, createLangChainCallbackHandler, instrumentLangChainEmbeddings, httpHeadersToSpanAttributes, winterCGHeadersToDict, anrIntegration, disableAnrDetectionForCallback, consoleIntegration, httpIntegration, httpServerIntegration, httpServerSpansIntegration, nativeNodeFetchIntegration, onUncaughtExceptionIntegration, onUnhandledRejectionIntegration, mistralAIIntegration, openAIIntegration, langChainIntegration, langGraphIntegration, mastraIntegration, SentryMastraExporter, createFlueInstrumentation, modulesIntegration, nodeRuntimeMetricsIntegration, type NodeRuntimeMetricsOptions, contextLinesIntegration, nodeContextIntegration, localVariablesIntegration, requestDataIntegration, fsIntegration, functionToStringIntegration, eventFiltersIntegration, linkedErrorsIntegration, setMeasurement, getActiveSpan, startSpan, startInactiveSpan, startSpanManual, startNewTrace, bindScopeToEmitter, suppressTracing, withActiveSpan, getRootSpan, getSpanDescendants, continueTrace, getAutoPerformanceIntegrations, cron, parameterize, SEMANTIC_ATTRIBUTE_SENTRY_OP, SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN, SENTRY_SEGMENT_NAME_SOURCE, SEMANTIC_ATTRIBUTE_SENTRY_SAMPLE_RATE, dataloaderIntegration, expressIntegration, expressErrorHandler, setupExpressErrorHandler, koaIntegration, setupKoaErrorHandler, fastifyIntegration, firebaseIntegration, genericPoolIntegration, graphqlIntegration, knexIntegration, kafkaIntegration, lruMemoizerIntegration, mongoIntegration, mongooseIntegration, mysqlIntegration, mysql2Integration, redisIntegration, tediousIntegration, pinoIntegration, postgresIntegration, postgresJsIntegration, prismaIntegration, openTelemetryIntegration, getOtlpTracesEndpoint, processSessionIntegration, hapiIntegration, setupHapiErrorHandler, spotlightIntegration, initOpenTelemetry, spanToStaticSpanJSON, spanToJSON, spanToTraceHeader, spanToBaggageHeader, trpcMiddleware, updateSpanName, supabaseIntegration, systemErrorIntegration, instrumentSupabaseClient, instrumentMistralAiClient, instrumentOpenAiClient, instrumentAnthropicAiClient, instrumentGoogleGenAIClient, instrumentStateGraph, instrumentStateGraphCompile, zodErrorsIntegration, profiler, amqplibIntegration, anthropicAIIntegration, googleGenAIIntegration, childProcessIntegration, workerThreadsIntegration, createSentryWinstonTransport, vercelAIIntegration, logger, consoleLoggingIntegration, createConsolaReporter, wrapMcpServerWithSentry, NODE_VERSION, featureFlagsIntegration, type FeatureFlagsIntegration, launchDarklyIntegration, growthbookIntegration, buildLaunchDarklyFlagUsedHandler, openFeatureIntegration, OpenFeatureIntegrationHook, statsigIntegration, unleashIntegration, metrics, spanStreamingIntegration, withStaticSpan, withStreamedSpan, eveConversationHook, getInstrumentedModuleNames, } from '@sentry/node';
|
|
2
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';
|
|
@@ -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,EACf,SAAS,EACT,aAAa,EACb,SAAS,EACT,eAAe,EACf,cAAc,EACd,iBAAiB,EACjB,YAAY,EACZ,gBAAgB,EAChB,gBAAgB,EAChB,KAAK,EACL,WAAW,EACX,UAAU,EACV,iBAAiB,EACjB,QAAQ,EACR,SAAS,EACT,MAAM,EACN,OAAO,EACP,YAAY,EACZ,aAAa,EACb,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,8BAA8B,EAC9B,6BAA6B,EAC7B,2BAA2B,EAC3B,qBAAqB,EAErB,cAAc,EAEd,8BAA8B,EAC9B,kBAAkB,EAClB,eAAe,EACf,qBAAqB,EACrB,0BAA0B,EAC1B,0BAA0B,EAC1B,8BAA8B,EAC9B,+BAA+B,EAC/B,iBAAiB,EACjB,oBAAoB,EACpB,oBAAoB,EACpB,kBAAkB,EAClB,6BAA6B,EAC7B,KAAK,yBAAyB,EAC9B,uBAAuB,EACvB,sB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AsB,EACtB,0BAA0B,EAC1B,kBAAkB,EAClB,kBAAkB,EAClB,OAAO,EACP,wBAAwB,EACxB,cAAc,EAEd,gBAAgB,
|
|
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,SAAS,EACT,eAAe,EACf,cAAc,EACd,iBAAiB,EACjB,YAAY,EACZ,gBAAgB,EAChB,gBAAgB,EAChB,KAAK,EACL,WAAW,EACX,UAAU,EACV,iBAAiB,EACjB,QAAQ,EACR,SAAS,EACT,MAAM,EACN,OAAO,EACP,YAAY,EACZ,aAAa,EACb,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,8BAA8B,EAC9B,6BAA6B,EAC7B,2BAA2B,EAC3B,qBAAqB,EAErB,cAAc,EAEd,8BAA8B,EAC9B,kBAAkB,EAClB,eAAe,EACf,qBAAqB,EACrB,0BAA0B,EAC1B,0BAA0B,EAC1B,8BAA8B,EAC9B,+BAA+B,EAC/B,oBAAoB,EACpB,iBAAiB,EACjB,oBAAoB,EACpB,oBAAoB,EACpB,iBAAiB,EACjB,oBAAoB,EACpB,yBAAyB,EACzB,kBAAkB,EAClB,6BAA6B,EAC7B,KAAK,yBAAyB,EAC9B,uBAAuB,EACvB,sBAAsB,EACtB,yBAAyB,EACzB,sBAAsB,EACtB,aAAa,EACb,2BAA2B,EAC3B,uBAAuB,EACvB,uBAAuB,EACvB,cAAc,EACd,aAAa,EACb,SAAS,EACT,iBAAiB,EACj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0B,GAC3B,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"}
|
package/build/types/utils.d.ts
CHANGED
|
@@ -15,4 +15,13 @@ export declare function proxyFunction<A extends any[], R, F extends (...args: A)
|
|
|
15
15
|
* Marks an event as unhandled by adding a span processor to the passed scope.
|
|
16
16
|
*/
|
|
17
17
|
export declare function markEventUnhandled(scope: Scope, type: string): Scope;
|
|
18
|
+
/**
|
|
19
|
+
* Resolves the name of the currently executing cloud function.
|
|
20
|
+
*
|
|
21
|
+
* `FUNCTION_TARGET` ("the function to be executed") is set by GCP for every deployed function, and
|
|
22
|
+
* by the functions-framework when running locally, where `K_SERVICE` is absent. `K_SERVICE` is the
|
|
23
|
+
* Cloud Run service the function runs as; the two differ whenever the entry point is named
|
|
24
|
+
* separately from the service, as in `gcloud run deploy my-service --function myHandler`.
|
|
25
|
+
*/
|
|
26
|
+
export declare function getFunctionName(): string | undefined;
|
|
18
27
|
//# sourceMappingURL=utils.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../src/utils.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,cAAc,CAAC;AAG1C;;;GAGG;AACH,wBAAgB,SAAS,CAAC,CAAC,SAAS,OAAO,EAAE,EAAE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I,EAAE,MAAM,GAAG,KAAK,CAOpE;AAED;;;;;;;GAOG;AACH,wBAAgB,eAAe,IAAI,MAAM,GAAG,SAAS,CAEpD"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sentry/google-cloud-serverless",
|
|
3
|
-
"version": "11.0.0-
|
|
3
|
+
"version": "11.0.0-rc.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",
|
|
@@ -36,11 +36,11 @@
|
|
|
36
36
|
"access": "public"
|
|
37
37
|
},
|
|
38
38
|
"dependencies": {
|
|
39
|
-
"@sentry/conventions": "^0.
|
|
40
|
-
"@sentry/core": "11.0.0-
|
|
41
|
-
"@sentry/node": "11.0.0-
|
|
42
|
-
"@sentry/server-runtime-injection": "11.0.0-
|
|
43
|
-
"@sentry/server-utils": "11.0.0-
|
|
39
|
+
"@sentry/conventions": "^0.23.0",
|
|
40
|
+
"@sentry/core": "11.0.0-rc.0",
|
|
41
|
+
"@sentry/node": "11.0.0-rc.0",
|
|
42
|
+
"@sentry/server-runtime-injection": "11.0.0-rc.0",
|
|
43
|
+
"@sentry/server-utils": "11.0.0-rc.0"
|
|
44
44
|
},
|
|
45
45
|
"devDependencies": {
|
|
46
46
|
"@google-cloud/bigquery": "^5.3.0",
|