Hi Pinaki
Welcome to Java Simon. Answers are in between your lines:
On Wed, Jul 31, 2013 at 2:42 PM, <
pinakib...@gmail.com> wrote:
> 1> Like if i want to measure one big activity (say login) which is composed
> of small activities (say doAuthentication, fetchProfileData etc), I can
> create stop watches at defferent parts of my code
The trouble is that aggregation is not supported (yet). There is no
clear answer whether to aggregate continuously - which may not be
needed if you need the sum only occasionally - or the other way around
- only on demand, when you may need the aggregate more often than the
simon changes. Answer might be to cache the aggregate in simon's
attributes and just remove it if simon changes - but then - any simon
change down the hierarchy needs to perform this reset.
Lastly - there is no standard way now, how to differentiate aggregate
simons from normal ones. And what to do with splits for aggregate
simons... too many questions I did not resolve yet.
You can utilize method org.javasimon.Manager#getSimons(pattern) to go
through all the subsimons of some simon and aggregate them on demand.
If there are tons of simons total it may be better to use
org.javasimon.Simon#getChildren recursively. Of course check for the
type of simons (don't aggregate coutners with stopwatches).
> At the end I can get aggregation on each level.
> I want to enable this type of monitoring all the time
Your requirement suggests normal and aggregate values needed on the
same Simon. Maybe aggregate Sample object could be put into
attributes.
> 2> By using a threadLocal logging Context and appending it I can capture the
> breakup for a single invocation as well.
> I put a random context initially say "Request-<random>"
> ("Request-14-27-34-334") and keeping appending api names and clear it at the
> end of bigger activity.
I don't understand exactly, but you probably mean something similar
like we do in SimonServletFilter with this callback:
org.javasimon.javaee.SimonServletFilter.SplitSaverCallback
Here we don't create many stopwatches, but we just log individual
splits when we decide so (mostly for long request, but policy can be
overriden). I'd consider logging of splits instead of many stopwatches
for every request.
> At the end I can get the breakup of times per request.
> I want this type of monitoring to be enabled if needed for a short time.
You can either use dedicated Manager for this -
org.javasimon.SwitchingManager to be precise, because you want to
enable and disable it. After you disable it, you may just call
org.javasimon.Manager#clear - then you:
- effectively clear the manager for this particular measuring
- you may still use long-term manager for normal production monitoring
> For Point 1 type of use (if in production env) I would like to know whether
> I can communicate to Simon API to use soft references for all Stopwatch
> objects.
> Even those Stopwatches are not reachable from my code after start/stop() and
> exit of my api(s), Simon will have the references for ever.
> I don't want the memory occupied by Simon objects to cause memory leak and
> cause OOM. I am happy to skip OOM and not to see nice Simon console if that
> is the case.
No, we don't have this capability as of now. It is possible to
implement another manager... however I can't imagine how should Simons
work when suddenly any of them can disappear from the hierarchy.
As of now I can't imagine anything but normal references.
Regards
Virgo