Skip to content

Commit

Permalink
Merge pull request #72 from decentraland/fix/remove-data-from-metrics
Browse files Browse the repository at this point in the history
fix: remove data and from from metrics
  • Loading branch information
nachomazzara committed Aug 2, 2021
2 parents d789b69 + 8dee9aa commit 225f82a
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 18 deletions.
17 changes: 7 additions & 10 deletions src/logic/transaction.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,22 +39,21 @@ export async function sendMetaTransaction(
method: 'POST',
})

const metricPayload = {
contract: transactionData.params[0],
}

if (!result.ok) {
const errorMessage = await result.text()
const errorPayload = {
contract: transactionData.params[0],
data: transactionData.params[1],
from: transactionData.from,
}
if (errorMessage.includes('UNPREDICTABLE_GAS_LIMIT')) {
// This error happens when the contract execution will fail. See https://github.com/decentraland/transactions-server/blob/2e5d833f672a87a7acf0ff761f986421676c4ec9/ERRORS.md
metrics.increment(
'dcl_error_cannot_estimate_gas_transactions_biconomy',
errorPayload
metricPayload
)
} else {
// Any other error is related to the Biconomy API
metrics.increment('dcl_error_relay_transactions_biconomy', errorPayload)
metrics.increment('dcl_error_relay_transactions_biconomy', metricPayload)
}

throw new MetaTransactionError(
Expand All @@ -65,9 +64,7 @@ export async function sendMetaTransaction(

const data: MetaTransactionResponse = await result.json()

metrics.increment('dcl_sent_transactions_biconomy', {
contract: transactionData.params[0],
})
metrics.increment('dcl_sent_transactions_biconomy', metricPayload)

return data.txHash!
}
Expand Down
4 changes: 2 additions & 2 deletions src/metrics.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,12 @@ export const metricDeclarations = {
dcl_error_cannot_estimate_gas_transactions_biconomy: {
help: 'Count errors of cannot estimate gas when trying to relay a transaction to BICONOMY',
type: IMetricsComponent.CounterType,
labelNames: ['contract', 'data', 'from'],
labelNames: ['contract'],
},
dcl_error_relay_transactions_biconomy: {
help: 'Count errors of BICONOMY Api when trying to relay a transaction to BICONOMY',
type: IMetricsComponent.CounterType,
labelNames: ['contract', 'data', 'from'],
labelNames: ['contract'],
},
}

Expand Down
8 changes: 2 additions & 6 deletions test/tests/biconomy.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,9 +67,7 @@ test('biconomy flow test 1', function ({ components, stubComponents }) {

expect(
metrics.increment.calledOnceWith('dcl_error_relay_transactions_biconomy', {
contract: tx.params[0],
data: tx.params[1],
from: tx.from
contract: tx.params[0]
})
).toEqual(true)
})
Expand All @@ -92,9 +90,7 @@ test('biconomy flow test 1', function ({ components, stubComponents }) {

expect(
metrics.increment.calledOnceWith('dcl_error_cannot_estimate_gas_transactions_biconomy', {
contract: tx.params[0],
data: tx.params[1],
from: tx.from
contract: tx.params[0]
})
).toEqual(true)
})
Expand Down

0 comments on commit 225f82a

Please sign in to comment.