@nimee/initialize-ms 1.0.47 → 1.0.49
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/dist/src/index.js +16 -0
- package/dist/src/index.js.map +1 -1
- package/dist/src/tracerCoralogix.d.ts +7 -0
- package/dist/src/tracerCoralogix.js +48 -0
- package/dist/src/tracerCoralogix.js.map +1 -0
- package/package.json +4 -5
- package/src/index.ts +16 -0
- package/src/tracerCoralogix.ts +45 -0
- package/src/tracer.ts +0 -68
package/dist/src/index.js
CHANGED
|
@@ -12,6 +12,22 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
12
12
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
13
|
};
|
|
14
14
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
+
const tracerCoralogix_1 = __importDefault(require("./tracerCoralogix"));
|
|
16
|
+
// import initialize from "helios-opentelemetry-sdk";
|
|
17
|
+
// const helios = initialize({
|
|
18
|
+
// apiToken: process.env.heliosApiToken,
|
|
19
|
+
// serviceName: `${process.env.SERVICE_NAME}`,
|
|
20
|
+
// environment: process.env.NODE_ENV,
|
|
21
|
+
// enable: true,
|
|
22
|
+
// collectorEndpoint: process.env.GRAFANA_OTEL_EXPORTER_URL,
|
|
23
|
+
// ignoredIncomingPaths: [/\/readiness/, /\/liveness/, /\/metrics/],
|
|
24
|
+
// });
|
|
25
|
+
const tracer = new tracerCoralogix_1.default();
|
|
26
|
+
tracer.init({
|
|
27
|
+
serviceName: process.env.SERVICE_NAME,
|
|
28
|
+
environment: process.env.NODE_ENV,
|
|
29
|
+
basicAuth: "cxtp_XF0BuYWEG9KNGKkT1pYw7by14dV0Bc",
|
|
30
|
+
});
|
|
15
31
|
// import tracer from "./tracer";
|
|
16
32
|
// import initialize from "helios-opentelemetry-sdk";
|
|
17
33
|
// if (process.env.NODE_ENV !== "local") {
|
package/dist/src/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
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AAoF;YACtF,CAAC;YACD,4BAAY,CAAC,0BAA0B,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;YACrD,MAAM,IAAI,gBAAa,CAAC,IAAI,CAAC,MAAM,EAAE,SAAS,CAAC,CAAC,KAAK,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC;YACxE,gCAAsB,CAAC,8BAA8B,CAAC,IAAI,CAAC,MAAM,EAAE,UAAU,EAAE,IAAI,EAAE,OAAO,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC;YAE3G,IAAI,sBAAsB,EAAE,CAAC;gBAC3B,MAAM,yBAAyB,GAAG,CAAC,sBAAsB,CAAC,CAAC;gBAC3D,yBAAyB,CAAC,OAAO,CAAC,CAAC,qBAAqB,EAAE,EAAE;oBAC1D,gBAAM,CAAC,IAAI,CAAC,mDAAmD,IAAI,CAAC,WAAW,KAAK,CAAC,CAAC;oBACtF,IAAI,qBAAqB,EAAE,CAAC,UAAU,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;gBACtD,CAAC,CAAC,CAAC;gBACH,gBAAM,CAAC,IAAI,CAAC,sCAAsC,IAAI,CAAC,WAAW,KAAK,CAAC,CAAC;YAC3E,CAAC;YACD,IAAI,UAAU;gBAAE,MAAM,OAAO,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;QAC7C,CAAC;KAAA;CACF;AAED,kBAAe,cAAc,CAAC"}
|
|
@@ -0,0 +1,48 @@
|
|
|
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
|
+
const { NodeSDK } = require("@opentelemetry/sdk-node"); // Add this line
|
|
7
|
+
const { AlwaysOnSampler } = require("@opentelemetry/sdk-trace-base");
|
|
8
|
+
const { diag, DiagConsoleLogger, DiagLogLevel } = require("@opentelemetry/api");
|
|
9
|
+
const opentelemetry_1 = require("@coralogix/opentelemetry");
|
|
10
|
+
const { Resource } = require("@opentelemetry/resources");
|
|
11
|
+
const { SemanticResourceAttributes } = require("@opentelemetry/semantic-conventions");
|
|
12
|
+
const { getNodeAutoInstrumentations } = require("@opentelemetry/auto-instrumentations-node");
|
|
13
|
+
// Optional libraries for metrics configuration
|
|
14
|
+
const { OTLPMetricExporter } = require("@opentelemetry/exporter-metrics-otlp-proto");
|
|
15
|
+
const { PeriodicExportingMetricReader } = require("@opentelemetry/sdk-metrics");
|
|
16
|
+
const { HttpInstrumentation } = require("@opentelemetry/instrumentation-http");
|
|
17
|
+
const { FastifyInstrumentation } = require("@opentelemetry/instrumentation-fastify");
|
|
18
|
+
const logger_1 = __importDefault(require("@nimee/logger"));
|
|
19
|
+
class TracerCoralogix {
|
|
20
|
+
init({ serviceName, environment, basicAuth }) {
|
|
21
|
+
try {
|
|
22
|
+
logger_1.default.info(`Initializing the new tracer with the service name: ${serviceName} and node environment: ${environment}`);
|
|
23
|
+
diag.setLogger(new DiagConsoleLogger(), DiagLogLevel.DEBUG);
|
|
24
|
+
// Now we"ll initialize the OTEL sdk:
|
|
25
|
+
const sdk = new NodeSDK({
|
|
26
|
+
// // Optional resource configuration section
|
|
27
|
+
resource: new Resource({
|
|
28
|
+
[SemanticResourceAttributes.SERVICE_NAME]: serviceName,
|
|
29
|
+
[SemanticResourceAttributes.SERVICE_VERSION]: "1.0",
|
|
30
|
+
}),
|
|
31
|
+
// Optional metrics configuration section
|
|
32
|
+
metricReader: new PeriodicExportingMetricReader({
|
|
33
|
+
exporter: new OTLPMetricExporter({
|
|
34
|
+
concurrencyLimit: 1,
|
|
35
|
+
}),
|
|
36
|
+
}),
|
|
37
|
+
sampler: new opentelemetry_1.CoralogixTransactionSampler(new AlwaysOnSampler()),
|
|
38
|
+
instrumentations: [new HttpInstrumentation(), new FastifyInstrumentation()],
|
|
39
|
+
});
|
|
40
|
+
sdk.start();
|
|
41
|
+
}
|
|
42
|
+
catch (error) {
|
|
43
|
+
logger_1.default.error(`Error initializing the new tracer: ${error}`);
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
exports.default = TracerCoralogix;
|
|
48
|
+
//# sourceMappingURL=tracerCoralogix.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tracerCoralogix.js","sourceRoot":"","sources":["../../src/tracerCoralogix.ts"],"names":[],"mappings":";;;;;AAAA,MAAM,EAAE,OAAO,EAAE,GAAG,OAAO,CAAC,yBAAyB,CAAC,CAAC,CAAC,gBAAgB;AACxE,MAAM,EAAE,eAAe,EAAE,GAAG,OAAO,CAAC,+BAA+B,CAAC,CAAC;AAErE,MAAM,EAAE,IAAI,EAAE,iBAAiB,EAAE,YAAY,EAAE,GAAG,OAAO,CAAC,oBAAoB,CAAC,CAAC;AAChF,4DAAuE;AACvE,MAAM,EAAE,QAAQ,EAAE,GAAG,OAAO,CAAC,0BAA0B,CAAC,CAAC;AACzD,MAAM,EAAE,0BAA0B,EAAE,GAAG,OAAO,CAAC,qCAAqC,CAAC,CAAC;AACtF,MAAM,EAAE,2BAA2B,EAAE,GAAG,OAAO,CAAC,2CAA2C,CAAC,CAAC;AAE7F,+CAA+C;AAC/C,MAAM,EAAE,kBAAkB,EAAE,GAAG,OAAO,CAAC,4CAA4C,CAAC,CAAC;AACrF,MAAM,EAAE,6BAA6B,EAAE,GAAG,OAAO,CAAC,4BAA4B,CAAC,CAAC;AAChF,MAAM,EAAE,mBAAmB,EAAE,GAAG,OAAO,CAAC,qCAAqC,CAAC,CAAC;AAC/E,MAAM,EAAE,sBAAsB,EAAE,GAAG,OAAO,CAAC,wCAAwC,CAAC,CAAC;AAErF,2DAAmC;AACnC,MAAqB,eAAe;IAC3B,IAAI,CAAC,EAAE,WAAW,EAAE,WAAW,EAAE,SAAS,EAAmE;QAClH,IAAI,CAAC;YACH,gBAAM,CAAC,IAAI,CAAC,sDAAsD,WAAW,0BAA0B,WAAW,EAAE,CAAC,CAAC;YACtH,IAAI,CAAC,SAAS,CAAC,IAAI,iBAAiB,EAAE,EAAE,YAAY,CAAC,KAAK,CAAC,CAAC;YAE5D,qCAAqC;YACrC,MAAM,GAAG,GAAG,IAAI,OAAO,CAAC;gBACtB,6CAA6C;gBAC7C,QAAQ,EAAE,IAAI,QAAQ,CAAC;oBACrB,CAAC,0BAA0B,CAAC,YAAY,CAAC,EAAE,WAAW;oBACtD,CAAC,0BAA0B,CAAC,eAAe,CAAC,EAAE,KAAK;iBACpD,CAAC;gBACF,yCAAyC;gBACzC,YAAY,EAAE,IAAI,6BAA6B,CAAC;oBAC9C,QAAQ,EAAE,IAAI,kBAAkB,CAAC;wBAC/B,gBAAgB,EAAE,CAAC;qBACpB,CAAC;iBACH,CAAC;gBACF,OAAO,EAAE,IAAI,2CAA2B,CAAC,IAAI,eAAe,EAAE,CAAC;gBAC/D,gBAAgB,EAAE,CAAC,IAAI,mBAAmB,EAAE,EAAE,IAAI,sBAAsB,EAAE,CAAC;aAC5E,CAAC,CAAC;YAEH,GAAG,CAAC,KAAK,EAAE,CAAC;QACd,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,gBAAM,CAAC,KAAK,CAAC,sCAAsC,KAAK,EAAE,CAAC,CAAC;QAC9D,CAAC;IACH,CAAC;CACF;AA5BD,kCA4BC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nimee/initialize-ms",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.49",
|
|
4
4
|
"description": "init behavior for each ms",
|
|
5
5
|
"main": "dist/src/index.js",
|
|
6
6
|
"author": "dan goldberg",
|
|
@@ -28,6 +28,7 @@
|
|
|
28
28
|
},
|
|
29
29
|
"types": "dist/src/index.d.ts",
|
|
30
30
|
"dependencies": {
|
|
31
|
+
"@coralogix/opentelemetry": "^0.1.3",
|
|
31
32
|
"@fastify/basic-auth": "^5.1.1",
|
|
32
33
|
"@fastify/cors": "^8.1.1",
|
|
33
34
|
"@fastify/request-context": "^5.0.0",
|
|
@@ -39,9 +40,8 @@
|
|
|
39
40
|
"@nimee/metrics": "2.0.13",
|
|
40
41
|
"@opentelemetry/api": "^1.7.0",
|
|
41
42
|
"@opentelemetry/auto-instrumentations-node": "^0.41.1",
|
|
42
|
-
"@opentelemetry/exporter-
|
|
43
|
-
"@opentelemetry/exporter-trace-otlp-
|
|
44
|
-
"@opentelemetry/exporter-trace-otlp-proto": "^0.47.0",
|
|
43
|
+
"@opentelemetry/exporter-metrics-otlp-proto": "^0.54.0",
|
|
44
|
+
"@opentelemetry/exporter-trace-otlp-proto": "^0.54.0",
|
|
45
45
|
"@opentelemetry/instrumentation-fastify": "^0.34.0",
|
|
46
46
|
"@opentelemetry/instrumentation-http": "^0.49.1",
|
|
47
47
|
"@opentelemetry/resources": "^1.20.0",
|
|
@@ -49,7 +49,6 @@
|
|
|
49
49
|
"@opentelemetry/sdk-trace-base": "^1.20.0",
|
|
50
50
|
"@opentelemetry/sdk-trace-node": "^1.21.0",
|
|
51
51
|
"fastify": "4.24.3",
|
|
52
|
-
"helios-opentelemetry-sdk": "^1.0.91",
|
|
53
52
|
"mongoose": "6.2.10"
|
|
54
53
|
}
|
|
55
54
|
}
|
package/src/index.ts
CHANGED
|
@@ -1,3 +1,19 @@
|
|
|
1
|
+
import TracerCoralogix from "./tracerCoralogix";
|
|
2
|
+
// import initialize from "helios-opentelemetry-sdk";
|
|
3
|
+
// const helios = initialize({
|
|
4
|
+
// apiToken: process.env.heliosApiToken,
|
|
5
|
+
// serviceName: `${process.env.SERVICE_NAME}`,
|
|
6
|
+
// environment: process.env.NODE_ENV,
|
|
7
|
+
// enable: true,
|
|
8
|
+
// collectorEndpoint: process.env.GRAFANA_OTEL_EXPORTER_URL,
|
|
9
|
+
// ignoredIncomingPaths: [/\/readiness/, /\/liveness/, /\/metrics/],
|
|
10
|
+
// });
|
|
11
|
+
const tracer = new TracerCoralogix();
|
|
12
|
+
tracer.init({
|
|
13
|
+
serviceName: process.env.SERVICE_NAME,
|
|
14
|
+
environment: process.env.NODE_ENV,
|
|
15
|
+
basicAuth: "cxtp_XF0BuYWEG9KNGKkT1pYw7by14dV0Bc",
|
|
16
|
+
});
|
|
1
17
|
// import tracer from "./tracer";
|
|
2
18
|
// import initialize from "helios-opentelemetry-sdk";
|
|
3
19
|
// if (process.env.NODE_ENV !== "local") {
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
const { NodeSDK } = require("@opentelemetry/sdk-node"); // Add this line
|
|
2
|
+
const { AlwaysOnSampler } = require("@opentelemetry/sdk-trace-base");
|
|
3
|
+
|
|
4
|
+
const { diag, DiagConsoleLogger, DiagLogLevel } = require("@opentelemetry/api");
|
|
5
|
+
import { CoralogixTransactionSampler } from "@coralogix/opentelemetry";
|
|
6
|
+
const { Resource } = require("@opentelemetry/resources");
|
|
7
|
+
const { SemanticResourceAttributes } = require("@opentelemetry/semantic-conventions");
|
|
8
|
+
const { getNodeAutoInstrumentations } = require("@opentelemetry/auto-instrumentations-node");
|
|
9
|
+
|
|
10
|
+
// Optional libraries for metrics configuration
|
|
11
|
+
const { OTLPMetricExporter } = require("@opentelemetry/exporter-metrics-otlp-proto");
|
|
12
|
+
const { PeriodicExportingMetricReader } = require("@opentelemetry/sdk-metrics");
|
|
13
|
+
const { HttpInstrumentation } = require("@opentelemetry/instrumentation-http");
|
|
14
|
+
const { FastifyInstrumentation } = require("@opentelemetry/instrumentation-fastify");
|
|
15
|
+
|
|
16
|
+
import logger from "@nimee/logger";
|
|
17
|
+
export default class TracerCoralogix {
|
|
18
|
+
public init({ serviceName, environment, basicAuth }: { serviceName: string; environment: string; basicAuth: string }) {
|
|
19
|
+
try {
|
|
20
|
+
logger.info(`Initializing the new tracer with the service name: ${serviceName} and node environment: ${environment}`);
|
|
21
|
+
diag.setLogger(new DiagConsoleLogger(), DiagLogLevel.DEBUG);
|
|
22
|
+
|
|
23
|
+
// Now we"ll initialize the OTEL sdk:
|
|
24
|
+
const sdk = new NodeSDK({
|
|
25
|
+
// // Optional resource configuration section
|
|
26
|
+
resource: new Resource({
|
|
27
|
+
[SemanticResourceAttributes.SERVICE_NAME]: serviceName,
|
|
28
|
+
[SemanticResourceAttributes.SERVICE_VERSION]: "1.0",
|
|
29
|
+
}),
|
|
30
|
+
// Optional metrics configuration section
|
|
31
|
+
metricReader: new PeriodicExportingMetricReader({
|
|
32
|
+
exporter: new OTLPMetricExporter({
|
|
33
|
+
concurrencyLimit: 1,
|
|
34
|
+
}),
|
|
35
|
+
}),
|
|
36
|
+
sampler: new CoralogixTransactionSampler(new AlwaysOnSampler()),
|
|
37
|
+
instrumentations: [new HttpInstrumentation(), new FastifyInstrumentation()],
|
|
38
|
+
});
|
|
39
|
+
|
|
40
|
+
sdk.start();
|
|
41
|
+
} catch (error) {
|
|
42
|
+
logger.error(`Error initializing the new tracer: ${error}`);
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
}
|
package/src/tracer.ts
DELETED
|
@@ -1,68 +0,0 @@
|
|
|
1
|
-
import { OTLPTraceExporter } from "@opentelemetry/exporter-trace-otlp-grpc";
|
|
2
|
-
import { SimpleSpanProcessor } from "@opentelemetry/sdk-trace-node";
|
|
3
|
-
const grpc = require("@grpc/grpc-js");
|
|
4
|
-
|
|
5
|
-
import logger from "@nimee/logger";
|
|
6
|
-
class Tracer {
|
|
7
|
-
private provider: any;
|
|
8
|
-
|
|
9
|
-
public init({
|
|
10
|
-
serviceName,
|
|
11
|
-
url,
|
|
12
|
-
environment,
|
|
13
|
-
basicAuth,
|
|
14
|
-
helios,
|
|
15
|
-
}: {
|
|
16
|
-
serviceName: string;
|
|
17
|
-
url: string;
|
|
18
|
-
environment: string;
|
|
19
|
-
basicAuth: string;
|
|
20
|
-
helios: any;
|
|
21
|
-
}) {
|
|
22
|
-
try {
|
|
23
|
-
const metadata = new grpc.Metadata();
|
|
24
|
-
// after "Basic", comes the output of:
|
|
25
|
-
// echo -n username:password | base64 -w 0
|
|
26
|
-
metadata.set("authorization", basicAuth);
|
|
27
|
-
|
|
28
|
-
const exporter = new OTLPTraceExporter({
|
|
29
|
-
url: url,
|
|
30
|
-
credentials: grpc.credentials.createSsl(),
|
|
31
|
-
metadata,
|
|
32
|
-
});
|
|
33
|
-
this.provider = helios;
|
|
34
|
-
|
|
35
|
-
// this.provider = new BasicTracerProvider({
|
|
36
|
-
// resource: new Resource({
|
|
37
|
-
// [SemanticResourceAttributes.SERVICE_NAME]: serviceName,
|
|
38
|
-
// [SemanticResourceAttributes.SERVICE_VERSION]: "1.0.0",
|
|
39
|
-
// [SemanticResourceAttributes.DEPLOYMENT_ENVIRONMENT]: environment,
|
|
40
|
-
// [SemanticResourceAttributes.TELEMETRY_SDK_LANGUAGE]: "node",
|
|
41
|
-
// }),
|
|
42
|
-
// });
|
|
43
|
-
// export spans to console (useful for debugging)s
|
|
44
|
-
// this.provider.addSpanProcessor(new SimpleSpanProcessor(new ConsoleSpanExporter()));
|
|
45
|
-
// export spans to opentelemetry collector
|
|
46
|
-
this.provider.addSpanProcessor(new SimpleSpanProcessor(exporter));
|
|
47
|
-
// this.provider.register();
|
|
48
|
-
// this.sdk = new NodeSDK({
|
|
49
|
-
// traceExporter: exporter,
|
|
50
|
-
// instrumentations: [
|
|
51
|
-
// getNodeAutoInstrumentations({
|
|
52
|
-
// // Lets disable fs for now, otherwise we cannot see the traces we want,
|
|
53
|
-
// // You can disable or enable instrumentation as needed
|
|
54
|
-
// "@opentelemetry/instrumentation-fs": { enabled: false },
|
|
55
|
-
// }),
|
|
56
|
-
// ],
|
|
57
|
-
// });
|
|
58
|
-
|
|
59
|
-
// this.sdk.start();
|
|
60
|
-
|
|
61
|
-
logger.info(`The tracer has been initialized with the service name: ${serviceName} and node environment: ${environment}`);
|
|
62
|
-
} catch (e) {
|
|
63
|
-
logger.error(`Failed to initialize the trace with error: ${e}`);
|
|
64
|
-
}
|
|
65
|
-
}
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
export default new Tracer();
|