-
Notifications
You must be signed in to change notification settings - Fork 821
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* docs: add ioredis example * refactor: simplify example * fix: ioredis example * fix: tracerRegistry not tracer * fix: test only with set command * fix: only use Jaeger as backend Signed-off-by: Naseem <[email protected]> Co-authored-by: Daniel Dyla <[email protected]>
- Loading branch information
Showing
4 changed files
with
115 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
# Overview | ||
|
||
OpenTelemetry IORedis Instrumentation allows the user to automatically collect trace data and export them to the backend(s) of choice (Jaeger in this example). | ||
|
||
## Tracing backend setup | ||
|
||
### Jaeger | ||
|
||
- Setup [Jaeger Tracing](https://www.jaegertracing.io/docs/latest/getting-started/#all-in-one) | ||
|
||
## Installation | ||
|
||
```sh | ||
npm install | ||
``` | ||
|
||
## Run the Application | ||
|
||
- Start redis via docker | ||
|
||
```sh | ||
npm run docker:start | ||
``` | ||
|
||
- Run the main program | ||
|
||
```sh | ||
npm run start | ||
``` | ||
|
||
- Cleanup docker | ||
|
||
```sh | ||
npm run docker:stop | ||
``` | ||
|
||
## LICENSE | ||
|
||
Apache License 2.0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
'use strict'; | ||
|
||
// Require tracer before any other modules | ||
require('./tracer'); | ||
const Redis = require('ioredis'); | ||
|
||
const redis = new Redis(); | ||
|
||
async function main() { | ||
try { | ||
await redis.set('test', 'data'); | ||
process.exit(0); | ||
} catch (error) { | ||
console.error(error); | ||
process.exit(1); | ||
} | ||
} | ||
|
||
main(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
{ | ||
"name": "ioredis-example", | ||
"private": true, | ||
"version": "0.3.3", | ||
"description": "Example of HTTP integration with OpenTelemetry", | ||
"main": "index.js", | ||
"scripts": { | ||
"docker:start": "docker run -d -p 6379:6379 --name otjsredis redis:alpine", | ||
"docker:stop": "docker stop otjsredis && docker rm otjsredis", | ||
"start": "node index.js" | ||
}, | ||
"repository": { | ||
"type": "git", | ||
"url": "git+ssh://[email protected]/open-telemetry/opentelemetry-js.git" | ||
}, | ||
"keywords": [ | ||
"opentelemetry", | ||
"redis", | ||
"ioredis", | ||
"tracing" | ||
], | ||
"engines": { | ||
"node": ">=8" | ||
}, | ||
"author": "OpenTelemetry Authors", | ||
"license": "Apache-2.0", | ||
"bugs": { | ||
"url": "https://github.com/open-telemetry/opentelemetry-js/issues" | ||
}, | ||
"dependencies": { | ||
"@opentelemetry/core": "^0.3.3", | ||
"@opentelemetry/exporter-jaeger": "^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", | ||
"devDependencies": {} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
'use strict'; | ||
|
||
const opentelemetry = require('@opentelemetry/core'); | ||
const { NodeTracerRegistry } = require('@opentelemetry/node'); | ||
const { SimpleSpanProcessor } = require('@opentelemetry/tracing'); | ||
const { JaegerExporter } = require('@opentelemetry/exporter-jaeger'); | ||
|
||
const tracerRegistry = new NodeTracerRegistry(); | ||
|
||
const exporter = new JaegerExporter({ serviceName: 'ioredis-example' }); | ||
|
||
tracerRegistry.addSpanProcessor(new SimpleSpanProcessor(exporter)); | ||
|
||
// Initialize the OpenTelemetry APIs to use the BasicTracer bindings | ||
opentelemetry.initGlobalTracerRegistry(tracerRegistry); | ||
|
||
module.exports = opentelemetry.getTracer(); |