Skip to content

Commit

Permalink
fix: ioredis example
Browse files Browse the repository at this point in the history
  • Loading branch information
Naseem committed Jan 23, 2020
1 parent ee14dd3 commit aa877f4
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 21 deletions.
29 changes: 17 additions & 12 deletions examples/ioredis/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
```
Expand All @@ -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

Expand Down
2 changes: 2 additions & 0 deletions examples/ioredis/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}

Expand Down
14 changes: 7 additions & 7 deletions examples/ioredis/package.json
Original file line number Diff line number Diff line change
@@ -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": {
Expand All @@ -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",
Expand Down
4 changes: 2 additions & 2 deletions examples/ioredis/tracer.js
Original file line number Diff line number Diff line change
Expand Up @@ -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')) {
Expand All @@ -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();

0 comments on commit aa877f4

Please sign in to comment.