0

I found myself stuck on an unconventional problem. I am to write a component in Java that will gather some information from a multi-thread system. I will appreciate any information or advice that could help me progress. Here are some details:

-system contains many subsystems that exchange information between each other (e.g. one component can run other component to do some logging or calculate data)

-each operation performed on the system is more of a chain of commands and leads to running few components in a row,

-system gets a great number of requests and operations have no ID so its hard to keep track of which operation belongs to which chain (I need to get the time of operation on every step of the chain)

The problems I have to deal with: -lack of IDs on operations -eventual exchanging IDs between subsystems -least possible change of code (Its a HUGE system) -eventually finding existing open-source solution to this kind of problem (or at least some part of it)

Here is and example result of my component from a single operation:

Search nr 60

Component1 45s Component6 2s Component4 32s Component2 4s

Where 45, 2, 32, 4 stand for the time spent in each component

If anyone found himself solving similar problem or has experience in the field of logging/information gathering, your advice can greatly help me.

Edit: I created component in AspectJ which can measure time 'around' every method and gather together results from each subsystem. The main problem is I cannot identify which log belong to which request (e.g. particular "search no. 60" or "add no. 5" request). So the question is: is any effective way to create request-ID which can be transferred (and how to transfer it) with control flow without massive source-code change?

alicjasalamon
  • 4,171
  • 15
  • 41
  • 65
  • If each operation cannot identify itself, and the path of the operation request/data/result object through your system can vary, I can't see how this can be done effectively. Can you not add a 'register/getID' operation somewhere at the top of your inheritance tree to introduce an operation ID, preferably with start() and end() methods that can record the operation times in an array/list data member of the operation object? – Martin James Jul 23 '12 at 04:23

1 Answers1

0

If operations are within a single JVM, then you might be able to use their system hashcode (obtained via System.identityHashcode() to track the objects. If the system is multi-process or distributed then you are out of luck with this approach.

You might be able to use aspect-oriented programming to weave in instrumentation code without changing the existing code.

DNA
  • 42,007
  • 12
  • 107
  • 146