-
Notifications
You must be signed in to change notification settings - Fork 18
Traceability
pmzajaczkowski edited this page Mar 17, 2016
·
3 revisions
Ratel provides a notion of ProcessContext that is a thread-local set of context variables, such as randomly generated process id. It allows you to log the execution of a process going through multiple nodes. You can always refer to the actual process context by calling
ProcessContext.getInstance()
Suppose that you have the following two services, deployed on different machines and one is calling the other:
public class FirstServiceImpl implements FirstService{
...
@Discover
SecondService second;
public void firstJob() {
LOGGER.info("Doing 1st " + ProcessContext.getInstance().getProcessId());
second.secondJob(); //<- Ratel guarantees that ProcessContext will be populated to a remote
}
public class SecondServiceImpl implements SecondService{
...
public void secondJob() {
LOGGER.info("Doing 2nd " + ProcessContext.getInstance().getProcessId());
}
Running firstServiceClient.firstJob()
can produce the following entry in the two servers log:
2015-04-14 17:06:47.475 INFO 15056 --- [nio-8031-exec-3] c.p.r.t.s.t.FirstServiceImpl : doing 1st 1e5b3300-9fb2-4b2e-839d-4bd4774c7bef
...
2015-04-14 17:06:47.679 INFO 12056 --- [nio-8031-exec-5] c.p.r.t.s.t.SecondServiceImpl : doing 2nd 1e5b3300-9fb2-4b2e-839d-4bd4774c7bef
When you are using a common log collector, you can correlate these two logs by the processId, and build convenient tracing and monitoring dashboards with it