@@ -51,6 +51,9 @@ class ClientInfo(object):
5151 library, generally used if the client library was not generated
5252 by gapic or if additional functionality was built on top of
5353 a gapic client library.
54+ user_agent (Optional[str]): Prefix to the user agent header. This is
55+ used to supply information such as application name or partner tool.
56+ Recommended format: ``application-or-tool-ID/major.minor.version``.
5457 """
5558
5659 def __init__ (
@@ -60,18 +63,26 @@ def __init__(
6063 api_core_version = _API_CORE_VERSION ,
6164 gapic_version = None ,
6265 client_library_version = None ,
66+ user_agent = None ,
6367 ):
6468 self .python_version = python_version
6569 self .grpc_version = grpc_version
6670 self .api_core_version = api_core_version
6771 self .gapic_version = gapic_version
6872 self .client_library_version = client_library_version
73+ self .user_agent = user_agent
6974
7075 def to_user_agent (self ):
7176 """Returns the user-agent string for this client info."""
77+
7278 # Note: the order here is important as the internal metrics system
7379 # expects these items to be in specific locations.
74- ua = "gl-python/{python_version} "
80+ ua = ""
81+
82+ if self .user_agent is not None :
83+ ua += "{user_agent} "
84+
85+ ua += "gl-python/{python_version} "
7586
7687 if self .grpc_version is not None :
7788 ua += "grpc/{grpc_version} "
0 commit comments