{
    "content": [
        {
            "type": "text",
            "text": "# MongoDB::Monitoring (perldoc)\n\n## NAME\n\nMongoDB::Monitoring - Internal event monitoring API for instrumentation\n\n## DESCRIPTION\n\nThe MongoDB::MongoClient takes an optional \"monitoringcallback\" attribute, which can be used to\nmonitor events that occur during the operation of the driver.\n\n## Sections\n\n- **NAME**\n- **VERSION**\n- **DESCRIPTION**\n- **EVENT TYPES** (2 subsections)\n- **REDACTION**\n- **AUTHORS**\n- **COPYRIGHT AND LICENSE**\n\nUse structuredContent.sections for detailed options, examples, and full documentation.\n"
        }
    ],
    "structuredContent": {
        "command": "MongoDB::Monitoring",
        "section": "",
        "mode": "perldoc",
        "summary": "MongoDB::Monitoring - Internal event monitoring API for instrumentation",
        "synopsis": null,
        "tldr_summary": null,
        "tldr_examples": [],
        "tldr_source": null,
        "flags": [],
        "examples": [],
        "see_also": [],
        "section_outline": [
            {
                "name": "NAME",
                "lines": 2,
                "subsections": []
            },
            {
                "name": "VERSION",
                "lines": 2,
                "subsections": []
            },
            {
                "name": "DESCRIPTION",
                "lines": 11,
                "subsections": []
            },
            {
                "name": "EVENT TYPES",
                "lines": 3,
                "subsections": [
                    {
                        "name": "Command Monitoring",
                        "lines": 66
                    },
                    {
                        "name": "Server Discovery and Monitoring",
                        "lines": 106
                    }
                ]
            },
            {
                "name": "REDACTION",
                "lines": 19,
                "subsections": []
            },
            {
                "name": "AUTHORS",
                "lines": 10,
                "subsections": []
            },
            {
                "name": "COPYRIGHT AND LICENSE",
                "lines": 6,
                "subsections": []
            }
        ],
        "sections": {
            "NAME": {
                "content": "MongoDB::Monitoring - Internal event monitoring API for instrumentation\n",
                "subsections": []
            },
            "VERSION": {
                "content": "version v2.2.2\n",
                "subsections": []
            },
            "DESCRIPTION": {
                "content": "The MongoDB::MongoClient takes an optional \"monitoringcallback\" attribute, which can be used to\nmonitor events that occur during the operation of the driver.\n\nThe API is very simple: given a code reference, a hashref for each event is passed to the code\nreference. Here is a simple example that just accumulates events in an array:\n\nour @events;\nmy $cb = sub { push @events, $[0] };\n\nMongoDB->connect( $uri, { monitoringcallback => $cb } );\n",
                "subsections": []
            },
            "EVENT TYPES": {
                "content": "Every event is a hash reference, with a \"type\" field indicating the type, e.g.\n\"commandstarted\". Each type is described below.\n",
                "subsections": [
                    {
                        "name": "Command Monitoring",
                        "content": "These events are fired for commands directly to the wire and the response.\n\ncommandstarted\nThis event is sent just before a command is put one the wire. It will be followed by either a\n\"commandsucceeded\" or \"commandfailed\" event.\n\nFields:\n\n*   type: \"commandstarted\"\n\n*   databaseName: the name of the database to which the command applies\n\n*   commandName: the name of the command being executed; for legacy operations that don't use\ncommands, the driver will convert them to appear as if they are in command form.\n\n*   command: a hash reference representing the full command to be sent\n\n*   requestId: the request identifier sent to the server\n\n*   connectionId: address and port of the destination server\n\ncommandsucceeded\nThis event is sent just after a command reply is received, but only if the database reply\ndocument contains a non-false \"ok\" field. NOTE: write errors will have \"ok:1\" even though they\nhave write errors; for writes, success indicates that the write attempt was valid, not that the\nwrite succeeded.\n\nFields:\n\n*   type: \"commandsucceeded\"\n\n*   commandName: the name of the command being executed\n\n*   durationSecs: the elapsed time in seconds since the \"commandstarted\" event.\n\n*   reply: a hash reference representing the full database reply\n\n*   requestId: the request identifier sent to the server\n\n*   connectionId: address and port of the destination server\n\ncommandfailed\nThis event is sent just after a command reply is received, but only if the database reply\ndocument contains a false \"ok\" field or if an exception occurred during send or receive\noperations.\n\nFields:\n\n*   type: \"commandfailed\"\n\n*   commandName: the name of the command being executed\n\n*   durationSecs: the elapsed time in seconds since the \"commandstarted\" event.\n\n*   failure: a string with a error message about the failure\n\n*   evalerror: if an exception occurs, this contains the value of $@ when the exception was\ncaught\n\n*   reply: a hash reference representing the full database reply or an empty hashref if the\nfailure is due to an exception\n\n*   requestId: the request identifier sent to the server\n\n*   connectionId: address and port of the destination server\n"
                    },
                    {
                        "name": "Server Discovery and Monitoring",
                        "content": "These events are fired when servers and topology are amended.\n\nserveropeningevent\nThis event is sent when a new server is added to the topology.\n\nFields:\n\n*   type: \"serveropeningevent\"\n\n*   topologyId: The topology refaddr\n\n*   address: address of the server\n\nserverclosedevent\nThis event is sent when a server is removed from the topology.\n\nFields:\n\n*   type: \"serverclosedevent\"\n\n*   topologyId: The topology refaddr\n\n*   address: address of the server\n\nserverdescriptionchangedevent\nThis event is sent when the server description changes, but does not include changes to the RTT.\n\nFields:\n\n*   type: \"serverdescriptionchangedevent\"\n\n*   address: address of the server\n\n*   topologyId: The topology refaddr\n\n*   previousDescription: Server Description before the change\n\n*   newDescription: Server Description after the change\n\ntopologyopeningevent\nThis event is sent when the topology is created.\n\nFields:\n\n*   type: \"topologyopeningevent\"\n\n*   topologyId: The topology refaddr\n\ntopologyclosedevent\nThis event is sent when the topology is closed.\n\nFields:\n\n*   type: \"topologyclosedevent\"\n\n*   topologyId: The topology refaddr\n\ntopologydescriptionchangedevent\nThis event is sent when the topology description changes.\n\nFields:\n\n*   type: \"topologydescriptionchangedevent\"\n\n*   topologyId: The topology refaddr\n\n*   previousDescription: Topology Description before the change\n\n*   newDescription: Topology Description after the change\n\nserverheartbeatstartedevent\nThis event is sent before the ismaster command is sent to the server.\n\nFields:\n\n*   type: \"serverheartbeatstartedevent\"\n\n*   connectionId: address of the link to connect to\n\nserverheartbeatsucceededevent\nThis event is sent after the reply from the ismaster command arrives from a successful reply.\n\nFields:\n\n*   type: \"serverheartbeatsucceededevent\"\n\n*   duration: time it took to send and receive a reply\n\n*   reply: the ismaster command reply\n\n*   connectionId: address of the server\n\nserverheartbeatfailedevent\nThis event is sent if there is a failure from the ismaster command, which returns an error\nstring of some sort.\n\nFields:\n\n*   type: \"serverheartbeatfailedevent\"\n\n*   duration: time it took to send and receive a reply\n\n*   failure: Returns an error string of the failure\n\n*   connectionId: address of the server\n"
                    }
                ]
            },
            "REDACTION": {
                "content": "Certain commands are considered sensitive. When any of the following commands are seen in\nmonitoring, the command body and database reply body are replaced with an empty document:\n\n*   authenticate\n\n*   saslStart\n\n*   saslContinue\n\n*   getnonce\n\n*   createUser\n\n*   updateUser\n\n*   copydbgetnonce\n\n*   copydbsaslstart\n",
                "subsections": []
            },
            "AUTHORS": {
                "content": "*   David Golden <david@mongodb.com>\n\n*   Rassi <rassi@mongodb.com>\n\n*   Mike Friedman <friedo@friedo.com>\n\n*   Kristina Chodorow <k.chodorow@gmail.com>\n\n*   Florian Ragwitz <rafl@debian.org>\n",
                "subsections": []
            },
            "COPYRIGHT AND LICENSE": {
                "content": "This software is Copyright (c) 2020 by MongoDB, Inc.\n\nThis is free software, licensed under:\n\nThe Apache License, Version 2.0, January 2004\n",
                "subsections": []
            }
        }
    }
}