From cb35b4ff1995b7597b2d96458083a4936cd2608e Mon Sep 17 00:00:00 2001 From: Danil Beltyukov Date: Wed, 9 Sep 2020 23:46:02 +0300 Subject: [PATCH 1/5] add opentracing --- lib/tracer.ts | 36 +++++++++ lib/worker.ts | 54 ++++++++++--- package.json | 9 ++- runner.ts | 9 +++ yarn.lock | 207 +++++++++++++++++++++++++++++++++++++++++++++++++- 5 files changed, 298 insertions(+), 17 deletions(-) create mode 100644 lib/tracer.ts diff --git a/lib/tracer.ts b/lib/tracer.ts new file mode 100644 index 00000000..cf3e66f5 --- /dev/null +++ b/lib/tracer.ts @@ -0,0 +1,36 @@ +import { NodeTracerProvider } from '@opentelemetry/node'; +import { + BatchSpanProcessor, + SimpleSpanProcessor, + ConsoleSpanExporter, +} from '@opentelemetry/tracing'; +import { JaegerExporter } from '@opentelemetry/exporter-jaeger'; + +let provider: NodeTracerProvider; +let exporter: JaegerExporter; + +export const setupTracing = (): void => { + provider = new NodeTracerProvider(); + + if (process.env.TRACING_ENABLED === 'true') { + exporter = new JaegerExporter({ + serviceName: 'worker', + endpoint: process.env.JAEGER_ENDPOINT, + }); + + provider.addSpanProcessor(new BatchSpanProcessor(exporter)); + } + + // Print spans to console if not in prod + if (process.env.NODE_ENV !== 'PRODUCTION') { + provider.addSpanProcessor( + new SimpleSpanProcessor(new ConsoleSpanExporter()) + ); + } + + provider.register(); +}; + +export const stopTracing = (): void => { + if (exporter) exporter.shutdown(); +}; diff --git a/lib/worker.ts b/lib/worker.ts index 8f9cf191..aa033b8e 100644 --- a/lib/worker.ts +++ b/lib/worker.ts @@ -1,5 +1,6 @@ import * as amqp from 'amqplib'; import * as client from 'prom-client'; +import opentelemetry, { Tracer, Span } from '@opentelemetry/api'; import { createLogger, format, transports, Logger } from 'winston'; import { WorkerTask } from './types/worker-task'; import { CriticalError, NonCriticalError, ParsingError } from './workerErrors'; @@ -53,12 +54,19 @@ export abstract class Worker { format.timestamp(), format.colorize(), format.simple(), - format.printf((msg) => `${msg.timestamp} - ${msg.level}: ${msg.message}`) + format.printf( + (msg) => `${msg.timestamp} - ${msg.level}: ${msg.message}` + ) ), }), ], }); + /** + * Opentracing tracer + */ + protected tracer: Tracer; + /** * Prometheus metrics * metricProcessedMessages: prom-client.Counter – number of successfully processed messages @@ -73,7 +81,8 @@ export abstract class Worker { /** * How many task Worker should do concurrently */ - private readonly simultaneousTasks: number = +process.env.SIMULTANEOUS_TASKS || 1; + private readonly simultaneousTasks: number = + +process.env.SIMULTANEOUS_TASKS || 1; /** * Registry connection status true/false @@ -122,7 +131,14 @@ export abstract class Worker { * Get array of available prometheus metrics */ public getMetrics(): client.Counter[] { - return [ this.metricSuccessfullyProcessedMessages ]; + return [this.metricSuccessfullyProcessedMessages]; + } + + /** + * Initialize opentracing tracer + */ + public initTracing(): void { + this.tracer = opentelemetry.trace.getTracer(this.type); } /** @@ -137,12 +153,15 @@ export abstract class Worker { await this.connect(); } - const { consumerTag } = await this.channelWithRegistry.consume(this.type, (msg: amqp.ConsumeMessage) => { - const promise = this.processMessage(msg) as Promise; + const { consumerTag } = await this.channelWithRegistry.consume( + this.type, + (msg: amqp.ConsumeMessage) => { + const promise = this.processMessage(msg) as Promise; - this.tasksMap.set(msg, promise); - promise.then(() => this.tasksMap.delete(msg)); - }); + this.tasksMap.set(msg, promise); + promise.then(() => this.tasksMap.delete(msg)); + } + ); /** * Remember consumer tag to cancel subscription in future @@ -240,6 +259,8 @@ export abstract class Worker { private async processMessage(msg: amqp.ConsumeMessage): Promise { let event: WorkerTask; + const span = this.tracer.startSpan('processMessage'); + try { const stringifiedEvent = msg.content.toString(); @@ -255,7 +276,11 @@ export abstract class Worker { } try { - await this.handle(event); + const handleSpan = this.tracer.startSpan('handle', { parent: span }); + + await this.handle(event, handleSpan); + + handleSpan.end(); /** * Let RabbitMQ know that we processed the message @@ -270,8 +295,12 @@ export abstract class Worker { HawkCatcher.send(e); this.logger.error('Worker::processMessage: An error occurred:\n', e); - this.logger.debug('instanceof CriticalError? ' + (e instanceof CriticalError)); - this.logger.debug('instanceof NonCriticalError? ' + (e instanceof NonCriticalError)); + this.logger.debug( + 'instanceof CriticalError? ' + (e instanceof CriticalError) + ); + this.logger.debug( + 'instanceof NonCriticalError? ' + (e instanceof NonCriticalError) + ); /** * Send back message to registry since we failed to handle it @@ -290,6 +319,7 @@ export abstract class Worker { this.logger.error('Unknown error:\n', e); } } + span.end(); } /** @@ -334,5 +364,5 @@ export abstract class Worker { * * @param {WorkerTask} event - Event object from consume method */ - protected abstract handle(event: WorkerTask): Promise; + protected abstract handle(event: WorkerTask, span: Span): Promise; } diff --git a/package.json b/package.json index 850719ef..f5cce824 100644 --- a/package.json +++ b/package.json @@ -46,6 +46,11 @@ }, "dependencies": { "@hawk.so/nodejs": "^2.0.7", + "@opentelemetry/api": "^0.11.0", + "@opentelemetry/exporter-jaeger": "^0.11.0", + "@opentelemetry/node": "^0.11.0", + "@opentelemetry/plugin-mongodb": "^0.10.0", + "@opentelemetry/tracing": "^0.11.0", "@types/amqplib": "^0.5.13", "@types/jest": "^25.2.1", "@types/mongodb": "^3.5.15", @@ -53,6 +58,7 @@ "amqplib": "^0.5.5", "debug": "^4.1.1", "dotenv": "^8.2.0", + "jaeger-client": "^3.18.1", "lodash.mergewith": "^4.6.2", "migrate-mongo": "^7.2.1", "mongodb": "^3.5.7", @@ -68,6 +74,7 @@ "@shelf/jest-mongodb": "^1.1.5", "eslint": "^6.8.0", "eslint-config-codex": "^1.3.4", + "eslint-config-prettier": "^6.11.0", "jest": "25.5.4", "nodemon": "^2.0.3", "random-words": "^1.1.1", @@ -76,4 +83,4 @@ "webpack": "^4.43.0", "yargs": "^15.3.1" } -} \ No newline at end of file +} diff --git a/runner.ts b/runner.ts index dc92ff59..f53bc555 100644 --- a/runner.ts +++ b/runner.ts @@ -9,6 +9,7 @@ import * as url from 'url'; import { Worker } from './lib/worker'; import HawkCatcher from '@hawk.so/nodejs'; import * as dotenv from 'dotenv'; +import { setupTracing, stopTracing } from './lib/tracer'; dotenv.config(); @@ -131,6 +132,13 @@ class WorkerRunner { }, 1000); } + /** + * Start tracing + */ + private startTracing(): void { + setupTracing(); + } + /** * Dynamically loads workers through the yarn workspaces */ @@ -258,6 +266,7 @@ class WorkerRunner { private async stopWorker(worker: Worker): Promise { try { await worker.finish(); + stopTracing(); console.log( '\x1b[33m%s\x1b[0m', diff --git a/yarn.lock b/yarn.lock index d54eab44..57afb054 100644 --- a/yarn.lock +++ b/yarn.lock @@ -479,6 +479,89 @@ "@types/yargs" "^15.0.0" chalk "^3.0.0" +"@opentelemetry/api@^0.11.0": + version "0.11.0" + resolved "https://registry.yarnpkg.com/@opentelemetry/api/-/api-0.11.0.tgz#e0f6d96b3754306e55fe6154d81ee048c7529fd6" + integrity sha512-K+1ADLMxduhsXoZ0GRfi9Pw162FvzBQLDQlHru1lg86rpIU+4XqdJkSGo6y3Kg+GmOWq1HNHOA/ydw/rzHQkRg== + dependencies: + "@opentelemetry/context-base" "^0.11.0" + +"@opentelemetry/context-async-hooks@^0.11.0": + version "0.11.0" + resolved "https://registry.yarnpkg.com/@opentelemetry/context-async-hooks/-/context-async-hooks-0.11.0.tgz#97061fb862e43097b8c1a711bd4dd62f67d49ffa" + integrity sha512-4z0X9EfvoLNA6R5yi+2taUyaSCUiyi/ht1qBYZMgpWvWwARgc5hcgGkZo7bekPk1zWfE9NFIhW6ySOXOP9CXyQ== + dependencies: + "@opentelemetry/context-base" "^0.11.0" + +"@opentelemetry/context-base@^0.11.0": + version "0.11.0" + resolved "https://registry.yarnpkg.com/@opentelemetry/context-base/-/context-base-0.11.0.tgz#60bb6daf0800b6a8aa9f48403a84825f3bb0b1d1" + integrity sha512-ESRk+572bftles7CVlugAj5Azrz61VO0MO0TS2pE9MLVL/zGmWuUBQryART6/nsrFqo+v9HPt37GPNcECTZR1w== + +"@opentelemetry/core@^0.11.0": + version "0.11.0" + resolved "https://registry.yarnpkg.com/@opentelemetry/core/-/core-0.11.0.tgz#4f1aacc825fa25bc1b0977a9983713f814e27f98" + integrity sha512-ZEKjBXeDGBqzouz0uJmrbEKNExEsQOhsZ3tJDCLcz5dUNoVw642oIn2LYWdQK2YdIfZbEmltiF65/csGsaBtFA== + dependencies: + "@opentelemetry/api" "^0.11.0" + "@opentelemetry/context-base" "^0.11.0" + semver "^7.1.3" + +"@opentelemetry/exporter-jaeger@^0.11.0": + version "0.11.0" + resolved "https://registry.yarnpkg.com/@opentelemetry/exporter-jaeger/-/exporter-jaeger-0.11.0.tgz#df0aa44e9a4fc1b280f68e48e6636016808e7172" + integrity sha512-fSmSHU9kK/x5Gid6eGzT8bLW47sPdqQUdlA15U0bVxtkdpiIoArgYYj5cbnQYfCoxwnsTVeYn13TW94G/JsbxA== + dependencies: + "@opentelemetry/api" "^0.11.0" + "@opentelemetry/core" "^0.11.0" + "@opentelemetry/tracing" "^0.11.0" + jaeger-client "^3.15.0" + +"@opentelemetry/node@^0.11.0": + version "0.11.0" + resolved "https://registry.yarnpkg.com/@opentelemetry/node/-/node-0.11.0.tgz#81036e8ea51edd2381c3bbab60751b06d22e3cba" + integrity sha512-1SrZNbF7aBShySvsmWL+3bir6fVugjSnCyXsKMwclinhZIHd2cUfgjKdi42OCcA5G4Pp8TpO7/8ue8qI5yKX8w== + dependencies: + "@opentelemetry/api" "^0.11.0" + "@opentelemetry/context-async-hooks" "^0.11.0" + "@opentelemetry/core" "^0.11.0" + "@opentelemetry/tracing" "^0.11.0" + require-in-the-middle "^5.0.0" + semver "^7.1.3" + +"@opentelemetry/plugin-mongodb@^0.10.0": + version "0.10.0" + resolved "https://registry.yarnpkg.com/@opentelemetry/plugin-mongodb/-/plugin-mongodb-0.10.0.tgz#9e22c3fa061f3538c121228a960136464bb843d9" + integrity sha512-+63RawXaAZw1d+LvR4zRmHC6JiKn/nUpDWQpjI22Z3LRdwsN+tiY+c8PX1oBOfS4PuOZlLZ1zti+so+OveXdTA== + dependencies: + "@opentelemetry/api" "^0.11.0" + "@opentelemetry/core" "^0.11.0" + shimmer "^1.2.1" + +"@opentelemetry/resources@^0.11.0": + version "0.11.0" + resolved "https://registry.yarnpkg.com/@opentelemetry/resources/-/resources-0.11.0.tgz#e522354eb791c3bb3b20a06b7793259ad1cedf6c" + integrity sha512-o7DwV1TcezqBtS5YW2AWBcn01nVpPptIbTr966PLlVBcS//w8LkjeOShiSZxQ0lmV4b2en0FiSouSDoXk/5qIQ== + dependencies: + "@opentelemetry/api" "^0.11.0" + "@opentelemetry/core" "^0.11.0" + +"@opentelemetry/semantic-conventions@^0.11.0": + version "0.11.0" + resolved "https://registry.yarnpkg.com/@opentelemetry/semantic-conventions/-/semantic-conventions-0.11.0.tgz#9d2bb0d67620bb8c01c95174fbaaefc109189963" + integrity sha512-xsthnI/J+Cx0YVDGgUzvrH0ZTtfNtl866M454NarYwDrc0JvC24sYw+XS5PJyk2KDzAHtb0vlrumUc1OAut/Fw== + +"@opentelemetry/tracing@^0.11.0": + version "0.11.0" + resolved "https://registry.yarnpkg.com/@opentelemetry/tracing/-/tracing-0.11.0.tgz#4003660e91d1069decc4754ba72ab6b32b6035b6" + integrity sha512-QweFmxzl32BcyzwdWCNjVXZT1WeENNS/RWETq/ohqu+fAsTcMyGcr6cOq/yDdFmtBy+bm5WVVdeByEjNS+c4/w== + dependencies: + "@opentelemetry/api" "^0.11.0" + "@opentelemetry/context-base" "^0.11.0" + "@opentelemetry/core" "^0.11.0" + "@opentelemetry/resources" "^0.11.0" + "@opentelemetry/semantic-conventions" "^0.11.0" + "@shelf/jest-mongodb@^1.1.5": version "1.2.3" resolved "https://registry.yarnpkg.com/@shelf/jest-mongodb/-/jest-mongodb-1.2.3.tgz#7cb34f0bcb71871b0d1c8d16a4f1fdb18b1620df" @@ -1036,6 +1119,11 @@ ansi-align@^3.0.0: dependencies: string-width "^3.0.0" +ansi-color@^0.2.1: + version "0.2.1" + resolved "https://registry.yarnpkg.com/ansi-color/-/ansi-color-0.2.1.tgz#3e75c037475217544ed763a8db5709fa9ae5bf9a" + integrity sha1-PnXAN0dSF1RO12Oo21cJ+prlv5o= + ansi-colors@3.2.3: version "3.2.3" resolved "https://registry.yarnpkg.com/ansi-colors/-/ansi-colors-3.2.3.tgz#57d35b8686e851e2cc04c403f1c00203976a1813" @@ -1589,6 +1677,16 @@ buffer@^5.5.0: base64-js "^1.0.2" ieee754 "^1.1.4" +bufrw@^1.3.0: + version "1.3.0" + resolved "https://registry.yarnpkg.com/bufrw/-/bufrw-1.3.0.tgz#28d6cfdaf34300376836310f5c31d57eeb40c8fa" + integrity sha512-jzQnSbdJqhIltU9O5KUiTtljP9ccw2u5ix59McQy4pV2xGhVLhRZIndY8GIrgh5HjXa6+QJ9AQhOd2QWQizJFQ== + dependencies: + ansi-color "^0.2.1" + error "^7.0.0" + hexer "^1.5.0" + xtend "^4.0.0" + builtin-status-codes@^3.0.0: version "3.0.0" resolved "https://registry.yarnpkg.com/builtin-status-codes/-/builtin-status-codes-3.0.0.tgz#85982878e21b98e1c66425e03d0174788f569ee8" @@ -2412,6 +2510,21 @@ error-ex@^1.2.0, error-ex@^1.3.1: dependencies: is-arrayish "^0.2.1" +error@7.0.2: + version "7.0.2" + resolved "https://registry.yarnpkg.com/error/-/error-7.0.2.tgz#a5f75fff4d9926126ddac0ea5dc38e689153cb02" + integrity sha1-pfdf/02ZJhJt2sDqXcOOaJFTywI= + dependencies: + string-template "~0.2.1" + xtend "~4.0.0" + +error@^7.0.0: + version "7.2.1" + resolved "https://registry.yarnpkg.com/error/-/error-7.2.1.tgz#eab21a4689b5f684fc83da84a0e390de82d94894" + integrity sha512-fo9HBvWnx3NGUKMvMwB/CBCMMrfEJgbDTVDEkPygA3Bdd3lM1OyCd+rbQ8BwnpF6GdVeOLDNmyL4N5Bg80ZvdA== + dependencies: + string-template "~0.2.1" + es-abstract@^1.17.0, es-abstract@^1.17.0-next.1, es-abstract@^1.17.5: version "1.17.6" resolved "https://registry.yarnpkg.com/es-abstract/-/es-abstract-1.17.6.tgz#9142071707857b2cacc7b89ecb670316c3e2d52a" @@ -2481,6 +2594,13 @@ eslint-config-codex@^1.3.4: typescript "^3.7.3" typescript-eslint "^0.0.1-alpha.0" +eslint-config-prettier@^6.11.0: + version "6.11.0" + resolved "https://registry.yarnpkg.com/eslint-config-prettier/-/eslint-config-prettier-6.11.0.tgz#f6d2238c1290d01c859a8b5c1f7d352a0b0da8b1" + integrity sha512-oB8cpLWSAjOVFEJhhyMZh6NOEOtBVziaqdDQ86+qhDHFbZXoRTM7pNSvFRfW/W/L/LrQ38C99J5CGuRBBzBsdA== + dependencies: + get-stdin "^6.0.0" + eslint-config-standard@14.1.0: version "14.1.0" resolved "https://registry.yarnpkg.com/eslint-config-standard/-/eslint-config-standard-14.1.0.tgz#b23da2b76fe5a2eba668374f246454e7058f15d4" @@ -3131,6 +3251,11 @@ get-port@^5.1.1: resolved "https://registry.yarnpkg.com/get-port/-/get-port-5.1.1.tgz#0469ed07563479de6efb986baf053dcd7d4e3193" integrity sha512-g/Q1aTSDOxFpchXC4i8ZWvxA1lnPqx/JHqcpIw0/LX9T8x/GBbi6YnlN5nhaKIFkT8oFsscUKgDJYxfwfS6QsQ== +get-stdin@^6.0.0: + version "6.0.0" + resolved "https://registry.yarnpkg.com/get-stdin/-/get-stdin-6.0.0.tgz#9e09bf712b360ab9225e812048f71fde9c89657b" + integrity sha512-jp4tHawyV7+fkkSKyvjuLZswblUtz+SQKzSWnBbii16BuZksJlU1wuBYXY75r+duh/llF1ur6oNwi+2ZzjKZ7g== + get-stream@^4.0.0, get-stream@^4.1.0: version "4.1.0" resolved "https://registry.yarnpkg.com/get-stream/-/get-stream-4.1.0.tgz#c1b255575f3dc21d59bfc79cd3d2b46b1c3a54b5" @@ -3345,6 +3470,16 @@ he@1.2.0: resolved "https://registry.yarnpkg.com/he/-/he-1.2.0.tgz#84ae65fa7eafb165fddb61566ae14baf05664f0f" integrity sha512-F/1DnUGPopORZi0ni+CvrCgHQ5FyEAHRLSApuYWMmrbSwoN2Mn/7k+Gl38gJnR7yyDZk6WLXwiGod1JOWNDKGw== +hexer@^1.5.0: + version "1.5.0" + resolved "https://registry.yarnpkg.com/hexer/-/hexer-1.5.0.tgz#b86ce808598e8a9d1892c571f3cedd86fc9f0653" + integrity sha1-uGzoCFmOip0YksVx887dhvyfBlM= + dependencies: + ansi-color "^0.2.1" + minimist "^1.1.0" + process "^0.10.0" + xtend "^4.0.0" + hmac-drbg@^1.0.0: version "1.0.1" resolved "https://registry.yarnpkg.com/hmac-drbg/-/hmac-drbg-1.0.1.tgz#d2745701025a6c775a6c545793ed502fc0c649a1" @@ -3851,6 +3986,17 @@ istanbul-reports@^3.0.2: html-escaper "^2.0.0" istanbul-lib-report "^3.0.0" +jaeger-client@^3.15.0, jaeger-client@^3.18.1: + version "3.18.1" + resolved "https://registry.yarnpkg.com/jaeger-client/-/jaeger-client-3.18.1.tgz#a8c7a778244ba117f4fb8775eb6aa5508703564e" + integrity sha512-eZLM2U6rJvYo0XbzQYFeMYfp29gQix7SKlmDReorp9hJkUwXZtTyxW81AcKdmFCjLHO5tFysTX+394BnjEnUZg== + dependencies: + node-int64 "^0.4.0" + opentracing "^0.14.4" + thriftrw "^3.5.0" + uuid "^3.2.1" + xorshift "^0.2.0" + jest-changed-files@^25.5.0: version "25.5.0" resolved "https://registry.yarnpkg.com/jest-changed-files/-/jest-changed-files-25.5.0.tgz#141cc23567ceb3f534526f8614ba39421383634c" @@ -4573,6 +4719,11 @@ lolex@^5.0.0: dependencies: "@sinonjs/commons" "^1.7.0" +long@^2.4.0: + version "2.4.0" + resolved "https://registry.yarnpkg.com/long/-/long-2.4.0.tgz#9fa180bb1d9500cdc29c4156766a1995e1f4524f" + integrity sha1-n6GAux2VAM3CnEFWdmoZleH0Uk8= + lowercase-keys@^1.0.0, lowercase-keys@^1.0.1: version "1.0.1" resolved "https://registry.yarnpkg.com/lowercase-keys/-/lowercase-keys-1.0.1.tgz#6f9e30b47084d971a7c820ff15a6c5167b74c26f" @@ -4757,7 +4908,7 @@ minimatch@3.0.4, minimatch@3.0.x, minimatch@^3.0.4: dependencies: brace-expansion "^1.1.7" -minimist@^1.1.1, minimist@^1.2.0, minimist@^1.2.5: +minimist@^1.1.0, minimist@^1.1.1, minimist@^1.2.0, minimist@^1.2.5: version "1.2.5" resolved "https://registry.yarnpkg.com/minimist/-/minimist-1.2.5.tgz#67d66014b66a6a8aaa0c083c5fd58df4e4e97602" integrity sha512-FM9nNUYrRBAELZQT3xeZQ7fmMOBg6nWNmJKTcgsJeaLstP/UODVpGsr5OhXhhXg6f+qtJ8uiZ+PUxkDWcgIXLw== @@ -4848,6 +4999,11 @@ mockdate@^3.0.2: resolved "https://registry.yarnpkg.com/mockdate/-/mockdate-3.0.2.tgz#a5a7bb5820da617747af424d7a4dcb22c6c03d79" integrity sha512-ldfYSUW1ocqSHGTK6rrODUiqAFPGAg0xaHqYJ5tvj1hQyFsjuHpuWgWFTZWwDVlzougN/s2/mhDr8r5nY5xDpA== +module-details-from-path@^1.0.3: + version "1.0.3" + resolved "https://registry.yarnpkg.com/module-details-from-path/-/module-details-from-path-1.0.3.tgz#114c949673e2a8a35e9d35788527aa37b679da2b" + integrity sha1-EUyUlnPiqKNenTV4hSeqN7Z52is= + mongodb-memory-server-core@6.6.7: version "6.6.7" resolved "https://registry.yarnpkg.com/mongodb-memory-server-core/-/mongodb-memory-server-core-6.6.7.tgz#f402bb5808f052e20d040cd9ce03a64dde94fc62" @@ -5282,6 +5438,11 @@ onetime@^5.1.0: dependencies: mimic-fn "^2.1.0" +opentracing@^0.14.4: + version "0.14.4" + resolved "https://registry.yarnpkg.com/opentracing/-/opentracing-0.14.4.tgz#a113408ea740da3a90fde5b3b0011a375c2e4268" + integrity sha512-nNnZDkUNExBwEpb7LZaeMeQgvrlO8l4bgY/LvGNZCR0xG/dGWqHqjKrAmR5GUoYo0FIz38kxasvA1aevxWs2CA== + optional@^0.1.3: version "0.1.4" resolved "https://registry.yarnpkg.com/optional/-/optional-0.1.4.tgz#cdb1a9bedc737d2025f690ceeb50e049444fd5b3" @@ -5607,6 +5768,11 @@ process-nextick-args@~2.0.0: resolved "https://registry.yarnpkg.com/process-nextick-args/-/process-nextick-args-2.0.1.tgz#7820d9b16120cc55ca9ae7792680ae7dba6d7fe2" integrity sha512-3ouUOpQhtgrbOa17J7+uxOTpITYWaGP7/AhoR3+A+/1e9skrzelGi/dXzEYyvbxubEF6Wn2ypscTKiKJFFn1ag== +process@^0.10.0: + version "0.10.1" + resolved "https://registry.yarnpkg.com/process/-/process-0.10.1.tgz#842457cc51cfed72dc775afeeafb8c6034372725" + integrity sha1-hCRXzFHP7XLcd1r+6vuMYDQ3JyU= + process@^0.11.10: version "0.11.10" resolved "https://registry.yarnpkg.com/process/-/process-0.11.10.tgz#7332300e840161bda3e69a1d1d91a7d4bc16f182" @@ -5982,6 +6148,15 @@ require-directory@^2.1.1: resolved "https://registry.yarnpkg.com/require-directory/-/require-directory-2.1.1.tgz#8c64ad5fd30dab1c976e2344ffe7f792a6a6df42" integrity sha1-jGStX9MNqxyXbiNE/+f3kqam30I= +require-in-the-middle@^5.0.0: + version "5.0.3" + resolved "https://registry.yarnpkg.com/require-in-the-middle/-/require-in-the-middle-5.0.3.tgz#ef8bfd771760db573bc86d1341d8ae411a04c600" + integrity sha512-p/ICV8uMlqC4tjOYabLMxAWCIKa0YUQgZZ6KDM0xgXJNgdGQ1WmL2A07TwmrZw+wi6ITUFKzH5v3n+ENEyXVkA== + dependencies: + debug "^4.1.1" + module-details-from-path "^1.0.3" + resolve "^1.12.0" + require-main-filename@^2.0.0: version "2.0.0" resolved "https://registry.yarnpkg.com/require-main-filename/-/require-main-filename-2.0.0.tgz#d0b329ecc7cc0f61649f62215be69af54aa8989b" @@ -6194,7 +6369,7 @@ semver@6.x, semver@^6.0.0, semver@^6.1.0, semver@^6.1.2, semver@^6.2.0, semver@^ resolved "https://registry.yarnpkg.com/semver/-/semver-6.3.0.tgz#ee0a64c8af5e8ceea67687b133761e1becbd1d3d" integrity sha512-b39TBaTSfV6yBrapU89p5fKekE2m/NwnDocOVruQFS1/veMgdzuPcnOM34M6CwxW8jH/lxEa5rBoDeUwu5HHTw== -semver@^7.3.2: +semver@^7.1.3, semver@^7.3.2: version "7.3.2" resolved "https://registry.yarnpkg.com/semver/-/semver-7.3.2.tgz#604962b052b81ed0786aae84389ffba70ffd3938" integrity sha512-OrOb32TeeambH6UrhtShmF7CRDqhL6/5XpPNp2DuRH6+9QLw/orhp72j87v8Qa1ScDkvrrBNpZcDejAirJmfXQ== @@ -6263,6 +6438,11 @@ shellwords@^0.1.1: resolved "https://registry.yarnpkg.com/shellwords/-/shellwords-0.1.1.tgz#d6b9181c1a48d397324c84871efbcfc73fc0654b" integrity sha512-vFwSUfQvqybiICwZY5+DAWIPLKsWO31Q91JSKl3UYv+K5c2QRPzn0qzec6QPu1Qc9eHYItiP3NdJqNVqetYAww== +shimmer@^1.2.1: + version "1.2.1" + resolved "https://registry.yarnpkg.com/shimmer/-/shimmer-1.2.1.tgz#610859f7de327b587efebf501fb43117f9aff337" + integrity sha512-sQTKC1Re/rM6XyFM6fIAGHRPVGvyXfgzIDvzoq608vM+jeyVD0Tu1E6Np0Kc2zAIFWIj963V2800iF/9LPieQw== + short-number@^1.0.7: version "1.0.7" resolved "https://registry.yarnpkg.com/short-number/-/short-number-1.0.7.tgz#5ab8021b86f20a4bdd1bbe01a85c22ff1cd15514" @@ -6516,6 +6696,11 @@ string-length@^3.1.0: astral-regex "^1.0.0" strip-ansi "^5.2.0" +string-template@~0.2.1: + version "0.2.1" + resolved "https://registry.yarnpkg.com/string-template/-/string-template-0.2.1.tgz#42932e598a352d01fc22ec3367d9d84eec6c9add" + integrity sha1-QpMuWYo1LQH8IuwzZ9nYTuxsmt0= + string-width@^1.0.1: version "1.0.2" resolved "https://registry.yarnpkg.com/string-width/-/string-width-1.0.2.tgz#118bdf5b8cdc51a2a7e70d211e07e2b0b9b107d3" @@ -6785,6 +6970,15 @@ text-table@^0.2.0: resolved "https://registry.yarnpkg.com/text-table/-/text-table-0.2.0.tgz#7f5ee823ae805207c00af2df4a84ec3fcfa570b4" integrity sha1-f17oI66AUgfACvLfSoTsP8+lcLQ= +thriftrw@^3.5.0: + version "3.12.0" + resolved "https://registry.yarnpkg.com/thriftrw/-/thriftrw-3.12.0.tgz#30857847755e7f036b2e0a79d11c9f55075539d9" + integrity sha512-4YZvR4DPEI41n4Opwr4jmrLGG4hndxr7387kzRFIIzxHQjarPusH4lGXrugvgb7TtPrfZVTpZCVe44/xUxowEw== + dependencies: + bufrw "^1.3.0" + error "7.0.2" + long "^2.4.0" + throat@^5.0.0: version "5.0.0" resolved "https://registry.yarnpkg.com/throat/-/throat-5.0.0.tgz#c5199235803aad18754a667d659b5e72ce16764b" @@ -7172,7 +7366,7 @@ uuid@8.3.0, uuid@^8.2.0, uuid@^8.3.0: resolved "https://registry.yarnpkg.com/uuid/-/uuid-8.3.0.tgz#ab738085ca22dc9a8c92725e459b1d507df5d6ea" integrity sha512-fX6Z5o4m6XsXBdli9g7DtWgAx+osMsRRZFKma1mIUsLCz6vRvv+pz5VNbyu9UEDzpMWulZfvpgb/cmDXVulYFQ== -uuid@^3.3.2: +uuid@^3.2.1, uuid@^3.3.2: version "3.4.0" resolved "https://registry.yarnpkg.com/uuid/-/uuid-3.4.0.tgz#b23e4358afa8a202fe7a100af1f5f883f02007ee" integrity sha512-HjSDRw6gZE5JMggctHBcjVak08+KEVhSIiDzFnT9S9aegmp85S/bReBVTb4QTFaRNptJ9kuYaNhnbNEOkbKb/A== @@ -7457,7 +7651,12 @@ xmlchars@^2.1.1: resolved "https://registry.yarnpkg.com/xmlchars/-/xmlchars-2.2.0.tgz#060fe1bcb7f9c76fe2a17db86a9bc3ab894210cb" integrity sha512-JZnDKK8B0RCDw84FNdDAIpZK+JuJw+s7Lz8nksI7SIuU3UXJJslUthsi+uWBUYOwPFwW7W7PRLRfUKpxjtjFCw== -xtend@^4.0.0, xtend@~4.0.1: +xorshift@^0.2.0: + version "0.2.1" + resolved "https://registry.yarnpkg.com/xorshift/-/xorshift-0.2.1.tgz#fcd82267e9351c13f0fb9c73307f25331d29c63a" + integrity sha1-/NgiZ+k1HBPw+5xzMH8lMx0pxjo= + +xtend@^4.0.0, xtend@~4.0.0, xtend@~4.0.1: version "4.0.2" resolved "https://registry.yarnpkg.com/xtend/-/xtend-4.0.2.tgz#bb72779f5fa465186b1f438f674fa347fdb5db54" integrity sha512-LKYU1iAXJXUgAXn9URjiu+MWhyUXHsvfp7mcuYm9dSUKK0/CjtrUwFAxD82/mCWbtLsGjFIad0wIsod4zrTAEQ== From 0beb504621ad40ed6ce91f7b6f4b2fc0a3d3ec32 Mon Sep 17 00:00:00 2001 From: Danil Beltyukov Date: Wed, 9 Sep 2020 23:46:17 +0300 Subject: [PATCH 2/5] enable tracing on js worker --- workers/javascript/src/index.ts | 22 +++++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) diff --git a/workers/javascript/src/index.ts b/workers/javascript/src/index.ts index b79249b3..eef6175c 100644 --- a/workers/javascript/src/index.ts +++ b/workers/javascript/src/index.ts @@ -1,5 +1,6 @@ import * as path from 'path'; import { BasicSourceMapConsumer, IndexedSourceMapConsumer, NullableMappedPosition, SourceMapConsumer } from 'source-map'; +import { Span } from "@opentelemetry/api"; import { DatabaseController } from '../../../lib/db/controller'; import { EventWorker } from '../../../lib/event-worker'; import { BacktraceFrame, SourceCodeLine } from '../../../lib/types/event-worker-task'; @@ -70,17 +71,26 @@ export default class JavascriptEventWorker extends EventWorker { * Message handle function * * @param event - event to handle + * @param span - opentracing's Span */ - public async handle(event: JavaScriptEventWorkerTask): Promise { + public async handle(event: JavaScriptEventWorkerTask, span: Span): Promise { if (event.payload.release && event.payload.backtrace) { - event.payload.backtrace = await this.beautifyBacktrace(event); + const beautifySpan = this.tracer.startSpan('beautify', { parent: span }); + + event.payload.backtrace = await this.beautifyBacktrace(event, beautifySpan); + + beautifySpan.end(); } + const mqSpan = this.tracer.startSpan('mq',{ parent: span }); + await this.addTask(WorkerNames.GROUPER, { projectId: event.projectId, catcherType: this.type, event: event.payload, } as GroupWorkerTask); + + mqSpan.end(); } /** @@ -88,16 +98,22 @@ export default class JavascriptEventWorker extends EventWorker { * and overrides a backtrace with parsed source-map * * @param {JavaScriptEventWorkerTask} event — js error minified + * @param {Span} span — opentracing's Span * @returns {BacktraceFrame[]} - parsed backtrace */ - private async beautifyBacktrace(event: JavaScriptEventWorkerTask): Promise { + private async beautifyBacktrace(event: JavaScriptEventWorkerTask, span: Span): Promise { /** * Find source map in Mongo */ + + const currentSpan = this.tracer.startSpan('get release', { parent: span }); + const releaseRecord: SourceMapsRecord = await this.getReleaseRecord( event.projectId, event.payload.release.toString()); + currentSpan.end(); + if (!releaseRecord) { return event.payload.backtrace; } From 15bf14a4822deca0ed06d511ccbce23e18f23aba Mon Sep 17 00:00:00 2001 From: Danil Beltyukov Date: Wed, 9 Sep 2020 23:46:37 +0300 Subject: [PATCH 3/5] add tracing section to readme --- README.md | 37 ++++++++++++++++++++++++++++++------- 1 file changed, 30 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index cc7af550..abf74b2d 100644 --- a/README.md +++ b/README.md @@ -4,8 +4,6 @@ Workers are services for processing hawk's background tasks - - ## Requirements - [Registry](https://github.com/codex-team/hawk.registry) @@ -29,8 +27,7 @@ For simplicity, Hawk workers can be used as part of the [Mono repository](https: - Set `LOG_LEVEL` to `verbose` if you want message logs > Also you can use `worker.logger` which is [`winston.Logger`](https://github.com/winstonjs/winston) to log something - > - > + ## How to run workers 1. Make sure you are in Workers root directory @@ -73,21 +70,24 @@ SIMULTANEOUS_TASKS=1 yarn worker hawk-worker-sourcemaps ## Running workers with Docker -Basic configuration is in `docker-compose.dev.yml`. +Basic configuration is in `docker-compose.dev.yml`. Pull image from https://hub.docker.com/r/codexteamuser/hawk-workers + ``` docker-compose -f docker-compose.dev.yml pull ``` -If you run mongodb and rabbitmq with `hawk.mono` repository, by default your docker network will be named `hawkmono_default`. +If you run mongodb and rabbitmq with `hawk.mono` repository, by default your docker network will be named `hawkmono_default`. This network name is written as external for workers. Run chosen worker (say hawk-worker-javascript) + ``` docker-compose -f docker-compose.dev.yml up hawk-worker-javascript ``` ### Adding new workers + Make sure that your `.env` configurations exists. Add new section to the `docker-compose.{dev,prod}.yml` files. @@ -145,7 +145,7 @@ You can tweak it (add schemas, etc) and use it in your workers to handle databas ### Example ```javascript -const db = require("lib/db/mongoose-controller"); +const db = require('lib/db/mongoose-controller'); await db.connect(); // Requires `MONGO_URL` @@ -201,3 +201,26 @@ yarn migrate Refactor mongo-migrate commands to have an opportunity to create or rollback [More details](https://www.npmjs.com/package/migrate-mongo) + +## Tracing + +Worker supports Opentracing with Jaeger exporter + +To test add `JAEGER_ENDPOINT` in `.env`, set `TRACING_ENABLED=true`, and run Jaeger: + +```shell +docker run -d --name jaeger \ + -e COLLECTOR_ZIPKIN_HTTP_PORT=9411 \ + -p 5775:5775/udp \ + -p 6831:6831/udp \ + -p 6832:6832/udp \ + -p 5778:5778 \ + -p 16686:16686 \ + -p 14268:14268 \ + -p 9411:9411 \ + jaegertracing/all-in-one:latest +``` + +Start worker, send events + +Navigate to `http://localhost:16686` From aded5c8a5a40f9bf1d0011d0d6096f88d8ef7338 Mon Sep 17 00:00:00 2001 From: Danil Beltyukov Date: Thu, 10 Sep 2020 00:32:05 +0300 Subject: [PATCH 4/5] fix tracer init --- .env.sample | 8 +++++++ .eslintrc.js | 24 +++++++++---------- .prettierrc.js | 6 +++++ lib/tracer.ts | 6 +++-- lib/worker.ts | 2 ++ package.json | 1 + runner.ts | 4 +++- yarn.lock | 65 ++++++++++++++++++++++++++++++++++++++++++++++++++ 8 files changed, 101 insertions(+), 15 deletions(-) create mode 100644 .prettierrc.js diff --git a/.env.sample b/.env.sample index 84213294..ec785a64 100644 --- a/.env.sample +++ b/.env.sample @@ -32,3 +32,11 @@ HAWK_CATCHER_TOKEN= ## If true, Grouper worker will send messages about new events to Notifier worker IS_NOTIFIER_WORKER_ENABLED=false + +# Tracing + +## Is tracing enabled (only `true` to enable) +TRACING_ENABLED=false + +## Jaeger-collector endpoint +JAEGER_ENDPOINT=http://jaeger-collector:14268/api/traces \ No newline at end of file diff --git a/.eslintrc.js b/.eslintrc.js index 9d537f89..d932207f 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -1,15 +1,15 @@ module.exports = { - env: { - es6: true, - node: true, - jest: true - }, - extends: ['codex'], - rules: { - "@typescript-eslint/no-unused-expressions": "error", - "no-unused-expressions": "off" - }, + env: { + es6: true, + node: true, + jest: true, + }, + extends: ['codex', 'prettier', 'prettier/@typescript-eslint'], + rules: { + '@typescript-eslint/no-unused-expressions': 'error', + 'no-unused-expressions': 'off', + }, globals: { - NodeJS: true - } + NodeJS: true, + }, }; diff --git a/.prettierrc.js b/.prettierrc.js new file mode 100644 index 00000000..9001fa67 --- /dev/null +++ b/.prettierrc.js @@ -0,0 +1,6 @@ +module.exports = { + trailingComma: 'es5', + tabWidth: 2, + semi: true, + singleQuote: true, +} diff --git a/lib/tracer.ts b/lib/tracer.ts index cf3e66f5..da830d19 100644 --- a/lib/tracer.ts +++ b/lib/tracer.ts @@ -9,16 +9,18 @@ import { JaegerExporter } from '@opentelemetry/exporter-jaeger'; let provider: NodeTracerProvider; let exporter: JaegerExporter; -export const setupTracing = (): void => { +export const setupTracing = (name: string): void => { provider = new NodeTracerProvider(); if (process.env.TRACING_ENABLED === 'true') { exporter = new JaegerExporter({ serviceName: 'worker', + tags: [{ key: 'type', value: name }], endpoint: process.env.JAEGER_ENDPOINT, }); - provider.addSpanProcessor(new BatchSpanProcessor(exporter)); + provider.addSpanProcessor(new SimpleSpanProcessor(exporter)); + console.log('Jaeger set up'); } // Print spans to console if not in prod diff --git a/lib/worker.ts b/lib/worker.ts index aa033b8e..8eb78231 100644 --- a/lib/worker.ts +++ b/lib/worker.ts @@ -149,6 +149,8 @@ export abstract class Worker { throw new Error('Worker type is not defined'); } + this.initTracing(); + if (!this.registryConnected) { await this.connect(); } diff --git a/package.json b/package.json index f5cce824..6a972c68 100644 --- a/package.json +++ b/package.json @@ -59,6 +59,7 @@ "debug": "^4.1.1", "dotenv": "^8.2.0", "jaeger-client": "^3.18.1", + "jsonwebtoken": "^8.5.1", "lodash.mergewith": "^4.6.2", "migrate-mongo": "^7.2.1", "mongodb": "^3.5.7", diff --git a/runner.ts b/runner.ts index f53bc555..6e9e8d60 100644 --- a/runner.ts +++ b/runner.ts @@ -57,6 +57,7 @@ class WorkerRunner { .then(() => { try { this.startMetrics(); + this.startTracing(); } catch (e) { HawkCatcher.send(e); console.error(`Metrics not started: ${e}`); @@ -136,7 +137,8 @@ class WorkerRunner { * Start tracing */ private startTracing(): void { - setupTracing(); + setupTracing(workerNames[0]); // If many workers running, bug here + console.log("Trasing initialized") } /** diff --git a/yarn.lock b/yarn.lock index 57afb054..38b89678 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1645,6 +1645,11 @@ buffer-crc32@~0.2.3: resolved "https://registry.yarnpkg.com/buffer-crc32/-/buffer-crc32-0.2.13.tgz#0d333e3f00eac50aa1454abd30ef8c2a5d9a7242" integrity sha1-DTM+PwDqxQqhRUq9MO+MKl2ackI= +buffer-equal-constant-time@1.0.1: + version "1.0.1" + resolved "https://registry.yarnpkg.com/buffer-equal-constant-time/-/buffer-equal-constant-time-1.0.1.tgz#f8e71132f7ffe6e01a5c9697a4c6f3e48d5cc819" + integrity sha1-+OcRMvf/5uAaXJaXpMbz5I1cyBk= + buffer-from@1.x, buffer-from@^1.0.0: version "1.1.1" resolved "https://registry.yarnpkg.com/buffer-from/-/buffer-from-1.1.1.tgz#32713bc028f75c02fdb710d7c7bcec1f2c6070ef" @@ -2447,6 +2452,13 @@ ecc-jsbn@~0.1.1: jsbn "~0.1.0" safer-buffer "^2.1.0" +ecdsa-sig-formatter@1.0.11: + version "1.0.11" + resolved "https://registry.yarnpkg.com/ecdsa-sig-formatter/-/ecdsa-sig-formatter-1.0.11.tgz#ae0f0fa2d85045ef14a817daa3ce9acd0489e5bf" + integrity sha512-nagl3RYrbNv6kQkeJIpt6NJZy8twLB/2vtz6yN9Z4vRKHN4/QZJIEbqohALSgwKdnksuY3k5Addp5lg8sVoVcQ== + dependencies: + safe-buffer "^5.0.1" + elliptic@^6.5.3: version "6.5.3" resolved "https://registry.yarnpkg.com/elliptic/-/elliptic-6.5.3.tgz#cb59eb2efdaf73a0bd78ccd7015a62ad6e0f93d6" @@ -4492,6 +4504,22 @@ jsonfile@^6.0.1: optionalDependencies: graceful-fs "^4.1.6" +jsonwebtoken@^8.5.1: + version "8.5.1" + resolved "https://registry.yarnpkg.com/jsonwebtoken/-/jsonwebtoken-8.5.1.tgz#00e71e0b8df54c2121a1f26137df2280673bcc0d" + integrity sha512-XjwVfRS6jTMsqYs0EsuJ4LGxXV14zQybNd4L2r0UvbVnSF9Af8x7p5MzbJ90Ioz/9TI41/hTCvznF/loiSzn8w== + dependencies: + jws "^3.2.2" + lodash.includes "^4.3.0" + lodash.isboolean "^3.0.3" + lodash.isinteger "^4.0.4" + lodash.isnumber "^3.0.3" + lodash.isplainobject "^4.0.6" + lodash.isstring "^4.0.1" + lodash.once "^4.0.0" + ms "^2.1.1" + semver "^5.6.0" + jsprim@^1.2.2: version "1.4.1" resolved "https://registry.yarnpkg.com/jsprim/-/jsprim-1.4.1.tgz#313e66bc1e5cc06e438bc1b7499c2e5c56acb6a2" @@ -4502,6 +4530,23 @@ jsprim@^1.2.2: json-schema "0.2.3" verror "1.10.0" +jwa@^1.4.1: + version "1.4.1" + resolved "https://registry.yarnpkg.com/jwa/-/jwa-1.4.1.tgz#743c32985cb9e98655530d53641b66c8645b039a" + integrity sha512-qiLX/xhEEFKUAJ6FiBMbes3w9ATzyk5W7Hvzpa/SLYdxNtng+gcurvrI7TbACjIXlsJyr05/S1oUhZrc63evQA== + dependencies: + buffer-equal-constant-time "1.0.1" + ecdsa-sig-formatter "1.0.11" + safe-buffer "^5.0.1" + +jws@^3.2.2: + version "3.2.2" + resolved "https://registry.yarnpkg.com/jws/-/jws-3.2.2.tgz#001099f3639468c9414000e99995fa52fb478304" + integrity sha512-YHlZCB6lMTllWDtSPHz/ZXTsi8S00usEV6v1tjq8tOUZzw7DpSDWVXjXDre6ed1w/pd495ODpHZYSdkRTsa0HA== + dependencies: + jwa "^1.4.1" + safe-buffer "^5.0.1" + keyv@^3.0.0: version "3.1.0" resolved "https://registry.yarnpkg.com/keyv/-/keyv-3.1.0.tgz#ecc228486f69991e49e9476485a5be1e8fc5c4d9" @@ -4634,11 +4679,21 @@ lodash-es@^4.17.11: resolved "https://registry.yarnpkg.com/lodash-es/-/lodash-es-4.17.15.tgz#21bd96839354412f23d7a10340e5eac6ee455d78" integrity sha512-rlrc3yU3+JNOpZ9zj5pQtxnx2THmvRykwL4Xlxoa8I9lHBlVbbyPhgyPMioxVZ4NqyxaVVtaJnzsyOidQIhyyQ== +lodash.includes@^4.3.0: + version "4.3.0" + resolved "https://registry.yarnpkg.com/lodash.includes/-/lodash.includes-4.3.0.tgz#60bb98a87cb923c68ca1e51325483314849f553f" + integrity sha1-YLuYqHy5I8aMoeUTJUgzFISfVT8= + lodash.isboolean@^3.0.3: version "3.0.3" resolved "https://registry.yarnpkg.com/lodash.isboolean/-/lodash.isboolean-3.0.3.tgz#6c2e171db2a257cd96802fd43b01b20d5f5870f6" integrity sha1-bC4XHbKiV82WgC/UOwGyDV9YcPY= +lodash.isinteger@^4.0.4: + version "4.0.4" + resolved "https://registry.yarnpkg.com/lodash.isinteger/-/lodash.isinteger-4.0.4.tgz#619c0af3d03f8b04c31f5882840b77b11cd68343" + integrity sha1-YZwK89A/iwTDH1iChAt3sRzWg0M= + lodash.isnumber@^3.0.3: version "3.0.3" resolved "https://registry.yarnpkg.com/lodash.isnumber/-/lodash.isnumber-3.0.3.tgz#3ce76810c5928d03352301ac287317f11c0b1ffc" @@ -4649,6 +4704,11 @@ lodash.isobject@^3.0.2: resolved "https://registry.yarnpkg.com/lodash.isobject/-/lodash.isobject-3.0.2.tgz#3c8fb8d5b5bf4bf90ae06e14f2a530a4ed935e1d" integrity sha1-PI+41bW/S/kK4G4U8qUwpO2TXh0= +lodash.isplainobject@^4.0.6: + version "4.0.6" + resolved "https://registry.yarnpkg.com/lodash.isplainobject/-/lodash.isplainobject-4.0.6.tgz#7c526a52d89b45c45cc690b88163be0497f550cb" + integrity sha1-fFJqUtibRcRcxpC4gWO+BJf1UMs= + lodash.isstring@^4.0.1: version "4.0.1" resolved "https://registry.yarnpkg.com/lodash.isstring/-/lodash.isstring-4.0.1.tgz#d527dfb5456eca7cc9bb95d5daeaf88ba54a5451" @@ -4679,6 +4739,11 @@ lodash.omitby@^4.6.0: resolved "https://registry.yarnpkg.com/lodash.omitby/-/lodash.omitby-4.6.0.tgz#5c15ff4754ad555016b53c041311e8f079204791" integrity sha1-XBX/R1StVVAWtTwEExHo8HkgR5E= +lodash.once@^4.0.0: + version "4.1.1" + resolved "https://registry.yarnpkg.com/lodash.once/-/lodash.once-4.1.1.tgz#0dd3971213c7c56df880977d504c88fb471a97ac" + integrity sha1-DdOXEhPHxW34gJd9UEyI+0cal6w= + lodash.sortby@^4.7.0: version "4.7.0" resolved "https://registry.yarnpkg.com/lodash.sortby/-/lodash.sortby-4.7.0.tgz#edd14c824e2cc9c1e0b0a1b42bb5210516a42438" From 02074de0d11fa547595f962c8010e7d66df7fce9 Mon Sep 17 00:00:00 2001 From: Danil Beltyukov Date: Thu, 10 Sep 2020 00:41:50 +0300 Subject: [PATCH 5/5] fix argument to pass tests --- workers/javascript/src/index.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/workers/javascript/src/index.ts b/workers/javascript/src/index.ts index eef6175c..713d2923 100644 --- a/workers/javascript/src/index.ts +++ b/workers/javascript/src/index.ts @@ -73,7 +73,7 @@ export default class JavascriptEventWorker extends EventWorker { * @param event - event to handle * @param span - opentracing's Span */ - public async handle(event: JavaScriptEventWorkerTask, span: Span): Promise { + public async handle(event: JavaScriptEventWorkerTask, span: Span = undefined /* to pass tests */): Promise { if (event.payload.release && event.payload.backtrace) { const beautifySpan = this.tracer.startSpan('beautify', { parent: span });