Skip to main content
Version: 20 R7 BETA

START MONITORING ACTIVITY

START MONITORING ACTIVITY ( duration {; source} )

ParameterTypeDescription
durationRealLength of time (in seconds) before logging begins
sourceIntegerOrigin of an operation

Description

The START MONITORING ACTIVITY command records operations exceeding a specified duration in memory. It can be called and executed on 4D remote, 4D Server, and 4D standalone applications (if source isn't from network activity). Recorded activity can be retrieved using the Monitored activity command. Call STOP MONITORING ACTIVITY when you want to stop tracking activity.

In the duration parameter, pass a number defining a length of time before loggin begins (in seconds, can be expressed as a decimal) for an operation's execution. Once an operation's execution exceeds the duration, the operation will be recorded in memory.

The optional source parameter defines the kind of activity to monitor. Possible values:

ConstantValueComment
Activity all-1Activity from all sources (default value)
Activity language1Language execution operations
Activity network2Network request operations
Activity operations44D data operations

Note: If the debug logs have been stopped on the 4D Server GRAPH SETTINGS, START MONITORING ACTIVITY with Activity network will restart the logs.

Example

You want to start/stop monitoring and review 4D data and debug activities lasting longer than a millisecond:

 var $activities : Collection
 
 START MONITORING ACTIVITY(0.001;Activity operations+Activity language)
 
 $coll:=ds.Persons.all().toCollection("firstname, lastname, address.*")
 
  //return all operations over 1 millisecond from the 4D data activity and the debug log
 $activities:=Monitored activity
 
 $text:=JSON Stringify($activities.orderBy("startTime");*)
 TEXT TO DOCUMENT("result.txt";$text)
 
  //end monitoring for 4D data activity and from the debug log
 STOP MONITORING ACTIVITY()

result.txt:

[
{
"activityKind": 4,
"activityDuration": 0.005,
"activityData": {
"message": "Exporting selection of entities in Persons as a collection: 400 of 401 entities",
"maxValue": 401,
"currentValue": 400,
"interruptible": true,
"remote": false,
"uuid": "4ED341FCF8BF40649C9A827EF794A688",
"taskId": -5,
"startTime": "2020-02-28 13:20:00:010",
"duration": 5,
"title": "Entities To Collection"
}
},
{
"activityKind": 1,
"activityDuration": 0.005,
"activityData": {
"sequenceNumber": 2514,
"elapsedTime": 5,
"processID": 7,
"uniqueProcessID": 14,
"stackLevel": 0,
"duration": 5056,
"kind": "Member",
"parameters": "firstname, lastname, address.*",
"functionName": "toCollection"
}
}
]

See also

Monitored activity
STOP MONITORING ACTIVITY