-
Notifications
You must be signed in to change notification settings - Fork 767
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 shim #212
Conversation
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 work! Added a few comments, will review tests in the second round.
@@ -0,0 +1,11 @@ | |||
# OpenTracing shim | |||
[![Gitter chat][gitter-image]][gitter-url] |
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.
All the links are missing...
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 should include these reference-style links at the bottom.
[gitter-image]: https://badges.gitter.im/open-telemetry/opentelemetry-js.svg
[gitter-url]: https://gitter.im/open-telemetry/opentelemetry-node?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge
[license-url]: https://github.com/open-telemetry/opentelemetry-js/blob/master/LICENSE
[license-image]: https://img.shields.io/badge/license-Apache_2.0-green.svg?style=flat
[dependencies-image]: https://david-dm.org/open-telemetry/opentelemetry-js/status.svg?path=packages/opentelemetry-shim-opentracing
[dependencies-url]: https://david-dm.org/open-telemetry/opentelemetry-js?path=packages%2Fopentelemetry-shim-opentracing
[devDependencies-image]: https://david-dm.org/open-telemetry/opentelemetry-js/dev-status.svg?path=packages/opentelemetry-shim-opentracing
[devDependencies-url]: https://david-dm.org/open-telemetry/opentelemetry-js?path=packages%2Fopentelemetry-shim-opentracing&type=dev
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.
yeah will add them shortly, finally have the build working :)
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.
Looks like this is still missing.
} | ||
|
||
setTag(key: string, value: unknown): this { | ||
this._span.setAttribute(key, value); |
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.
If key === opentracing.Tags.ERROR
, we should report them as this._span.setStatus
(CanonicalCode.OK or CanonicalCode.UNKNOWN). Also, If key === opentracing.Tags.SPAN_KIND
, we should ignore that tag, see open-telemetry/opentelemetry-java#42.
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 don't think we should ignore tags since that might break existing instrumentation and dashboards if the user relies on span.kind. For example, within LightStep you can define an arbitrary search and collect traces+latency metrics for that search. A common example is operation_name:my-rpc-call tag:span.kind=client
and operation_name:my-rpc-call tag:span.kind=server
to differentiate latency between clients and servers.
Strangely, CircleCI jobs are not running for this PR. Any idea? |
Oh interesting... so when I created a PR for this in my forked repo, the circleCI jobs kicked off. |
|
||
/** | ||
* TracerShim wraps a {@link types.Tracer} and implements the | ||
* OpenTracing span context API. |
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.
typo: s/span context API/Tracer API
?
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.
Any update here?
} | ||
|
||
getBaggageItem(key: string): string | undefined { | ||
// TODO: should this go into the context? |
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.
For now, return undefined
?
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.
Could you please issues on baggage
and binaryFormat
(mentioned in the Open questions)? Probably we can merge this one and handle these issues separately.
* @param finishTime An optional timestamp to explicitly set the span's end time. | ||
*/ | ||
finish(finishTime?: number): void { | ||
this._span.end(finishTime); |
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.
If I recall correctly, OpenTracing uses epoch times, but we are using performance.now
timestamps in OpenTelemetry for higher accuracy. Do we need to reverse translate this?
Alternatively, we could also make OpenTelemetry accept either type of timestamp - you can deterministically tell what type of timestamp it is based on its size (this is true because no Node processes or browser tabs were open in 1970...)
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.
Per conversation in the SIG, we will make the API accept either peformance.now
timestamps or epoch timestamps so that this code can be left as-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.
LGTM
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 pending final comment about adding a tslint.json
based on the base one and the tslint-microsoft-contrib
package (that change happened since this PR was started ...)
"access": "public" | ||
}, | ||
"devDependencies": { | ||
"@types/mocha": "^5.2.7", |
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.
Could you add a tslint.json
file that matches https://github.com/open-telemetry/opentelemetry-js/blob/master/packages/opentelemetry-core/tslint.json ? And then also add the tslint-microsoft-contrib
package? That will enable this package to pick up new TSLint goodies such as the license header checks, and anything else we add in 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.
also please add "tslint-consistent-codestyle":"^1.15.1",
@OlivierAlbertini @danielkhan @vmarchaud @hekike @rochdev ping, for reviews. |
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 but I'm no OpenTracing expert. I think it's still safe to go ahead and try some end-to-end tests to discover possible issues.
@mayurkale22 I think we have enough approvals to merge |
"access": "public" | ||
}, | ||
"devDependencies": { | ||
"@types/mocha": "^5.2.7", |
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.
also please add "tslint-consistent-codestyle":"^1.15.1",
@@ -0,0 +1,4 @@ | |||
{ |
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.
should be
{
"rulesDirectory": ["node_modules/tslint-microsoft-contrib"],
"extends": ["../../tslint.base.js", "./node_modules/tslint-consistent-codestyle"]
}
```
case opentracing.FORMAT_BINARY: | ||
// @todo: Implement binary format | ||
return; | ||
default: |
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.
default should have logger.warning(${format} is unsupported
) or never
(https://basarat.gitbooks.io/typescript/docs/types/never.html)
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.
went with logger
switch (format) { | ||
// tslint:disable-next-line:no-switch-case-fall-through | ||
case opentracing.FORMAT_HTTP_HEADERS: | ||
case opentracing.FORMAT_TEXT_MAP: |
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'm not sure that opentracing.FORMAT_HTTP_HEADERS is the same as opentracing.FORMAT_TEXT_MAP
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.
since opentelemetry doesn't support a text map format, http is the closest we get. fwiw both http and text have the same carrier type in opentracing and http is a stricter subset of text map so I think they're basically equivalent, plus it's going to the same inject/extract implementation
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 few comments. Good job!
@bg451 Once Olivier's comments fixed, feel free to merge 👍 |
Signed-off-by: Naseem <naseem@transit.app>
Resolves #181
In order to make the transition to OpenTelemetry easy for existing OpenCensus and Opentracing users, we'd like to allow folks to keep using their existing instrumentation and have it report to an OpenTelemetry backend. The shim wraps opentelem span types and implements the OpenTracing API.
Open Questions
I don't have a good answer here so I'd like to ask for some help here.
TODOs