Skip to content
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

pass query itself to endQuery event. #200

Closed
facelessTT opened this issue Sep 5, 2016 · 3 comments
Closed

pass query itself to endQuery event. #200

facelessTT opened this issue Sep 5, 2016 · 3 comments
Assignees

Comments

@facelessTT
Copy link

facelessTT commented Sep 5, 2016

subj. It can be really helpful while catching slow queries.

    this.db.on("endQuery", function (obj, q) {
        if (obj.err)
            console.error(obj.err);

        var queryPerformance = obj && obj.perf && obj.perf.query ? obj.perf.query : -1;
        if (queryPerformance > 500)
            console.log('slow query performance:' + queryPerformance + ' on connection ' + options.connectionID);
//It would be nice to see, what query did its job slow
    });

in db.js:

  if (this.listeners('endQuery').length > 0) {
    var err, e, s = Date.now();
    promise
      .bind(this)
      .catch(function (_err) {
        err = _err;
      })
      .tap(function (res) {
        e = Date.now();
        this.emit("endQuery", {
          err: err,
          result: res,
          perf: {
            query: e - s
          }, 
            data: data
        });
      });
  }
@wolf4ood wolf4ood closed this as completed Sep 5, 2016
@wolf4ood wolf4ood reopened this Sep 5, 2016
@wolf4ood wolf4ood self-assigned this Sep 5, 2016
@wolf4ood wolf4ood added this to the 2.2.x (next hotfix) milestone Sep 5, 2016
@StarpTech
Copy link

StarpTech commented Sep 5, 2016

Would be great to get informations from serialization, network and query execution on the db. Measure time at the highest level is just an estimated value.

wolf4ood added a commit that referenced this issue Sep 7, 2016
@wolf4ood
Copy link
Member

wolf4ood commented Sep 7, 2016

@StarpTech

what would be cool but it will require more efforts.
Meanwhile i've implemented this. We can open a new issue to track the other enhancements.
Thanks

@wolf4ood
Copy link
Member

wolf4ood commented Sep 7, 2016

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants