Skip to content

Commit cae1f0f

Browse files
committed
ref(google-cloud-serverless): Add mechanism.type to captured errors
1 parent 1d59d8a commit cae1f0f

File tree

4 files changed

+7
-7
lines changed

4 files changed

+7
-7
lines changed

packages/google-cloud-serverless/src/gcpfunction/cloud_events.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ function _wrapCloudEventFunction(
4949

5050
const newCallback = domainify((...args: unknown[]) => {
5151
if (args[0] !== null && args[0] !== undefined) {
52-
captureException(args[0], scope => markEventUnhandled(scope));
52+
captureException(args[0], scope => markEventUnhandled(scope, 'google-cloud-serverless.cloud_event'));
5353
}
5454
span.end();
5555

@@ -69,7 +69,7 @@ function _wrapCloudEventFunction(
6969
return handleCallbackErrors(
7070
() => (fn as CloudEventFunctionWithCallback)(context, newCallback),
7171
err => {
72-
captureException(err, scope => markEventUnhandled(scope));
72+
captureException(err, scope => markEventUnhandled(scope, 'google-cloud-serverless.cloud_event'));
7373
},
7474
);
7575
}

packages/google-cloud-serverless/src/gcpfunction/events.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ function _wrapEventFunction<F extends EventFunction | EventFunctionWithCallback>
5252

5353
const newCallback = domainify((...args: unknown[]) => {
5454
if (args[0] !== null && args[0] !== undefined) {
55-
captureException(args[0], scope => markEventUnhandled(scope));
55+
captureException(args[0], scope => markEventUnhandled(scope, 'google-cloud-serverless.event'));
5656
}
5757
span.end();
5858

@@ -72,7 +72,7 @@ function _wrapEventFunction<F extends EventFunction | EventFunctionWithCallback>
7272
return handleCallbackErrors(
7373
() => (fn as EventFunctionWithCallback)(data, context, newCallback),
7474
err => {
75-
captureException(err, scope => markEventUnhandled(scope));
75+
captureException(err, scope => markEventUnhandled(scope, 'google-cloud-serverless.event'));
7676
},
7777
);
7878
}

packages/google-cloud-serverless/src/gcpfunction/http.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ function _wrapHttpFunction(fn: HttpFunction, options: Partial<WrapperOptions>):
7878
return handleCallbackErrors(
7979
() => fn(req, res),
8080
err => {
81-
captureException(err, scope => markEventUnhandled(scope));
81+
captureException(err, scope => markEventUnhandled(scope, 'google-cloud-serverless.http'));
8282
},
8383
);
8484
},

packages/google-cloud-serverless/src/utils.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,9 +43,9 @@ export function proxyFunction<A extends any[], R, F extends (...args: A) => R>(
4343
/**
4444
* Marks an event as unhandled by adding a span processor to the passed scope.
4545
*/
46-
export function markEventUnhandled(scope: Scope): Scope {
46+
export function markEventUnhandled(scope: Scope, type = 'google-cloud-serverless'): Scope {
4747
scope.addEventProcessor(event => {
48-
addExceptionMechanism(event, { handled: false });
48+
addExceptionMechanism(event, { handled: false, type });
4949
return event;
5050
});
5151

0 commit comments

Comments
 (0)