Skip to content

CDRIVER-4557 add int64 connection_id functions #1246

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 6 commits into from
Apr 26, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,9 @@ Synopsis

int32_t
mongoc_apm_command_failed_get_server_connection_id (
const mongoc_apm_command_failed_t *event);
const mongoc_apm_command_failed_t *event)
BSON_GNUC_DEPRECATED_FOR (
"mongoc_apm_command_failed_get_server_connection_id_int64");

Returns this event's context.

Expand All @@ -19,6 +21,12 @@ distinct from the server ID (:symbol:`mongoc_apm_command_failed_get_server_id`)
and is returned by the hello or legacy hello response as "connectionId" from the
server on 4.2+.

Deprecated
----------

This function is deprecated. Please use
:symbol:`mongoc_apm_command_failed_get_server_connection_id_int64` in new code.

Parameters
----------

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
:man_page: mongoc_apm_command_failed_get_server_connection_id_int64

mongoc_apm_command_failed_get_server_connection_id_int64()
==========================================================

Synopsis
--------

.. code-block:: c

int64_t
mongoc_apm_command_failed_get_server_connection_id_int64 (
const mongoc_apm_command_failed_t *event);

Returns this event's context.

Returns the server connection ID for the command. The server connection ID is
distinct from the server ID (:symbol:`mongoc_apm_command_failed_get_server_id`)
and is returned by the hello or legacy hello response as "connectionId" from the
server on 4.2+.

Parameters
----------

* ``event``: A :symbol:`mongoc_apm_command_failed_t`.

Returns
-------

The server connection ID as a positive integer or -1 if it is not available.

.. seealso::

| :doc:`Introduction to Application Performance Monitoring <application-performance-monitoring>`

1 change: 1 addition & 0 deletions src/libmongoc/doc/mongoc_apm_command_failed_t.rst
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ An event notification sent when the driver fails to execute a MongoDB command.
mongoc_apm_command_failed_get_server_id
mongoc_apm_command_failed_get_service_id
mongoc_apm_command_failed_get_server_connection_id
mongoc_apm_command_failed_get_server_connection_id_int64

.. seealso::

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,21 @@ Synopsis

int32_t
mongoc_apm_command_started_get_server_connection_id (
const mongoc_apm_command_started_t *event);
const mongoc_apm_command_started_t *event)
BSON_GNUC_DEPRECATED_FOR (
"mongoc_apm_command_started_get_server_connection_id_int64");

Returns the server connection ID for the command. The server connection ID is
distinct from the server ID (:symbol:`mongoc_apm_command_started_get_server_id`)
and is returned by the hello or legacy hello response as "connectionId" from the
server on 4.2+.

Deprecated
----------

This function is deprecated. Please use
:symbol:`mongoc_apm_command_started_get_server_connection_id_int64` in new code.

Parameters
----------

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
:man_page: mongoc_apm_command_started_get_server_connection_id_int64

mongoc_apm_command_started_get_server_connection_id_int64()
===========================================================

Synopsis
--------

.. code-block:: c

int64_t
mongoc_apm_command_started_get_server_connection_id_int64 (
const mongoc_apm_command_started_t *event);

Returns the server connection ID for the command. The server connection ID is
distinct from the server ID (:symbol:`mongoc_apm_command_started_get_server_id`)
and is returned by the hello or legacy hello response as "connectionId" from the
server on 4.2+.

Parameters
----------

* ``event``: A :symbol:`mongoc_apm_command_started_t`.

Returns
-------

The server connection ID as a positive integer or -1 if it is not available.

.. seealso::

| :doc:`Introduction to Application Performance Monitoring <application-performance-monitoring>`

1 change: 1 addition & 0 deletions src/libmongoc/doc/mongoc_apm_command_started_t.rst
Original file line number Diff line number Diff line change
Expand Up @@ -33,4 +33,5 @@ An event notification sent when the driver begins executing a MongoDB command.
mongoc_apm_command_started_get_server_id
mongoc_apm_command_started_get_service_id
mongoc_apm_command_started_get_server_connection_id
mongoc_apm_command_started_get_server_connection_id_int64

Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,21 @@ Synopsis

int32_t
mongoc_apm_command_succeeded_get_server_connection_id (
const mongoc_apm_command_succeeded_t *event);
const mongoc_apm_command_succeeded_t *event)
BSON_GNUC_DEPRECATED_FOR (
"mongoc_apm_command_succeeded_get_server_connection_id_int64");

Returns the server connection ID for the command. The server connection ID is
distinct from the server ID
(:symbol:`mongoc_apm_command_succeeded_get_server_id`) and is returned by the
hello or legacy hello response as "connectionId" from the server on 4.2+.

Deprecated
----------

This function is deprecated. Please use
:symbol:`mongoc_apm_command_succeeded_get_server_connection_id_int64` in new code.

Parameters
----------

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
:man_page: mongoc_apm_command_succeeded_get_server_connection_id_int64

mongoc_apm_command_succeeded_get_server_connection_id_int64()
=============================================================

Synopsis
--------

.. code-block:: c

int64_t
mongoc_apm_command_succeeded_get_server_connection_id_int64 (
const mongoc_apm_command_succeeded_t *event);

Returns the server connection ID for the command. The server connection ID is
distinct from the server ID
(:symbol:`mongoc_apm_command_succeeded_get_server_id`) and is returned by the
hello or legacy hello response as "connectionId" from the server on 4.2+.

Parameters
----------

* ``event``: A :symbol:`mongoc_apm_command_succeeded_t`.

Returns
-------

The server connection ID as a positive integer or -1 if it is not available.

.. seealso::

| :doc:`Introduction to Application Performance Monitoring <application-performance-monitoring>`

1 change: 1 addition & 0 deletions src/libmongoc/doc/mongoc_apm_command_succeeded_t.rst
Original file line number Diff line number Diff line change
Expand Up @@ -33,4 +33,5 @@ An event notification sent when the driver successfully executes a MongoDB comma
mongoc_apm_command_succeeded_get_server_id
mongoc_apm_command_succeeded_get_service_id
mongoc_apm_command_succeeded_get_server_connection_id
mongoc_apm_command_succeeded_get_server_connection_id_int64

39 changes: 39 additions & 0 deletions src/libmongoc/src/mongoc/mongoc-apm.c
Original file line number Diff line number Diff line change
Expand Up @@ -392,13 +392,26 @@ mongoc_apm_command_started_get_server_connection_id (
{
if (event->server_connection_id > INT32_MAX ||
event->server_connection_id < INT32_MIN) {
MONGOC_WARNING (
"Server connection ID %" PRId64
" is outside of int32 range. Returning -1. Use "
"mongoc_apm_command_started_get_server_connection_id_int64.",
event->server_connection_id);
return MONGOC_NO_SERVER_CONNECTION_ID;
}

return (int32_t) event->server_connection_id;
}


int64_t
mongoc_apm_command_started_get_server_connection_id_int64 (
const mongoc_apm_command_started_t *event)
{
return event->server_connection_id;
}


void *
mongoc_apm_command_started_get_context (
const mongoc_apm_command_started_t *event)
Expand Down Expand Up @@ -484,13 +497,26 @@ mongoc_apm_command_succeeded_get_server_connection_id (
{
if (event->server_connection_id > INT32_MAX ||
event->server_connection_id < INT32_MIN) {
MONGOC_WARNING (
"Server connection ID %" PRId64
" is outside of int32 range. Returning -1. Use "
"mongoc_apm_command_succeeded_get_server_connection_id_int64.",
event->server_connection_id);
return MONGOC_NO_SERVER_CONNECTION_ID;
}

return (int32_t) event->server_connection_id;
}


int64_t
mongoc_apm_command_succeeded_get_server_connection_id_int64 (
const mongoc_apm_command_succeeded_t *event)
{
return event->server_connection_id;
}


void *
mongoc_apm_command_succeeded_get_context (
const mongoc_apm_command_succeeded_t *event)
Expand Down Expand Up @@ -580,13 +606,26 @@ mongoc_apm_command_failed_get_server_connection_id (
{
if (event->server_connection_id > INT32_MAX ||
event->server_connection_id < INT32_MIN) {
MONGOC_WARNING (
"Server connection ID %" PRId64
" is outside of int32 range. Returning -1. Use "
"mongoc_apm_command_failed_get_server_connection_id_int64.",
event->server_connection_id);
return MONGOC_NO_SERVER_CONNECTION_ID;
}

return (int32_t) event->server_connection_id;
}


int64_t
mongoc_apm_command_failed_get_server_connection_id_int64 (
const mongoc_apm_command_failed_t *event)
{
return event->server_connection_id;
}


void *
mongoc_apm_command_failed_get_context (const mongoc_apm_command_failed_t *event)
{
Expand Down
15 changes: 15 additions & 0 deletions src/libmongoc/src/mongoc/mongoc-apm.h
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,11 @@ mongoc_apm_command_started_get_service_id (
const mongoc_apm_command_started_t *event);
MONGOC_EXPORT (int32_t)
mongoc_apm_command_started_get_server_connection_id (
const mongoc_apm_command_started_t *event)
BSON_GNUC_DEPRECATED_FOR (
"mongoc_apm_command_started_get_server_connection_id_int64");
MONGOC_EXPORT (int64_t)
mongoc_apm_command_started_get_server_connection_id_int64 (
const mongoc_apm_command_started_t *event);
MONGOC_EXPORT (void *)
mongoc_apm_command_started_get_context (
Expand Down Expand Up @@ -137,6 +142,11 @@ mongoc_apm_command_succeeded_get_service_id (
const mongoc_apm_command_succeeded_t *event);
MONGOC_EXPORT (int32_t)
mongoc_apm_command_succeeded_get_server_connection_id (
const mongoc_apm_command_succeeded_t *event)
BSON_GNUC_DEPRECATED_FOR (
"mongoc_apm_command_succeeded_get_server_connection_id_int64");
MONGOC_EXPORT (int64_t)
mongoc_apm_command_succeeded_get_server_connection_id_int64 (
const mongoc_apm_command_succeeded_t *event);
MONGOC_EXPORT (void *)
mongoc_apm_command_succeeded_get_context (
Expand Down Expand Up @@ -172,6 +182,11 @@ mongoc_apm_command_failed_get_service_id (
const mongoc_apm_command_failed_t *event);
MONGOC_EXPORT (int32_t)
mongoc_apm_command_failed_get_server_connection_id (
const mongoc_apm_command_failed_t *event)
BSON_GNUC_DEPRECATED_FOR (
"mongoc_apm_command_failed_get_server_connection_id_int64");
MONGOC_EXPORT (int64_t)
mongoc_apm_command_failed_get_server_connection_id_int64 (
const mongoc_apm_command_failed_t *event);
MONGOC_EXPORT (void *)
mongoc_apm_command_failed_get_context (
Expand Down
27 changes: 14 additions & 13 deletions src/libmongoc/tests/unified/entity-map.c
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,7 @@ typedef struct command_callback_funcs_t {
apm_func_int64_t get_operation_id;
apm_func_bson_oid_t get_service_id;
apm_func_host_list_t get_host;
apm_func_int32_t get_server_connection_id;
apm_func_int64_t get_server_connection_id;
apm_func_serialize_t serialize;
} command_callback_funcs_t;

Expand Down Expand Up @@ -310,10 +310,10 @@ store_event_serialize_started (bson_t *doc,
"connectionId",
mongoc_apm_command_started_get_host (apm_command)->host_and_port);

BSON_APPEND_INT32 (
BSON_APPEND_INT64 (
doc,
"serverConnectionId",
mongoc_apm_command_started_get_server_connection_id (apm_command));
mongoc_apm_command_started_get_server_connection_id_int64 (apm_command));

{
const bson_oid_t *const service_id =
Expand Down Expand Up @@ -355,10 +355,10 @@ store_event_serialize_failed (bson_t *doc,
"connectionId",
mongoc_apm_command_failed_get_host (apm_command)->host_and_port);

BSON_APPEND_INT32 (
BSON_APPEND_INT64 (
doc,
"serverConnectionId",
mongoc_apm_command_failed_get_server_connection_id (apm_command));
mongoc_apm_command_failed_get_server_connection_id_int64 (apm_command));

{
const bson_oid_t *const service_id =
Expand Down Expand Up @@ -403,10 +403,11 @@ store_event_serialize_succeeded (
"connectionId",
mongoc_apm_command_succeeded_get_host (apm_command)->host_and_port);

BSON_APPEND_INT32 (
BSON_APPEND_INT64 (
doc,
"serverConnectionId",
mongoc_apm_command_succeeded_get_server_connection_id (apm_command));
mongoc_apm_command_succeeded_get_server_connection_id_int64 (
apm_command));

{
const bson_oid_t *const service_id =
Expand Down Expand Up @@ -498,8 +499,8 @@ command_started (const mongoc_apm_command_started_t *started)
.get_service_id =
(apm_func_bson_oid_t) mongoc_apm_command_started_get_service_id,
.get_host = (apm_func_host_list_t) mongoc_apm_command_started_get_host,
.get_server_connection_id =
(apm_func_int32_t) mongoc_apm_command_started_get_server_connection_id,
.get_server_connection_id = (apm_func_int64_t)
mongoc_apm_command_started_get_server_connection_id_int64,
.serialize = (apm_func_serialize_t) store_event_serialize_started,
};

Expand All @@ -523,8 +524,8 @@ command_failed (const mongoc_apm_command_failed_t *failed)
.get_service_id =
(apm_func_bson_oid_t) mongoc_apm_command_failed_get_service_id,
.get_host = (apm_func_host_list_t) mongoc_apm_command_failed_get_host,
.get_server_connection_id =
(apm_func_int32_t) mongoc_apm_command_failed_get_server_connection_id,
.get_server_connection_id = (apm_func_int64_t)
mongoc_apm_command_failed_get_server_connection_id_int64,
.serialize = (apm_func_serialize_t) store_event_serialize_failed,
};

Expand All @@ -548,8 +549,8 @@ command_succeeded (const mongoc_apm_command_succeeded_t *succeeded)
.get_service_id =
(apm_func_bson_oid_t) mongoc_apm_command_succeeded_get_service_id,
.get_host = (apm_func_host_list_t) mongoc_apm_command_succeeded_get_host,
.get_server_connection_id = (apm_func_int32_t)
mongoc_apm_command_succeeded_get_server_connection_id,
.get_server_connection_id = (apm_func_int64_t)
mongoc_apm_command_succeeded_get_server_connection_id_int64,
.serialize = (apm_func_serialize_t) store_event_serialize_succeeded,
};

Expand Down