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

Postgres instrumentation creates a new span every time even when part of a request #227

Closed
iAmMrinal0 opened this issue Jul 2, 2018 · 6 comments

Comments

@iAmMrinal0
Copy link
Contributor

iAmMrinal0 commented Jul 2, 2018

I am using the zipkin express middleware with zipkin postgres and when I look in the zipkin dashboard, the middleware service shows up as a separate span and postgres as a separate span even though they are part of the same request. And this breaks any further traces for other services I have, like redis, axios. As seen in the image, all spans above express_middleware should have been a part of it and not separate on their own. If you could guide me as to what to change in the postgres instrumentation, that would be helpful too.

How it shows up:
screen shot 2018-07-02 at 20 03 20 2

How I am expecting it(this is for a different request which doesn't hit postgres):
screen shot 2018-07-02 at 20 09 39 2

Edit: Adding a few changes I have made to postgres instrumentation as I use an older version of pg

Changed the following few lines:

to:

promise.on('end', function () {
  annotateSuccess(id);
});
promise.on('error', function (error) {
  annotateError(id, error);
});
return promise;
@jcchavezs
Copy link
Contributor

Do you use CLS to keep the trace across spans into the same request?

@iAmMrinal0
Copy link
Contributor Author

Yes, I do use CLS in all the instrumentations.

@iAmMrinal0
Copy link
Contributor Author

I missed mentioning an important part of the setup, which is sequelize. I had to add CLS to sequelize and I checked zipkin-context-cls which was getting or creating the zipkin namespace for the CLS. That solved the issue.

@jcchavezs
Copy link
Contributor

jcchavezs commented Jul 4, 2018 via email

@saasen
Copy link

saasen commented Nov 3, 2019

@iAmMrinal0: Are you only using useCLS on sequlize, or do you manually trace stuff yourself? Does simply adding useCLS('zipkin') give you tracing against Postgres? Nothing of this works for me.

@iAmMrinal0
Copy link
Contributor Author

I had to manually trace each component I wanted. useCls('zipkin') only makes sure the context is passed further down the line to your other tracing components. So I had to modify the postgres related connection code in sequelize at that time.
Please note that, my knowledge is based on when I worked on it, which was around the time I created the issue. It could be possible that things have changed in sequelize/zipkin-js side to allow for easier tracing support. I hope I was helpful and answered what you were looking for.

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

No branches or pull requests

3 participants