MongoDB::Monitoring(3pm) | User Contributed Perl Documentation | MongoDB::Monitoring(3pm) |
MongoDB::Monitoring - Internal event monitoring API for instrumentation
version v2.0.3
The MongoDB::MongoClient takes an optional "monitoring_callback" attribute, which can be used to monitor events that occur during the operation of the driver.
The API is very simple: given a code reference, a hashref for each event is passed to the code reference. Here is a simple example that just accumulates events in an array:
our @events; my $cb = sub { push @events, $_[0] }; MongoDB->connect( $uri, { monitoring_callback => $cb } );
Every event is a hash reference, with a "type" field indicating the type, e.g. "command_started". Each type is described below.
This event is sent just before a command is put one the wire. It will be followed by either a "command_succeeded" or "command_failed" event.
Fields:
This event is sent just after a command reply is received, but only if the database reply document contains a non-false "ok" field. NOTE: write errors will have "ok:1" even though they have write errors; for writes, success indicates that the write attempt was valid, not that the write succeeded.
Fields:
This event is sent just after a command reply is received, but only if the database reply document contains a false "ok" field or if an exception occurred during send or receive operations.
Fields:
Certain commands are considered sensitive. When any of the following commands are seen in monitoring, the command body and database reply body are replaced with an empty document:
This software is Copyright (c) 2019 by MongoDB, Inc.
This is free software, licensed under:
The Apache License, Version 2.0, January 2004
2019-02-09 | perl v5.28.1 |