Skip to content

Commit b9b271c

Browse files
author
rtkay123
committed
refactor: use lib apm service
1 parent c6e34bf commit b9b271c

File tree

4 files changed

+23
-23
lines changed

4 files changed

+23
-23
lines changed

package-lock.json

Lines changed: 9 additions & 8 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,12 +39,11 @@
3939
],
4040
"license": "ISC",
4141
"dependencies": {
42-
"@frmscoe/frms-coe-lib": "^0.3.2",
42+
"@frmscoe/frms-coe-lib": "^0.3.5",
4343
"@frmscoe/frms-coe-startup-lib": "^0.0.14",
4444
"@log4js-node/logstash-http": "^1.1.0",
4545
"arangojs": "^8.4.0",
4646
"dotenv": "^8.6.0",
47-
"elastic-apm-node": "^3.49.0",
4847
"log4js": "^6.4.0",
4948
"tslib": "^2.6.0",
5049
"uuid": "^8.3.2"

src/apm.ts

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
1-
import apm from 'elastic-apm-node';
1+
import { Apm } from '@frmscoe/frms-coe-lib/lib/services/apm';
22
import { configuration } from './config';
33
/*
44
* Initialize the APM Logging
55
**/
6-
if (configuration.apm.active === 'true') {
7-
apm.start({
8-
serviceName: configuration.serviceName,
9-
secretToken: configuration.apm?.secretToken,
10-
serverUrl: configuration.apm?.url,
11-
usePathAsTransactionName: true,
12-
active: Boolean(configuration.apm?.active),
13-
transactionIgnoreUrls: ['/health'],
14-
});
15-
}
6+
const apm = new Apm({
7+
serviceName: configuration.serviceName,
8+
secretToken: configuration.apm?.secretToken,
9+
serverUrl: configuration.apm?.url,
10+
usePathAsTransactionName: true,
11+
active: Boolean(configuration.apm?.active),
12+
transactionIgnoreUrls: ['/health'],
13+
});
14+
15+
export default apm;

src/services/logic.service.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/* eslint-disable @typescript-eslint/no-non-null-assertion */
22
/* eslint-disable @typescript-eslint/no-explicit-any */
3-
import apm from 'elastic-apm-node';
3+
import apm from '../apm';
44
import { type Message, type NetworkMap } from '@frmscoe/frms-coe-lib/lib/interfaces';
55
import { Alert } from '../classes/alert';
66
import { ChannelResult } from '../classes/channel-result';
@@ -16,7 +16,7 @@ const calculateDuration = (startTime: bigint): number => {
1616
};
1717

1818
export const handleExecute = async (rawTransaction: any): Promise<any> => {
19-
let apmTransaction: apm.Transaction | null = null;
19+
let apmTransaction = null;
2020
try {
2121
const startTime = process.hrtime.bigint();
2222
// Get the request body and parse it to variables

0 commit comments

Comments
 (0)