fix metrics batch size
This commit is contained in:
parent
88ffb41f05
commit
a4e9a23d74
4 changed files with 8 additions and 4 deletions
|
|
@ -690,7 +690,7 @@ export default class {
|
||||||
throw new Error("user is banned, cannot retrieve operations")
|
throw new Error("user is banned, cannot retrieve operations")
|
||||||
}
|
}
|
||||||
const [outgoingInvoices, outgoingTransactions, incomingInvoices, incomingTransactions, incomingUserToUser, outgoingUserToUser] = await Promise.all([
|
const [outgoingInvoices, outgoingTransactions, incomingInvoices, incomingTransactions, incomingUserToUser, outgoingUserToUser] = await Promise.all([
|
||||||
this.storage.paymentStorage.GetUserInvoicePayments(userId, req.latestOutgoingInvoice, req.max_size),
|
this.storage.paymentStorage.GetUserInvoicePayments(userId, req.latestOutgoingInvoice, req.max_size), //
|
||||||
this.storage.paymentStorage.GetUserTransactionPayments(userId, req.latestOutgoingTx, req.max_size),
|
this.storage.paymentStorage.GetUserTransactionPayments(userId, req.latestOutgoingTx, req.max_size),
|
||||||
this.storage.paymentStorage.GetUserInvoicesFlaggedAsPaid(userId, req.latestIncomingInvoice, req.max_size),
|
this.storage.paymentStorage.GetUserInvoicesFlaggedAsPaid(userId, req.latestIncomingInvoice, req.max_size),
|
||||||
this.storage.paymentStorage.GetUserReceivingTransactions(userId, req.latestIncomingTx, req.max_size),
|
this.storage.paymentStorage.GetUserReceivingTransactions(userId, req.latestIncomingTx, req.max_size),
|
||||||
|
|
|
||||||
|
|
@ -70,7 +70,8 @@ export default class Handler {
|
||||||
}
|
}
|
||||||
|
|
||||||
async GetUsageMetrics(): Promise<Types.UsageMetrics> {
|
async GetUsageMetrics(): Promise<Types.UsageMetrics> {
|
||||||
return this.storage.metricsEventStorage.LoadLatestMetrics()
|
const metrics = await this.storage.metricsEventStorage.LoadLatestMetrics()
|
||||||
|
return metrics
|
||||||
}
|
}
|
||||||
|
|
||||||
async GetErrorStats(): Promise<Types.ErrorStats> {
|
async GetErrorStats(): Promise<Types.ErrorStats> {
|
||||||
|
|
|
||||||
|
|
@ -107,7 +107,7 @@ export default class {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
LoadLatestMetrics = async (): Promise<Types.UsageMetrics> => {
|
LoadLatestMetrics = async (limit = 100): Promise<Types.UsageMetrics> => {
|
||||||
this.persistMetrics()
|
this.persistMetrics()
|
||||||
const metrics: Types.UsageMetrics = { apps: {} }
|
const metrics: Types.UsageMetrics = { apps: {} }
|
||||||
this.foreachMetricMethodFile((app, method, tlvFiles) => {
|
this.foreachMetricMethodFile((app, method, tlvFiles) => {
|
||||||
|
|
@ -120,6 +120,9 @@ export default class {
|
||||||
if (!metrics.apps[app]) {
|
if (!metrics.apps[app]) {
|
||||||
metrics.apps[app] = { app_metrics: {} }
|
metrics.apps[app] = { app_metrics: {} }
|
||||||
}
|
}
|
||||||
|
if (decoded.length > limit) {
|
||||||
|
decoded.splice(0, decoded.length - limit)
|
||||||
|
}
|
||||||
metrics.apps[app].app_metrics[method] = {
|
metrics.apps[app].app_metrics[method] = {
|
||||||
base_64_tlvs: decoded.map(d => Buffer.from(d).toString('base64')),
|
base_64_tlvs: decoded.map(d => Buffer.from(d).toString('base64')),
|
||||||
current_chunk: latest,
|
current_chunk: latest,
|
||||||
|
|
|
||||||
|
|
@ -213,7 +213,7 @@ export default class {
|
||||||
user_id: userId
|
user_id: userId
|
||||||
},
|
},
|
||||||
serial_id: MoreThanOrEqual(fromIndex),
|
serial_id: MoreThanOrEqual(fromIndex),
|
||||||
paid_at_unix: MoreThan(0),
|
paid_at_unix: MoreThan(-1),
|
||||||
},
|
},
|
||||||
order: {
|
order: {
|
||||||
paid_at_unix: 'DESC'
|
paid_at_unix: 'DESC'
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue