Ability to pass additional info to sdk header#783
Conversation
9f7607d to
a420baa
Compare
There was a problem hiding this comment.
Pull request overview
This PR extends the SDK build-info gRPC metadata header to optionally include additional client/library identifiers, allowing callers to append extra “sdk-like” segments to the x-ydb-sdk-build-info value.
Changes:
- Add
additional_sdk_headerstoDriverConfigand propagate it into request metadata construction (sync + aio). - Update
_utilities.x_ydb_sdk_build_info_headerto append additional entries to the header value. - Add unit tests covering the new header formatting behavior.
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
ydb/driver.py |
Adds additional_sdk_headers field to driver configuration. |
ydb/connection.py |
Passes additional_sdk_headers into SDK build-info header for sync metadata. |
ydb/aio/connection.py |
Passes additional_sdk_headers into SDK build-info header for async metadata. |
ydb/_utilities.py |
Extends SDK build-info header builder to join additional segments. |
ydb/_utilities_test.py |
Adds tests for header formatting with 0/1/N additional segments. |
Comments suppressed due to low confidence (1)
ydb/driver.py:162
additional_sdk_headerswas added toDriverConfig.__init__, but it is not described in the constructor docstring alongside the other parameters. Please document what format is expected (e.g.,("lib/1.2.3", ...)) and how it affects thex-ydb-sdk-build-infoheader.
"""
A driver config to initialize a driver instance
:param endpoint: A endpoint specified in pattern host:port to be used for initial channel initialization and for YDB endpoint discovery mechanism
:param database: A name of the database
:param ca_cert: A CA certificate when SSL should be used
:param auth_token: A authentication token
:param credentials: An instance of AbstractCredentials
:param use_all_nodes: A balancing policy that forces to use all available nodes.
:param root_certificates: The PEM-encoded root certificates as a byte string.
:param private_key: The PEM-encoded private key as a byte string, or None if no\
private key should be used.
:param certificate_chain: The PEM-encoded certificate chain as a byte string\
to use or or None if no certificate chain should be used.
:param grpc_keep_alive_timeout: GRpc KeepAlive timeout, ms
:param ydb.Tracer tracer: ydb.Tracer instance to trace requests in driver.\
If tracing aio ScopeManager must be ContextVarsScopeManager
:param grpc_lb_policy_name: A load balancing policy to be used for discovery channel construction. Default value is `round_round`
:param discovery_request_timeout: A default timeout to complete the discovery. The default value is 10 seconds.
:param disable_discovery: If True, endpoint discovery is disabled and only the start endpoint is used for all requests.
"""
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
ec6f6d3 to
cc3dd41
Compare
There was a problem hiding this comment.
Pull request overview
Adds support for SDK integrations (e.g., DBAPI/SQLAlchemy) to append additional build-info fragments into the x-ydb-sdk-build-info request metadata header.
Changes:
- Extends
DriverConfigto carry_additional_sdk_headersfor integration-specific header fragments. - Updates sync/async connection metadata construction to include these additional fragments.
- Updates
_utilities.x_ydb_sdk_build_info_headerand adds unit tests for the new formatting behavior.
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| ydb/driver.py | Stores integration-provided additional SDK header fragments on DriverConfig. |
| ydb/connection.py | Passes additional fragments into the build-info header during metadata construction (sync). |
| ydb/aio/connection.py | Passes additional fragments into the build-info header during metadata construction (async). |
| ydb/_utilities.py | Changes header builder to concatenate base SDK info + optional additional fragments. |
| ydb/_utilities_test.py | Adds tests validating formatting with 0/1/N additional fragments. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| @@ -135,6 +136,7 @@ def __init__( | |||
| discovery_request_timeout: int = 10, | |||
| compression: Optional[grpc.Compression] = None, | |||
| disable_discovery: bool = False, | |||
| self.discovery_request_timeout = discovery_request_timeout | ||
| self.compression = compression | ||
| self.disable_discovery = disable_discovery | ||
| self._additional_sdk_headers = _additional_sdk_headers |
cc3dd41 to
ba19c54
Compare
Pull request type
Please check the type of change your PR introduces:
What is the current behavior?
Fixes: #784
What is the new behavior?
Other information