0

I hava a WebApp that authenticates the users and each of their main actions are recorded in the log files.However those actions call some webservice the might call other webservices on other machines.

I would like to be able to track in the logs of those machines each user request because I am allowed to add more logs but not to change the signature of the service by adding a new field.

I was thinking to use an UUID (correlation id) and Http header to carry it.

Do you know another solution ?

Thanks

Cris
  • 4,947
  • 6
  • 44
  • 73

1 Answers1

1

Not sure if you are using Spring, but with Spring you could intercept methods and log stuff in there, and you could do it without changing your signatures at all.

Check this answer, may help you How to intercept a method in java

Community
  • 1
  • 1
psabbate
  • 767
  • 1
  • 5
  • 22
  • Not intercepting is my concern ....is how i pass the initial correlation id from one system to another – Cris Sep 27 '16 at 22:41
  • What's the correlation ID? can't you pass it using a ThreadLocal variable? – psabbate Sep 27 '16 at 22:42
  • @Cris something like this http://tutorials.jenkov.com/java-concurrency/threadlocal.html. That way you don't have to change any signature at all. Your UUID (whatever it is, is going to write/read for that specific thread, which is in fact the original request) – psabbate Sep 27 '16 at 22:46
  • Threadlocal is inside the webapp but the webapp is calling a WS on another machine and so on...http and jms, so question is if it is ok to use the transport protocol for that ? – Cris Sep 27 '16 at 22:48
  • Sorry, you lost me man. Your question said that you are allowed to add logs an such, but not changing signatures. I thought you were planning to add logs and such to those other webservices. If you can't change the code to the other webservices/webapps, and think the only thing you can do is access their access.log files. Maybe you can add some queryString parameter like: myOriginalRequestPath/aPathParam?t=123&yourUUID=456 That way you can use that paramter to filter/analyze those access logs. – psabbate Sep 27 '16 at 23:06