log: add APM to handler
parent
583b754315
commit
fcaf4a07a1
|
@ -23,6 +23,10 @@ export class CouchService {
|
|||
for (const database of DatabaseListen) {
|
||||
const db = nano.db.use(database);
|
||||
db.changesReader.start({ includeDocs: true }).on('change', (change) => {
|
||||
Logger.log(
|
||||
`Receive Data from ${database}: ${change?.id}`,
|
||||
'CouchService',
|
||||
);
|
||||
this.changeDoc(change, database);
|
||||
});
|
||||
|
||||
|
|
|
@ -13,7 +13,6 @@ export class SeasonPeriodHolidayHandler
|
|||
const queryRunner = this.dataService
|
||||
.getRepository()
|
||||
.manager.connection.createQueryRunner();
|
||||
const holidayDates = [];
|
||||
|
||||
if (event.data.data.holidays?.length) {
|
||||
// foreach holiday
|
||||
|
@ -35,9 +34,11 @@ export class SeasonPeriodHolidayHandler
|
|||
});
|
||||
holidayDate.priority = 1;
|
||||
|
||||
await this.dataService.createBatch(queryRunner, SeasonPeriodModel, [
|
||||
await this.dataService.create(
|
||||
queryRunner,
|
||||
SeasonPeriodModel,
|
||||
holidayDate,
|
||||
]);
|
||||
);
|
||||
}
|
||||
|
||||
// delete data
|
||||
|
|
|
@ -10,7 +10,7 @@ import { TransactionModel } from '../../../data/models/transaction.model';
|
|||
import { mappingRevertTransaction } from '../managers/helpers/mapping-transaction.helper';
|
||||
import { apm } from '../../../../../../core/apm';
|
||||
|
||||
// @EventsHandler(ChangeDocEvent)
|
||||
@EventsHandler(ChangeDocEvent)
|
||||
export class PosTransactionHandler implements IEventHandler<ChangeDocEvent> {
|
||||
constructor(
|
||||
private dataService: TransactionDataService,
|
||||
|
@ -19,6 +19,10 @@ export class PosTransactionHandler implements IEventHandler<ChangeDocEvent> {
|
|||
) {}
|
||||
|
||||
async handle(event: ChangeDocEvent) {
|
||||
const apmTransactions = apm.startTransaction(
|
||||
`ChangeDocEvent ${event?.data?.database}`,
|
||||
'handler',
|
||||
);
|
||||
try {
|
||||
const database = event.data.database;
|
||||
const data = event.data.data;
|
||||
|
@ -75,11 +79,17 @@ export class PosTransactionHandler implements IEventHandler<ChangeDocEvent> {
|
|||
sales_price_formula: sales_formula.formula_string,
|
||||
});
|
||||
|
||||
apmTransactions.setLabel('Code', data?.code);
|
||||
|
||||
await this.dataService.create(queryRunner, TransactionModel, data);
|
||||
apmTransactions.result = 'Success';
|
||||
}
|
||||
} catch (error) {
|
||||
apmTransactions.result = 'Failed';
|
||||
apm.captureError(error);
|
||||
console.log('error handling pos transaction couch');
|
||||
} finally {
|
||||
apmTransactions.end();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue