Documentation Archive Developer
Search
[an error occurred while processing this directive] PATH  Documentation > WebObjects 4.5 > WebObjects Reference

Table of Contents

WOStatisticsStore


Inherits from: NSObject
Conforms to: NSObject
(NSObject)
Declared in: WebObjects/WOStatisticsStore.h




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:inContext: method, the WOSession sends the recordStatisticsForResponse:inContext: message to the WOStatisticsStore. This message tells the WOStatisticsStore to begin recording statistics. Then, WOSession sends it a descriptionForResponse:inContext: message. This method sends the response component a descriptionForResponse:inContext: message. The default implementation of descriptionForResponse:inContext: in WOComponent returns the component's name.

You can override descriptionForResponse:inContext: 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:rotationFrequencyInDays: 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:forResponse:inContext: 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.




Adopted Protocols


NSLocking
- lock
- unlock


Method Types


Recording information
- recordStatisticsForResponse:inContext:
- descriptionForResponse:inContext:
- setSessionMovingAverageSampleSize:
- transactionMovingAverageSampleSize
Retrieving information
- statistics
Maintaining a CLFF log file
- setLogFile:rotationFrequencyInDays:
- logFileRotationFrequencyInDays
- logFile
Recording information in the CLFF log file
- formatDescription:forResponse:inContext:
- logString:
Securing access to the WOStats page
- setPassword:
- validateLogin:forSession:


Instance Methods



descriptionForResponse:inContext:

- (NSString *)descriptionForResponse:(WOResponse *)aResponse inContext:(WOContext *)aContext

Records information about the current response by sending the descriptionForResponse:inContext: 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:inContext: method, after the recordStatisticsForResponse:inContext: method.

formatDescription:forResponse:inContext:

- (NSString *)formatDescription:(NSString *)responseDescription forResponse:(WOResponse *)aResponse inContext:(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:

You enable log file recording by setting a log file using the setLogFile:rotationFrequencyInDays: method.

This method is used by WOSession to record information about the current transaction when log file recording is enabled.

See Also: - logFile, - logString:



logFile

- (NSString *)logFile

Returns the full path to the CLFF log file. This log file does not exist unless you send setLogFile:rotationFrequencyInDays: to the WOStatisticsStore.

See Also: - formatDescription:forResponse:inContext:, - logFileRotationFrequencyInDays, - logString:



logFileRotationFrequencyInDays

- (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:rotationFrequencyInDays:



logString:

- (void)logString:(NSString *)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:forResponse:inContext:



recordStatisticsForResponse:inContext:

- (void)recordStatisticsForResponse:(WOResponse *)aResponse inContext:(WOContext *)aContext

Records statistics for the current cycle of the request-response loop. This method is invoked at the end of WOSession's appendToResponse:inContext: method, immediately before the descriptionForResponse:inContext: 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.

sessionMovingAverageSampleSize

- (int)sessionMovingAverageSampleSize

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:



setLogFile:rotationFrequencyInDays:

- (void)setLogFile:(NSString *)filePath rotationFrequencyInDays:(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



setPassword:

- (void)setPassword:(NSString *)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:forSession:



setSessionMovingAverageSampleSize:

- (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



setTransactionMovingAverageSampleSize:

- (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

- (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

- (int)transactionMovingAverageSampleSize

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:forSession:

- (BOOL)validateLogin:(NSString *)string forSession:(WOSession *)aSession

Returns YES if string is the password set by setPassword:, and NO otherwise. The password controls if the user can see the WOStats page.


Table of Contents