-
Notifications
You must be signed in to change notification settings - Fork 19
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
Count eth transactions and errors #1051
base: develop
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -13,7 +13,9 @@ import { | |
TransactionResponse, | ||
TransactionReceipt, | ||
} from '@ethersproject/abstract-provider' | ||
import { ServiceMetrics as Metrics } from '@ceramicnetwork/observability' | ||
import { Utils } from '../../../utils.js' | ||
import { METRIC_NAMES } from '../../../settings.js' | ||
|
||
const BASE_CHAIN_ID = 'eip155' | ||
const TX_FAILURE = 0 | ||
|
@@ -410,6 +412,7 @@ export class EthereumBlockchainService implements BlockchainService { | |
const txData = await this._buildTransactionRequest(rootCid) | ||
const txResponses: Array<TransactionResponse> = [] | ||
|
||
Metrics.count(METRIC_NAMES.ETH_REQUEST_TOTAL, 1) | ||
return this.withWalletBalance((walletBalance) => { | ||
return attempt(MAX_RETRIES, async (attemptNum) => { | ||
try { | ||
|
@@ -420,6 +423,7 @@ export class EthereumBlockchainService implements BlockchainService { | |
} catch (err: any) { | ||
logger.err(err) | ||
const { code } = err | ||
Metrics.count(METRIC_NAMES.ETH_REQUEST_ERROR_TOTAL, 1, {'error_code': code}) | ||
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. There is a case where this "should" fail. Ex. First attempt is successful but times out before it can return success. Second attempt fails because the first attempt was successful (the error is nonce expired). Instead of throwing the error we check if the first attempt was successful. If this count disregards the above scenario then you can also disregard this comment 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. ok yeah that would change the behavior aside from metrics - i guess i will defer this or icebox for now, bc i think changing the error behavior of cas is out of scope from measuring the things The code should have something to do with the reason but not sure if it will sort these... |
||
switch (code) { | ||
case ErrorCode.INSUFFICIENT_FUNDS: | ||
return handleInsufficientFundsError(txData, walletBalance) | ||
|
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.
What does this metric represent?
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 its just for comparing to the error total - its like how many times did we make an eth transaction request, vs how many times it errored
it might also be the same as the number of anchors but unless we have knowledge of the code we don't know that for sure
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.
Yes currently this should corresponding to the number of anchors. Do you want this to include the number of retries? If so then you should move it into the try block after
_trySendTransaction
.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.
i don't think i want to move it to include retries, its just for the purpose of comparing to errors. we could remove it entirely and just count the errors maybe
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.
I think that makes sense