Inherits From:
NSObject
Inherits From:
com.apple.yellow.webobjects
Class Description
The WOStatisticsStore object records statistics about a WebObjects application while that application runs. All WebObjects applications have a WOStatisticsStore object, which you can access by sending statisticsStore to the WOApplication object.
Recording Information
The WOStatisticsStore object records the bulk of its statistics at the end of each cycle of the request-response loop. Specifically, at the end of WOSession's appendToResponse
method, the WOSession sends the recordStatisticsForResponse
message to the WOStatisticsStore. This message tells the WOStatisticsStore to begin recording statistics. Then, WOSession sends it a descriptionForResponse
message. This method sends the response component a descriptionForResponse
message. The default implementation of descriptionForResponse
in WOComponent returns the component's name.
You can override descriptionForResponse
in each of your components if you want to record more information. For example, you might want to record the values of all of the component's variables or perhaps just one or two key variables.
If you want to record extra information about the session, you can override WOStatisticsStore's recordStatisticsForResponse:inContext:
method.
Maintaining a Log File
You can maintain an application log file by sending the message setLogFile
to the WOStatisticsStore object. When a log file has been specified, each session records information in the log file about the pages it accessed.
The log is maintained in Common Log File Format (CLFF) so that it can be analyzed by any standard CLFF-analysis tool. (For more information about the statistics recorded in the log file, see the formatDescription
method description.) If a log file has been specified, the WOSession object keeps its own statistics about which pages it has accessed. When the session terminates, it writes this information to the log file.
WOStatisticsStore
()Returns an initialized WOStatisticsStore.
Instance Methods
descriptionForResponse
public java.lang.String descriptionForResponse
(WOResponse aResponse, WOContext aContext)
Records information about the current response by sending the descriptionForResponse
message to the response page and returning the result. This method is invoked at the end of the request-response loop in WOSession's appendToResponse
method, after the recordStatisticsForResponse
method.
formatDescription
public java.lang.String formatDescription
(java.lang.String responseDescription, WOResponse aResponse,
WOContext aContext)
If log file recording is enabled, this method formats the string responseDescription in using Common Log File Format (CLFF). The resulting string contains:
descriptionForResponse
method (by default, this method returns the response component's name)
setLogFile
method. This method is used by WOSession to record information about the current transaction when log file recording is enabled.
logFile
public java.lang.String logFile
()
Returns the full path to the CLFF log file. This log file does not exist unless you send setLogFile
to the WOStatisticsStore.
See also:
formatDescription
, logFileRotationFrequencyInDays
, logString
logFileRotationFrequencyInDays
public double logFileRotationFrequencyInDays
()
The number of days a log file lasts. That is, a log file's contents are flushed after a certain time interval to ensure that it does not grow too large and a new log file is started. This method returns that time interval.
Before a new log file is started, the contents of the current log file are saved to a backup file. You can then inspect this log file and/or remove it when its data has grown stale.
See also:
setLogFile
logString
public void logString
(java.lang.String aString)
Writes the string aString to the CLFF log file specified by logFile
. The method is used to record a session's statistics when that session ends. You can also use it to record any string to the log file that might be helpful to you.
See also:
formatDescription
sessionMovingAverageSampleSize
public int sessionMovingAverageSampleSiz
e()
Returns the sample size used to compute moving average statistics for each session. The WOStatisticsStore object uses this sample size to compute the response time for the last n transactions and the idle time between the last n transactions, where n is the number returned by this method. The default sample size is 10.
See also:
setSessionMovingAverageSampleSize
recordStatisticsForResponse
public void recordStatisticsForResponse
(WOResponse aResponse, WOContext aContext)
Records statistics for the current cycle of the request-response loop. This method is invoked at the end of WOSession's appendToResponse
method, immediately before the descriptionForResponse
method. By default, this method records the name of the response page for later use by descriptionForResponse:inContext:
. You can override it if you want to record more information about the session before the current request and response are deallocated. You must begin your implementation by invoking the superclass method.
setLogFile
public void setLogFile
(java.lang.String filePath, double logRotation)
Sets the full path of the log file to which CLFF statistics will be recorded to filePath. The logRotation argument specifies the number of days statistics will be recorded to this log file. Every logRotation days, the contents of the current log file are saved to a backup file and a new log file is started.
The default is not to record information to a log file.
See also:
logFile
, logFileRotationFrequencyInDays
setSessionMovingAverageSampleSize
public void setSessionMovingAverageSampleSize
(int aSize)
Sets the moving average sample size for each session to aSize. The WOStatisticsStore object uses this sample size to compute the response time for the last aSize transactions and the idle time between the last aSize transactions.
The default moving average session sample size is 10 transactions.
See also:
sessionMovingAverageSampleSize
setPassword
public void setPassword
(java.lang.String aPassword)
Implements security for the WOStats page by setting its password to aPassword. By default, there is no password, so any user can access the WOStats page (provided they know the URL). If you implement this method, when you enter the WOStats URL, a login panel appears. You can leave the User name field blank; as long as you type the appropriate password in the password field, the WOStats page will appear.
See also:
validateLogin
setTransactionMovingAverageSampleSize
public void setTransactionMovingAverageSampleSize
(int aSize)
Sets the moving average sample size for each transaction to aSize. The WOStatisticsStore object uses this sample size to compute the response time for the last aSize transactions and the idle time between the last aSize transactions.
The default moving average transaction sample size is 100 transactions.
See also:
transactionMovingAverageSampleSize
statistics
public NSDictionary statistics
()
Returns a dictionary containing the statistics that the WOStatisticsStore records.
The averages that are displayed by this method are not computed until this method is invoked. Therefore, invoking this method is costly and should not be done at every request.
transactionMovingAverageSampleSize
public int transactionMovingAverageSampleSiz
e()
Returns the sample size used to compute moving average statistics for each transaction. The WOStatisticsStore object uses this sample size to compute the response time for the last n transactions and the idle time between the last n transactions, where n is the number returned by this method. The default sample size is 100.
See also:
setTransactionMovingAverageSampleSize
validateLogin
public boolean validateLogin
(java.lang.String string, WOSession aSession)
Returns true
if string is the password set by setPassword
, and false
otherwise. The password controls if the user can see the WOStats page.