mblabs-roccato-backend-commons 1.0.73 → 1.0.75
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -7,16 +7,12 @@ interface Credentials {
|
|
|
7
7
|
export declare namespace ElasticAPM {
|
|
8
8
|
namespace Init {
|
|
9
9
|
interface Request {
|
|
10
|
-
data: {
|
|
11
|
-
type: 'trace' | 'debug' | 'info' | 'warn' | 'warning' | 'error' | 'fatal' | 'critical' | 'off';
|
|
12
|
-
};
|
|
13
10
|
credentials: Credentials;
|
|
14
11
|
}
|
|
15
12
|
}
|
|
16
13
|
namespace CaptureError {
|
|
17
14
|
interface Request {
|
|
18
15
|
data: {
|
|
19
|
-
type: 'trace' | 'debug' | 'info' | 'warn' | 'warning' | 'error' | 'fatal' | 'critical' | 'off';
|
|
20
16
|
error: Error | string;
|
|
21
17
|
};
|
|
22
18
|
credentials: Credentials;
|
|
@@ -26,5 +22,6 @@ export declare namespace ElasticAPM {
|
|
|
26
22
|
export interface IElasticAPMService {
|
|
27
23
|
init(req: ElasticAPM.Init.Request): void;
|
|
28
24
|
captureError(req: ElasticAPM.CaptureError.Request): void;
|
|
25
|
+
shutdown(): Promise<void>;
|
|
29
26
|
}
|
|
30
27
|
export {};
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import { ElasticAPM, IElasticAPMService } from '../interfaces';
|
|
2
2
|
declare class ElasticAPMService implements IElasticAPMService {
|
|
3
3
|
private self;
|
|
4
|
-
init({ credentials
|
|
4
|
+
init({ credentials }: ElasticAPM.Init.Request): void;
|
|
5
5
|
captureError({ data, credentials }: ElasticAPM.CaptureError.Request): void;
|
|
6
|
+
shutdown(): Promise<void>;
|
|
6
7
|
}
|
|
7
8
|
declare const _default: ElasticAPMService;
|
|
8
9
|
export default _default;
|
|
@@ -7,23 +7,26 @@ const elastic_apm_node_1 = __importDefault(require("elastic-apm-node"));
|
|
|
7
7
|
const utils_1 = require("../utils");
|
|
8
8
|
class ElasticAPMService {
|
|
9
9
|
self = null;
|
|
10
|
-
init({ credentials
|
|
10
|
+
init({ credentials }) {
|
|
11
11
|
this.self = elastic_apm_node_1.default.start({
|
|
12
12
|
serviceName: credentials.service,
|
|
13
13
|
serverUrl: credentials.server,
|
|
14
14
|
environment: credentials.environment,
|
|
15
15
|
secretToken: credentials.secretToken,
|
|
16
|
-
captureBody: 'all',
|
|
17
|
-
logLevel: data.type,
|
|
18
16
|
active: true,
|
|
19
17
|
verifyServerCert: false,
|
|
18
|
+
ignoreUrls: ['/docs', '/health'],
|
|
20
19
|
});
|
|
21
20
|
}
|
|
22
21
|
captureError({ data, credentials }) {
|
|
23
22
|
if (!this.self) {
|
|
24
|
-
this.init({ credentials
|
|
23
|
+
this.init({ credentials });
|
|
25
24
|
}
|
|
26
25
|
this.self.captureError((0, utils_1.safeStringify)(data.error));
|
|
27
26
|
}
|
|
27
|
+
async shutdown() {
|
|
28
|
+
if (this.self)
|
|
29
|
+
await this.self.flush();
|
|
30
|
+
}
|
|
28
31
|
}
|
|
29
32
|
exports.default = new ElasticAPMService();
|
package/package.json
CHANGED
|
@@ -8,9 +8,6 @@ interface Credentials {
|
|
|
8
8
|
export namespace ElasticAPM {
|
|
9
9
|
export namespace Init {
|
|
10
10
|
export interface Request {
|
|
11
|
-
data: {
|
|
12
|
-
type: 'trace' | 'debug' | 'info' | 'warn' | 'warning' | 'error' | 'fatal' | 'critical' | 'off';
|
|
13
|
-
};
|
|
14
11
|
credentials: Credentials;
|
|
15
12
|
}
|
|
16
13
|
}
|
|
@@ -18,7 +15,6 @@ export namespace ElasticAPM {
|
|
|
18
15
|
export namespace CaptureError {
|
|
19
16
|
export interface Request {
|
|
20
17
|
data: {
|
|
21
|
-
type: 'trace' | 'debug' | 'info' | 'warn' | 'warning' | 'error' | 'fatal' | 'critical' | 'off';
|
|
22
18
|
error: Error | string;
|
|
23
19
|
};
|
|
24
20
|
credentials: Credentials;
|
|
@@ -29,4 +25,5 @@ export namespace ElasticAPM {
|
|
|
29
25
|
export interface IElasticAPMService {
|
|
30
26
|
init (req: ElasticAPM.Init.Request): void;
|
|
31
27
|
captureError (req: ElasticAPM.CaptureError.Request): void;
|
|
28
|
+
shutdown (): Promise<void>;
|
|
32
29
|
}
|
|
@@ -6,28 +6,31 @@ import { safeStringify } from '../utils';
|
|
|
6
6
|
class ElasticAPMService implements IElasticAPMService {
|
|
7
7
|
private self: typeof APM | null = null;
|
|
8
8
|
|
|
9
|
-
init ({ credentials
|
|
9
|
+
init ({ credentials }: ElasticAPM.Init.Request): void {
|
|
10
10
|
this.self = APM.start({
|
|
11
11
|
serviceName: credentials.service,
|
|
12
12
|
serverUrl: credentials.server,
|
|
13
13
|
environment: credentials.environment,
|
|
14
14
|
secretToken: credentials.secretToken,
|
|
15
|
-
captureBody: 'all',
|
|
16
|
-
logLevel: data.type,
|
|
17
15
|
active: true,
|
|
18
16
|
verifyServerCert: false,
|
|
17
|
+
ignoreUrls: [ '/docs', '/health' ],
|
|
19
18
|
});
|
|
20
19
|
}
|
|
21
20
|
|
|
22
21
|
captureError ({ data, credentials }: ElasticAPM.CaptureError.Request): void {
|
|
23
22
|
if (!this.self) {
|
|
24
|
-
this.init({ credentials
|
|
23
|
+
this.init({ credentials });
|
|
25
24
|
}
|
|
26
25
|
|
|
27
26
|
this.self.captureError(
|
|
28
27
|
safeStringify(data.error)
|
|
29
28
|
);
|
|
30
29
|
}
|
|
30
|
+
|
|
31
|
+
async shutdown () {
|
|
32
|
+
if (this.self) await this.self.flush();
|
|
33
|
+
}
|
|
31
34
|
}
|
|
32
35
|
|
|
33
36
|
export default new ElasticAPMService();
|