Skip to content

Commit

Permalink
chore: actually record errors
Browse files Browse the repository at this point in the history
  • Loading branch information
achingbrain committed Oct 26, 2024
1 parent 4162f9a commit 094eb0b
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 11 deletions.
2 changes: 1 addition & 1 deletion packages/kad-dht/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@
* peerInfoMapper: removePrivateAddressesMapper,
* logPrefix: 'libp2p:dht-amino',
* datastorePrefix: '/dht-amino',
* metricsPrefix: 'libp2p_dht_amino
* metricsPrefix: 'libp2p_dht_amino'
* })
* }
* })
Expand Down
20 changes: 10 additions & 10 deletions packages/kad-dht/src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -247,15 +247,15 @@ export function timeOperationGenerator (fn: (...args: any[]) => AsyncGenerator<a

yield * fn(...args)
} catch (err) {
errored = false
errored = true
stopErrorTimer?.()
operationMetrics.errors?.increment({ [type]: true })

throw err
} finally {
operationMetrics.queries?.decrement({ [type]: true })

if (errored) {
stopErrorTimer?.()
operationMetrics.errors?.increment({ [type]: true })
} else {
if (!errored) {
stopSuccessTimer?.()
}
}
Expand All @@ -273,15 +273,15 @@ export function timeOperationMethod (fn: (...args: any[]) => Promise<any>, opera

return await fn(...args)
} catch (err) {
errored = false
errored = true
stopErrorTimer?.()
operationMetrics.errors?.increment({ [type]: true })

throw err
} finally {
operationMetrics.queries?.decrement({ [type]: true })

if (errored) {
stopErrorTimer?.()
operationMetrics.errors?.increment({ [type]: true })
} else {
if (!errored) {
stopSuccessTimer?.()
}
}
Expand Down

0 comments on commit 094eb0b

Please sign in to comment.