diff --git a/.eslintrc.json b/.eslintrc.json index e57a95e4..34d4ef7f 100644 --- a/.eslintrc.json +++ b/.eslintrc.json @@ -12,8 +12,7 @@ "es2022": true // Defines `Promise`, etc. }, "extends": [ - // XXX - // "plugin:prettier/recommended", // comment this out to check without style + "plugin:prettier/recommended", // comment this out to check without style "eslint:recommended" ], "plugins": [ diff --git a/packages/mockotlpserver/examples/simple-http-server.js b/packages/mockotlpserver/examples/simple-http-server.js index eb886e9e..7154a042 100644 --- a/packages/mockotlpserver/examples/simple-http-server.js +++ b/packages/mockotlpserver/examples/simple-http-server.js @@ -2,42 +2,50 @@ // NOTE: For simplicity we added the instrumentation coee in the same file // have a commmand line arg to decide the exporter? -const { NodeSDK } = require('@opentelemetry/sdk-node'); +const {NodeSDK} = require('@opentelemetry/sdk-node'); // const { ConsoleSpanExporter } = require('@opentelemetry/sdk-trace-node'); -const { OTLPTraceExporter: OTLPTraceExporterHttp } = require('@opentelemetry/exporter-trace-otlp-http'); -const { OTLPTraceExporter: OTLPTraceExporterProto } = require('@opentelemetry/exporter-trace-otlp-proto'); -const { OTLPTraceExporter: OTLPTraceExporterGrpc } = require('@opentelemetry/exporter-trace-otlp-grpc'); const { - getNodeAutoInstrumentations, + OTLPTraceExporter: OTLPTraceExporterHttp, +} = require('@opentelemetry/exporter-trace-otlp-http'); +const { + OTLPTraceExporter: OTLPTraceExporterProto, +} = require('@opentelemetry/exporter-trace-otlp-proto'); +const { + OTLPTraceExporter: OTLPTraceExporterGrpc, +} = require('@opentelemetry/exporter-trace-otlp-grpc'); +const { + getNodeAutoInstrumentations, } = require('@opentelemetry/auto-instrumentations-node'); // TODO make this flavor configurable let otlpFlavor = 'grpc'; const OTLPTraceExporter = { - http: OTLPTraceExporterHttp, - proto: OTLPTraceExporterProto, - grpc: OTLPTraceExporterGrpc + http: OTLPTraceExporterHttp, + proto: OTLPTraceExporterProto, + grpc: OTLPTraceExporterGrpc, }[otlpFlavor]; const sdk = new NodeSDK({ - // traceExporter: new ConsoleSpanExporter(), - traceExporter: new OTLPTraceExporter(), - instrumentations: [getNodeAutoInstrumentations({ - // To reduce noise in the console since we just want - // http and mongodb spans - "@opentelemetry/instrumentation-fs": { - enabled: false, - }, - "@opentelemetry/instrumentation-connect": { - enabled:false, - }, - "@opentelemetry/instrumentation-net": { - enabled: false, - }, - "@opentelemetry/instrumentation-dns": { - enabled: false, - } - })], + // traceExporter: new ConsoleSpanExporter(), + traceExporter: new OTLPTraceExporter(), + instrumentations: [ + getNodeAutoInstrumentations({ + // To reduce noise in the console since we just want + // http and mongodb spans + '@opentelemetry/instrumentation-fs': { + enabled: false, + }, + '@opentelemetry/instrumentation-connect': { + enabled: false, + }, + '@opentelemetry/instrumentation-net': { + enabled: false, + }, + '@opentelemetry/instrumentation-dns': { + enabled: false, + }, + }), + ], }); sdk.start(); diff --git a/packages/mockotlpserver/lib/client.js b/packages/mockotlpserver/lib/client.js index 02035959..9ac2b02e 100644 --- a/packages/mockotlpserver/lib/client.js +++ b/packages/mockotlpserver/lib/client.js @@ -1,4 +1,4 @@ -const { resolve } = require('path'); +const {resolve} = require('path'); const grpc = require('@grpc/grpc-js'); const loader = require('@grpc/proto-loader'); @@ -6,54 +6,57 @@ const loader = require('@grpc/proto-loader'); const prefix = resolve(__dirname, '../opentelemetry/proto'); const pkgsBase = resolve(__dirname, '..'); const traceDefinition = loader.loadSync( - `${prefix}/collector/trace/v1/trace_service.proto`, - { - includeDirs: [pkgsBase] - } + `${prefix}/collector/trace/v1/trace_service.proto`, + { + includeDirs: [pkgsBase], + } ); const traceDescriptor = grpc.loadPackageDefinition(traceDefinition); const traceNamespace = traceDescriptor.opentelemetry.proto.collector.trace.v1; const client = new traceNamespace.TraceService( - "localhost:4317", - grpc.credentials.createInsecure() + 'localhost:4317', + grpc.credentials.createInsecure() ); -client.Export({ - resourceSpans: [ +client.Export( { - resource: { - "attributes": [ - { - "key": "service.name", - "value": { - "stringValue": "unknown_service:node" - } - }, - { - "key": "telemetry.sdk.language", - "value": { - "stringValue": "nodejs" - } - }, - { - "key": "telemetry.sdk.name", - "value": { - "stringValue": "opentelemetry" - } - }, - { - "key": "telemetry.sdk.version", - "value": { - "stringValue": "1.15.2" - } - }, + resourceSpans: [ + { + resource: { + attributes: [ + { + key: 'service.name', + value: { + stringValue: 'unknown_service:node', + }, + }, + { + key: 'telemetry.sdk.language', + value: { + stringValue: 'nodejs', + }, + }, + { + key: 'telemetry.sdk.name', + value: { + stringValue: 'opentelemetry', + }, + }, + { + key: 'telemetry.sdk.version', + value: { + stringValue: '1.15.2', + }, + }, + ], + droppedAttributesCount: 0, + }, + }, ], - "droppedAttributesCount": 0 - } + }, + (err, response) => { + console.log('From server error', err); + console.log('From server response', response); } - ] -}, (err, response) => { - console.log("From server error", err); - console.log("From server response", response); -}) +); diff --git a/packages/mockotlpserver/lib/grpc.js b/packages/mockotlpserver/lib/grpc.js index e597a7dc..0ad0e48c 100644 --- a/packages/mockotlpserver/lib/grpc.js +++ b/packages/mockotlpserver/lib/grpc.js @@ -1,4 +1,4 @@ -const { resolve } = require('path'); +const {resolve} = require('path'); const grpc = require('@grpc/grpc-js'); const loader = require('@grpc/proto-loader'); @@ -9,31 +9,33 @@ const loader = require('@grpc/proto-loader'); const prefix = resolve(__dirname, '../opentelemetry/proto'); const pkgsBase = resolve(__dirname, '..'); const packages = { - logs: '/collector/logs/v1/logs_service.proto', - metrics: '/collector/metrics/v1/metrics_service.proto', - trace: '/collector/trace/v1/trace_service.proto', + logs: '/collector/logs/v1/logs_service.proto', + metrics: '/collector/metrics/v1/metrics_service.proto', + trace: '/collector/trace/v1/trace_service.proto', }; for (const [name, path] of Object.entries(packages)) { - const definition = loader.loadSync(`${prefix}${path}`, { includeDirs: [pkgsBase] }); - const descriptor = grpc.loadPackageDefinition(definition); - const namespace = descriptor.opentelemetry.proto.collector[name].v1 + const definition = loader.loadSync(`${prefix}${path}`, { + includeDirs: [pkgsBase], + }); + const descriptor = grpc.loadPackageDefinition(definition); + const namespace = descriptor.opentelemetry.proto.collector[name].v1; - packages[name] = namespace; + packages[name] = namespace; } // helper functions function intakeTraces(call, callback) { - const tracesReq = call.request; - // console.log('grpc spans', tracesReq); - console.dir(tracesReq, { depth: 5 }); - - callback(null, { - partial_success: { - rejected_spans: 0, - } - }); + const tracesReq = call.request; + // console.log('grpc spans', tracesReq); + console.dir(tracesReq, {depth: 5}); + + callback(null, { + partial_success: { + rejected_spans: 0, + }, + }); } // function intakeMetrics(call, callback) { @@ -44,7 +46,6 @@ function intakeTraces(call, callback) { // // TODO: check proto // } - /** * * @param {Object} options @@ -52,22 +53,24 @@ function intakeTraces(call, callback) { * @param {number} options.port */ function startGrpc(options) { - const { hostname, port } = options; - const grpcServer = new grpc.Server(); - - console.log(packages.trace.TraceService) - grpcServer.addService(packages.trace.TraceService.service, { - Export: intakeTraces, - }); - - grpcServer.bindAsync(`${hostname}:${port}`, grpc.ServerCredentials.createInsecure(), () => { - console.log('grpc started', port); - grpcServer.start(); - }); - + const {hostname, port} = options; + const grpcServer = new grpc.Server(); + + console.log(packages.trace.TraceService); + grpcServer.addService(packages.trace.TraceService.service, { + Export: intakeTraces, + }); + + grpcServer.bindAsync( + `${hostname}:${port}`, + grpc.ServerCredentials.createInsecure(), + () => { + console.log('grpc started', port); + grpcServer.start(); + } + ); } - module.exports = { - startGrpc, + startGrpc, }; diff --git a/packages/mockotlpserver/lib/http.js b/packages/mockotlpserver/lib/http.js index 7d1cb665..3702b5a4 100644 --- a/packages/mockotlpserver/lib/http.js +++ b/packages/mockotlpserver/lib/http.js @@ -4,8 +4,8 @@ const path = require('path'); const protobuf = require('protobufjs'); const parsersMap = { - 'application/json': jsonParser, - 'application/x-protobuf': protoParser, + 'application/json': jsonParser, + 'application/x-protobuf': protoParser, }; // TODO: for now `proto` files are copied from @@ -13,30 +13,31 @@ const parsersMap = { // but maybe its better to have a submodule like otel-js does const prefix = path.resolve(__dirname, '../opentelemetry/proto/'); const paths = [ - '/common/v1/common.proto', - '/resource/v1/resource.proto', - '/logs/v1/logs.proto', - '/metrics/v1/metrics.proto', - '/trace/v1/trace.proto', - '/collector/logs/v1/logs_service.proto', - '/collector/metrics/v1/metrics_service.proto', - '/collector/trace/v1/trace_service.proto', + '/common/v1/common.proto', + '/resource/v1/resource.proto', + '/logs/v1/logs.proto', + '/metrics/v1/metrics.proto', + '/trace/v1/trace.proto', + '/collector/logs/v1/logs_service.proto', + '/collector/metrics/v1/metrics_service.proto', + '/collector/trace/v1/trace_service.proto', ]; let root; for (const p of paths) { - root = protobuf.loadSync(`${prefix}${p}`, root); + root = protobuf.loadSync(`${prefix}${p}`, root); } - // helper functions function badRequest(res) { - res.writeHead(400); - res.end(JSON.stringify({ - error: { - code: 400, - message: 'Invalid or no data received', - }, - })); + res.writeHead(400); + res.end( + JSON.stringify({ + error: { + code: 400, + message: 'Invalid or no data received', + }, + }) + ); } /** @@ -45,11 +46,11 @@ function badRequest(res) { * @param {http.IncomingMessage} req */ function jsonParser(buff, req) { - const reqText = buff.toString('utf-8'); + const reqText = buff.toString('utf-8'); - console.log('JSON parsing') - // NOTE: check for bignums - return JSON.parse(reqText); + console.log('JSON parsing'); + // NOTE: check for bignums + return JSON.parse(reqText); } /** @@ -58,22 +59,28 @@ function jsonParser(buff, req) { * @param {http.IncomingMessage} req */ function protoParser(buff, req) { - const pkgPrefix = 'opentelemetry.proto.collector'; - let decoder; - if (req.url === '/v1/logs') { - decoder = root.lookupType(`${pkgPrefix}.logs.v1.ExportLogsServiceRequest`); - } else if (req.url === '/v1/metrics') { - decoder = root.lookupType(`${pkgPrefix}.metrics.v1.ExportMetricsServiceRequest`); - } else if (req.url === '/v1/traces') { - console.log('PROTO parsing') - decoder = root.lookupType(`${pkgPrefix}.trace.v1.ExportTraceServiceRequest`); - } - - if (decoder) { - return decoder.decode(buff); - } - console.error(`no decoder found for ${req.url}`); - return {}; + const pkgPrefix = 'opentelemetry.proto.collector'; + let decoder; + if (req.url === '/v1/logs') { + decoder = root.lookupType( + `${pkgPrefix}.logs.v1.ExportLogsServiceRequest` + ); + } else if (req.url === '/v1/metrics') { + decoder = root.lookupType( + `${pkgPrefix}.metrics.v1.ExportMetricsServiceRequest` + ); + } else if (req.url === '/v1/traces') { + console.log('PROTO parsing'); + decoder = root.lookupType( + `${pkgPrefix}.trace.v1.ExportTraceServiceRequest` + ); + } + + if (decoder) { + return decoder.decode(buff); + } + console.error(`no decoder found for ${req.url}`); + return {}; } /** @@ -82,11 +89,10 @@ function protoParser(buff, req) { * @param {http.IncomingMessage} req */ function unknownParser(buff, req) { - const contentType = req.headers['content-type']; - console.log(`parser for ${contentType} not defined for url ${req.url}`); + const contentType = req.headers['content-type']; + console.log(`parser for ${contentType} not defined for url ${req.url}`); } - /** * * @param {Object} options @@ -94,48 +100,48 @@ function unknownParser(buff, req) { * @param {number} options.port */ function startHttp(options) { - const { hostname, port } = options; - const server = http.createServer((req, res) => { - const chunks = []; - req.on('data', (chunk) => chunks.push(chunk)); - req.on('end', () => { - // TODO: send back the proper error - if (chunks.length === 0) { - return badRequest(res); - } - - const contentType = req.headers['content-type']; - const parseData = parsersMap[contentType] || unknownParser; - const reqBuffer = Buffer.concat(chunks); - const data = parseData(reqBuffer, req); - - // TODO: this is the place to do something with the data based on - // console.log(data); - console.dir(data, { depth: 5 }); - - - // TODO: in future response may add some header to communicate back - // some information about - // - the collector - // - the config - // - something else - // PS: maybe collector could be able to tell the sdk/distro to stop sending - // because of: high load, sample rate changed, et al?? - res.writeHead(200); - res.end(JSON.stringify({ - ok: 1 - })); + const {hostname, port} = options; + const server = http.createServer((req, res) => { + const chunks = []; + req.on('data', (chunk) => chunks.push(chunk)); + req.on('end', () => { + // TODO: send back the proper error + if (chunks.length === 0) { + return badRequest(res); + } + + const contentType = req.headers['content-type']; + const parseData = parsersMap[contentType] || unknownParser; + const reqBuffer = Buffer.concat(chunks); + const data = parseData(reqBuffer, req); + + // TODO: this is the place to do something with the data based on + // console.log(data); + console.dir(data, {depth: 5}); + + // TODO: in future response may add some header to communicate back + // some information about + // - the collector + // - the config + // - something else + // PS: maybe collector could be able to tell the sdk/distro to stop sending + // because of: high load, sample rate changed, et al?? + res.writeHead(200); + res.end( + JSON.stringify({ + ok: 1, + }) + ); + }); + + req.resume(); }); - req.resume(); - }); - - server.listen(port, hostname, function () { - console.info('listening', server.address()) - }); + server.listen(port, hostname, function () { + console.info('listening', server.address()); + }); } - module.exports = { - startHttp, + startHttp, }; diff --git a/packages/mockotlpserver/lib/index.js b/packages/mockotlpserver/lib/index.js index 24f29197..7bab5b5a 100644 --- a/packages/mockotlpserver/lib/index.js +++ b/packages/mockotlpserver/lib/index.js @@ -2,15 +2,15 @@ const DEFAULT_HOSTNAME = '127.0.0.1'; const DEFAULT_HTTP_PORT = 4318; const DEFAULT_GRPC_PORT = 4317; -const { startHttp } = require('./http'); -const { startGrpc } = require('./grpc'); +const {startHttp} = require('./http'); +const {startGrpc} = require('./grpc'); // Start a server which accepts incoming HTTP requests. Exporters supported: // - @opentelemetry/exporter-trace-otlp-http (HTTP + JSON) // - @opentelemetry/exporter-trace-otlp-proto (HTTP + protobuf) startHttp({ - hostname: DEFAULT_HOSTNAME, - port: DEFAULT_HTTP_PORT, + hostname: DEFAULT_HOSTNAME, + port: DEFAULT_HTTP_PORT, }); // Start a server which accepts incoming GRPC calls. Exporters supported: @@ -18,6 +18,6 @@ startHttp({ // // NOTE: to debug read this: https://github.com/grpc/grpc-node/blob/master/TROUBLESHOOTING.md startGrpc({ - hostname: DEFAULT_HOSTNAME, - port: DEFAULT_GRPC_PORT, -}) + hostname: DEFAULT_HOSTNAME, + port: DEFAULT_GRPC_PORT, +}); diff --git a/packages/opentelemetry-node/examples/simple-http-server.js b/packages/opentelemetry-node/examples/simple-http-server.js index 4fd88cde..17c37968 100644 --- a/packages/opentelemetry-node/examples/simple-http-server.js +++ b/packages/opentelemetry-node/examples/simple-http-server.js @@ -1,34 +1,31 @@ const http = require('http'); const server = http.createServer(function onRequest(req, res) { - console.log('incoming request: %s %s %s', req.method, req.url, req.headers); - req.resume(); - req.on('end', function () { - const body = 'pong'; - res.writeHead(200, { - 'content-type': 'text/plain', - 'content-length': Buffer.byteLength(body), + console.log('incoming request: %s %s %s', req.method, req.url, req.headers); + req.resume(); + req.on('end', function () { + const body = 'pong'; + res.writeHead(200, { + 'content-type': 'text/plain', + 'content-length': Buffer.byteLength(body), + }); + res.end(body); }); - res.end(body); - }); }); server.listen(3000, function () { - // Make a request to our HTTP server listening at http://localhost:3000. - const clientReq = http.request( - 'http://localhost:3000/', - function (cres) { - console.log('client response: %s %s', cres.statusCode, cres.headers); - const chunks = []; - cres.on('data', function (chunk) { - chunks.push(chunk); - }); - cres.on('end', function () { - const body = chunks.join(''); - console.log('client response body: %j', body); - server.close(); - }); - }, - ); - clientReq.end(); + // Make a request to our HTTP server listening at http://localhost:3000. + const clientReq = http.request('http://localhost:3000/', function (cres) { + console.log('client response: %s %s', cres.statusCode, cres.headers); + const chunks = []; + cres.on('data', function (chunk) { + chunks.push(chunk); + }); + cres.on('end', function () { + const body = chunks.join(''); + console.log('client response body: %j', body); + server.close(); + }); + }); + clientReq.end(); }); diff --git a/packages/opentelemetry-node/lib/index.js b/packages/opentelemetry-node/lib/index.js index 4ba52ba2..f053ebf7 100644 --- a/packages/opentelemetry-node/lib/index.js +++ b/packages/opentelemetry-node/lib/index.js @@ -1 +1 @@ -module.exports = {} +module.exports = {}; diff --git a/packages/opentelemetry-node/lib/sdk.js b/packages/opentelemetry-node/lib/sdk.js index 756422ed..f7bc543c 100644 --- a/packages/opentelemetry-node/lib/sdk.js +++ b/packages/opentelemetry-node/lib/sdk.js @@ -1,6 +1,10 @@ -const { NodeSDK, tracing, api } = require('@opentelemetry/sdk-node'); -const { envDetectorSync, hostDetectorSync, processDetectorSync } = require('@opentelemetry/resources'); -const { HttpInstrumentation } = require('@opentelemetry/instrumentation-http'); +const {NodeSDK, tracing, api} = require('@opentelemetry/sdk-node'); +const { + envDetectorSync, + hostDetectorSync, + processDetectorSync, +} = require('@opentelemetry/resources'); +const {HttpInstrumentation} = require('@opentelemetry/instrumentation-http'); const luggite = require('./luggite'); @@ -13,86 +17,90 @@ const luggite = require('./luggite'); * https://github.com/open-telemetry/opentelemetry-specification/issues/2039 */ function luggiteLevelFromOtelLogLevel(otelLogLevel) { - const luggiteLevel = { - NONE: luggite.FATAL + 1, // TODO: support 'silent' luggite level - ERROR: 'error', - WARN: 'warn', - INFO: 'info', - DEBUG: 'debug', - VERBOSE: 'trace', - ALL: 'trace', - }[otelLogLevel] || null; - return luggiteLevel; + const luggiteLevel = + { + NONE: luggite.FATAL + 1, // TODO: support 'silent' luggite level + ERROR: 'error', + WARN: 'warn', + INFO: 'info', + DEBUG: 'debug', + VERBOSE: 'trace', + ALL: 'trace', + }[otelLogLevel] || null; + return luggiteLevel; } class ElasticNodeSDK { - constructor() { - this._setupLogger(); + constructor() { + this._setupLogger(); - // TODO accept serviceName, detect service name - this._otelSdk = new NodeSDK({ - serviceName: 'unknown-node-service', - resourceDetectors: [ - envDetectorSync, - processDetectorSync, - // hostDetectorSync is not currently in the OTel default, but may be added - hostDetectorSync - // TODO cloud/container detectors by default - ], - // TODO real span exporter, debug exporter support (better than ConsoleSpanExporter) - spanProcessor: new tracing.SimpleSpanProcessor(new tracing.ConsoleSpanExporter()), - // TODO metrics - // TODO log exporter? Optionally. Compare to apm-agent-java opts. - // logRecordProcessor: new logs.SimpleLogRecordProcessor(new logs.ConsoleLogRecordExporter()), - instrumentations: [ - // TODO All the instrumentations. Perf. Config support. Custom given instrs. - new HttpInstrumentation(), - ] - }); - } - - start() { - return this._otelSdk.start(); - } - - shutdown() { - return this._otelSdk.shutdown(); - } + // TODO accept serviceName, detect service name + this._otelSdk = new NodeSDK({ + serviceName: 'unknown-node-service', + resourceDetectors: [ + envDetectorSync, + processDetectorSync, + // hostDetectorSync is not currently in the OTel default, but may be added + hostDetectorSync, + // TODO cloud/container detectors by default + ], + // TODO real span exporter, debug exporter support (better than ConsoleSpanExporter) + spanProcessor: new tracing.SimpleSpanProcessor( + new tracing.ConsoleSpanExporter() + ), + // TODO metrics + // TODO log exporter? Optionally. Compare to apm-agent-java opts. + // logRecordProcessor: new logs.SimpleLogRecordProcessor(new logs.ConsoleLogRecordExporter()), + instrumentations: [ + // TODO All the instrumentations. Perf. Config support. Custom given instrs. + new HttpInstrumentation(), + ], + }); + } - /** - * Setup a `this._log` using the level from OTEL_LOG_LEVEL, default 'info'. - * Also set this logger to handle `api.diag.*()` log methods. - */ - _setupLogger() { - let level; - let diagLevel; - if (process.env.OTEL_LOG_LEVEL) { - const otelLogLevel = process.env.OTEL_LOG_LEVEL.toUpperCase() - level = luggiteLevelFromOtelLogLevel(otelLogLevel); - diagLevel = otelLogLevel; - // Make sure NodeSDK doesn't see this envvar and overwrite our diag logger. - delete process.env.OTEL_LOG_LEVEL; + start() { + return this._otelSdk.start(); } - if (!level) { - level = 'info'; // default level - diagLevel = 'INFO'; + + shutdown() { + return this._otelSdk.shutdown(); } - const log = luggite.createLogger({name: 'elastic-otel-node', level}); - api.diag.setLogger( - { - error: log.error.bind(log), - warn: log.warn.bind(log), - info: log.info.bind(log), - debug: log.debug.bind(log), - verbose: log.trace.bind(log), - }, - api.DiagLogLevel[diagLevel]); + /** + * Setup a `this._log` using the level from OTEL_LOG_LEVEL, default 'info'. + * Also set this logger to handle `api.diag.*()` log methods. + */ + _setupLogger() { + let level; + let diagLevel; + if (process.env.OTEL_LOG_LEVEL) { + const otelLogLevel = process.env.OTEL_LOG_LEVEL.toUpperCase(); + level = luggiteLevelFromOtelLogLevel(otelLogLevel); + diagLevel = otelLogLevel; + // Make sure NodeSDK doesn't see this envvar and overwrite our diag logger. + delete process.env.OTEL_LOG_LEVEL; + } + if (!level) { + level = 'info'; // default level + diagLevel = 'INFO'; + } + + const log = luggite.createLogger({name: 'elastic-otel-node', level}); + api.diag.setLogger( + { + error: log.error.bind(log), + warn: log.warn.bind(log), + info: log.info.bind(log), + debug: log.debug.bind(log), + verbose: log.trace.bind(log), + }, + api.DiagLogLevel[diagLevel] + ); - this._log = log; - } + this._log = log; + } } module.exports = { - ElasticNodeSDK + ElasticNodeSDK, }; diff --git a/packages/opentelemetry-node/start.js b/packages/opentelemetry-node/start.js index 9a9086a2..36961dda 100644 --- a/packages/opentelemetry-node/start.js +++ b/packages/opentelemetry-node/start.js @@ -1,16 +1,15 @@ -const { ElasticNodeSDK } = require('./lib/sdk.js'); +const {ElasticNodeSDK} = require('./lib/sdk.js'); const sdk = new ElasticNodeSDK(); // TODO sdk shutdown: auto shutdown on beforeExit? SIGINT, better log on err process.on('SIGTERM', () => { - sdk - .shutdown() - .then( - () => {}, - (err) => console.log("warning: error shutting down OTel SDK", err) - ) - .finally(() => process.exit(0)); + sdk.shutdown() + .then( + () => {}, + (err) => console.log('warning: error shutting down OTel SDK', err) + ) + .finally(() => process.exit(0)); }); sdk.start();