From aa877f4aef834212e5c0c33d34b38f03d56bca9a Mon Sep 17 00:00:00 2001 From: Naseem Date: Wed, 22 Jan 2020 21:06:20 -0500 Subject: [PATCH] fix: ioredis example --- examples/ioredis/README.md | 29 +++++++++++++++++------------ examples/ioredis/index.js | 2 ++ examples/ioredis/package.json | 14 +++++++------- examples/ioredis/tracer.js | 4 ++-- 4 files changed, 28 insertions(+), 21 deletions(-) diff --git a/examples/ioredis/README.md b/examples/ioredis/README.md index e7ea9f4006..8818ad850d 100644 --- a/examples/ioredis/README.md +++ b/examples/ioredis/README.md @@ -5,17 +5,21 @@ OpenTelemetry IORedis Instrumentation allows the user to automatically collect t ## Tracing backend setup ### Zipkin + - Setup [Zipkin Tracing](https://zipkin.io/pages/quickstart.html) - Set EXPORTER variable + ```sh export EXPORTER=zipkin ``` ### Jaeger + - Setup [Jaeger Tracing](https://www.jaegertracing.io/docs/latest/getting-started/#all-in-one) - Set EXPORTER variable + ```sh export EXPORTER=jaeger ``` @@ -28,22 +32,23 @@ npm install ## Run the Application - - Start redis via docker +- Start redis via docker + + ```sh + npm run docker:start + ``` - ```sh - npm run docker:start - ``` +- Run the main program - - Run the main program - ```sh - npm start - ``` + ```sh + npm start + ``` - - Cleanup docker +- Cleanup docker - ```sh - npm run docker:stop - ``` + ```sh + npm run docker:stop + ``` ## LICENSE diff --git a/examples/ioredis/index.js b/examples/ioredis/index.js index aac0986be4..ac1e5ec4f6 100644 --- a/examples/ioredis/index.js +++ b/examples/ioredis/index.js @@ -10,8 +10,10 @@ async function main() { try { await redis.set('test', 'data'); await redis.get('test'); + process.exit(0); } catch (error) { console.error(error); + process.exit(1); } } diff --git a/examples/ioredis/package.json b/examples/ioredis/package.json index 056121566f..97f1248a81 100644 --- a/examples/ioredis/package.json +++ b/examples/ioredis/package.json @@ -1,7 +1,7 @@ { "name": "ioredis-example", "private": true, - "version": "0.3.2", + "version": "0.3.3", "description": "Example of HTTP integration with OpenTelemetry", "main": "index.js", "scripts": { @@ -28,12 +28,12 @@ "url": "https://github.com/open-telemetry/opentelemetry-js/issues" }, "dependencies": { - "@opentelemetry/core": "^0.3.2", - "@opentelemetry/exporter-jaeger": "^0.3.2", - "@opentelemetry/exporter-zipkin": "^0.3.2", - "@opentelemetry/node": "^0.3.2", - "@opentelemetry/plugin-ioredis": "^0.3.2", - "@opentelemetry/tracing": "^0.3.2", + "@opentelemetry/core": "^0.3.3", + "@opentelemetry/exporter-jaeger": "^0.3.3", + "@opentelemetry/exporter-zipkin": "^0.3.3", + "@opentelemetry/node": "^0.3.3", + "@opentelemetry/plugin-ioredis": "^0.3.3", + "@opentelemetry/tracing": "^0.3.3", "ioredis": "^4.14.1" }, "homepage": "https://github.com/open-telemetry/opentelemetry-js#readme", diff --git a/examples/ioredis/tracer.js b/examples/ioredis/tracer.js index 11e053fef7..34b29d1fa3 100644 --- a/examples/ioredis/tracer.js +++ b/examples/ioredis/tracer.js @@ -8,7 +8,7 @@ const { ZipkinExporter } = require('@opentelemetry/exporter-zipkin'); const EXPORTER = process.env.EXPORTER || ''; -const tracer = new NodeTracer(); +const tracerRegistry = new NodeTracerRegistry(); let exporter; if (EXPORTER.toLowerCase().startsWith('z')) { @@ -24,6 +24,6 @@ if (EXPORTER.toLowerCase().startsWith('z')) { tracer.addSpanProcessor(new SimpleSpanProcessor(exporter)); // Initialize the OpenTelemetry APIs to use the BasicTracer bindings -opentelemetry.initGlobalTracer(tracer); +opentelemetry.initGlobalTracerRegistry(tracerRegistry); module.exports = opentelemetry.getTracer();