-
Notifications
You must be signed in to change notification settings - Fork 388
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
Adding ioredis support. #212
Conversation
It now adds support to ioredis and has the same integration tests as the other Redis module. |
👍 This PR is really useful for my projects |
@guilhermef thanks for doing this, nice work. It looks like it is more or less a drop in for the redis module. We should be able to include it in one of our upcoming releases. |
thanks @martinkuba . |
Is there a newrelic recommendation on how to utilize this change while we're waiting on an official merge? I could replace |
@philidem yes, that's what you would have to do for now. Another option would be to fork and install from Github. |
This is the code that I used to manually instrument ioredis: const newrelic = require('newrelic');
const Redis = require('ioredis');
let orig_sendCommand = Redis.prototype.sendCommand;
let nextId = 0;
Redis.prototype.sendCommand = function(command, stream) {
let promise = orig_sendCommand.call(this, command, stream);
if (promise) {
promise.finally(newrelic.createTracer('redis ' + command.name, () => {
// nothing to do
}));
}
return promise;
}; It seems to be working but if you see anything wrong with this approach then please let me know. |
// capture connection info for datastore instance metric | ||
segment.port = this.connector.options.port | ||
segment.host = this.connector.options.host | ||
args[0].promise._then = (function(promise, original){ |
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 would take this wrapping out - we probably do not want to represent these as callback segments (the bind() call is meant specifically for callbacks). Also, wrapping 'then' here will not work well with chained promises, as far as how they would be displayed in traces. Better place to handle this would be by instrumenting Bluebird, which we are planning to work on.
@guilhermef See my comment about wrapping 'then'. In addition, ioredis allows using callbacks instead of promises, which would need more work. We think we can address all of this by instrumenting Bluebird better. If you take out wrapping 'then', we will accept the PR. |
Sure, I'll change the PR this weekend.
|
is there any plan to merge it and release? |
👍 we need this support as well |
This is really useful @guilhermef 👍 |
This was merged out of band in v1.26.2, thanks so much! |
What should I do to use this support? |
@wong2 node-newrelic supports ioredis out-of-the-box: https://github.com/newrelic/node-newrelic/blob/master/lib/instrumentation/ioredis.js |
@guilhermef yeah I find it out, it's because I'm using async/await |
@wong2 I am using async/await for ioredis as well. is there a way to make it work? |
@wong2 @guilhermef The New Relic Node Agent supports async/await on Node 8 since 2.3.0. If you're having problems with async/await support in the Node Agent, I recommend checking our support website and maybe opening a post on our forums where our support engineers can help you. |
…/babel/traverse-and-babel/traverse-7.23.2 chore(deps): bump @babel/traverse
…/babel/traverse-and-babel/traverse-7.23.2 chore(deps): bump @babel/traverse
Ioredis is the top recommended client for Redis, and It's the only one that supports Sentinel and cluster.
Right now a few tests are broken, I'll change the PR as soon as it passes.
I'll just leave this here to get some help from the community on a few issues.