MongoDB\Driver\Monitoring\ServerHeartbeatSucceededEvent::getDurationMicros()

获取MongoDB服务器心跳成功事件的持续时间(以微秒为单位)

首字母:M

函数名称:MongoDB\Driver\Monitoring\ServerHeartbeatSucceededEvent::getDurationMicros()

函数描述:该函数用于获取MongoDB服务器心跳成功事件的持续时间(以微秒为单位)。

用法示例:

subscribe($subscriber);
// 创建一个MongoDB\Driver\Monitoring\CommandSucceededEvent对象
$event = new MongoDB\Driver\Monitoring\ServerHeartbeatSucceededEvent($manager, "localhost:27017", 1234);
// 获取事件持续时间(以微秒为单位)
$duration = $event->getDurationMicros();
echo "Server heartbeat succeeded event duration: " . $duration . " microseconds";
?>

注意事项:

  • 在使用该函数之前,需要先创建一个MongoDB\Driver\Monitoring\ServerHeartbeatSucceededEvent对象。
  • 该函数返回一个整数值,表示事件的持续时间(以微秒为单位)。
  • 该函数仅适用于MongoDB\Driver\Monitoring\ServerHeartbeatSucceededEvent对象。
  • 请确保在使用该函数之前,已经正确地配置和连接到MongoDB服务器。

同首字母函数