-
Notifications
You must be signed in to change notification settings - Fork 89
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(localenv): add performance metrics #2999
Changes from 26 commits
5de7ad9
751ffa9
a003c3e
10b4ea4
6c660ad
46e00aa
bbddc36
ff3fd70
6357f79
0b83806
29143f4
522b339
3033c2a
0ede073
a3efc73
84f825f
dfd8b2b
c8753fc
f70cc29
b1b1866
87e73d3
e050a40
328ebbe
5c06039
b5143b7
fb19aeb
4ae9649
2ad883b
24a5eff
ba42a29
6803522
ef85d8b
658f85f
03d929b
ed1b5d3
7f07761
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -440,13 +440,25 @@ export const depositOutgoingPaymentLiquidity: MutationResolvers<ApolloContext>[' | |
args, | ||
ctx | ||
): Promise<ResolversTypes['LiquidityMutationResponse']> => { | ||
const telemetry = await ctx.container.use('telemetry') | ||
const stopTimer = telemetry.startTimer( | ||
'deposit_outgoing_payment_liquidity_ms', | ||
{ | ||
callName: 'depositOutgoingPaymentLiquidity' | ||
} | ||
) | ||
const { outgoingPaymentId } = args.input | ||
const webhookService = await ctx.container.use('webhookService') | ||
const stopTimerWh = telemetry.startTimer('wh_get_latest_ms', { | ||
callName: 'webhookService.getLatestByResourceId' | ||
}) | ||
const event = await webhookService.getLatestByResourceId({ | ||
outgoingPaymentId, | ||
types: [OutgoingPaymentDepositType.PaymentCreated] | ||
}) | ||
stopTimerWh() | ||
if (!event || !isOutgoingPaymentEvent(event)) { | ||
stopTimer() | ||
throw new GraphQLError(errorToMessage[LiquidityError.InvalidId], { | ||
extensions: { | ||
code: errorToCode[LiquidityError.InvalidId] | ||
|
@@ -455,23 +467,31 @@ export const depositOutgoingPaymentLiquidity: MutationResolvers<ApolloContext>[' | |
} | ||
|
||
if (!event.data.debitAmount) { | ||
stopTimer() | ||
throw new Error('No debit amount') | ||
} | ||
const outgoingPaymentService = await ctx.container.use( | ||
'outgoingPaymentService' | ||
) | ||
const stopTimerFund = telemetry.startTimer('fund_payment_ms', { | ||
callName: 'outgoingPaymentService.fund' | ||
}) | ||
const paymentOrErr = await outgoingPaymentService.fund({ | ||
id: outgoingPaymentId, | ||
amount: BigInt(event.data.debitAmount.value), | ||
transferId: event.id | ||
}) | ||
stopTimerFund() | ||
|
||
if (isFundingError(paymentOrErr)) { | ||
stopTimer() | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. maybe a finally would be nice here to avoid calling There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. good idea. put everything in a new try and removed the |
||
throw new GraphQLError(fundingErrorToMessage[paymentOrErr], { | ||
extensions: { | ||
code: fundingErrorToCode[paymentOrErr] | ||
} | ||
}) | ||
} | ||
stopTimer() | ||
return { | ||
success: true | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Something we don't necessary have to tackle in this PR, but what can we do when it comes to stopping timers during a happy path vs an error? is there something we can add to make that distinction in the metrics?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah we could have a
success: boolean
attribute on the underlying histogram. I was inspired by a pattern that was shown to me during the WW, and it had that.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not used currently, but it should be possible now. I updated the closure returned from
startTimer
to acceptadditionalAttributes
which will be merged on the ones initially provided tostartTimer
. Usage example added to tests (and tests added forstartTimer
in general - noticed we didnt have any).