MongoDB C++ Driver  mongocxx-3.7.0
apm.hpp
1 // Copyright 2018-present MongoDB Inc.
2 //
3 // Licensed under the Apache License, Version 2.0 (the "License");
4 // you may not use this file except in compliance with the License.
5 // You may obtain a copy of the License at
6 //
7 // http://www.apache.org/licenses/LICENSE-2.0
8 //
9 // Unless required by applicable law or agreed to in writing, software
10 // distributed under the License is distributed on an "AS IS" BASIS,
11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 // See the License for the specific language governing permissions and
13 // limitations under the License.
14 
15 #pragma once
16 
17 #include <functional>
18 
19 #include <mongocxx/events/command_failed_event.hpp>
20 #include <mongocxx/events/command_started_event.hpp>
21 #include <mongocxx/events/command_succeeded_event.hpp>
22 #include <mongocxx/events/heartbeat_failed_event.hpp>
23 #include <mongocxx/events/heartbeat_started_event.hpp>
24 #include <mongocxx/events/heartbeat_succeeded_event.hpp>
25 #include <mongocxx/events/server_changed_event.hpp>
26 #include <mongocxx/events/server_closed_event.hpp>
27 #include <mongocxx/events/server_opening_event.hpp>
28 #include <mongocxx/events/topology_changed_event.hpp>
29 #include <mongocxx/events/topology_closed_event.hpp>
30 #include <mongocxx/events/topology_opening_event.hpp>
31 
32 #include <mongocxx/config/prelude.hpp>
33 
34 namespace mongocxx {
35 MONGOCXX_INLINE_NAMESPACE_BEGIN
36 namespace options {
37 
41 class MONGOCXX_API apm {
42  public:
54  apm& on_command_started(
55  std::function<void(const mongocxx::events::command_started_event&)> command_started);
56 
62  const std::function<void(const mongocxx::events::command_started_event&)>& command_started()
63  const;
64 
76  apm& on_command_failed(
77  std::function<void(const mongocxx::events::command_failed_event&)> command_failed);
78 
84  const std::function<void(const mongocxx::events::command_failed_event&)>& command_failed()
85  const;
86 
98  apm& on_command_succeeded(
99  std::function<void(const mongocxx::events::command_succeeded_event&)> command_succeeded);
100 
106  const std::function<void(const mongocxx::events::command_succeeded_event&)>& command_succeeded()
107  const;
108 
120  apm& on_server_opening(
121  std::function<void(const mongocxx::events::server_opening_event&)> server_opening);
122 
128  const std::function<void(const mongocxx::events::server_opening_event&)>& server_opening()
129  const;
130 
142  apm& on_server_closed(
143  std::function<void(const mongocxx::events::server_closed_event&)> server_closed);
144 
150  const std::function<void(const mongocxx::events::server_closed_event&)>& server_closed() const;
151 
164  apm& on_server_changed(
165  std::function<void(const mongocxx::events::server_changed_event&)> server_changed);
166 
172  const std::function<void(const mongocxx::events::server_changed_event&)>& server_changed()
173  const;
174 
186  apm& on_topology_opening(
187  std::function<void(const mongocxx::events::topology_opening_event&)> topology_opening);
188 
194  const std::function<void(const mongocxx::events::topology_opening_event&)>& topology_opening()
195  const;
196 
208  apm& on_topology_closed(
209  std::function<void(const mongocxx::events::topology_closed_event&)> topology_closed);
210 
216  const std::function<void(const mongocxx::events::topology_closed_event&)>& topology_closed()
217  const;
218 
232  apm& on_topology_changed(
233  std::function<void(const mongocxx::events::topology_changed_event&)> topology_changed);
234 
240  const std::function<void(const mongocxx::events::topology_changed_event&)>& topology_changed()
241  const;
242 
254  apm& on_heartbeat_started(
255  std::function<void(const mongocxx::events::heartbeat_started_event&)> heartbeat_started);
256 
262  const std::function<void(const mongocxx::events::heartbeat_started_event&)>& heartbeat_started()
263  const;
264 
276  apm& on_heartbeat_failed(
277  std::function<void(const mongocxx::events::heartbeat_failed_event&)> heartbeat_failed);
278 
284  const std::function<void(const mongocxx::events::heartbeat_failed_event&)>& heartbeat_failed()
285  const;
286 
299  apm& on_heartbeat_succeeded(
300  std::function<void(const mongocxx::events::heartbeat_succeeded_event&)>
301  heartbeat_succeeded);
302 
308  const std::function<void(const mongocxx::events::heartbeat_succeeded_event&)>&
309  heartbeat_succeeded() const;
310 
311  private:
312  std::function<void(const mongocxx::events::command_started_event&)> _command_started;
313  std::function<void(const mongocxx::events::command_failed_event&)> _command_failed;
314  std::function<void(const mongocxx::events::command_succeeded_event&)> _command_succeeded;
315  std::function<void(const mongocxx::events::server_closed_event&)> _server_closed;
316  std::function<void(const mongocxx::events::server_changed_event&)> _server_changed;
317  std::function<void(const mongocxx::events::server_opening_event&)> _server_opening;
318  std::function<void(const mongocxx::events::topology_closed_event&)> _topology_closed;
319  std::function<void(const mongocxx::events::topology_changed_event&)> _topology_changed;
320  std::function<void(const mongocxx::events::topology_opening_event&)> _topology_opening;
321  std::function<void(const mongocxx::events::heartbeat_started_event&)> _heartbeat_started;
322  std::function<void(const mongocxx::events::heartbeat_failed_event&)> _heartbeat_failed;
323  std::function<void(const mongocxx::events::heartbeat_succeeded_event&)> _heartbeat_succeeded;
324 };
325 
326 } // namespace options
327 MONGOCXX_INLINE_NAMESPACE_END
328 } // namespace mongocxx
329 
330 #include <mongocxx/config/postlude.hpp>
mongocxx::events::heartbeat_started_event
An event notification sent when the driver begins executing a "hello" command to check the status of ...
Definition: heartbeat_started_event.hpp:33
mongocxx
Top level namespace for the MongoDB C++ driver.
Definition: bulk_write.hpp:24
mongocxx::events::heartbeat_failed_event
An event notification sent when the driver failed to send an "hello" command to check the status of a...
Definition: heartbeat_failed_event.hpp:33
mongocxx::events::command_failed_event
An event notification sent when the driver fails to execute a MongoDB command.
Definition: command_failed_event.hpp:36
mongocxx::events::topology_closed_event
An event notification sent when the driver stops monitoring a server topology and destroys its descri...
Definition: topology_closed_event.hpp:33
mongocxx::events::server_changed_event
An event notification sent when the driver observes a change in the status of a server it is connecte...
Definition: server_changed_event.hpp:35
mongocxx::events::server_closed_event
An event notification sent when the driver stops monitoring a MongoDB server and removes it from the ...
Definition: server_closed_event.hpp:34
mongocxx::events::command_succeeded_event
An event notification sent when the driver successfully executes a MongoDB command.
Definition: command_succeeded_event.hpp:36
mongocxx::events::heartbeat_succeeded_event
An event notification sent when the driver completes a "hello" command to check the status of a serve...
Definition: heartbeat_succeeded_event.hpp:34
mongocxx::options::apm
Class representing MongoDB application performance monitoring.
Definition: apm.hpp:41
mongocxx::events::server_opening_event
An event notification sent when the driver adds a MongoDB server to the topology description and begi...
Definition: server_opening_event.hpp:33
mongocxx::events::command_started_event
An event notification sent when the driver begins executing a MongoDB command.
Definition: command_started_event.hpp:36
mongocxx::events::topology_changed_event
An event notification sent when the driver observes a change in any of the servers it is connected to...
Definition: topology_changed_event.hpp:34
mongocxx::events::topology_opening_event
An event notification sent when the driver initializes a server topology.
Definition: topology_opening_event.hpp:33