Skip to content

Commit 2e1d88c

Browse files
committed
CXX-2723 Document exception undefined behavior for APM callbacks
1 parent 6ab81f4 commit 2e1d88c

File tree

2 files changed

+40
-2
lines changed

2 files changed

+40
-2
lines changed

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,3 +16,6 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1616

1717
### Changed
1818
- Do not build tests as part of `all` target. Configure with `BUILD_TESTING=ON` to build tests.
19+
20+
### Fixed
21+
- Explicitly document that throwing an exception from an APM callback is undefined behavior.

src/mongocxx/options/apm.hpp

Lines changed: 37 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,9 @@ class MONGOCXX_API apm {
4444
/// Set the command started monitoring callback. The callback takes a reference to a
4545
/// command_started_event which will only contain valid data for the duration of the callback.
4646
///
47+
/// @warning
48+
/// If the callback throws an exception, the behavior is undefined.
49+
///
4750
/// @param command_started
4851
/// The command started monitoring callback.
4952
///
@@ -66,6 +69,9 @@ class MONGOCXX_API apm {
6669
/// Set the command failed monitoring callback. The callback takes a reference to a
6770
/// command_failed_event which will only contain valid data for the duration of the callback.
6871
///
72+
/// @warning
73+
/// If the callback throws an exception, the behavior is undefined.
74+
///
6975
/// @param command_failed
7076
/// The command failed monitoring callback.
7177
///
@@ -88,6 +94,9 @@ class MONGOCXX_API apm {
8894
/// Set the command succeeded monitoring callback. The callback takes a reference to a
8995
/// command_succeeded_event which will only contain valid data for the duration of the callback.
9096
///
97+
/// @warning
98+
/// If the callback throws an exception, the behavior is undefined.
99+
///
91100
/// @param command_succeeded
92101
/// The command succeeded monitoring callback.
93102
///
@@ -110,6 +119,9 @@ class MONGOCXX_API apm {
110119
/// Set the server opening monitoring callback. The callback takes a reference to a
111120
/// server_opening_event which will only contain valid data for the duration of the callback.
112121
///
122+
/// @warning
123+
/// If the callback throws an exception, the behavior is undefined.
124+
///
113125
/// @param server_opening
114126
/// The server opening monitoring callback.
115127
///
@@ -132,6 +144,9 @@ class MONGOCXX_API apm {
132144
/// Set the server closed monitoring callback. The callback takes a reference to a
133145
/// server_closed_event which will only contain valid data for the duration of the callback.
134146
///
147+
/// @warning
148+
/// If the callback throws an exception, the behavior is undefined.
149+
///
135150
/// @param server_closed
136151
/// The server closed monitoring callback.
137152
///
@@ -154,6 +169,9 @@ class MONGOCXX_API apm {
154169
/// server_changed_event which will only contain valid data for the duration of the
155170
/// callback.
156171
///
172+
/// @warning
173+
/// If the callback throws an exception, the behavior is undefined.
174+
///
157175
/// @param server_changed
158176
/// The server description changed monitoring callback.
159177
///
@@ -176,6 +194,9 @@ class MONGOCXX_API apm {
176194
/// Set the topology_opening monitoring callback. The callback takes a reference to a
177195
/// topology_opening_event which will only contain valid data for the duration of the callback.
178196
///
197+
/// @warning
198+
/// If the callback throws an exception, the behavior is undefined.
199+
///
179200
/// @param topology_opening
180201
/// The topology_opening monitoring callback.
181202
///
@@ -198,6 +219,9 @@ class MONGOCXX_API apm {
198219
/// Set the topology closed monitoring callback. The callback takes a reference to a
199220
/// topology_closed_event which will only contain valid data for the duration of the callback.
200221
///
222+
/// @warning
223+
/// If the callback throws an exception, the behavior is undefined.
224+
///
201225
/// @param topology_closed
202226
/// The topology closed monitoring callback.
203227
///
@@ -218,10 +242,12 @@ class MONGOCXX_API apm {
218242

219243
///
220244
/// Set the topology description changed monitoring callback. The callback takes a reference to
221-
/// a
222-
/// topology_changed_event which will only contain valid data for the duration of
245+
/// a topology_changed_event which will only contain valid data for the duration of
223246
/// the callback.
224247
///
248+
/// @warning
249+
/// If the callback throws an exception, the behavior is undefined.
250+
///
225251
/// @param topology_changed
226252
/// The topology description changed monitoring callback.
227253
///
@@ -244,6 +270,9 @@ class MONGOCXX_API apm {
244270
/// Set the heartbeat started monitoring callback. The callback takes a reference to a
245271
/// heartbeat_started_event which will only contain valid data for the duration of the callback.
246272
///
273+
/// @warning
274+
/// If the callback throws an exception, the behavior is undefined.
275+
///
247276
/// @param heartbeat_started
248277
/// The heartbeat started monitoring callback.
249278
///
@@ -266,6 +295,9 @@ class MONGOCXX_API apm {
266295
/// Set the heartbeat failed monitoring callback. The callback takes a reference to a
267296
/// heartbeat_failed_event which will only contain valid data for the duration of the callback.
268297
///
298+
/// @warning
299+
/// If the callback throws an exception, the behavior is undefined.
300+
///
269301
/// @param heartbeat_failed
270302
/// The heartbeat failed monitoring callback.
271303
///
@@ -289,6 +321,9 @@ class MONGOCXX_API apm {
289321
/// heartbeat_succeeded_event which will only contain valid data for the duration of the
290322
/// callback.
291323
///
324+
/// @warning
325+
/// If the callback throws an exception, the behavior is undefined.
326+
///
292327
/// @param heartbeat_succeeded
293328
/// The heartbeat succeeded monitoring callback.
294329
///

0 commit comments

Comments
 (0)