-
Notifications
You must be signed in to change notification settings - Fork 823
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
feat: add OpenTracing example #581
feat: add OpenTracing example #581
Conversation
Codecov Report
@@ Coverage Diff @@
## master #581 +/- ##
==========================================
- Coverage 90.45% 90.44% -0.01%
==========================================
Files 181 177 -4
Lines 9166 8990 -176
Branches 815 787 -28
==========================================
- Hits 8291 8131 -160
+ Misses 875 859 -16
|
examples/opentracing-shim/tracer.js
Outdated
|
||
const opentracing = require("opentracing"); | ||
|
||
function init(serviceName) { |
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.
The fact that this file does OpenTracing and OpenTelemetry
things together might be confusing, especially since the names are so similar. I would rather have one file that sets up open tracing the way you would normally set it up with open tracing, and another file called something like shim.js
that sets up the shim. This way the example more clearly shows where the shim happens.
// shim.js
exports.shim = function shim(serviceName) {
const tracer = new NodeTracer();
tracer.addSpanProcessor(new SimpleSpanProcessor(getExporter()));
return new TracerShim(tracer);
}
function getExporter() {
const type = process.env.EXPORTER || "jaeger";
if (type.match(/^z/)) {
return new ZipkinExporter({ serviceName });
}
return new JaegerExporter({ serviceName, flushInterval: 100 });
}
// client.js
const shim = require("./shim").shim("http_client_service");
opentracing.initGlobalTracer(shim);
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.
I was initially imagining people usually have a tracer package which does initialization for open tracing and vendor specific instance (e.g. Zipkin or Jaeger). In this case, open telemetry is just another vendor so I made this decision to put all of them together.
I'm wondering if this makes sense to you and if adding some comments in the code can help or it will still be better to be separated as you suggest?
Many thanks for the suggestion! 👍
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.
I think i can go either way. I would still rather have the shim separate from the opentracing tracer so it is clear where the break is
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.
Sure, as your suggestion, I've created a shim
file to make thing more clear. Thanks!
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.
Great! Added few comments.
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 the PR, added a few comments.
- Combine `Tracer` and `.init` to one line - Use `setTimeout` to be consistent with other example - Remove unused dependency - Add missing keywords - Update README - Add missing `"use strict";`
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.
lgtm, added one comment.
@open-telemetry/javascript-approvers: We need more reviews for this one! |
- Update README - Separate shim to another file
@hieven please rebase with the master, looks good to merge. |
Which problem is this PR solving?
Short description of the changes
shim-opentracing