Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit d613b57

Browse filesBrowse files
authored
Add client_info support to clients. (#7899)
1 parent 1925cb2 commit d613b57
Copy full SHA for d613b57

File tree

Expand file treeCollapse file tree

8 files changed

+176
-239
lines changed
Filter options
Expand file treeCollapse file tree

8 files changed

+176
-239
lines changed

‎trace/google/cloud/trace/_gapic.py

Copy file name to clipboardExpand all lines: trace/google/cloud/trace/_gapic.py
+1-6Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,20 +14,15 @@
1414

1515
"""Wrapper for interacting with the Stackdriver Trace API."""
1616

17-
from google.api_core.gapic_v1 import client_info
1817
from google.api_core.gapic_v1 import method
1918
from google.cloud._helpers import _datetime_to_pb_timestamp
20-
from google.cloud.trace import __version__
2119
from google.cloud.trace_v2.gapic import trace_service_client
2220
from google.cloud.trace_v2.proto import trace_pb2
2321
from google.protobuf.json_format import ParseDict
2422
from google.rpc import status_pb2 as google_dot_rpc_dot_status__pb2
2523
from google.protobuf import wrappers_pb2 as google_dot_protobuf_dot_wrappers__pb2
2624

2725

28-
_CLIENT_INFO = client_info.ClientInfo(client_library_version=__version__)
29-
30-
3126
class _TraceAPI(object):
3227
"""
3328
Wrapper to help mapping trace-related APIs.
@@ -319,6 +314,6 @@ def make_trace_api(client):
319314
proper configurations.
320315
"""
321316
generated = trace_service_client.TraceServiceClient(
322-
credentials=client._credentials, client_info=_CLIENT_INFO
317+
credentials=client._credentials, client_info=client._client_info
323318
)
324319
return _TraceAPI(generated, client)

‎trace/google/cloud/trace/client.py

Copy file name to clipboardExpand all lines: trace/google/cloud/trace/client.py
+13-2Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,13 @@
1414

1515
"""Client for interacting with the Stackdriver Trace API."""
1616

17-
from google.cloud.trace._gapic import make_trace_api
17+
from google.api_core.gapic_v1 import client_info
1818
from google.cloud.client import ClientWithProject
19+
from google.cloud.trace import __version__
20+
from google.cloud.trace._gapic import make_trace_api
21+
22+
23+
_CLIENT_INFO = client_info.ClientInfo(client_library_version=__version__)
1924

2025

2126
class Client(ClientWithProject):
@@ -29,6 +34,11 @@ class Client(ClientWithProject):
2934
credentials (Optional[:class:`~google.auth.credentials.Credentials`]):
3035
The OAuth2 Credentials to use for this client. If not passed,
3136
falls back to the default inferred from the environment.
37+
client_info (google.api_core.gapic_v1.client_info.ClientInfo):
38+
The client info used to send a user-agent string along with API
39+
requests. If ``None``, then default info will be used. Generally,
40+
you only need to set this if you're developing your own library
41+
or partner tool.
3242
"""
3343

3444
SCOPE = (
@@ -39,8 +49,9 @@ class Client(ClientWithProject):
3949

4050
_trace_api = None
4151

42-
def __init__(self, project=None, credentials=None):
52+
def __init__(self, project=None, credentials=None, client_info=_CLIENT_INFO):
4353
super(Client, self).__init__(project=project, credentials=credentials)
54+
self._client_info = client_info
4455

4556
@property
4657
def trace_api(self):

‎trace/google/cloud/trace/v1/_gapic.py

Copy file name to clipboardExpand all lines: trace/google/cloud/trace/v1/_gapic.py
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,7 @@ def make_trace_api(client):
178178
proper configurations.
179179
"""
180180
generated = trace_service_client.TraceServiceClient(
181-
credentials=client._credentials, client_info=_CLIENT_INFO
181+
credentials=client._credentials, client_info=client._client_info
182182
)
183183
return _TraceAPI(generated, client)
184184

‎trace/google/cloud/trace/v1/client.py

Copy file name to clipboardExpand all lines: trace/google/cloud/trace/v1/client.py
+14-4Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,14 @@
1414

1515
"""Client for interacting with the Stackdriver Trace API."""
1616

17-
from google.cloud.trace.v1._gapic import make_trace_api
18-
from google.cloud.client import ClientWithProject
17+
from google.api_core.gapic_v1 import client_info
1918
from google.cloud._helpers import _datetime_to_pb_timestamp
19+
from google.cloud.client import ClientWithProject
20+
from google.cloud.trace import __version__
21+
from google.cloud.trace.v1._gapic import make_trace_api
22+
23+
24+
_CLIENT_INFO = client_info.ClientInfo(client_library_version=__version__)
2025

2126

2227
class Client(ClientWithProject):
@@ -27,11 +32,15 @@ class Client(ClientWithProject):
2732
project (str): Required. The project which the client acts on behalf
2833
of. If not passed, falls back to the default inferred
2934
from the environment.
30-
3135
credentials (Optional[~google.auth.credentials.Credentials]):
3236
The OAuth2 Credentials to use for this client. If not
3337
passed, falls back to the default inferred from the
3438
environment.
39+
client_info (google.api_core.gapic_v1.client_info.ClientInfo):
40+
The client info used to send a user-agent string along with API
41+
requests. If ``None``, then default info will be used. Generally,
42+
you only need to set this if you're developing your own library
43+
or partner tool.
3544
"""
3645

3746
SCOPE = (
@@ -42,8 +51,9 @@ class Client(ClientWithProject):
4251

4352
_trace_api = None
4453

45-
def __init__(self, project=None, credentials=None):
54+
def __init__(self, project=None, credentials=None, client_info=_CLIENT_INFO):
4655
super(Client, self).__init__(project=project, credentials=credentials)
56+
self._client_info = client_info
4757

4858
@property
4959
def trace_api(self):

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.