BusinessEvents Performance Profiler : Turning Profiler On and Off

Turning Profiler On and Off
This section explains the different ways you can turn the profiler on and off.
To Turn Profiler On and Off Using BusinessEvents Monitoring and Management
If you have deployed the processing unit using BusinessEvents Monitoring and Management (MM), you can turn the profiler on and off using the MM Console.
Use of MM is documented in the TIBCO BusinessEvents Administration guide. In particular, see the section To Execute a Method and the section Profiler Group, both in Chapter 9, Monitoring and Managing a TIBCO BusinessEvents Cluster.
To Turn Profiler On and Off Using Properties
Set the following properties in the Cluster Deployment Descriptor (CDD) Processing Unit tab, for all processing units (engines) whose RTC performance you want to profile.
be.engine.profile.Agent_Class_Name.enable
If set to true, enables profiler for the specified agent class (Agent_Class_Name) when the agent initializes.
be.engine.profile.Agent_Class_Name.file
Optional, if be.engine.profile.*.file is specified.
If be.engine.profile.*.file is specified and be.engine.profile.Agent_Class_Name.file is not specified, then the file name is the value of be.engine.profile.*.file, with the Agent_Class_Name appended.
If the properties be.engine.profile.*.file and be.engine.profile.Agent_Class_Name.files are not specified the following occurs:
The file name is be-profile.csv, followed by an underbar, followed by the Agent_Class_Name: be-profile_Agent_Class_Name.csv
Default name is be-profile.csv and it is located under the current working directory, if file name is not specified.
be.engine.profile.Agent_Class_Name.duration
When the duration period ends, the profiler continues to collect statistics for the current RTC until the RTC is completed, then outputs data and stops. So the RTC in progress is always completed, even if the profiler is directed to stop during an RTC.
If you set duration to a value of zero or less (<= 0), then profiling continues until agent stops or profiler is explicitly turned of using a function or Hawk method.
When the duration period ends, the profiler continues to collect statistics for the current RTC until the RTC is completed, then outputs data and stops. So the RTC in progress is always completed, even if the profiler is directed to stop during an RTC.
If you set duration to a value of zero or less (<= 0), then profiling continues until the agents stop or profiler is explicitly turned of using a function or Hawk method.
When be.engine.profile.Agent_Class_Name.duration and be.engine.profile.*.duration are both present, the duration specified in be.engine.profile.Agent_Class_Name.duration takes precedence.
be.engine.profile.Agent_Class_Name.level
When be.engine.profile.Agent_Class_Name.level and be.engine.profile.*.level are both present, the level specified in be.engine.profile.Agent_Class_Name.level takes precedence.
To Turn Profiler On and Off Using Functions
This section assumes you understand how to use BusinessEvents functions. It tells you which functions to use and the effect of each function.
You can turn the profiler on using the engine properties, and turn it off using a function or Hawk method, as desired. See notes for be.engine.Agent_Class_Name.profile.duration and be.engine.*.profile.duration in Table 39, Profiler Configuration Properties (Sheet 1 of 3).
To turn the profiler on  In your rule or rule function, use the following function to turn on the profiler:

 
Engine.Profiler.startCollectingToFile(String fileName, int level, long duration)

 
The above function turns on the BusinessEvents Profiler and starts collecting data for the specified duration for the agent in which the rule or rule function that calls this function is executed. The profiler starts collecting data at the beginning of next RTC.
Profile data is output to the specified file in comma-separated value format at the end of the duration period, unless the profiler is turned off before the end of the duration, in which case it is output at the end of the RTC that completes after the profiler is turned off.
Input arguments are the same as the engine properties show in Table 39, Profiler Configuration Properties (Sheet 1 of 3):
String fileName: See be.engine.profile.Agent_Class_Name.file
int level: See be.engine.profile.Agent_Class_Name.level
long duration: See be.engine.profile.Agent_Class_Name.duration (Here Agent_Class_Name is the current agent in which the rule or rule function that calls this function is executed.)
To turn the profiler off  In your rule or rule function, use the following function to turn off the profiler:

 
Engine.Profiler.stopCollecting()

 
The above function turns off the BusinessEvents profiler and writes the profile data to a file for the agent in which the rule or rule function that calls this function is included (the file is output at the end of the RTC that completes after the profiler is turned off). There is no effect if the profiler is not on.
To Turn Profiler On and Off Using TIBCO Hawk Methods
This section assumes you understand how to use TIBCO Hawk methods. It tells you which methods to use and the effect of each method
Before you Begin  Ensure that the property hawk.enabled is set to true in the CDD at the cluster level before the BusinessEvents engine starts.
To turn the profiler on  Use the following method to turn on the profiler:

 
StartFileBasedProfiler(String session, String fileName, int level, long duration)

 
The above method turns on the BusinessEvents profiler for the specified agent. The profiler starts collecting data at the beginning of next RTC for the specified duration.
This method works the same way as the Engine.Profiler.startCollectingToFile() function (see To Turn Profiler On and Off Using Functions), except that it requires you to specify an agent class.
Input arguments are the same as the engine properties shown in Table 39, Profiler Configuration Properties (Sheet 1 of 3):
String session: If you want to monitor multiple agents, execute the method once for each, specifying the agent class name in each case. If there is only one agent, the session parameter is optional.
String fileName: See be.engine.profile.Agent_Class_Name.file
int level: See be.engine.profile.Agent_Class_Name.level
long duration: See be.engine.profile.Agent_Class_Name.duration
If you attempt to turn on the profiler when it is already running, an error is returned, but the running profiler is not affected.
To turn the profiler off  In your rule or rule function, use the following function to turn off the profiler:

 
StopFileBasedProfiler(String session)

 
The above method turns off the BusinessEvents profiler and writes the profile data into a file for the specified agent when the current RTC has completed. You must execute the method once for each session, as needed.
If you attempt to turn off the profiler when it is already off, an error is returned, but there is no effect on the profiler.