@@ -62,8 +62,9 @@ export function init(options: Sentry.NodeOptions = {}): void {
62
62
*
63
63
* @param scope Scope that should be enhanced
64
64
* @param context AWS Lambda context that will be used to extract some part of the data
65
+ * @param startTime performance.now() when wrapHandler was invoked
65
66
*/
66
- function enhanceScopeWithEnvironmentData ( scope : Scope , context : Context ) : void {
67
+ function enhanceScopeWithEnvironmentData ( scope : Scope , context : Context , startTime : number ) : void {
67
68
scope . setTransactionName ( context . functionName ) ;
68
69
69
70
scope . setTag ( 'server_name' , process . env . _AWS_XRAY_DAEMON_ADDRESS || process . env . SENTRY_NAME || hostname ( ) ) ;
@@ -79,7 +80,7 @@ function enhanceScopeWithEnvironmentData(scope: Scope, context: Context): void {
79
80
function_name : context . functionName ,
80
81
function_version : context . functionVersion ,
81
82
invoked_function_arn : context . invokedFunctionArn ,
82
- execution_duration_in_millis : performance . now ( ) ,
83
+ execution_duration_in_millis : performance . now ( ) - startTime ,
83
84
remaining_time_in_millis : context . getRemainingTimeInMillis ( ) ,
84
85
'sys.argv' : process . argv ,
85
86
} ) ;
@@ -106,6 +107,7 @@ export function wrapHandler<TEvent, TResult>(
106
107
handler : Handler < TEvent , TResult > ,
107
108
wrapOptions : Partial < WrapperOptions > = { } ,
108
109
) : Handler < TEvent , TResult | undefined > {
110
+ const START_TIME = performance . now ( ) ;
109
111
const options : WrapperOptions = {
110
112
flushTimeout : 2000 ,
111
113
rethrowAfterCapture : true ,
@@ -176,7 +178,7 @@ export function wrapHandler<TEvent, TResult>(
176
178
const scope = hub . pushScope ( ) ;
177
179
let rv : TResult | undefined ;
178
180
try {
179
- enhanceScopeWithEnvironmentData ( scope , context ) ;
181
+ enhanceScopeWithEnvironmentData ( scope , context , START_TIME ) ;
180
182
// We put the transaction on the scope so users can attach children to it
181
183
scope . setSpan ( transaction ) ;
182
184
rv = await asyncHandler ( event , context ) ;
0 commit comments