alexbevi opened a new pull request, #821: URL: https://github.com/apache/burr/pull/821
## Summary This PR identifies Burr in the MongoDB [driver handshake][handshake-spec], enabling server-side telemetry to attribute connections back to the library. MongoDB records this metadata at connection time, making it visible in`currentOp`, Atlas performance advisor, and `mongod` logs. [handshake-spec]: https://github.com/mongodb/specifications/blob/master/source/mongodb-handshake/handshake.md ## What changes A module-level constant is defined once in `b_pymongo.py`: ```python _DRIVER_INFO = DriverInfo(name="Burr", version=_VERSION) ``` This is injected at every `MongoClient` construction site and, for the case where a caller passes in an existing client, via `append_metadata`. ## How it appears in the logs On a MongoDB 4.4+ server, the `isMaster`/`hello` handshake carries the following client metadata document (truncated to key fields): ```json { "driver": { "name": "PyMongo|Burr", "version": "4.9.2|0.42.0" }, "platform": "CPython 3.10.3.final.0" } ``` In `mongod` diagnostic logs this appears as: > `{"t":{"$date":"..."},"s":"I","c":"NETWORK","id":51800,"ctx":"conn1","msg":"client metadata","attr":{"remote":"127.0.0.1:54321","client":"conn1","doc":{"driver":{"name":"PyMongo|Burr","version":"4.9.2|0.42.0"},...}}}` The `PyMongo|Burr` driver name lets operators distinguish Burr connections from bare PyMongo connections in server logs, Atlas metrics, and `db.currentOp()`. ## Testing Six unit tests added in `tests/integrations/persisters/test_b_pymongo_driver_info.py` (no live database required): - `_DRIVER_INFO` has `name="Burr"` and version matching the installed package - `from_values()` passes `driver=_DRIVER_INFO` to `MongoClient` - `from_values()` does not override a caller-supplied `driver` - `__init__()` calls `append_metadata(_DRIVER_INFO)` when the client supports it - `__init__()` does not raise when the client lacks `append_metadata` (older pymongo) No version constraint change is needed — `DriverInfo` is available since pymongo 4.0, and `append_metadata` since 4.14; the existing unconstrained `"pymongo"` dependency satisfies both. ## Checklist - [x] PR has an informative and human-readable title (this will be pulled into the release notes) - [x] Changes are limited to a single goal (no scope creep) - [x] Code passed the pre-commit check & code is left cleaner/nicer than when first encountered. - [x] Any _change_ in functionality is tested - [x] New functions are documented (with a description, list of inputs, and expected output) - [x] Placeholder code is flagged / future TODOs are captured in comments - [x] Project documentation has been updated if adding/changing functionality. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
