org.javasimon.javaee.reqreporter
Class DefaultRequestReporter

java.lang.Object
  extended by org.javasimon.javaee.reqreporter.DefaultRequestReporter
All Implemented Interfaces:
RequestReporter
Direct Known Subclasses:
StandardRequestReporter

public class DefaultRequestReporter
extends Object
implements RequestReporter

Reports significant splits (longer than 5% of the request) and list of all used stopwatches with their split counts. Report is sent through Manager.message(String). Following aspects of the class can be overridden:

Author:
Richard "Virgo" Richter

Nested Class Summary
protected  class DefaultRequestReporter.StopwatchInfo
           
 
Field Summary
private static int NOTE_OUTPUT_MAX_LEN
           
private  SimonServletFilter simonServletFilter
           
 
Constructor Summary
DefaultRequestReporter()
           
 
Method Summary
private  void addStopwatchInfo(StringBuilder messageBuilder, DefaultRequestReporter.StopwatchInfo info)
           
private  void addStopwatchSplitDistribution(StringBuilder messageBuilder, Map<String,DefaultRequestReporter.StopwatchInfo> stopwatchInfos)
           
private  void buildSplitDetails(Split requestSplit, List<Split> splits, StringBuilder messageBuilder)
           
protected  boolean isSignificantSplit(Split split, Split requestSplit)
          Can be overridden to decide whether Split is considered significant to be reported in the first part of the output.
private  void processSplitsAndAddSignificantOnes(Split requestSplit, List<Split> splits, StringBuilder messageBuilder, Map<String,DefaultRequestReporter.StopwatchInfo> stopwatchInfos)
           
protected  void reportMessage(String message)
          Reports the prepared message through the method Manager.message(String) - can be overridden to emit the message to log/console/etc.
 void reportRequest(javax.servlet.http.HttpServletRequest request, Split requestSplit, List<Split> splits)
          Reports request that exceeds the threshold.
 void setSimonServletFilter(SimonServletFilter simonServletFilter)
          Called by initialization after the instance creation.
protected  boolean shouldBeAddedStopwatchInfo(DefaultRequestReporter.StopwatchInfo info)
          Decides whether stopwatch info should be included in the report - by default all are included.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

NOTE_OUTPUT_MAX_LEN

private static final int NOTE_OUTPUT_MAX_LEN
See Also:
Constant Field Values

simonServletFilter

private SimonServletFilter simonServletFilter
Constructor Detail

DefaultRequestReporter

public DefaultRequestReporter()
Method Detail

reportRequest

public void reportRequest(javax.servlet.http.HttpServletRequest request,
                          Split requestSplit,
                          List<Split> splits)
Description copied from interface: RequestReporter
Reports request that exceeds the threshold.

Specified by:
reportRequest in interface RequestReporter
Parameters:
request - offending HTTP request
requestSplit - split measuring the offending request
splits - list of all splits started for this request

reportMessage

protected void reportMessage(String message)
Reports the prepared message through the method Manager.message(String) - can be overridden to emit the message to log/console/etc.

Parameters:
message - prepared message with report

buildSplitDetails

private void buildSplitDetails(Split requestSplit,
                               List<Split> splits,
                               StringBuilder messageBuilder)

processSplitsAndAddSignificantOnes

private void processSplitsAndAddSignificantOnes(Split requestSplit,
                                                List<Split> splits,
                                                StringBuilder messageBuilder,
                                                Map<String,DefaultRequestReporter.StopwatchInfo> stopwatchInfos)

isSignificantSplit

protected boolean isSignificantSplit(Split split,
                                     Split requestSplit)
Can be overridden to decide whether Split is considered significant to be reported in the first part of the output. By default all Splits with time over 5% of total request time are significant. This includes overlapping splits too, so more than 20 splits can be reported.

Parameters:
split - tested Split
requestSplit - Split for the whole HTTP request
Returns:
true, if tested Split is significant

addStopwatchSplitDistribution

private void addStopwatchSplitDistribution(StringBuilder messageBuilder,
                                           Map<String,DefaultRequestReporter.StopwatchInfo> stopwatchInfos)

shouldBeAddedStopwatchInfo

protected boolean shouldBeAddedStopwatchInfo(DefaultRequestReporter.StopwatchInfo info)
Decides whether stopwatch info should be included in the report - by default all are included.

Parameters:
info - stopwatch info contains list of all splits, max split and total time of splits for the reported request
Returns:
true, if the stopatch info should be reported

addStopwatchInfo

private void addStopwatchInfo(StringBuilder messageBuilder,
                              DefaultRequestReporter.StopwatchInfo info)

setSimonServletFilter

public void setSimonServletFilter(SimonServletFilter simonServletFilter)
Description copied from interface: RequestReporter
Called by initialization after the instance creation. Useful when Manager is needed (SimonServletFilter.getManager()) and possibly for other scenarios.

Specified by:
setSimonServletFilter in interface RequestReporter


Copyright © 2013. All Rights Reserved.