Skip to content
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

chore: refactor error metrics #381

Merged
merged 7 commits into from
Jan 6, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
50 changes: 25 additions & 25 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 4 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -111,18 +111,18 @@
"@mojaloop/central-services-health": "15.0.0",
"@mojaloop/central-services-logger": "11.5.1",
"@mojaloop/central-services-metrics": "12.4.2",
"@mojaloop/central-services-shared": "18.14.1",
"@mojaloop/central-services-shared": "18.15.0",
"@mojaloop/central-services-stream": "11.4.1",
"@mojaloop/event-sdk": "14.1.1",
"@mojaloop/inter-scheme-proxy-cache-lib": "2.3.1",
"@mojaloop/ml-number": "11.2.4",
"@mojaloop/ml-schema-transformer-lib": "2.4.2",
"@mojaloop/ml-schema-transformer-lib": "2.5.1",
"@mojaloop/sdk-standard-components": "18.1.0",
"ajv": "8.17.1",
"ajv-keywords": "5.1.0",
"axios": "1.7.9",
"blipp": "4.0.2",
"commander": "12.1.0",
"commander": "13.0.0",
"event-stream": "4.0.1",
"fast-safe-stringify": "^2.1.1",
"good-console": "8.0.0",
Expand All @@ -145,7 +145,7 @@
"ioredis-mock": "8.9.0",
"jest": "29.7.0",
"jest-junit": "16.0.0",
"npm-check-updates": "17.1.11",
"npm-check-updates": "17.1.13",
"nyc": "17.1.0",
"pre-commit": "1.2.2",
"proxyquire": "2.1.3",
Expand Down
11 changes: 1 addition & 10 deletions src/api/bulkQuotes.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@
const Metrics = require('@mojaloop/central-services-metrics')
const { Producer } = require('@mojaloop/central-services-stream').Util
const { Http, Events } = require('@mojaloop/central-services-shared').Enum
const { reformatFSPIOPError } = require('@mojaloop/central-services-error-handling').Factory

const util = require('../lib/util')
const Config = require('../lib/config')
Expand All @@ -59,7 +58,6 @@ module.exports = {
'Publish HTTP POST bulkQuotes request',
['success']
).startTimer()
const errorCounter = Metrics.getCounter('errorCount')
let step

try {
Expand All @@ -80,14 +78,7 @@ module.exports = {
return h.response().code(Http.ReturnCodes.ACCEPTED.CODE)
} catch (err) {
histTimerEnd({ success: false })
const fspiopError = reformatFSPIOPError(err)
errorCounter.inc({
code: fspiopError?.apiErrorCode.code,
system: undefined,
operation: 'postBulkQuotes',
step
})
util.rethrowFspiopError(err)
util.rethrowAndCountFspiopError(err, { operation: 'postBulkQuotes', step })
}
}
}
21 changes: 2 additions & 19 deletions src/api/bulkQuotes/{id}.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@
const Metrics = require('@mojaloop/central-services-metrics')
const { Producer } = require('@mojaloop/central-services-stream').Util
const { Http, Events } = require('@mojaloop/central-services-shared').Enum
const { reformatFSPIOPError } = require('@mojaloop/central-services-error-handling').Factory

const util = require('../../lib/util')
const Config = require('../../lib/config')
Expand All @@ -58,7 +57,6 @@ module.exports = {
'Publish HTTP GET /bulkQuotes/{id} request',
['success']
).startTimer()
const errorCounter = Metrics.getCounter('errorCount')
let step

try {
Expand All @@ -79,14 +77,7 @@ module.exports = {
return h.response().code(Http.ReturnCodes.ACCEPTED.CODE)
} catch (err) {
histTimerEnd({ success: false })
const fspiopError = reformatFSPIOPError(err)
errorCounter.inc({
code: fspiopError?.apiErrorCode.code,
system: undefined,
operation: 'getBulkQuotesById',
step
})
util.rethrowFspiopError(err)
util.rethrowAndCountFspiopError(err, { operation: 'getBulkQuotesById', step })
}
},
/**
Expand All @@ -102,7 +93,6 @@ module.exports = {
'Publish HTTP PUT /bulkQuotes/{id} request',
['success']
).startTimer()
const errorCounter = Metrics.getCounter('errorCount')
let step

try {
Expand All @@ -123,14 +113,7 @@ module.exports = {
return h.response().code(Http.ReturnCodes.OK.CODE)
} catch (err) {
histTimerEnd({ success: false })
const fspiopError = reformatFSPIOPError(err)
errorCounter.inc({
code: fspiopError?.apiErrorCode.code,
system: undefined,
operation: 'putBulkQuotesById',
step
})
util.rethrowFspiopError(err)
util.rethrowAndCountFspiopError(err, { operation: 'putBulkQuotesById', step })
}
}
}
13 changes: 2 additions & 11 deletions src/api/bulkQuotes/{id}/error.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,10 @@
const Metrics = require('@mojaloop/central-services-metrics')
const { Producer } = require('@mojaloop/central-services-stream').Util
const { Http, Events } = require('@mojaloop/central-services-shared').Enum
const { reformatFSPIOPError } = require('@mojaloop/central-services-error-handling').Factory

const util = require('../../../lib/util')
const Config = require('../../../lib/config')
const dto = require('../../../lib/dto')
const util = require('../../../lib/util')

const { kafkaConfig } = new Config()

Expand All @@ -59,7 +58,6 @@ module.exports = {
'Process HTTP PUT /bulkQuotes/{id}/error request',
['success']
).startTimer()
const errorCounter = Metrics.getCounter('errorCount')
let step

try {
Expand All @@ -80,14 +78,7 @@ module.exports = {
return h.response().code(Http.ReturnCodes.OK.CODE)
} catch (err) {
histTimerEnd({ success: false })
const fspiopError = reformatFSPIOPError(err)
errorCounter.inc({
code: fspiopError?.apiErrorCode.code,
system: undefined,
operation: 'putBulkQuotesByIdError',
step
})
util.rethrowFspiopError(err)
util.rethrowAndCountFspiopError(err, { operation: 'putBulkQuotesByIdError', step })
}
}
}
11 changes: 1 addition & 10 deletions src/api/quotes.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@
const Metrics = require('@mojaloop/central-services-metrics')
const { Producer } = require('@mojaloop/central-services-stream').Util
const { Http, Events } = require('@mojaloop/central-services-shared').Enum
const { reformatFSPIOPError } = require('@mojaloop/central-services-error-handling').Factory

const util = require('../lib/util')
const dto = require('../lib/dto')
Expand Down Expand Up @@ -62,7 +61,6 @@ module.exports = {
isFX ? 'Publish HTTP POST fxQuotes request' : 'Publish HTTP POST quotes request',
['success']
).startTimer()
const errorCounter = Metrics.getCounter('errorCount')
let step

try {
Expand All @@ -88,14 +86,7 @@ module.exports = {
return h.response().code(Http.ReturnCodes.ACCEPTED.CODE)
} catch (err) {
histTimerEnd({ success: false })
const fspiopError = reformatFSPIOPError(err)
errorCounter.inc({
code: fspiopError?.apiErrorCode.code,
system: undefined,
operation: 'postQuotes',
step
})
util.rethrowFspiopError(err)
util.rethrowAndCountFspiopError(err, { operation: 'postQuotes', step })
}
}
}
21 changes: 2 additions & 19 deletions src/api/quotes/{id}.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@
const Metrics = require('@mojaloop/central-services-metrics')
const { Producer } = require('@mojaloop/central-services-stream').Util
const { Http, Events } = require('@mojaloop/central-services-shared').Enum
const { reformatFSPIOPError } = require('@mojaloop/central-services-error-handling').Factory

const util = require('../../lib/util')
const dto = require('../../lib/dto')
Expand Down Expand Up @@ -62,7 +61,6 @@ module.exports = {
isFX ? 'Publish HTTP GET /fxQuotes/{ID} request' : 'Publish HTTP GET /quotes/{id} request',
['success']
).startTimer()
const errorCounter = Metrics.getCounter('errorCount')
let step

try {
Expand All @@ -88,14 +86,7 @@ module.exports = {
return h.response().code(Http.ReturnCodes.ACCEPTED.CODE)
} catch (err) {
histTimerEnd({ success: false })
const fspiopError = reformatFSPIOPError(err)
errorCounter.inc({
code: fspiopError?.apiErrorCode.code,
system: undefined,
operation: 'getQuotesById',
step
})
util.rethrowFspiopError(err)
util.rethrowAndCountFspiopError(err, { operation: 'getQuotesById', step })
}
},

Expand Down Expand Up @@ -127,7 +118,6 @@ module.exports = {
isFX ? `Publish HTTP PUT /fxQuotes/{id}${pathSuffix} request` : `Publish HTTP PUT /quotes/{id}${pathSuffix} request`,
['success']
).startTimer()
const errorCounter = Metrics.getCounter('errorCount')
let step

try {
Expand All @@ -151,14 +141,7 @@ module.exports = {
return h.response().code(Http.ReturnCodes.OK.CODE)
} catch (err) {
histTimerEnd({ success: false })
const fspiopError = reformatFSPIOPError(err)
errorCounter.inc({
code: fspiopError?.apiErrorCode.code,
system: undefined,
operation: 'putQuotesById',
step
})
util.rethrowFspiopError(err)
util.rethrowAndCountFspiopError(err, { operation: 'putQuotesById', step })
}
}
}
Loading