@edirect/trace 9.0.13 → 9.0.14
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.
- package/.editorconfig +14 -14
- package/.eslintignore +1 -1
- package/.eslintrc.js +44 -44
- package/.eslintrc.json +159 -159
- package/.idea/inspectionProfiles/Project_Default.xml +6 -0
- package/.idea/modules.xml +8 -0
- package/.idea/trace.iml +12 -0
- package/.idea/vcs.xml +6 -0
- package/.prettierrc +4 -4
- package/README.md +352 -267
- package/dist/constants/headers.d.ts +4 -4
- package/dist/constants/headers.js +5 -5
- package/dist/constants/index.d.ts +1 -1
- package/dist/constants/index.js +8 -8
- package/dist/index.d.ts +4 -4
- package/dist/index.js +30 -30
- package/dist/middlewares/CLS.d.ts +5 -5
- package/dist/middlewares/CLS.js +33 -33
- package/dist/middlewares/body.d.ts +5 -7
- package/dist/middlewares/body.js +40 -57
- package/dist/middlewares/body.js.map +1 -1
- package/dist/middlewares/index.d.ts +4 -3
- package/dist/middlewares/index.js +14 -12
- package/dist/middlewares/index.js.map +1 -1
- package/dist/middlewares/nextjs.d.ts +5 -0
- package/dist/middlewares/nextjs.js +39 -0
- package/dist/middlewares/nextjs.js.map +1 -0
- package/dist/middlewares/trace.d.ts +5 -5
- package/dist/middlewares/trace.js +26 -26
- package/dist/otel.d.ts +1 -1
- package/dist/otel.js +88 -86
- package/dist/otel.js.map +1 -1
- package/dist/services/APM.d.ts +14 -14
- package/dist/services/APM.js +57 -57
- package/dist/services/index.d.ts +1 -1
- package/dist/services/index.js +8 -8
- package/dist/tsconfig.build.tsbuildinfo +1 -1
- package/dist/utils/CLS.d.ts +5 -5
- package/dist/utils/CLS.js +41 -41
- package/dist/utils/body-prop-tools.d.ts +5 -0
- package/dist/utils/body-prop-tools.js +24 -0
- package/dist/utils/body-prop-tools.js.map +1 -0
- package/dist/utils/index.d.ts +3 -2
- package/dist/utils/index.js +12 -10
- package/dist/utils/index.js.map +1 -1
- package/dist/utils/trace.d.ts +5 -5
- package/dist/utils/trace.js +12 -12
- package/package.json +42 -42
- package/tsconfig.build.json +9 -9
package/dist/otel.js
CHANGED
|
@@ -1,87 +1,89 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
-
}) : function(o, v) {
|
|
16
|
-
o["default"] = v;
|
|
17
|
-
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
-
if (mod && mod.__esModule) return mod;
|
|
20
|
-
var result = {};
|
|
21
|
-
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
-
__setModuleDefault(result, mod);
|
|
23
|
-
return result;
|
|
24
|
-
};
|
|
25
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
-
const exporter_trace_otlp_http_1 = require("@opentelemetry/exporter-trace-otlp-http");
|
|
27
|
-
const semantic_conventions_1 = require("@opentelemetry/semantic-conventions");
|
|
28
|
-
const resources_1 = require("@opentelemetry/resources");
|
|
29
|
-
const opentelemetry = __importStar(require("@opentelemetry/sdk-node"));
|
|
30
|
-
const instrumentation_http_1 = require("@opentelemetry/instrumentation-http");
|
|
31
|
-
const instrumentation_express_1 = require("@opentelemetry/instrumentation-express");
|
|
32
|
-
const api_1 = require("@opentelemetry/api");
|
|
33
|
-
const TRACE_SERVER_URL = process.env['TRACE_SERVER_URL'];
|
|
34
|
-
const TRACE_TAG_SERVICENAME = process.env['TRACE_TAG_SERVICENAME'] || '';
|
|
35
|
-
const TRACE_TAG_SCOPE = process.env['TRACE_TAG_SCOPE'] || '';
|
|
36
|
-
const TRACE_TAG_ENV = process.env['TRACE_TAG_ENV'] || '';
|
|
37
|
-
const TRACE_TAG_CLUSTER = process.env['TRACE_TAG_CLUSTER'] || '';
|
|
38
|
-
const TRACE_TAG_TENANT = process.env['TRACE_TAG_TENANT'] || '';
|
|
39
|
-
const TRACE_TAG_SERVICE = process.env['TRACE_TAG_SERVICE'] || '';
|
|
40
|
-
const TRACE_TAG_VERSION = process.env['TRACE_TAG_VERSION'] || '';
|
|
41
|
-
const TRACE_TAG_OWNER = process.env['TRACE_TAG_OWNER'] || '';
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
['
|
|
53
|
-
['
|
|
54
|
-
['
|
|
55
|
-
['
|
|
56
|
-
['
|
|
57
|
-
['
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
[semantic_conventions_1.SemanticResourceAttributes.
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
})
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
.
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
.
|
|
84
|
-
.
|
|
85
|
-
|
|
86
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
25
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
+
const exporter_trace_otlp_http_1 = require("@opentelemetry/exporter-trace-otlp-http");
|
|
27
|
+
const semantic_conventions_1 = require("@opentelemetry/semantic-conventions");
|
|
28
|
+
const resources_1 = require("@opentelemetry/resources");
|
|
29
|
+
const opentelemetry = __importStar(require("@opentelemetry/sdk-node"));
|
|
30
|
+
const instrumentation_http_1 = require("@opentelemetry/instrumentation-http");
|
|
31
|
+
const instrumentation_express_1 = require("@opentelemetry/instrumentation-express");
|
|
32
|
+
const api_1 = require("@opentelemetry/api");
|
|
33
|
+
const TRACE_SERVER_URL = process.env['TRACE_SERVER_URL'];
|
|
34
|
+
const TRACE_TAG_SERVICENAME = process.env['TRACE_TAG_SERVICENAME'] || '';
|
|
35
|
+
const TRACE_TAG_SCOPE = process.env['TRACE_TAG_SCOPE'] || '';
|
|
36
|
+
const TRACE_TAG_ENV = process.env['TRACE_TAG_ENV'] || '';
|
|
37
|
+
const TRACE_TAG_CLUSTER = process.env['TRACE_TAG_CLUSTER'] || '';
|
|
38
|
+
const TRACE_TAG_TENANT = process.env['TRACE_TAG_TENANT'] || '';
|
|
39
|
+
const TRACE_TAG_SERVICE = process.env['TRACE_TAG_SERVICE'] || '';
|
|
40
|
+
const TRACE_TAG_VERSION = process.env['TRACE_TAG_VERSION'] || '';
|
|
41
|
+
const TRACE_TAG_OWNER = process.env['TRACE_TAG_OWNER'] || '';
|
|
42
|
+
console.log('AQUIII');
|
|
43
|
+
api_1.diag.setLogger(new api_1.DiagConsoleLogger(), api_1.DiagLogLevel.INFO);
|
|
44
|
+
console.log('EXECUTOU', TRACE_SERVER_URL);
|
|
45
|
+
if (TRACE_SERVER_URL) {
|
|
46
|
+
const collectorOptions = {
|
|
47
|
+
url: `https://${TRACE_SERVER_URL}/v1/traces`,
|
|
48
|
+
concurrencyLimit: 10,
|
|
49
|
+
};
|
|
50
|
+
const addEnvAttributes = (span) => {
|
|
51
|
+
span.setAttributes({
|
|
52
|
+
['SCOPE']: TRACE_TAG_SCOPE,
|
|
53
|
+
['ENV']: TRACE_TAG_ENV,
|
|
54
|
+
['CLUSTER']: TRACE_TAG_CLUSTER,
|
|
55
|
+
['TENANT']: TRACE_TAG_TENANT,
|
|
56
|
+
['SERVICE']: TRACE_TAG_SERVICE,
|
|
57
|
+
['VERSION']: TRACE_TAG_VERSION,
|
|
58
|
+
['OWNER']: TRACE_TAG_OWNER,
|
|
59
|
+
['SERVICENAME']: TRACE_TAG_SERVICENAME,
|
|
60
|
+
});
|
|
61
|
+
};
|
|
62
|
+
const resource = resources_1.Resource.default().merge(new resources_1.Resource({
|
|
63
|
+
[semantic_conventions_1.SemanticResourceAttributes.DEPLOYMENT_ENVIRONMENT]: TRACE_TAG_ENV,
|
|
64
|
+
[semantic_conventions_1.SemanticResourceAttributes.SERVICE_NAME]: TRACE_TAG_SERVICE,
|
|
65
|
+
[semantic_conventions_1.SemanticResourceAttributes.SERVICE_NAMESPACE]: TRACE_TAG_SERVICENAME,
|
|
66
|
+
}));
|
|
67
|
+
const traceExporter = new exporter_trace_otlp_http_1.OTLPTraceExporter(collectorOptions);
|
|
68
|
+
const sdk = new opentelemetry.NodeSDK({
|
|
69
|
+
resource,
|
|
70
|
+
traceExporter,
|
|
71
|
+
instrumentations: [new instrumentation_http_1.HttpInstrumentation({
|
|
72
|
+
applyCustomAttributesOnSpan: addEnvAttributes,
|
|
73
|
+
}), new instrumentation_express_1.ExpressInstrumentation({
|
|
74
|
+
requestHook: addEnvAttributes,
|
|
75
|
+
})],
|
|
76
|
+
});
|
|
77
|
+
sdk
|
|
78
|
+
.start()
|
|
79
|
+
.then(() => console.log(`Tracing initialized: ${TRACE_TAG_SERVICENAME} shipping to ${TRACE_SERVER_URL}`))
|
|
80
|
+
.catch((error) => console.log("Error initializing tracing", error));
|
|
81
|
+
process.on("SIGTERM", () => {
|
|
82
|
+
sdk
|
|
83
|
+
.shutdown()
|
|
84
|
+
.then(() => console.log("Tracing terminated"))
|
|
85
|
+
.catch((error) => console.log("Error terminating tracing", error))
|
|
86
|
+
.finally(() => process.exit(0));
|
|
87
|
+
});
|
|
88
|
+
}
|
|
87
89
|
//# sourceMappingURL=otel.js.map
|
package/dist/otel.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"otel.js","sourceRoot":"","sources":["../src/otel.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAAA,sFAA4E;AAC5E,8EAAiF;AACjF,wDAAoD;AACpD,uEAAyD;AACzD,8EAA0E;AAC1E,oFAAgF;AAEhF,4CAA2E;AAG3E,MAAM,gBAAgB,GAAG,OAAO,CAAC,GAAG,CAAC,kBAAkB,C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
private scope;
|
|
4
|
-
private environment;
|
|
5
|
-
private cluster;
|
|
6
|
-
private tenant;
|
|
7
|
-
private service;
|
|
8
|
-
private version;
|
|
9
|
-
private owner;
|
|
10
|
-
private serviceName;
|
|
11
|
-
constructor(serverUrl?: string, scope?: string, environment?: string, cluster?: string, tenant?: string, service?: string, version?: string, owner?: string, serviceName?: string);
|
|
12
|
-
startTrace(): void;
|
|
13
|
-
}
|
|
14
|
-
export default APM;
|
|
1
|
+
declare class APM {
|
|
2
|
+
private serverUrl;
|
|
3
|
+
private scope;
|
|
4
|
+
private environment;
|
|
5
|
+
private cluster;
|
|
6
|
+
private tenant;
|
|
7
|
+
private service;
|
|
8
|
+
private version;
|
|
9
|
+
private owner;
|
|
10
|
+
private serviceName;
|
|
11
|
+
constructor(serverUrl?: string, scope?: string, environment?: string, cluster?: string, tenant?: string, service?: string, version?: string, owner?: string, serviceName?: string);
|
|
12
|
+
startTrace(): void;
|
|
13
|
+
}
|
|
14
|
+
export default APM;
|
package/dist/services/APM.js
CHANGED
|
@@ -1,58 +1,58 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const config_1 = require("@edirect/config");
|
|
4
|
-
const exporter_trace_otlp_http_1 = require("@opentelemetry/exporter-trace-otlp-http");
|
|
5
|
-
const sdk_trace_base_1 = require("@opentelemetry/sdk-trace-base");
|
|
6
|
-
const sdk_trace_node_1 = require("@opentelemetry/sdk-trace-node");
|
|
7
|
-
const resources_1 = require("@opentelemetry/resources");
|
|
8
|
-
const semantic_conventions_1 = require("@opentelemetry/semantic-conventions");
|
|
9
|
-
const instrumentation_1 = require("@opentelemetry/instrumentation");
|
|
10
|
-
const instrumentation_http_1 = require("@opentelemetry/instrumentation-http");
|
|
11
|
-
const instrumentation_express_1 = require("@opentelemetry/instrumentation-express");
|
|
12
|
-
const config = new config_1.ConfigService(`.${process.env.NODE_ENV || 'development'}.env`);
|
|
13
|
-
const env = config.getConfig();
|
|
14
|
-
const TRACE_SERVER_URL = env['TRACE_SERVER_URL'];
|
|
15
|
-
const TRACE_TAG_SCOPE = env['TRACE_TAG_SCOPE'] || '';
|
|
16
|
-
const TRACE_TAG_ENV = env['TRACE_TAG_ENV'] || '';
|
|
17
|
-
const TRACE_TAG_CLUSTER = env['TRACE_TAG_CLUSTER'] || '';
|
|
18
|
-
const TRACE_TAG_TENANT = env['TRACE_TAG_TENANT'] || '';
|
|
19
|
-
const TRACE_TAG_SERVICE = env['TRACE_TAG_SERVICE'] || '';
|
|
20
|
-
const TRACE_TAG_VERSION = env['TRACE_TAG_VERSION'] || '';
|
|
21
|
-
const TRACE_TAG_OWNER = env['TRACE_TAG_OWNER'] || '';
|
|
22
|
-
const TRACE_TAG_SERVICENAME = env['TRACE_TAG_SERVICENAME'] || '';
|
|
23
|
-
class APM {
|
|
24
|
-
constructor(serverUrl = TRACE_SERVER_URL, scope = TRACE_TAG_SCOPE, environment = TRACE_TAG_ENV, cluster = TRACE_TAG_CLUSTER, tenant = TRACE_TAG_TENANT, service = TRACE_TAG_SERVICE, version = TRACE_TAG_VERSION, owner = TRACE_TAG_OWNER, serviceName = TRACE_TAG_SERVICENAME) {
|
|
25
|
-
this.serverUrl = serverUrl;
|
|
26
|
-
this.scope = scope;
|
|
27
|
-
this.environment = environment;
|
|
28
|
-
this.cluster = cluster;
|
|
29
|
-
this.tenant = tenant;
|
|
30
|
-
this.service = service;
|
|
31
|
-
this.version = version;
|
|
32
|
-
this.owner = owner;
|
|
33
|
-
this.serviceName = serviceName;
|
|
34
|
-
}
|
|
35
|
-
startTrace() {
|
|
36
|
-
if (!this.serverUrl)
|
|
37
|
-
return;
|
|
38
|
-
const exporter = new exporter_trace_otlp_http_1.OTLPTraceExporter({ url: `https://${this.serverUrl}/v1/traces` });
|
|
39
|
-
const provider = new sdk_trace_node_1.NodeTracerProvider({
|
|
40
|
-
resource: new resources_1.Resource(Object.assign({ [semantic_conventions_1.SemanticResourceAttributes.SERVICE_NAME]: this.serviceName }, { ['SCOPE']: this.scope, ['ENV']: this.environment, ['CLUSTER']: this.cluster, ['TENANT']: this.tenant, ['SERVICE']: this.service, ['VERSION']: this.version, ['OWNER']: this.owner, ['SERVICENAME']: this.serviceName })),
|
|
41
|
-
});
|
|
42
|
-
provider.addSpanProcessor(new sdk_trace_base_1.BatchSpanProcessor(exporter));
|
|
43
|
-
provider.register();
|
|
44
|
-
(0, instrumentation_1.registerInstrumentations)({
|
|
45
|
-
instrumentations: [
|
|
46
|
-
new instrumentation_http_1.HttpInstrumentation({
|
|
47
|
-
ignoreIncomingPaths: ['/healthcheck', 'healthcheck'],
|
|
48
|
-
}),
|
|
49
|
-
new instrumentation_express_1.ExpressInstrumentation({
|
|
50
|
-
ignoreLayers: ['/healthcheck', 'healthcheck'],
|
|
51
|
-
}),
|
|
52
|
-
],
|
|
53
|
-
});
|
|
54
|
-
return;
|
|
55
|
-
}
|
|
56
|
-
}
|
|
57
|
-
exports.default = APM;
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const config_1 = require("@edirect/config");
|
|
4
|
+
const exporter_trace_otlp_http_1 = require("@opentelemetry/exporter-trace-otlp-http");
|
|
5
|
+
const sdk_trace_base_1 = require("@opentelemetry/sdk-trace-base");
|
|
6
|
+
const sdk_trace_node_1 = require("@opentelemetry/sdk-trace-node");
|
|
7
|
+
const resources_1 = require("@opentelemetry/resources");
|
|
8
|
+
const semantic_conventions_1 = require("@opentelemetry/semantic-conventions");
|
|
9
|
+
const instrumentation_1 = require("@opentelemetry/instrumentation");
|
|
10
|
+
const instrumentation_http_1 = require("@opentelemetry/instrumentation-http");
|
|
11
|
+
const instrumentation_express_1 = require("@opentelemetry/instrumentation-express");
|
|
12
|
+
const config = new config_1.ConfigService(`.${process.env.NODE_ENV || 'development'}.env`);
|
|
13
|
+
const env = config.getConfig();
|
|
14
|
+
const TRACE_SERVER_URL = env['TRACE_SERVER_URL'];
|
|
15
|
+
const TRACE_TAG_SCOPE = env['TRACE_TAG_SCOPE'] || '';
|
|
16
|
+
const TRACE_TAG_ENV = env['TRACE_TAG_ENV'] || '';
|
|
17
|
+
const TRACE_TAG_CLUSTER = env['TRACE_TAG_CLUSTER'] || '';
|
|
18
|
+
const TRACE_TAG_TENANT = env['TRACE_TAG_TENANT'] || '';
|
|
19
|
+
const TRACE_TAG_SERVICE = env['TRACE_TAG_SERVICE'] || '';
|
|
20
|
+
const TRACE_TAG_VERSION = env['TRACE_TAG_VERSION'] || '';
|
|
21
|
+
const TRACE_TAG_OWNER = env['TRACE_TAG_OWNER'] || '';
|
|
22
|
+
const TRACE_TAG_SERVICENAME = env['TRACE_TAG_SERVICENAME'] || '';
|
|
23
|
+
class APM {
|
|
24
|
+
constructor(serverUrl = TRACE_SERVER_URL, scope = TRACE_TAG_SCOPE, environment = TRACE_TAG_ENV, cluster = TRACE_TAG_CLUSTER, tenant = TRACE_TAG_TENANT, service = TRACE_TAG_SERVICE, version = TRACE_TAG_VERSION, owner = TRACE_TAG_OWNER, serviceName = TRACE_TAG_SERVICENAME) {
|
|
25
|
+
this.serverUrl = serverUrl;
|
|
26
|
+
this.scope = scope;
|
|
27
|
+
this.environment = environment;
|
|
28
|
+
this.cluster = cluster;
|
|
29
|
+
this.tenant = tenant;
|
|
30
|
+
this.service = service;
|
|
31
|
+
this.version = version;
|
|
32
|
+
this.owner = owner;
|
|
33
|
+
this.serviceName = serviceName;
|
|
34
|
+
}
|
|
35
|
+
startTrace() {
|
|
36
|
+
if (!this.serverUrl)
|
|
37
|
+
return;
|
|
38
|
+
const exporter = new exporter_trace_otlp_http_1.OTLPTraceExporter({ url: `https://${this.serverUrl}/v1/traces` });
|
|
39
|
+
const provider = new sdk_trace_node_1.NodeTracerProvider({
|
|
40
|
+
resource: new resources_1.Resource(Object.assign({ [semantic_conventions_1.SemanticResourceAttributes.SERVICE_NAME]: this.serviceName }, { ['SCOPE']: this.scope, ['ENV']: this.environment, ['CLUSTER']: this.cluster, ['TENANT']: this.tenant, ['SERVICE']: this.service, ['VERSION']: this.version, ['OWNER']: this.owner, ['SERVICENAME']: this.serviceName })),
|
|
41
|
+
});
|
|
42
|
+
provider.addSpanProcessor(new sdk_trace_base_1.BatchSpanProcessor(exporter));
|
|
43
|
+
provider.register();
|
|
44
|
+
(0, instrumentation_1.registerInstrumentations)({
|
|
45
|
+
instrumentations: [
|
|
46
|
+
new instrumentation_http_1.HttpInstrumentation({
|
|
47
|
+
ignoreIncomingPaths: ['/healthcheck', 'healthcheck'],
|
|
48
|
+
}),
|
|
49
|
+
new instrumentation_express_1.ExpressInstrumentation({
|
|
50
|
+
ignoreLayers: ['/healthcheck', 'healthcheck'],
|
|
51
|
+
}),
|
|
52
|
+
],
|
|
53
|
+
});
|
|
54
|
+
return;
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
exports.default = APM;
|
|
58
58
|
//# sourceMappingURL=APM.js.map
|
package/dist/services/index.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export { default as APM } from './APM';
|
|
1
|
+
export { default as APM } from './APM';
|
package/dist/services/index.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.APM = void 0;
|
|
7
|
-
var APM_1 = require("./APM");
|
|
8
|
-
Object.defineProperty(exports, "APM", { enumerable: true, get: function () { return __importDefault(APM_1).default; } });
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.APM = void 0;
|
|
7
|
+
var APM_1 = require("./APM");
|
|
8
|
+
Object.defineProperty(exports, "APM", { enumerable: true, get: function () { return __importDefault(APM_1).default; } });
|
|
9
9
|
//# sourceMappingURL=index.js.map
|