Skip to main content

Writing Custom Code to Record Activity

Writing Custom Code to Record Activity

In addition to using the built-in statistics mechanism, you can write custom code to:

  • Fill in the site dimension field of the recorded statistics. This allows you to provide additional information in the statistics.

  • Explicitly record custom statistics to be stored in the database. In this case, you don’t activate statistics for the component. You are using the mechanism that aggregates the data and transfers the statistics data from the temporary storage to the permanently stored database.

To specify the site dimension to be recorded with the statistics, use the SetStatsUserDimension()Opens in a new tab method. For example, the following code first checks that statistics are enabled and then it sets the site dimension to “CriticalAction”.

 If ##class(Ens.Util.Statistics).StatsStarted(..%ConfigName) {
  Do ##class(Ens.Util.Statistics).SetStatsUserDimension(..%ConfigName,"CriticalAction")
 }

The RecordStats()Opens in a new tab method writes the specified statistics data to the temporary storage. The data will be aggregated to the three tables. Consider the following example:

Do ##class(Ens.Util.Statistics).RecordStats(0,"IncomingMsgSrvc","ActiveMsgs",1,4087,35)

The parameters have the following meaning:

  • 0—specifies the unknown host type.

  • "IncomingMsgSrvc"—used as the configuration item name. This does not have to match the component’s configuration item name.

  • ”ActiveMsgs”—used for the site dimension.

  • 1—specifies to release temporary memory after writing the statistics.

  • 4087—specifies that 4087 messages were processed.

  • 35—specifies a total duration for the messages of 35 seconds.

FeedbackOpens in a new tab