-
Notifications
You must be signed in to change notification settings - Fork 821
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
docs: add ioredis example #665
Merged
dyladan
merged 14 commits into
open-telemetry:master
from
naseemkullah:ioredis-example-2
Jan 28, 2020
+115
−0
Merged
Changes from all commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
c0c64f5
docs: add ioredis example
naseemkullah 065c198
refactor: simplify example
naseemkullah dc678d9
Merge remote-tracking branch 'upstream/master' into ioredis-example-2
naseemkullah ee14dd3
Merge remote-tracking branch 'upstream/master' into ioredis-example-2
aa877f4
fix: ioredis example
9a7c7ec
Merge branch 'master' into ioredis-example-2
8861816
Merge branch 'master' into ioredis-example-2
0143bc0
fix: tracerRegistry not tracer
b9d544b
fix: test only with set command
5c86eec
Merge branch 'ioredis-example-2' of github.com:naseemkullah/opentelem…
4a097ca
Merge branch 'master' into ioredis-example-2
dyladan eae9b86
fix: only use Jaeger as backend
a712024
Merge branch 'ioredis-example-2' of github.com:naseemkullah/opentelem…
e11fd09
Merge branch 'master' into ioredis-example-2
dyladan File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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(); | ||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@dyladan should this now be
module.exports = opentelemetry.getTracerRegistry();
?Should the file be renamed to
tracer-registry.js
in this case?As a side note I find this whole tracer registry/factory thing to be confusing for the end user. I wish the focus was that libs just not have broken implementations of tracers.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes that means it becomes tracer registry.
"just don't have bugs" is not a feasible answer to the problem unfortunately.
Fortunately, most end users won't have to worry about it too much, just library developers. The only change for most end users is the name of the global object they need to create. Most users will never call any methods on the tracer registry manually.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for explaining.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@dyladan I had not yet made the above fix. Do you want a follow up PR for this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can make a follow up PR to handle it, but you're not actually using the exported value in your index, so it shouldn't matter.