-
Notifications
You must be signed in to change notification settings - Fork 805
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(plugin): implement redis plugin #503
feat(plugin): implement redis plugin #503
Conversation
Codecov Report
@@ Coverage Diff @@
## master #503 +/- ##
=========================================
+ Coverage 90.22% 90.3% +0.08%
=========================================
Files 144 149 +5
Lines 7189 7486 +297
Branches 651 662 +11
=========================================
+ Hits 6486 6760 +274
- Misses 703 726 +23
|
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.
Overall good, just little things to have the same config as other plugin
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.
Overall LGTM, added a few minor comments.
@@ -8,11 +8,14 @@ | |||
"repository": "open-telemetry/opentelemetry-js", | |||
"scripts": { | |||
"test": "nyc ts-mocha -p tsconfig.json 'test/**/*.ts'", |
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.
Do you think we should remove "private": true
to make this package available for the next release?
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.
Agreed. I removed it from this plugin. I think we should also remove it from other "ready" plugins (separate PR). Seems to just be postgres and http2 currently
|
||
export enum AttributeNames { | ||
// required by https://github.com/open-telemetry/opentelemetry-specification/blob/master/specification/data-semantic-conventions.md#databases-client-calls | ||
COMPONENT = 'component', |
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 we should move these common attributes to either core or base package, this is being used in almost all the plugins. WDYT?
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.
SGTM. I'll create an issue for it.
|
||
export class RedisPlugin extends BasePlugin<typeof redisTypes> { | ||
static readonly COMPONENT = 'redis'; | ||
readonly supportedVersions = ['^2.6.0']; // should be >= 2.6.0 |
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 include supported version in README.md?
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.
Done in 391326b
// New versions of redis (2.4+) use a single options object | ||
// instead of named arguments | ||
if (arguments.length === 1 && typeof cmd === 'object') { | ||
const span = plugin._tracer.startSpan(`redis-${cmd.command}`, { |
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.
const span = plugin._tracer.startSpan(`redis-${cmd.command}`, { | |
const span = plugin._tracer.startSpan(`${RedisPlugin.COMPONENT}-${cmd.command}`, { |
It would be awesome if you can include the example (may be in separate PR)? |
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.
Minor style suggestions, but LGTM
private _getPatchInternalSendCommand() { | ||
const plugin = this; | ||
return function internal_send_command(original: Function) { | ||
return function internal_send_command_trace( |
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.
Would it make sense to move this function out of the class and pass in plugin
as an argument (would need to wrap with an arrow function)? That could reducer the indentation of it
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.
Is this what you had in mind? 8654a71
} | ||
|
||
let spanEnded = false; | ||
const endSpan = (err?: Error | null) => { |
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 this be extracted as a helper function at the top level of the module?
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.
Agreed. I moved it out. I had to get rid of the spanEnded
check, but if the span is being ended more than once, its probably a bug that we should log out anyways.
@markwolff Could you please resolve Dave's comment and rebase with the master, looks good to go. |
Which problem is this PR solving?
Short description of the changes