diff --git a/trace/google/cloud/gapic/__init__.py b/trace/google/cloud/gapic/__init__.py deleted file mode 100644 index de40ea7ca058..000000000000 --- a/trace/google/cloud/gapic/__init__.py +++ /dev/null @@ -1 +0,0 @@ -__import__('pkg_resources').declare_namespace(__name__) diff --git a/trace/google/cloud/gapic/trace/__init__.py b/trace/google/cloud/gapic/trace/__init__.py deleted file mode 100644 index de40ea7ca058..000000000000 --- a/trace/google/cloud/gapic/trace/__init__.py +++ /dev/null @@ -1 +0,0 @@ -__import__('pkg_resources').declare_namespace(__name__) diff --git a/trace/google/cloud/gapic/trace/v1/trace_service_client.py b/trace/google/cloud/gapic/trace/v1/trace_service_client.py deleted file mode 100644 index ebe66cbec45f..000000000000 --- a/trace/google/cloud/gapic/trace/v1/trace_service_client.py +++ /dev/null @@ -1,310 +0,0 @@ -# Copyright 2017, Google LLC All rights reserved. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# -# EDITING INSTRUCTIONS -# This file was generated from the file -# https://github.com/google/googleapis/blob/master/google/devtools/cloudtrace/v1/trace.proto, -# and updates to that file get reflected here through a refresh process. -# For the short term, the refresh process will only be runnable by Google engineers. -# -# The only allowed edits are to method and file documentation. A 3-way -# merge preserves those additions if the generated source changes. -"""Accesses the google.devtools.cloudtrace.v1 TraceService API.""" - -import collections -import json -import os -import pkg_resources -import platform - -from google.gax import api_callable -from google.gax import config -from google.gax import path_template -import google.gax - -from google.cloud.gapic.trace.v1 import enums -from google.cloud.proto.devtools.cloudtrace.v1 import trace_pb2 -from google.protobuf import timestamp_pb2 - -_PageDesc = google.gax.PageDescriptor - - -class TraceServiceClient(object): - """ - This file describes an API for collecting and viewing traces and spans - within a trace. A Trace is a collection of spans corresponding to a single - operation or set of operations for an application. A span is an individual - timed event which forms a node of the trace tree. Spans for a single trace - may span multiple services. - """ - - SERVICE_ADDRESS = 'cloudtrace.googleapis.com' - """The default address of the service.""" - - DEFAULT_SERVICE_PORT = 443 - """The default port of the service.""" - - _PAGE_DESCRIPTORS = { - 'list_traces': _PageDesc('page_token', 'next_page_token', 'traces') - } - - # The scopes needed to make gRPC calls to all of the methods defined in - # this service - _ALL_SCOPES = ('https://www.googleapis.com/auth/cloud-platform', - 'https://www.googleapis.com/auth/trace.append', - 'https://www.googleapis.com/auth/trace.readonly', ) - - def __init__(self, - service_path=SERVICE_ADDRESS, - port=DEFAULT_SERVICE_PORT, - channel=None, - credentials=None, - ssl_credentials=None, - scopes=None, - client_config=None, - app_name=None, - app_version='', - lib_name=None, - lib_version='', - metrics_headers=()): - """Constructor. - - Args: - service_path (string): The domain name of the API remote host. - port (int): The port on which to connect to the remote host. - channel (:class:`grpc.Channel`): A ``Channel`` instance through - which to make calls. - credentials (object): The authorization credentials to attach to - requests. These credentials identify this application to the - service. - ssl_credentials (:class:`grpc.ChannelCredentials`): A - ``ChannelCredentials`` instance for use with an SSL-enabled - channel. - scopes (list[string]): A list of OAuth2 scopes to attach to requests. - client_config (dict): - A dictionary for call options for each method. See - :func:`google.gax.construct_settings` for the structure of - this data. Falls back to the default config if not specified - or the specified config is missing data points. - app_name (string): The name of the application calling - the service. Recommended for analytics purposes. - app_version (string): The version of the application calling - the service. Recommended for analytics purposes. - lib_name (string): The API library software used for calling - the service. (Unless you are writing an API client itself, - leave this as default.) - lib_version (string): The API library software version used - for calling the service. (Unless you are writing an API client - itself, leave this as default.) - metrics_headers (dict): A dictionary of values for tracking - client library metrics. Ultimately serializes to a string - (e.g. 'foo/1.2.3 bar/3.14.1'). This argument should be - considered private. - - Returns: - A TraceServiceClient object. - """ - # Unless the calling application specifically requested - # OAuth scopes, request everything. - if scopes is None: - scopes = self._ALL_SCOPES - - # Initialize an empty client config, if none is set. - if client_config is None: - client_config = {} - - # Initialize metrics_headers as an ordered dictionary - # (cuts down on cardinality of the resulting string slightly). - metrics_headers = collections.OrderedDict(metrics_headers) - metrics_headers['gl-python'] = platform.python_version() - - # The library may or may not be set, depending on what is - # calling this client. Newer client libraries set the library name - # and version. - if lib_name: - metrics_headers[lib_name] = lib_version - - # Finally, track the GAPIC package version. - metrics_headers['gapic'] = pkg_resources.get_distribution( - 'google-cloud-trace', ).version - - # Load the configuration defaults. - default_client_config = json.loads( - pkg_resources.resource_string( - __name__, 'trace_service_client_config.json').decode()) - defaults = api_callable.construct_settings( - 'google.devtools.cloudtrace.v1.TraceService', - default_client_config, - client_config, - config.STATUS_CODE_NAMES, - metrics_headers=metrics_headers, - page_descriptors=self._PAGE_DESCRIPTORS, ) - self.trace_service_stub = config.create_stub( - trace_pb2.TraceServiceStub, - channel=channel, - service_path=service_path, - service_port=port, - credentials=credentials, - scopes=scopes, - ssl_credentials=ssl_credentials) - - self._patch_traces = api_callable.create_api_call( - self.trace_service_stub.PatchTraces, - settings=defaults['patch_traces']) - self._get_trace = api_callable.create_api_call( - self.trace_service_stub.GetTrace, settings=defaults['get_trace']) - self._list_traces = api_callable.create_api_call( - self.trace_service_stub.ListTraces, - settings=defaults['list_traces']) - - # Service calls - def patch_traces(self, project_id, traces, options=None): - """ - Sends new traces to Stackdriver Trace or updates existing traces. If the ID - of a trace that you send matches that of an existing trace, any fields - in the existing trace and its spans are overwritten by the provided values, - and any new fields provided are merged with the existing trace data. If the - ID does not match, a new trace is created. - - Example: - >>> from google.cloud.gapic.trace.v1 import trace_service_client - >>> from google.cloud.proto.devtools.cloudtrace.v1 import trace_pb2 - >>> client = trace_service_client.TraceServiceClient() - >>> project_id = '' - >>> traces = trace_pb2.Traces() - >>> client.patch_traces(project_id, traces) - - Args: - project_id (string): ID of the Cloud project where the trace data is stored. - traces (:class:`google.cloud.proto.devtools.cloudtrace.v1.trace_pb2.Traces`): The body of the message. - options (:class:`google.gax.CallOptions`): Overrides the default - settings for this call, e.g, timeout, retries etc. - - Raises: - :exc:`google.gax.errors.GaxError` if the RPC is aborted. - :exc:`ValueError` if the parameters are invalid. - """ - # Create the request object. - request = trace_pb2.PatchTracesRequest( - project_id=project_id, traces=traces) - self._patch_traces(request, options) - - def get_trace(self, project_id, trace_id, options=None): - """ - Gets a single trace by its ID. - - Example: - >>> from google.cloud.gapic.trace.v1 import trace_service_client - >>> client = trace_service_client.TraceServiceClient() - >>> project_id = '' - >>> trace_id = '' - >>> response = client.get_trace(project_id, trace_id) - - Args: - project_id (string): ID of the Cloud project where the trace data is stored. - trace_id (string): ID of the trace to return. - options (:class:`google.gax.CallOptions`): Overrides the default - settings for this call, e.g, timeout, retries etc. - - Returns: - A :class:`google.cloud.proto.devtools.cloudtrace.v1.trace_pb2.Trace` instance. - - Raises: - :exc:`google.gax.errors.GaxError` if the RPC is aborted. - :exc:`ValueError` if the parameters are invalid. - """ - # Create the request object. - request = trace_pb2.GetTraceRequest( - project_id=project_id, trace_id=trace_id) - return self._get_trace(request, options) - - def list_traces(self, - project_id, - view=None, - page_size=None, - start_time=None, - end_time=None, - filter_=None, - order_by=None, - options=None): - """ - Returns of a list of traces that match the specified filter conditions. - - Example: - >>> from google.cloud.gapic.trace.v1 import trace_service_client - >>> from google.gax import CallOptions, INITIAL_PAGE - >>> client = trace_service_client.TraceServiceClient() - >>> project_id = '' - >>> - >>> # Iterate over all results - >>> for element in client.list_traces(project_id): - >>> # process element - >>> pass - >>> - >>> # Or iterate over results one page at a time - >>> for page in client.list_traces(project_id, options=CallOptions(page_token=INITIAL_PAGE)): - >>> for element in page: - >>> # process element - >>> pass - - Args: - project_id (string): ID of the Cloud project where the trace data is stored. - view (enum :class:`google.cloud.gapic.trace.v1.enums.ListTracesRequest.ViewType`): Type of data returned for traces in the list. Optional. Default is - ``MINIMAL``. - page_size (int): Maximum number of traces to return. If not specified or <= 0, the - implementation selects a reasonable value. The implementation may - return fewer traces than the requested page size. Optional. - start_time (:class:`google.protobuf.timestamp_pb2.Timestamp`): End of the time interval (inclusive) during which the trace data was - collected from the application. - end_time (:class:`google.protobuf.timestamp_pb2.Timestamp`): Start of the time interval (inclusive) during which the trace data was - collected from the application. - filter_ (string): An optional filter for the request. - order_by (string): Field used to sort the returned traces. Optional. - Can be one of the following: - - * ``trace_id`` - * ``name`` (``name`` field of root span in the trace) - * ``duration`` (difference between ``end_time`` and ``start_time`` fields of - :: - - the root span) - * ``start`` (``start_time`` field of the root span) - - Descending order can be specified by appending ``desc`` to the sort field - (for example, ``name desc``). - - Only one sort field is permitted. - options (:class:`google.gax.CallOptions`): Overrides the default - settings for this call, e.g, timeout, retries etc. - - Returns: - A :class:`google.gax.PageIterator` instance. By default, this - is an iterable of :class:`google.cloud.proto.devtools.cloudtrace.v1.trace_pb2.Trace` instances. - This object can also be configured to iterate over the pages - of the response through the `CallOptions` parameter. - - Raises: - :exc:`google.gax.errors.GaxError` if the RPC is aborted. - :exc:`ValueError` if the parameters are invalid. - """ - # Create the request object. - request = trace_pb2.ListTracesRequest( - project_id=project_id, - view=view, - page_size=page_size, - start_time=start_time, - end_time=end_time, - filter=filter_, - order_by=order_by) - return self._list_traces(request, options) diff --git a/trace/google/cloud/gapic/trace/v1/trace_service_client_config.json b/trace/google/cloud/gapic/trace/v1/trace_service_client_config.json deleted file mode 100644 index 5e826c186b13..000000000000 --- a/trace/google/cloud/gapic/trace/v1/trace_service_client_config.json +++ /dev/null @@ -1,43 +0,0 @@ -{ - "interfaces": { - "google.devtools.cloudtrace.v1.TraceService": { - "retry_codes": { - "idempotent": [ - "DEADLINE_EXCEEDED", - "UNAVAILABLE" - ], - "non_idempotent": [ - "UNAVAILABLE" - ] - }, - "retry_params": { - "default": { - "initial_retry_delay_millis": 100, - "retry_delay_multiplier": 1.2, - "max_retry_delay_millis": 1000, - "initial_rpc_timeout_millis": 20000, - "rpc_timeout_multiplier": 1.5, - "max_rpc_timeout_millis": 30000, - "total_timeout_millis": 45000 - } - }, - "methods": { - "PatchTraces": { - "timeout_millis": 30000, - "retry_codes_name": "idempotent", - "retry_params_name": "default" - }, - "GetTrace": { - "timeout_millis": 30000, - "retry_codes_name": "idempotent", - "retry_params_name": "default" - }, - "ListTraces": { - "timeout_millis": 30000, - "retry_codes_name": "idempotent", - "retry_params_name": "default" - } - } - } - } -} diff --git a/trace/google/cloud/proto/__init__.py b/trace/google/cloud/proto/__init__.py deleted file mode 100644 index de40ea7ca058..000000000000 --- a/trace/google/cloud/proto/__init__.py +++ /dev/null @@ -1 +0,0 @@ -__import__('pkg_resources').declare_namespace(__name__) diff --git a/trace/google/cloud/proto/devtools/__init__.py b/trace/google/cloud/proto/devtools/__init__.py deleted file mode 100644 index de40ea7ca058..000000000000 --- a/trace/google/cloud/proto/devtools/__init__.py +++ /dev/null @@ -1 +0,0 @@ -__import__('pkg_resources').declare_namespace(__name__) diff --git a/trace/google/cloud/proto/devtools/cloudtrace/__init__.py b/trace/google/cloud/proto/devtools/cloudtrace/__init__.py deleted file mode 100644 index de40ea7ca058..000000000000 --- a/trace/google/cloud/proto/devtools/cloudtrace/__init__.py +++ /dev/null @@ -1 +0,0 @@ -__import__('pkg_resources').declare_namespace(__name__) diff --git a/trace/google/cloud/proto/devtools/cloudtrace/v1/__init__.py b/trace/google/cloud/proto/devtools/cloudtrace/v1/__init__.py deleted file mode 100644 index 8b137891791f..000000000000 --- a/trace/google/cloud/proto/devtools/cloudtrace/v1/__init__.py +++ /dev/null @@ -1 +0,0 @@ - diff --git a/trace/google/cloud/trace.py b/trace/google/cloud/trace.py index 944f8f3cfebc..3762bfe2c571 100644 --- a/trace/google/cloud/trace.py +++ b/trace/google/cloud/trace.py @@ -12,13 +12,13 @@ # See the License for the specific language governing permissions and # limitations under the License. -from google.cloud.trace_v1 import enums -from google.cloud.trace_v1 import TraceServiceClient -from google.cloud.trace_v1 import types +from __future__ import absolute_import +from google.cloud.trace_v2 import TraceServiceClient +from google.cloud.trace_v2 import enums +from google.cloud.trace_v2 import types __all__ = ( 'enums', - 'TraceServiceClient', 'types', -) + 'TraceServiceClient', ) diff --git a/trace/google/cloud/trace/_gax.py b/trace/google/cloud/trace/_gax.py index f510541e918a..94bc5b88070b 100644 --- a/trace/google/cloud/trace/_gax.py +++ b/trace/google/cloud/trace/_gax.py @@ -15,12 +15,10 @@ """GAX Wrapper for interacting with the Stackdriver Trace API.""" from google.api_core import page_iterator -from google.cloud.gapic.trace.v1 import trace_service_client -from google.cloud.proto.devtools.cloudtrace.v1 import trace_pb2 +from google.cloud.trace_v1.gapic import trace_service_client +from google.cloud.trace_v1.proto import trace_pb2 from google.gax import CallOptions from google.gax import INITIAL_PAGE -from google.cloud._helpers import make_secure_channel -from google.cloud._http import DEFAULT_USER_AGENT from google.protobuf.json_format import MessageToDict from google.protobuf.json_format import ParseDict @@ -33,7 +31,7 @@ class _TraceAPI(object): cloudtrace.v1 :type gax_api: - :class:`~google.cloud.gapic.trace.v1.trace_service_client. + :class:`~google.cloud.trace_v1.gapic.trace_service_client. TraceServiceClient` :param gax_api: API object used to make GAX requests. @@ -99,7 +97,7 @@ def list_traces( :param project_id: ID of the Cloud project where the trace data is stored. - :type view: :class:`google.cloud.gapic.trace.v1.enums. + :type view: :class:`google.cloud.trace_v1.gapic.enums. ListTracesRequest.ViewType` :param view: (Optional) Type of data returned for traces in the list. Default is ``MINIMAL``. @@ -154,7 +152,7 @@ def list_traces( def _parse_trace_pb(trace_pb): """Parse a ``Trace`` protobuf to a dictionary. - :type trace_pb: :class:`google.cloud.proto.devtools.cloudtrace.v1. + :type trace_pb: :class:`google.cloud.trace_v1.proto. trace_pb2.Trace` :param trace_pb: A trace protobuf instance. @@ -173,7 +171,7 @@ def _item_to_mapping(iterator, trace_pb): :type iterator: :class:`~google.api_core.page_iterator.Iterator` :param iterator: The iterator that is currently in use. - :type trace_pb: :class:`google.cloud.proto.devtools.cloudtrace.v1. + :type trace_pb: :class:`google.cloud.trace_v1.proto. trace_pb2.Trace` :param trace_pb: A trace protobuf instance. """ @@ -190,13 +188,7 @@ def make_gax_trace_api(client): :rtype: :class:`~google.cloud.trace._gax._TraceAPI` :returns: A Trace API instance with the proper configurations. """ - channel = make_secure_channel( - client._credentials, - DEFAULT_USER_AGENT, - trace_service_client.TraceServiceClient.SERVICE_ADDRESS) - generated = trace_service_client.TraceServiceClient( - channel=channel, - lib_name='gccl') + generated = trace_service_client.TraceServiceClient() return _TraceAPI(generated, client) @@ -206,7 +198,7 @@ def _traces_mapping_to_pb(traces_mapping): :type traces_mapping: dict :param traces_mapping: A trace mapping. - :rtype: class:`google.cloud.proto.devtools.cloudtrace.v1.trace_pb2.Traces` + :rtype: class:`google.cloud.trace_v1.proto.trace_pb2.Traces` :returns: The converted protobuf type traces. """ traces_pb = trace_pb2.Traces() diff --git a/trace/google/cloud/trace/client.py b/trace/google/cloud/trace/client.py index a38a2e33e79e..5c6bd95c7c42 100644 --- a/trace/google/cloud/trace/client.py +++ b/trace/google/cloud/trace/client.py @@ -116,7 +116,7 @@ def list_traces( :param project_id: (Optional) ID of the Cloud project where the trace data is stored. - :type view: :class:`google.cloud.gapic.trace.v1.enums. + :type view: :class:`google.cloud.trace_v1.gapic.enums. ListTracesRequest.ViewType` :param view: (Optional) Type of data returned for traces in the list. Default is ``MINIMAL``. diff --git a/trace/google/cloud/trace_v1/__init__.py b/trace/google/cloud/trace_v1/__init__.py index 348cf61ee96f..f6df7d72495b 100644 --- a/trace/google/cloud/trace_v1/__init__.py +++ b/trace/google/cloud/trace_v1/__init__.py @@ -12,14 +12,19 @@ # See the License for the specific language governing permissions and # limitations under the License. -from google.cloud.gapic.trace.v1.trace_service_client import TraceServiceClient -from google.cloud.gapic.trace.v1 import enums +from __future__ import absolute_import from google.cloud.trace_v1 import types +from google.cloud.trace_v1.gapic import enums +from google.cloud.trace_v1.gapic import trace_service_client + + +class TraceServiceClient(trace_service_client.TraceServiceClient): + __doc__ = trace_service_client.TraceServiceClient.__doc__ + enums = enums __all__ = ( 'enums', - 'TraceServiceClient', 'types', -) + 'TraceServiceClient', ) diff --git a/trace/google/cloud/gapic/trace/v1/__init__.py b/trace/google/cloud/trace_v1/gapic/__init__.py similarity index 100% rename from trace/google/cloud/gapic/trace/v1/__init__.py rename to trace/google/cloud/trace_v1/gapic/__init__.py diff --git a/trace/google/cloud/gapic/trace/v1/enums.py b/trace/google/cloud/trace_v1/gapic/enums.py similarity index 82% rename from trace/google/cloud/gapic/trace/v1/enums.py rename to trace/google/cloud/trace_v1/gapic/enums.py index 0a223cc83eb0..72b374960d7a 100644 --- a/trace/google/cloud/gapic/trace/v1/enums.py +++ b/trace/google/cloud/trace_v1/gapic/enums.py @@ -1,10 +1,10 @@ -# Copyright 2016 Google LLC All rights reserved. +# Copyright 2017, Google LLC All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # -# http://www.apache.org/licenses/LICENSE-2.0 +# http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, @@ -23,9 +23,9 @@ class SpanKind(object): Attributes: SPAN_KIND_UNSPECIFIED (int): Unspecified. RPC_SERVER (int): Indicates that the span covers server-side handling of an RPC or other - remote network request. + remote network request. RPC_CLIENT (int): Indicates that the span covers the client-side wrapper around an RPC or - other remote request. + other remote request. """ SPAN_KIND_UNSPECIFIED = 0 RPC_SERVER = 1 @@ -40,12 +40,12 @@ class ViewType(object): Attributes: VIEW_TYPE_UNSPECIFIED (int): Default is ``MINIMAL`` if unspecified. MINIMAL (int): Minimal view of the trace record that contains only the project - and trace IDs. + and trace IDs. ROOTSPAN (int): Root span view of the trace record that returns the root spans along - with the minimal trace data. + with the minimal trace data. COMPLETE (int): Complete view of the trace record that contains the actual trace data. - This is equivalent to calling the REST ``get`` or RPC ``GetTrace`` method - using the ID of each listed trace. + This is equivalent to calling the REST ``get`` or RPC ``GetTrace`` method + using the ID of each listed trace. """ VIEW_TYPE_UNSPECIFIED = 0 MINIMAL = 1 diff --git a/trace/google/cloud/trace_v1/gapic/trace_service_client.py b/trace/google/cloud/trace_v1/gapic/trace_service_client.py new file mode 100644 index 000000000000..06026ad93561 --- /dev/null +++ b/trace/google/cloud/trace_v1/gapic/trace_service_client.py @@ -0,0 +1,363 @@ +# Copyright 2017, Google LLC All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# EDITING INSTRUCTIONS +# This file was generated from the file +# https://github.com/google/googleapis/blob/master/google/devtools/cloudtrace/v1/trace.proto, +# and updates to that file get reflected here through a refresh process. +# For the short term, the refresh process will only be runnable by Google engineers. +# +# The only allowed edits are to method and file documentation. A 3-way +# merge preserves those additions if the generated source changes. +"""Accesses the google.devtools.cloudtrace.v1 TraceService API.""" + +import functools +import pkg_resources + +import google.api_core.gapic_v1.client_info +import google.api_core.gapic_v1.config +import google.api_core.gapic_v1.method +import google.api_core.grpc_helpers +import google.api_core.page_iterator + +from google.cloud.trace_v1.gapic import enums +from google.cloud.trace_v1.gapic import trace_service_client_config +from google.cloud.trace_v1.proto import trace_pb2 +from google.protobuf import timestamp_pb2 + +_GAPIC_LIBRARY_VERSION = pkg_resources.get_distribution( + 'google-cloud-trace', ).version + + +class TraceServiceClient(object): + """ + This file describes an API for collecting and viewing traces and spans + within a trace. A Trace is a collection of spans corresponding to a single + operation or set of operations for an application. A span is an individual + timed event which forms a node of the trace tree. Spans for a single trace + may span multiple services. + """ + + SERVICE_ADDRESS = 'cloudtrace.googleapis.com:443' + """The default address of the service.""" + + # The scopes needed to make gRPC calls to all of the methods defined in + # this service + _DEFAULT_SCOPES = ( + 'https://www.googleapis.com/auth/cloud-platform', + 'https://www.googleapis.com/auth/trace.append', + 'https://www.googleapis.com/auth/trace.readonly', ) + + # The name of the interface for this client. This is the key used to find + # method configuration in the client_config dictionary + _INTERFACE_NAME = ('google.devtools.cloudtrace.v1.TraceService') + + def __init__(self, + channel=None, + credentials=None, + client_config=trace_service_client_config.config, + client_info=None): + """Constructor. + + Args: + channel (grpc.Channel): A ``Channel`` instance through + which to make calls. If specified, then the ``credentials`` + argument is ignored. + credentials (google.auth.credentials.Credentials): The + authorization credentials to attach to requests. These + credentials identify this application to the service. If none + are specified, the client will attempt to ascertain the + credentials from the environment. + client_config (dict): + A dictionary of call options for each method. If not specified + the default configuration is used. Generally, you only need + to set this if you're developing your own client library. + client_info (google.api_core.gapic_v1.client_info.ClientInfo): + The client info used to send a user-agent string along with + API requests. If ``None``, then default info will be used. + Generally, you only need to set this if you're developing + your own client library. + """ + if channel is not None and credentials is not None: + raise ValueError( + 'channel and credentials arguments to {} are mutually ' + 'exclusive.'.format(self.__class__.__name__)) + + if channel is None: + channel = google.api_core.grpc_helpers.create_channel( + self.SERVICE_ADDRESS, + credentials=credentials, + scopes=self._DEFAULT_SCOPES) + + self.trace_service_stub = (trace_pb2.TraceServiceStub(channel)) + + if client_info is None: + client_info = ( + google.api_core.gapic_v1.client_info.DEFAULT_CLIENT_INFO) + + client_info.gapic_version = _GAPIC_LIBRARY_VERSION + + interface_config = client_config['interfaces'][self._INTERFACE_NAME] + method_configs = google.api_core.gapic_v1.config.parse_method_configs( + interface_config) + + self._patch_traces = google.api_core.gapic_v1.method.wrap_method( + self.trace_service_stub.PatchTraces, + default_retry=method_configs['PatchTraces'].retry, + default_timeout=method_configs['PatchTraces'].timeout, + client_info=client_info) + self._get_trace = google.api_core.gapic_v1.method.wrap_method( + self.trace_service_stub.GetTrace, + default_retry=method_configs['GetTrace'].retry, + default_timeout=method_configs['GetTrace'].timeout, + client_info=client_info) + self._list_traces = google.api_core.gapic_v1.method.wrap_method( + self.trace_service_stub.ListTraces, + default_retry=method_configs['ListTraces'].retry, + default_timeout=method_configs['ListTraces'].timeout, + client_info=client_info) + + # Service calls + def patch_traces(self, + project_id, + traces, + retry=google.api_core.gapic_v1.method.DEFAULT, + timeout=google.api_core.gapic_v1.method.DEFAULT): + """ + Sends new traces to Stackdriver Trace or updates existing traces. If the ID + of a trace that you send matches that of an existing trace, any fields + in the existing trace and its spans are overwritten by the provided values, + and any new fields provided are merged with the existing trace data. If the + ID does not match, a new trace is created. + + Example: + >>> from google.cloud import trace_v1 + >>> + >>> client = trace_v1.TraceServiceClient() + >>> + >>> project_id = '' + >>> traces = {} + >>> + >>> client.patch_traces(project_id, traces) + + Args: + project_id (str): ID of the Cloud project where the trace data is stored. + traces (Union[dict, ~google.cloud.trace_v1.types.Traces]): The body of the message. + If a dict is provided, it must be of the same form as the protobuf + message :class:`~google.cloud.trace_v1.types.Traces` + retry (Optional[google.api_core.retry.Retry]): A retry object used + to retry requests. If ``None`` is specified, requests will not + be retried. + timeout (Optional[float]): The amount of time, in seconds, to wait + for the request to complete. Note that if ``retry`` is + specified, the timeout applies to each individual attempt. + + Raises: + google.api_core.exceptions.GoogleAPICallError: If the request + failed for any reason. + google.api_core.exceptions.RetryError: If the request failed due + to a retryable error and retry attempts failed. + ValueError: If the parameters are invalid. + """ + request = trace_pb2.PatchTracesRequest( + project_id=project_id, traces=traces) + self._patch_traces(request, retry=retry, timeout=timeout) + + def get_trace(self, + project_id, + trace_id, + retry=google.api_core.gapic_v1.method.DEFAULT, + timeout=google.api_core.gapic_v1.method.DEFAULT): + """ + Gets a single trace by its ID. + + Example: + >>> from google.cloud import trace_v1 + >>> + >>> client = trace_v1.TraceServiceClient() + >>> + >>> project_id = '' + >>> trace_id = '' + >>> + >>> response = client.get_trace(project_id, trace_id) + + Args: + project_id (str): ID of the Cloud project where the trace data is stored. + trace_id (str): ID of the trace to return. + retry (Optional[google.api_core.retry.Retry]): A retry object used + to retry requests. If ``None`` is specified, requests will not + be retried. + timeout (Optional[float]): The amount of time, in seconds, to wait + for the request to complete. Note that if ``retry`` is + specified, the timeout applies to each individual attempt. + + Returns: + A :class:`~google.cloud.trace_v1.types.Trace` instance. + + Raises: + google.api_core.exceptions.GoogleAPICallError: If the request + failed for any reason. + google.api_core.exceptions.RetryError: If the request failed due + to a retryable error and retry attempts failed. + ValueError: If the parameters are invalid. + """ + request = trace_pb2.GetTraceRequest( + project_id=project_id, trace_id=trace_id) + return self._get_trace(request, retry=retry, timeout=timeout) + + def list_traces(self, + project_id, + view=None, + page_size=None, + start_time=None, + end_time=None, + filter_=None, + order_by=None, + retry=google.api_core.gapic_v1.method.DEFAULT, + timeout=google.api_core.gapic_v1.method.DEFAULT): + """ + Returns of a list of traces that match the specified filter conditions. + + Example: + >>> from google.cloud import trace_v1 + >>> + >>> client = trace_v1.TraceServiceClient() + >>> + >>> project_id = '' + >>> + >>> + >>> # Iterate over all results + >>> for element in client.list_traces(project_id): + ... # process element + ... pass + >>> + >>> # Or iterate over results one page at a time + >>> for page in client.list_traces(project_id, options=CallOptions(page_token=INITIAL_PAGE)): + ... for element in page: + ... # process element + ... pass + + Args: + project_id (str): ID of the Cloud project where the trace data is stored. + view (~google.cloud.trace_v1.types.ViewType): Type of data returned for traces in the list. Optional. Default is + ``MINIMAL``. + page_size (int): Maximum number of traces to return. If not specified or <= 0, the + implementation selects a reasonable value. The implementation may + return fewer traces than the requested page size. Optional. + start_time (Union[dict, ~google.cloud.trace_v1.types.Timestamp]): Start of the time interval (inclusive) during which the trace data was + collected from the application. + If a dict is provided, it must be of the same form as the protobuf + message :class:`~google.cloud.trace_v1.types.Timestamp` + end_time (Union[dict, ~google.cloud.trace_v1.types.Timestamp]): End of the time interval (inclusive) during which the trace data was + collected from the application. + If a dict is provided, it must be of the same form as the protobuf + message :class:`~google.cloud.trace_v1.types.Timestamp` + filter_ (str): An optional filter against labels for the request. + + By default, searches use prefix matching. To specify exact match, prepend + a plus symbol (``+``) to the search term. + Multiple terms are ANDed. Syntax: + + * ``root:NAME_PREFIX`` or ``NAME_PREFIX``: Return traces where any root + :: + + span starts with `NAME_PREFIX`. + * ``+root:NAME`` or ``+NAME``: Return traces where any root span's name is + :: + + exactly `NAME`. + * ``span:NAME_PREFIX``: Return traces where any span starts with + :: + + `NAME_PREFIX`. + * ``+span:NAME``: Return traces where any span's name is exactly + :: + + `NAME`. + * ``latency:DURATION``: Return traces whose overall latency is + :: + + greater or equal to than `DURATION`. Accepted units are nanoseconds + (`ns`), milliseconds (`ms`), and seconds (`s`). Default is `ms`. For + example, `latency:24ms` returns traces whose overall latency + is greater than or equal to 24 milliseconds. + * ``label:LABEL_KEY``: Return all traces containing the specified + :: + + label key (exact match, case-sensitive) regardless of the key:value + pair's value (including empty values). + * ``LABEL_KEY:VALUE_PREFIX``: Return all traces containing the specified + :: + + label key (exact match, case-sensitive) whose value starts with + `VALUE_PREFIX`. Both a key and a value must be specified. + * ``+LABEL_KEY:VALUE``: Return all traces containing a key:value pair + :: + + exactly matching the specified text. Both a key and a value must be + specified. + * ``method:VALUE``: Equivalent to ``/http/method:VALUE``. + * ``url:VALUE``: Equivalent to ``/http/url:VALUE``. + order_by (str): Field used to sort the returned traces. Optional. + Can be one of the following: + + * ``trace_id`` + * ``name`` (``name`` field of root span in the trace) + * ``duration`` (difference between ``end_time`` and ``start_time`` fields of + :: + + the root span) + * ``start`` (``start_time`` field of the root span) + + Descending order can be specified by appending ``desc`` to the sort field + (for example, ``name desc``). + + Only one sort field is permitted. + retry (Optional[google.api_core.retry.Retry]): A retry object used + to retry requests. If ``None`` is specified, requests will not + be retried. + timeout (Optional[float]): The amount of time, in seconds, to wait + for the request to complete. Note that if ``retry`` is + specified, the timeout applies to each individual attempt. + + Returns: + A :class:`~google.gax.PageIterator` instance. By default, this + is an iterable of :class:`~google.cloud.trace_v1.types.Trace` instances. + This object can also be configured to iterate over the pages + of the response through the `options` parameter. + + Raises: + google.api_core.exceptions.GoogleAPICallError: If the request + failed for any reason. + google.api_core.exceptions.RetryError: If the request failed due + to a retryable error and retry attempts failed. + ValueError: If the parameters are invalid. + """ + request = trace_pb2.ListTracesRequest( + project_id=project_id, + view=view, + page_size=page_size, + start_time=start_time, + end_time=end_time, + filter=filter_, + order_by=order_by) + iterator = google.api_core.page_iterator.GRPCIterator( + client=None, + method=functools.partial( + self._list_traces, retry=retry, timeout=timeout), + request=request, + items_field='traces', + request_token_field='page_token', + response_token_field='next_page_token') + return iterator diff --git a/trace/google/cloud/trace_v1/gapic/trace_service_client_config.py b/trace/google/cloud/trace_v1/gapic/trace_service_client_config.py new file mode 100644 index 000000000000..e123085ccbac --- /dev/null +++ b/trace/google/cloud/trace_v1/gapic/trace_service_client_config.py @@ -0,0 +1,38 @@ +config = { + "interfaces": { + "google.devtools.cloudtrace.v1.TraceService": { + "retry_codes": { + "idempotent": ["DEADLINE_EXCEEDED", "UNAVAILABLE"], + "non_idempotent": [] + }, + "retry_params": { + "default": { + "initial_retry_delay_millis": 100, + "retry_delay_multiplier": 1.2, + "max_retry_delay_millis": 1000, + "initial_rpc_timeout_millis": 20000, + "rpc_timeout_multiplier": 1.5, + "max_rpc_timeout_millis": 30000, + "total_timeout_millis": 45000 + } + }, + "methods": { + "PatchTraces": { + "timeout_millis": 30000, + "retry_codes_name": "idempotent", + "retry_params_name": "default" + }, + "GetTrace": { + "timeout_millis": 30000, + "retry_codes_name": "idempotent", + "retry_params_name": "default" + }, + "ListTraces": { + "timeout_millis": 30000, + "retry_codes_name": "idempotent", + "retry_params_name": "default" + } + } + } + } +} diff --git a/trace/google/cloud/trace_v1/proto/__init__.py b/trace/google/cloud/trace_v1/proto/__init__.py new file mode 100644 index 000000000000..e69de29bb2d1 diff --git a/trace/google/cloud/proto/devtools/cloudtrace/v1/trace_pb2.py b/trace/google/cloud/trace_v1/proto/trace_pb2.py similarity index 72% rename from trace/google/cloud/proto/devtools/cloudtrace/v1/trace_pb2.py rename to trace/google/cloud/trace_v1/proto/trace_pb2.py index 389893c0d9fd..a4a61928cade 100644 --- a/trace/google/cloud/proto/devtools/cloudtrace/v1/trace_pb2.py +++ b/trace/google/cloud/trace_v1/proto/trace_pb2.py @@ -1,5 +1,5 @@ # Generated by the protocol buffer compiler. DO NOT EDIT! -# source: google/cloud/proto/devtools/cloudtrace/v1/trace.proto +# source: google/devtools/cloudtrace_v1/proto/trace.proto import sys _b=sys.version_info[0]<3 and (lambda x:x) or (lambda x:x.encode('latin1')) @@ -19,13 +19,12 @@ DESCRIPTOR = _descriptor.FileDescriptor( - name='google/cloud/proto/devtools/cloudtrace/v1/trace.proto', + name='google/devtools/cloudtrace_v1/proto/trace.proto', package='google.devtools.cloudtrace.v1', syntax='proto3', - serialized_pb=_b('\n5google/cloud/proto/devtools/cloudtrace/v1/trace.proto\x12\x1dgoogle.devtools.cloudtrace.v1\x1a\x1cgoogle/api/annotations.proto\x1a\x1bgoogle/protobuf/empty.proto\x1a\x1fgoogle/protobuf/timestamp.proto\"f\n\x05Trace\x12\x12\n\nproject_id\x18\x01 \x01(\t\x12\x10\n\x08trace_id\x18\x02 \x01(\t\x12\x37\n\x05spans\x18\x03 \x03(\x0b\x32(.google.devtools.cloudtrace.v1.TraceSpan\">\n\x06Traces\x12\x34\n\x06traces\x18\x01 \x03(\x0b\x32$.google.devtools.cloudtrace.v1.Trace\"\x9d\x03\n\tTraceSpan\x12\x0f\n\x07span_id\x18\x01 \x01(\x06\x12?\n\x04kind\x18\x02 \x01(\x0e\x32\x31.google.devtools.cloudtrace.v1.TraceSpan.SpanKind\x12\x0c\n\x04name\x18\x03 \x01(\t\x12.\n\nstart_time\x18\x04 \x01(\x0b\x32\x1a.google.protobuf.Timestamp\x12,\n\x08\x65nd_time\x18\x05 \x01(\x0b\x32\x1a.google.protobuf.Timestamp\x12\x16\n\x0eparent_span_id\x18\x06 \x01(\x06\x12\x44\n\x06labels\x18\x07 \x03(\x0b\x32\x34.google.devtools.cloudtrace.v1.TraceSpan.LabelsEntry\x1a-\n\x0bLabelsEntry\x12\x0b\n\x03key\x18\x01 \x01(\t\x12\r\n\x05value\x18\x02 \x01(\t:\x02\x38\x01\"E\n\x08SpanKind\x12\x19\n\x15SPAN_KIND_UNSPECIFIED\x10\x00\x12\x0e\n\nRPC_SERVER\x10\x01\x12\x0e\n\nRPC_CLIENT\x10\x02\"\xe7\x02\n\x11ListTracesRequest\x12\x12\n\nproject_id\x18\x01 \x01(\t\x12G\n\x04view\x18\x02 \x01(\x0e\x32\x39.google.devtools.cloudtrace.v1.ListTracesRequest.ViewType\x12\x11\n\tpage_size\x18\x03 \x01(\x05\x12\x12\n\npage_token\x18\x04 \x01(\t\x12.\n\nstart_time\x18\x05 \x01(\x0b\x32\x1a.google.protobuf.Timestamp\x12,\n\x08\x65nd_time\x18\x06 \x01(\x0b\x32\x1a.google.protobuf.Timestamp\x12\x0e\n\x06\x66ilter\x18\x07 \x01(\t\x12\x10\n\x08order_by\x18\x08 \x01(\t\"N\n\x08ViewType\x12\x19\n\x15VIEW_TYPE_UNSPECIFIED\x10\x00\x12\x0b\n\x07MINIMAL\x10\x01\x12\x0c\n\x08ROOTSPAN\x10\x02\x12\x0c\n\x08\x43OMPLETE\x10\x03\"c\n\x12ListTracesResponse\x12\x34\n\x06traces\x18\x01 \x03(\x0b\x32$.google.devtools.cloudtrace.v1.Trace\x12\x17\n\x0fnext_page_token\x18\x02 \x01(\t\"7\n\x0fGetTraceRequest\x12\x12\n\nproject_id\x18\x01 \x01(\t\x12\x10\n\x08trace_id\x18\x02 \x01(\t\"_\n\x12PatchTracesRequest\x12\x12\n\nproject_id\x18\x01 \x01(\t\x12\x35\n\x06traces\x18\x02 \x01(\x0b\x32%.google.devtools.cloudtrace.v1.Traces2\xd1\x03\n\x0cTraceService\x12\x9b\x01\n\nListTraces\x12\x30.google.devtools.cloudtrace.v1.ListTracesRequest\x1a\x31.google.devtools.cloudtrace.v1.ListTracesResponse\"(\x82\xd3\xe4\x93\x02\"\x12 /v1/projects/{project_id}/traces\x12\x95\x01\n\x08GetTrace\x12..google.devtools.cloudtrace.v1.GetTraceRequest\x1a$.google.devtools.cloudtrace.v1.Trace\"3\x82\xd3\xe4\x93\x02-\x12+/v1/projects/{project_id}/traces/{trace_id}\x12\x8a\x01\n\x0bPatchTraces\x12\x31.google.devtools.cloudtrace.v1.PatchTracesRequest\x1a\x16.google.protobuf.Empty\"0\x82\xd3\xe4\x93\x02*2 /v1/projects/{project_id}/traces:\x06tracesB\x92\x01\n!com.google.devtools.cloudtrace.v1B\nTraceProtoP\x01ZGgoogle.golang.org/genproto/googleapis/devtools/cloudtrace/v1;cloudtrace\xaa\x02\x15Google.Cloud.Trace.V1b\x06proto3') + serialized_pb=_b('\n/google/devtools/cloudtrace_v1/proto/trace.proto\x12\x1dgoogle.devtools.cloudtrace.v1\x1a\x1cgoogle/api/annotations.proto\x1a\x1bgoogle/protobuf/empty.proto\x1a\x1fgoogle/protobuf/timestamp.proto\"f\n\x05Trace\x12\x12\n\nproject_id\x18\x01 \x01(\t\x12\x10\n\x08trace_id\x18\x02 \x01(\t\x12\x37\n\x05spans\x18\x03 \x03(\x0b\x32(.google.devtools.cloudtrace.v1.TraceSpan\">\n\x06Traces\x12\x34\n\x06traces\x18\x01 \x03(\x0b\x32$.google.devtools.cloudtrace.v1.Trace\"\x9d\x03\n\tTraceSpan\x12\x0f\n\x07span_id\x18\x01 \x01(\x06\x12?\n\x04kind\x18\x02 \x01(\x0e\x32\x31.google.devtools.cloudtrace.v1.TraceSpan.SpanKind\x12\x0c\n\x04name\x18\x03 \x01(\t\x12.\n\nstart_time\x18\x04 \x01(\x0b\x32\x1a.google.protobuf.Timestamp\x12,\n\x08\x65nd_time\x18\x05 \x01(\x0b\x32\x1a.google.protobuf.Timestamp\x12\x16\n\x0eparent_span_id\x18\x06 \x01(\x06\x12\x44\n\x06labels\x18\x07 \x03(\x0b\x32\x34.google.devtools.cloudtrace.v1.TraceSpan.LabelsEntry\x1a-\n\x0bLabelsEntry\x12\x0b\n\x03key\x18\x01 \x01(\t\x12\r\n\x05value\x18\x02 \x01(\t:\x02\x38\x01\"E\n\x08SpanKind\x12\x19\n\x15SPAN_KIND_UNSPECIFIED\x10\x00\x12\x0e\n\nRPC_SERVER\x10\x01\x12\x0e\n\nRPC_CLIENT\x10\x02\"\xe7\x02\n\x11ListTracesRequest\x12\x12\n\nproject_id\x18\x01 \x01(\t\x12G\n\x04view\x18\x02 \x01(\x0e\x32\x39.google.devtools.cloudtrace.v1.ListTracesRequest.ViewType\x12\x11\n\tpage_size\x18\x03 \x01(\x05\x12\x12\n\npage_token\x18\x04 \x01(\t\x12.\n\nstart_time\x18\x05 \x01(\x0b\x32\x1a.google.protobuf.Timestamp\x12,\n\x08\x65nd_time\x18\x06 \x01(\x0b\x32\x1a.google.protobuf.Timestamp\x12\x0e\n\x06\x66ilter\x18\x07 \x01(\t\x12\x10\n\x08order_by\x18\x08 \x01(\t\"N\n\x08ViewType\x12\x19\n\x15VIEW_TYPE_UNSPECIFIED\x10\x00\x12\x0b\n\x07MINIMAL\x10\x01\x12\x0c\n\x08ROOTSPAN\x10\x02\x12\x0c\n\x08\x43OMPLETE\x10\x03\"c\n\x12ListTracesResponse\x12\x34\n\x06traces\x18\x01 \x03(\x0b\x32$.google.devtools.cloudtrace.v1.Trace\x12\x17\n\x0fnext_page_token\x18\x02 \x01(\t\"7\n\x0fGetTraceRequest\x12\x12\n\nproject_id\x18\x01 \x01(\t\x12\x10\n\x08trace_id\x18\x02 \x01(\t\"_\n\x12PatchTracesRequest\x12\x12\n\nproject_id\x18\x01 \x01(\t\x12\x35\n\x06traces\x18\x02 \x01(\x0b\x32%.google.devtools.cloudtrace.v1.Traces2\xd1\x03\n\x0cTraceService\x12\x9b\x01\n\nListTraces\x12\x30.google.devtools.cloudtrace.v1.ListTracesRequest\x1a\x31.google.devtools.cloudtrace.v1.ListTracesResponse\"(\x82\xd3\xe4\x93\x02\"\x12 /v1/projects/{project_id}/traces\x12\x95\x01\n\x08GetTrace\x12..google.devtools.cloudtrace.v1.GetTraceRequest\x1a$.google.devtools.cloudtrace.v1.Trace\"3\x82\xd3\xe4\x93\x02-\x12+/v1/projects/{project_id}/traces/{trace_id}\x12\x8a\x01\n\x0bPatchTraces\x12\x31.google.devtools.cloudtrace.v1.PatchTracesRequest\x1a\x16.google.protobuf.Empty\"0\x82\xd3\xe4\x93\x02*2 /v1/projects/{project_id}/traces:\x06tracesB\x92\x01\n!com.google.devtools.cloudtrace.v1B\nTraceProtoP\x01ZGgoogle.golang.org/genproto/googleapis/devtools/cloudtrace/v1;cloudtrace\xaa\x02\x15Google.Cloud.Trace.V1b\x06proto3') , dependencies=[google_dot_api_dot_annotations__pb2.DESCRIPTOR,google_dot_protobuf_dot_empty__pb2.DESCRIPTOR,google_dot_protobuf_dot_timestamp__pb2.DESCRIPTOR,]) -_sym_db.RegisterFileDescriptor(DESCRIPTOR) @@ -50,8 +49,8 @@ ], containing_type=None, options=None, - serialized_start=693, - serialized_end=762, + serialized_start=687, + serialized_end=756, ) _sym_db.RegisterEnumDescriptor(_TRACESPAN_SPANKIND) @@ -80,8 +79,8 @@ ], containing_type=None, options=None, - serialized_start=1046, - serialized_end=1124, + serialized_start=1040, + serialized_end=1118, ) _sym_db.RegisterEnumDescriptor(_LISTTRACESREQUEST_VIEWTYPE) @@ -126,8 +125,8 @@ extension_ranges=[], oneofs=[ ], - serialized_start=180, - serialized_end=282, + serialized_start=174, + serialized_end=276, ) @@ -157,8 +156,8 @@ extension_ranges=[], oneofs=[ ], - serialized_start=284, - serialized_end=346, + serialized_start=278, + serialized_end=340, ) @@ -195,8 +194,8 @@ extension_ranges=[], oneofs=[ ], - serialized_start=646, - serialized_end=691, + serialized_start=640, + serialized_end=685, ) _TRACESPAN = _descriptor.Descriptor( @@ -268,8 +267,8 @@ extension_ranges=[], oneofs=[ ], - serialized_start=349, - serialized_end=762, + serialized_start=343, + serialized_end=756, ) @@ -349,8 +348,8 @@ extension_ranges=[], oneofs=[ ], - serialized_start=765, - serialized_end=1124, + serialized_start=759, + serialized_end=1118, ) @@ -387,8 +386,8 @@ extension_ranges=[], oneofs=[ ], - serialized_start=1126, - serialized_end=1225, + serialized_start=1120, + serialized_end=1219, ) @@ -425,8 +424,8 @@ extension_ranges=[], oneofs=[ ], - serialized_start=1227, - serialized_end=1282, + serialized_start=1221, + serialized_end=1276, ) @@ -463,8 +462,8 @@ extension_ranges=[], oneofs=[ ], - serialized_start=1284, - serialized_end=1379, + serialized_start=1278, + serialized_end=1373, ) _TRACE.fields_by_name['spans'].message_type = _TRACESPAN @@ -488,17 +487,42 @@ DESCRIPTOR.message_types_by_name['ListTracesResponse'] = _LISTTRACESRESPONSE DESCRIPTOR.message_types_by_name['GetTraceRequest'] = _GETTRACEREQUEST DESCRIPTOR.message_types_by_name['PatchTracesRequest'] = _PATCHTRACESREQUEST +_sym_db.RegisterFileDescriptor(DESCRIPTOR) Trace = _reflection.GeneratedProtocolMessageType('Trace', (_message.Message,), dict( DESCRIPTOR = _TRACE, - __module__ = 'google.cloud.proto.devtools.cloudtrace.v1.trace_pb2' + __module__ = 'google.devtools.cloudtrace_v1.proto.trace_pb2' + , + __doc__ = """A trace describes how long it takes for an application to perform an + operation. It consists of a set of spans, each of which represent a + single timed event within the operation. + + + Attributes: + project_id: + Project ID of the Cloud project where the trace data is + stored. + trace_id: + Globally unique identifier for the trace. This identifier is a + 128-bit numeric value formatted as a 32-byte hex string. + spans: + Collection of spans in the trace. + """, # @@protoc_insertion_point(class_scope:google.devtools.cloudtrace.v1.Trace) )) _sym_db.RegisterMessage(Trace) Traces = _reflection.GeneratedProtocolMessageType('Traces', (_message.Message,), dict( DESCRIPTOR = _TRACES, - __module__ = 'google.cloud.proto.devtools.cloudtrace.v1.trace_pb2' + __module__ = 'google.devtools.cloudtrace_v1.proto.trace_pb2' + , + __doc__ = """List of new or updated traces. + + + Attributes: + traces: + List of traces. + """, # @@protoc_insertion_point(class_scope:google.devtools.cloudtrace.v1.Traces) )) _sym_db.RegisterMessage(Traces) @@ -507,12 +531,62 @@ LabelsEntry = _reflection.GeneratedProtocolMessageType('LabelsEntry', (_message.Message,), dict( DESCRIPTOR = _TRACESPAN_LABELSENTRY, - __module__ = 'google.cloud.proto.devtools.cloudtrace.v1.trace_pb2' + __module__ = 'google.devtools.cloudtrace_v1.proto.trace_pb2' # @@protoc_insertion_point(class_scope:google.devtools.cloudtrace.v1.TraceSpan.LabelsEntry) )) , DESCRIPTOR = _TRACESPAN, - __module__ = 'google.cloud.proto.devtools.cloudtrace.v1.trace_pb2' + __module__ = 'google.devtools.cloudtrace_v1.proto.trace_pb2' + , + __doc__ = """A span represents a single timed event within a trace. Spans can be + nested and form a trace tree. Often, a trace contains a root span that + describes the end-to-end latency of an operation and, optionally, one or + more subspans for its suboperations. Spans do not need to be contiguous. + There may be gaps between spans in a trace. + + + Attributes: + span_id: + Identifier for the span. Must be a 64-bit integer other than 0 + and unique within a trace. + kind: + Distinguishes between spans generated in a particular context. + For example, two spans with the same name may be distinguished + using ``RPC_CLIENT`` and ``RPC_SERVER`` to identify queueing + latency associated with the span. + name: + Name of the span. Must be less than 128 bytes. The span name + is sanitized and displayed in the Stackdriver Trace tool in + the {% dynamic print site\_values.console\_name %}. The name + may be a method name or some other per-call site name. For the + same executable and the same call point, a best practice is to + use a consistent name, which makes it easier to correlate + cross-trace spans. + start_time: + Start time of the span in nanoseconds from the UNIX epoch. + end_time: + End time of the span in nanoseconds from the UNIX epoch. + parent_span_id: + ID of the parent span, if any. Optional. + labels: + Collection of labels associated with the span. Label keys must + be less than 128 bytes. Label values must be less than 16 + kilobytes (10MB for ``/stacktrace`` values). Some predefined + label keys exist, or you may create your own. When creating + your own, we recommend the following formats: - + ``/category/product/key`` for agents of well-known products + (e.g. ``/db/mongodb/read_size``). - + ``short_host/path/key`` for domain-specific keys (e.g. + ``foo.com/myproduct/bar``) Predefined labels include: - + ``/agent`` - ``/component`` - ``/error/message`` - + ``/error/name`` - ``/http/client_city`` - + ``/http/client_country`` - ``/http/client_protocol`` - + ``/http/client_region`` - ``/http/host`` - ``/http/method`` + - ``/http/redirected_url`` - ``/http/request/size`` - + ``/http/response/size`` - ``/http/status_code`` - + ``/http/url`` - ``/http/user_agent`` - ``/pid`` - + ``/stacktrace`` - ``/tid`` + """, # @@protoc_insertion_point(class_scope:google.devtools.cloudtrace.v1.TraceSpan) )) _sym_db.RegisterMessage(TraceSpan) @@ -520,28 +594,124 @@ ListTracesRequest = _reflection.GeneratedProtocolMessageType('ListTracesRequest', (_message.Message,), dict( DESCRIPTOR = _LISTTRACESREQUEST, - __module__ = 'google.cloud.proto.devtools.cloudtrace.v1.trace_pb2' + __module__ = 'google.devtools.cloudtrace_v1.proto.trace_pb2' + , + __doc__ = """The request message for the ``ListTraces`` method. All fields are + required unless specified. + + + Attributes: + project_id: + ID of the Cloud project where the trace data is stored. + view: + Type of data returned for traces in the list. Optional. + Default is ``MINIMAL``. + page_size: + Maximum number of traces to return. If not specified or <= 0, + the implementation selects a reasonable value. The + implementation may return fewer traces than the requested page + size. Optional. + page_token: + Token identifying the page of results to return. If provided, + use the value of the ``next_page_token`` field from a previous + request. Optional. + start_time: + Start of the time interval (inclusive) during which the trace + data was collected from the application. + end_time: + End of the time interval (inclusive) during which the trace + data was collected from the application. + filter: + An optional filter against labels for the request. By + default, searches use prefix matching. To specify exact match, + prepend a plus symbol (``+``) to the search term. Multiple + terms are ANDed. Syntax: - ``root:NAME_PREFIX`` or + ``NAME_PREFIX``: Return traces where any root span starts + with ``NAME_PREFIX``. - ``+root:NAME`` or ``+NAME``: Return + traces where any root span's name is exactly ``NAME``. - + ``span:NAME_PREFIX``: Return traces where any span starts with + ``NAME_PREFIX``. - ``+span:NAME``: Return traces where any + span's name is exactly ``NAME``. - ``latency:DURATION``: + Return traces whose overall latency is greater or equal to + than ``DURATION``. Accepted units are nanoseconds (``ns``), + milliseconds (``ms``), and seconds (``s``). Default is + ``ms``. For example, ``latency:24ms`` returns traces whose + overall latency is greater than or equal to 24 + milliseconds. - ``label:LABEL_KEY``: Return all traces + containing the specified label key (exact match, case- + sensitive) regardless of the key:value pair's value + (including empty values). - ``LABEL_KEY:VALUE_PREFIX``: + Return all traces containing the specified label key (exact + match, case-sensitive) whose value starts with + ``VALUE_PREFIX``. Both a key and a value must be specified. - + ``+LABEL_KEY:VALUE``: Return all traces containing a key:value + pair exactly matching the specified text. Both a key and a + value must be specified. - ``method:VALUE``: Equivalent to + ``/http/method:VALUE``. - ``url:VALUE``: Equivalent to + ``/http/url:VALUE``. + order_by: + Field used to sort the returned traces. Optional. Can be one + of the following: - ``trace_id`` - ``name`` (``name`` field + of root span in the trace) - ``duration`` (difference between + ``end_time`` and ``start_time`` fields of the root span) - + ``start`` (``start_time`` field of the root span) Descending + order can be specified by appending ``desc`` to the sort field + (for example, ``name desc``). Only one sort field is + permitted. + """, # @@protoc_insertion_point(class_scope:google.devtools.cloudtrace.v1.ListTracesRequest) )) _sym_db.RegisterMessage(ListTracesRequest) ListTracesResponse = _reflection.GeneratedProtocolMessageType('ListTracesResponse', (_message.Message,), dict( DESCRIPTOR = _LISTTRACESRESPONSE, - __module__ = 'google.cloud.proto.devtools.cloudtrace.v1.trace_pb2' + __module__ = 'google.devtools.cloudtrace_v1.proto.trace_pb2' + , + __doc__ = """The response message for the ``ListTraces`` method. + + + Attributes: + traces: + List of trace records returned. + next_page_token: + If defined, indicates that there are more traces that match + the request and that this value should be passed to the next + request to continue retrieving additional traces. + """, # @@protoc_insertion_point(class_scope:google.devtools.cloudtrace.v1.ListTracesResponse) )) _sym_db.RegisterMessage(ListTracesResponse) GetTraceRequest = _reflection.GeneratedProtocolMessageType('GetTraceRequest', (_message.Message,), dict( DESCRIPTOR = _GETTRACEREQUEST, - __module__ = 'google.cloud.proto.devtools.cloudtrace.v1.trace_pb2' + __module__ = 'google.devtools.cloudtrace_v1.proto.trace_pb2' + , + __doc__ = """The request message for the ``GetTrace`` method. + + + Attributes: + project_id: + ID of the Cloud project where the trace data is stored. + trace_id: + ID of the trace to return. + """, # @@protoc_insertion_point(class_scope:google.devtools.cloudtrace.v1.GetTraceRequest) )) _sym_db.RegisterMessage(GetTraceRequest) PatchTracesRequest = _reflection.GeneratedProtocolMessageType('PatchTracesRequest', (_message.Message,), dict( DESCRIPTOR = _PATCHTRACESREQUEST, - __module__ = 'google.cloud.proto.devtools.cloudtrace.v1.trace_pb2' + __module__ = 'google.devtools.cloudtrace_v1.proto.trace_pb2' + , + __doc__ = """The request message for the ``PatchTraces`` method. + + + Attributes: + project_id: + ID of the Cloud project where the trace data is stored. + traces: + The body of the message. + """, # @@protoc_insertion_point(class_scope:google.devtools.cloudtrace.v1.PatchTracesRequest) )) _sym_db.RegisterMessage(PatchTracesRequest) diff --git a/trace/google/cloud/proto/devtools/cloudtrace/v1/trace_pb2_grpc.py b/trace/google/cloud/trace_v1/proto/trace_pb2_grpc.py similarity index 66% rename from trace/google/cloud/proto/devtools/cloudtrace/v1/trace_pb2_grpc.py rename to trace/google/cloud/trace_v1/proto/trace_pb2_grpc.py index de3ca9f57728..cfffb915f550 100644 --- a/trace/google/cloud/proto/devtools/cloudtrace/v1/trace_pb2_grpc.py +++ b/trace/google/cloud/trace_v1/proto/trace_pb2_grpc.py @@ -1,8 +1,8 @@ # Generated by the gRPC Python protocol compiler plugin. DO NOT EDIT! import grpc -import google.cloud.proto.devtools.cloudtrace.v1.trace_pb2 as google_dot_cloud_dot_proto_dot_devtools_dot_cloudtrace_dot_v1_dot_trace__pb2 -import google.protobuf.empty_pb2 as google_dot_protobuf_dot_empty__pb2 +from google.devtools.cloudtrace_v1.proto import trace_pb2 as google_dot_devtools_dot_cloudtrace__v1_dot_proto_dot_trace__pb2 +from google.protobuf import empty_pb2 as google_dot_protobuf_dot_empty__pb2 class TraceServiceStub(object): @@ -21,17 +21,17 @@ def __init__(self, channel): """ self.ListTraces = channel.unary_unary( '/google.devtools.cloudtrace.v1.TraceService/ListTraces', - request_serializer=google_dot_cloud_dot_proto_dot_devtools_dot_cloudtrace_dot_v1_dot_trace__pb2.ListTracesRequest.SerializeToString, - response_deserializer=google_dot_cloud_dot_proto_dot_devtools_dot_cloudtrace_dot_v1_dot_trace__pb2.ListTracesResponse.FromString, + request_serializer=google_dot_devtools_dot_cloudtrace__v1_dot_proto_dot_trace__pb2.ListTracesRequest.SerializeToString, + response_deserializer=google_dot_devtools_dot_cloudtrace__v1_dot_proto_dot_trace__pb2.ListTracesResponse.FromString, ) self.GetTrace = channel.unary_unary( '/google.devtools.cloudtrace.v1.TraceService/GetTrace', - request_serializer=google_dot_cloud_dot_proto_dot_devtools_dot_cloudtrace_dot_v1_dot_trace__pb2.GetTraceRequest.SerializeToString, - response_deserializer=google_dot_cloud_dot_proto_dot_devtools_dot_cloudtrace_dot_v1_dot_trace__pb2.Trace.FromString, + request_serializer=google_dot_devtools_dot_cloudtrace__v1_dot_proto_dot_trace__pb2.GetTraceRequest.SerializeToString, + response_deserializer=google_dot_devtools_dot_cloudtrace__v1_dot_proto_dot_trace__pb2.Trace.FromString, ) self.PatchTraces = channel.unary_unary( '/google.devtools.cloudtrace.v1.TraceService/PatchTraces', - request_serializer=google_dot_cloud_dot_proto_dot_devtools_dot_cloudtrace_dot_v1_dot_trace__pb2.PatchTracesRequest.SerializeToString, + request_serializer=google_dot_devtools_dot_cloudtrace__v1_dot_proto_dot_trace__pb2.PatchTracesRequest.SerializeToString, response_deserializer=google_dot_protobuf_dot_empty__pb2.Empty.FromString, ) @@ -74,17 +74,17 @@ def add_TraceServiceServicer_to_server(servicer, server): rpc_method_handlers = { 'ListTraces': grpc.unary_unary_rpc_method_handler( servicer.ListTraces, - request_deserializer=google_dot_cloud_dot_proto_dot_devtools_dot_cloudtrace_dot_v1_dot_trace__pb2.ListTracesRequest.FromString, - response_serializer=google_dot_cloud_dot_proto_dot_devtools_dot_cloudtrace_dot_v1_dot_trace__pb2.ListTracesResponse.SerializeToString, + request_deserializer=google_dot_devtools_dot_cloudtrace__v1_dot_proto_dot_trace__pb2.ListTracesRequest.FromString, + response_serializer=google_dot_devtools_dot_cloudtrace__v1_dot_proto_dot_trace__pb2.ListTracesResponse.SerializeToString, ), 'GetTrace': grpc.unary_unary_rpc_method_handler( servicer.GetTrace, - request_deserializer=google_dot_cloud_dot_proto_dot_devtools_dot_cloudtrace_dot_v1_dot_trace__pb2.GetTraceRequest.FromString, - response_serializer=google_dot_cloud_dot_proto_dot_devtools_dot_cloudtrace_dot_v1_dot_trace__pb2.Trace.SerializeToString, + request_deserializer=google_dot_devtools_dot_cloudtrace__v1_dot_proto_dot_trace__pb2.GetTraceRequest.FromString, + response_serializer=google_dot_devtools_dot_cloudtrace__v1_dot_proto_dot_trace__pb2.Trace.SerializeToString, ), 'PatchTraces': grpc.unary_unary_rpc_method_handler( servicer.PatchTraces, - request_deserializer=google_dot_cloud_dot_proto_dot_devtools_dot_cloudtrace_dot_v1_dot_trace__pb2.PatchTracesRequest.FromString, + request_deserializer=google_dot_devtools_dot_cloudtrace__v1_dot_proto_dot_trace__pb2.PatchTracesRequest.FromString, response_serializer=google_dot_protobuf_dot_empty__pb2.Empty.SerializeToString, ), } diff --git a/trace/google/cloud/trace_v1/types.py b/trace/google/cloud/trace_v1/types.py index 93571f39b29d..a013582829dd 100644 --- a/trace/google/cloud/trace_v1/types.py +++ b/trace/google/cloud/trace_v1/types.py @@ -15,14 +15,24 @@ from __future__ import absolute_import import sys -from google.cloud.proto.devtools.cloudtrace.v1 import trace_pb2 -from google.gax.utils.messages import get_messages +from google.api_core.protobuf_helpers import get_messages +from google.api import http_pb2 +from google.cloud.trace_v1.proto import trace_pb2 +from google.protobuf import descriptor_pb2 +from google.protobuf import empty_pb2 +from google.protobuf import timestamp_pb2 names = [] -for name, message in get_messages(trace_pb2).items(): - setattr(sys.modules[__name__], name, message) - names.append(name) - +for module in ( + http_pb2, + trace_pb2, + descriptor_pb2, + empty_pb2, + timestamp_pb2, ): + for name, message in get_messages(module).items(): + message.__module__ = 'google.cloud.trace_v1.types' + setattr(sys.modules[__name__], name, message) + names.append(name) __all__ = tuple(sorted(names)) diff --git a/trace/google/cloud/trace_v2/__init__.py b/trace/google/cloud/trace_v2/__init__.py new file mode 100644 index 000000000000..cc87465c42a6 --- /dev/null +++ b/trace/google/cloud/trace_v2/__init__.py @@ -0,0 +1,30 @@ +# Copyright 2017, Google LLC All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +from __future__ import absolute_import + +from google.cloud.trace_v2 import types +from google.cloud.trace_v2.gapic import enums +from google.cloud.trace_v2.gapic import trace_service_client + + +class TraceServiceClient(trace_service_client.TraceServiceClient): + __doc__ = trace_service_client.TraceServiceClient.__doc__ + enums = enums + + +__all__ = ( + 'enums', + 'types', + 'TraceServiceClient', ) diff --git a/trace/google/cloud/trace_v2/gapic/__init__.py b/trace/google/cloud/trace_v2/gapic/__init__.py new file mode 100644 index 000000000000..e69de29bb2d1 diff --git a/trace/google/cloud/trace_v2/gapic/enums.py b/trace/google/cloud/trace_v2/gapic/enums.py new file mode 100644 index 000000000000..bc2ee7fbe601 --- /dev/null +++ b/trace/google/cloud/trace_v2/gapic/enums.py @@ -0,0 +1,46 @@ +# Copyright 2017, Google LLC All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +"""Wrappers for protocol buffer enum types.""" + + +class Span(object): + class TimeEvent(object): + class MessageEvent(object): + class Type(object): + """ + Indicates whether the message was sent or received. + + Attributes: + TYPE_UNSPECIFIED (int): Unknown event type. + SENT (int): Indicates a sent message. + RECEIVED (int): Indicates a received message. + """ + TYPE_UNSPECIFIED = 0 + SENT = 1 + RECEIVED = 2 + + class Link(object): + class Type(object): + """ + The relationship of the current span relative to the linked span: child, + parent, or unspecified. + + Attributes: + TYPE_UNSPECIFIED (int): The relationship of the two spans is unknown. + CHILD_LINKED_SPAN (int): The linked span is a child of the current span. + PARENT_LINKED_SPAN (int): The linked span is a parent of the current span. + """ + TYPE_UNSPECIFIED = 0 + CHILD_LINKED_SPAN = 1 + PARENT_LINKED_SPAN = 2 diff --git a/trace/google/cloud/trace_v2/gapic/trace_service_client.py b/trace/google/cloud/trace_v2/gapic/trace_service_client.py new file mode 100644 index 000000000000..cbebd9063dce --- /dev/null +++ b/trace/google/cloud/trace_v2/gapic/trace_service_client.py @@ -0,0 +1,311 @@ +# Copyright 2017, Google LLC All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# EDITING INSTRUCTIONS +# This file was generated from the file +# https://github.com/google/googleapis/blob/master/google/devtools/cloudtrace/v2/tracing.proto, +# and updates to that file get reflected here through a refresh process. +# For the short term, the refresh process will only be runnable by Google engineers. +# +# The only allowed edits are to method and file documentation. A 3-way +# merge preserves those additions if the generated source changes. +"""Accesses the google.devtools.cloudtrace.v2 TraceService API.""" + +import pkg_resources + +import google.api_core.gapic_v1.client_info +import google.api_core.gapic_v1.config +import google.api_core.gapic_v1.method +import google.api_core.grpc_helpers +import google.api_core.path_template + +from google.cloud.trace_v2.gapic import enums +from google.cloud.trace_v2.gapic import trace_service_client_config +from google.cloud.trace_v2.proto import trace_pb2 +from google.cloud.trace_v2.proto import tracing_pb2 +from google.protobuf import timestamp_pb2 +from google.protobuf import wrappers_pb2 +from google.rpc import status_pb2 + +_GAPIC_LIBRARY_VERSION = pkg_resources.get_distribution( + 'google-cloud-trace', ).version + + +class TraceServiceClient(object): + """ + This file describes an API for collecting and viewing traces and spans + within a trace. A Trace is a collection of spans corresponding to a single + operation or set of operations for an application. A span is an individual + timed event which forms a node of the trace tree. A single trace may + contain span(s) from multiple services. + """ + + SERVICE_ADDRESS = 'cloudtrace.googleapis.com:443' + """The default address of the service.""" + + # The scopes needed to make gRPC calls to all of the methods defined in + # this service + _DEFAULT_SCOPES = ( + 'https://www.googleapis.com/auth/cloud-platform', + 'https://www.googleapis.com/auth/trace.append', ) + + # The name of the interface for this client. This is the key used to find + # method configuration in the client_config dictionary + _INTERFACE_NAME = ('google.devtools.cloudtrace.v2.TraceService') + + @classmethod + def project_path(cls, project): + """Returns a fully-qualified project resource name string.""" + return google.api_core.path_template.expand( + 'projects/{project}', + project=project, ) + + @classmethod + def span_path(cls, project, trace, span): + """Returns a fully-qualified span resource name string.""" + return google.api_core.path_template.expand( + 'projects/{project}/traces/{trace}/spans/{span}', + project=project, + trace=trace, + span=span, ) + + def __init__(self, + channel=None, + credentials=None, + client_config=trace_service_client_config.config, + client_info=None): + """Constructor. + + Args: + channel (grpc.Channel): A ``Channel`` instance through + which to make calls. If specified, then the ``credentials`` + argument is ignored. + credentials (google.auth.credentials.Credentials): The + authorization credentials to attach to requests. These + credentials identify this application to the service. If none + are specified, the client will attempt to ascertain the + credentials from the environment. + client_config (dict): + A dictionary of call options for each method. If not specified + the default configuration is used. Generally, you only need + to set this if you're developing your own client library. + client_info (google.api_core.gapic_v1.client_info.ClientInfo): + The client info used to send a user-agent string along with + API requests. If ``None``, then default info will be used. + Generally, you only need to set this if you're developing + your own client library. + """ + if channel is not None and credentials is not None: + raise ValueError( + 'channel and credentials arguments to {} are mutually ' + 'exclusive.'.format(self.__class__.__name__)) + + if channel is None: + channel = google.api_core.grpc_helpers.create_channel( + self.SERVICE_ADDRESS, + credentials=credentials, + scopes=self._DEFAULT_SCOPES) + + self.trace_service_stub = (tracing_pb2.TraceServiceStub(channel)) + + if client_info is None: + client_info = ( + google.api_core.gapic_v1.client_info.DEFAULT_CLIENT_INFO) + + client_info.gapic_version = _GAPIC_LIBRARY_VERSION + + interface_config = client_config['interfaces'][self._INTERFACE_NAME] + method_configs = google.api_core.gapic_v1.config.parse_method_configs( + interface_config) + + self._batch_write_spans = google.api_core.gapic_v1.method.wrap_method( + self.trace_service_stub.BatchWriteSpans, + default_retry=method_configs['BatchWriteSpans'].retry, + default_timeout=method_configs['BatchWriteSpans'].timeout, + client_info=client_info) + self._create_span = google.api_core.gapic_v1.method.wrap_method( + self.trace_service_stub.CreateSpan, + default_retry=method_configs['CreateSpan'].retry, + default_timeout=method_configs['CreateSpan'].timeout, + client_info=client_info) + + # Service calls + def batch_write_spans(self, + name, + spans, + retry=google.api_core.gapic_v1.method.DEFAULT, + timeout=google.api_core.gapic_v1.method.DEFAULT): + """ + Sends new spans to Stackdriver Trace or updates existing traces. If the + name of a trace that you send matches that of an existing trace, new spans + are added to the existing trace. Attempt to update existing spans results + undefined behavior. If the name does not match, a new trace is created + with given set of spans. + + Example: + >>> from google.cloud import trace_v2 + >>> + >>> client = trace_v2.TraceServiceClient() + >>> + >>> name = client.project_path('[PROJECT]') + >>> spans = [] + >>> + >>> client.batch_write_spans(name, spans) + + Args: + name (str): Required. Name of the project where the spans belong. The format is + ``projects/PROJECT_ID``. + spans (list[Union[dict, ~google.cloud.trace_v2.types.Span]]): A collection of spans. + If a dict is provided, it must be of the same form as the protobuf + message :class:`~google.cloud.trace_v2.types.Span` + retry (Optional[google.api_core.retry.Retry]): A retry object used + to retry requests. If ``None`` is specified, requests will not + be retried. + timeout (Optional[float]): The amount of time, in seconds, to wait + for the request to complete. Note that if ``retry`` is + specified, the timeout applies to each individual attempt. + + Raises: + google.api_core.exceptions.GoogleAPICallError: If the request + failed for any reason. + google.api_core.exceptions.RetryError: If the request failed due + to a retryable error and retry attempts failed. + ValueError: If the parameters are invalid. + """ + request = tracing_pb2.BatchWriteSpansRequest(name=name, spans=spans) + self._batch_write_spans(request, retry=retry, timeout=timeout) + + def create_span(self, + name, + span_id, + display_name, + start_time, + end_time, + parent_span_id=None, + attributes=None, + stack_trace=None, + time_events=None, + links=None, + status=None, + same_process_as_parent_span=None, + child_span_count=None, + retry=google.api_core.gapic_v1.method.DEFAULT, + timeout=google.api_core.gapic_v1.method.DEFAULT): + """ + Creates a new Span. + + Example: + >>> from google.cloud import trace_v2 + >>> + >>> client = trace_v2.TraceServiceClient() + >>> + >>> name = client.span_path('[PROJECT]', '[TRACE]', '[SPAN]') + >>> span_id = '' + >>> display_name = {} + >>> start_time = {} + >>> end_time = {} + >>> + >>> response = client.create_span(name, span_id, display_name, start_time, end_time) + + Args: + name (str): The resource name of the span in the following format: + + :: + + projects/[PROJECT_ID]/traces/[TRACE_ID]/spans/[SPAN_ID] + + [TRACE_ID] is a unique identifier for a trace within a project. + [SPAN_ID] is a unique identifier for a span within a trace, + assigned when the span is created. + span_id (str): The [SPAN_ID] portion of the span's resource name. + The ID is a 16-character hexadecimal encoding of an 8-byte array. + display_name (Union[dict, ~google.cloud.trace_v2.types.TruncatableString]): A description of the span's operation (up to 128 bytes). + Stackdriver Trace displays the description in the + {% dynamic print site_values.console_name %}. + For example, the display name can be a qualified method name or a file name + and a line number where the operation is called. A best practice is to use + the same display name within an application and at the same call point. + This makes it easier to correlate spans in different traces. + If a dict is provided, it must be of the same form as the protobuf + message :class:`~google.cloud.trace_v2.types.TruncatableString` + start_time (Union[dict, ~google.cloud.trace_v2.types.Timestamp]): The start time of the span. On the client side, this is the time kept by + the local machine where the span execution starts. On the server side, this + is the time when the server's application handler starts running. + If a dict is provided, it must be of the same form as the protobuf + message :class:`~google.cloud.trace_v2.types.Timestamp` + end_time (Union[dict, ~google.cloud.trace_v2.types.Timestamp]): The end time of the span. On the client side, this is the time kept by + the local machine where the span execution ends. On the server side, this + is the time when the server application handler stops running. + If a dict is provided, it must be of the same form as the protobuf + message :class:`~google.cloud.trace_v2.types.Timestamp` + parent_span_id (str): The [SPAN_ID] of this span's parent span. If this is a root span, + then this field must be empty. + attributes (Union[dict, ~google.cloud.trace_v2.types.Attributes]): A set of attributes on the span. There is a limit of 32 attributes per + span. + If a dict is provided, it must be of the same form as the protobuf + message :class:`~google.cloud.trace_v2.types.Attributes` + stack_trace (Union[dict, ~google.cloud.trace_v2.types.StackTrace]): Stack trace captured at the start of the span. + If a dict is provided, it must be of the same form as the protobuf + message :class:`~google.cloud.trace_v2.types.StackTrace` + time_events (Union[dict, ~google.cloud.trace_v2.types.TimeEvents]): The included time events. There can be up to 32 annotations and 128 message + events per span. + If a dict is provided, it must be of the same form as the protobuf + message :class:`~google.cloud.trace_v2.types.TimeEvents` + links (Union[dict, ~google.cloud.trace_v2.types.Links]): A maximum of 128 links are allowed per Span. + If a dict is provided, it must be of the same form as the protobuf + message :class:`~google.cloud.trace_v2.types.Links` + status (Union[dict, ~google.cloud.trace_v2.types.Status]): An optional final status for this span. + If a dict is provided, it must be of the same form as the protobuf + message :class:`~google.cloud.trace_v2.types.Status` + same_process_as_parent_span (Union[dict, ~google.cloud.trace_v2.types.BoolValue]): A highly recommended but not required flag that identifies when a trace + crosses a process boundary. True when the parent_span belongs to the + same process as the current span. + If a dict is provided, it must be of the same form as the protobuf + message :class:`~google.cloud.trace_v2.types.BoolValue` + child_span_count (Union[dict, ~google.cloud.trace_v2.types.Int32Value]): An optional number of child spans that were generated while this span + was active. If set, allows implementation to detect missing child spans. + If a dict is provided, it must be of the same form as the protobuf + message :class:`~google.cloud.trace_v2.types.Int32Value` + retry (Optional[google.api_core.retry.Retry]): A retry object used + to retry requests. If ``None`` is specified, requests will not + be retried. + timeout (Optional[float]): The amount of time, in seconds, to wait + for the request to complete. Note that if ``retry`` is + specified, the timeout applies to each individual attempt. + + Returns: + A :class:`~google.cloud.trace_v2.types.Span` instance. + + Raises: + google.api_core.exceptions.GoogleAPICallError: If the request + failed for any reason. + google.api_core.exceptions.RetryError: If the request failed due + to a retryable error and retry attempts failed. + ValueError: If the parameters are invalid. + """ + request = trace_pb2.Span( + name=name, + span_id=span_id, + display_name=display_name, + start_time=start_time, + end_time=end_time, + parent_span_id=parent_span_id, + attributes=attributes, + stack_trace=stack_trace, + time_events=time_events, + links=links, + status=status, + same_process_as_parent_span=same_process_as_parent_span, + child_span_count=child_span_count) + return self._create_span(request, retry=retry, timeout=timeout) diff --git a/trace/google/cloud/trace_v2/gapic/trace_service_client_config.py b/trace/google/cloud/trace_v2/gapic/trace_service_client_config.py new file mode 100644 index 000000000000..b9e875aed417 --- /dev/null +++ b/trace/google/cloud/trace_v2/gapic/trace_service_client_config.py @@ -0,0 +1,33 @@ +config = { + "interfaces": { + "google.devtools.cloudtrace.v2.TraceService": { + "retry_codes": { + "idempotent": ["DEADLINE_EXCEEDED", "UNAVAILABLE"], + "non_idempotent": [] + }, + "retry_params": { + "default": { + "initial_retry_delay_millis": 100, + "retry_delay_multiplier": 1.2, + "max_retry_delay_millis": 1000, + "initial_rpc_timeout_millis": 30000, + "rpc_timeout_multiplier": 1.5, + "max_rpc_timeout_millis": 60000, + "total_timeout_millis": 120000 + } + }, + "methods": { + "BatchWriteSpans": { + "timeout_millis": 30000, + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "CreateSpan": { + "timeout_millis": 30000, + "retry_codes_name": "idempotent", + "retry_params_name": "default" + } + } + } + } +} diff --git a/trace/google/cloud/trace_v2/proto/__init__.py b/trace/google/cloud/trace_v2/proto/__init__.py new file mode 100644 index 000000000000..e69de29bb2d1 diff --git a/trace/google/cloud/trace_v2/proto/trace_pb2.py b/trace/google/cloud/trace_v2/proto/trace_pb2.py new file mode 100644 index 000000000000..dd64c42d0d3d --- /dev/null +++ b/trace/google/cloud/trace_v2/proto/trace_pb2.py @@ -0,0 +1,1282 @@ +# -*- coding: utf-8 -*- +# Generated by the protocol buffer compiler. DO NOT EDIT! +# source: google/devtools/cloudtrace_v2/proto/trace.proto + +import sys +_b=sys.version_info[0]<3 and (lambda x:x) or (lambda x:x.encode('latin1')) +from google.protobuf import descriptor as _descriptor +from google.protobuf import message as _message +from google.protobuf import reflection as _reflection +from google.protobuf import symbol_database as _symbol_database +from google.protobuf import descriptor_pb2 +# @@protoc_insertion_point(imports) + +_sym_db = _symbol_database.Default() + + +from google.api import annotations_pb2 as google_dot_api_dot_annotations__pb2 +from google.protobuf import timestamp_pb2 as google_dot_protobuf_dot_timestamp__pb2 +from google.protobuf import wrappers_pb2 as google_dot_protobuf_dot_wrappers__pb2 +from google.rpc import status_pb2 as google_dot_rpc_dot_status__pb2 + + +DESCRIPTOR = _descriptor.FileDescriptor( + name='google/devtools/cloudtrace_v2/proto/trace.proto', + package='google.devtools.cloudtrace.v2', + syntax='proto3', + serialized_pb=_b('\n/google/devtools/cloudtrace_v2/proto/trace.proto\x12\x1dgoogle.devtools.cloudtrace.v2\x1a\x1cgoogle/api/annotations.proto\x1a\x1fgoogle/protobuf/timestamp.proto\x1a\x1egoogle/protobuf/wrappers.proto\x1a\x17google/rpc/status.proto\"\xc5\x0f\n\x04Span\x12\x0c\n\x04name\x18\x01 \x01(\t\x12\x0f\n\x07span_id\x18\x02 \x01(\t\x12\x16\n\x0eparent_span_id\x18\x03 \x01(\t\x12\x46\n\x0c\x64isplay_name\x18\x04 \x01(\x0b\x32\x30.google.devtools.cloudtrace.v2.TruncatableString\x12.\n\nstart_time\x18\x05 \x01(\x0b\x32\x1a.google.protobuf.Timestamp\x12,\n\x08\x65nd_time\x18\x06 \x01(\x0b\x32\x1a.google.protobuf.Timestamp\x12\x42\n\nattributes\x18\x07 \x01(\x0b\x32..google.devtools.cloudtrace.v2.Span.Attributes\x12>\n\x0bstack_trace\x18\x08 \x01(\x0b\x32).google.devtools.cloudtrace.v2.StackTrace\x12\x43\n\x0btime_events\x18\t \x01(\x0b\x32..google.devtools.cloudtrace.v2.Span.TimeEvents\x12\x38\n\x05links\x18\n \x01(\x0b\x32).google.devtools.cloudtrace.v2.Span.Links\x12\"\n\x06status\x18\x0b \x01(\x0b\x32\x12.google.rpc.Status\x12?\n\x1bsame_process_as_parent_span\x18\x0c \x01(\x0b\x32\x1a.google.protobuf.BoolValue\x12\x35\n\x10\x63hild_span_count\x18\r \x01(\x0b\x32\x1b.google.protobuf.Int32Value\x1a\xeb\x01\n\nAttributes\x12W\n\rattribute_map\x18\x01 \x03(\x0b\x32@.google.devtools.cloudtrace.v2.Span.Attributes.AttributeMapEntry\x12 \n\x18\x64ropped_attributes_count\x18\x02 \x01(\x05\x1a\x62\n\x11\x41ttributeMapEntry\x12\x0b\n\x03key\x18\x01 \x01(\t\x12<\n\x05value\x18\x02 \x01(\x0b\x32-.google.devtools.cloudtrace.v2.AttributeValue:\x02\x38\x01\x1a\xdf\x04\n\tTimeEvent\x12(\n\x04time\x18\x01 \x01(\x0b\x32\x1a.google.protobuf.Timestamp\x12N\n\nannotation\x18\x02 \x01(\x0b\x32\x38.google.devtools.cloudtrace.v2.Span.TimeEvent.AnnotationH\x00\x12S\n\rmessage_event\x18\x03 \x01(\x0b\x32:.google.devtools.cloudtrace.v2.Span.TimeEvent.MessageEventH\x00\x1a\x97\x01\n\nAnnotation\x12\x45\n\x0b\x64\x65scription\x18\x01 \x01(\x0b\x32\x30.google.devtools.cloudtrace.v2.TruncatableString\x12\x42\n\nattributes\x18\x02 \x01(\x0b\x32..google.devtools.cloudtrace.v2.Span.Attributes\x1a\xdf\x01\n\x0cMessageEvent\x12M\n\x04type\x18\x01 \x01(\x0e\x32?.google.devtools.cloudtrace.v2.Span.TimeEvent.MessageEvent.Type\x12\n\n\x02id\x18\x02 \x01(\x03\x12\x1f\n\x17uncompressed_size_bytes\x18\x03 \x01(\x03\x12\x1d\n\x15\x63ompressed_size_bytes\x18\x04 \x01(\x03\"4\n\x04Type\x12\x14\n\x10TYPE_UNSPECIFIED\x10\x00\x12\x08\n\x04SENT\x10\x01\x12\x0c\n\x08RECEIVED\x10\x02\x42\x07\n\x05value\x1a\x98\x01\n\nTimeEvents\x12\x41\n\ntime_event\x18\x01 \x03(\x0b\x32-.google.devtools.cloudtrace.v2.Span.TimeEvent\x12!\n\x19\x64ropped_annotations_count\x18\x02 \x01(\x05\x12$\n\x1c\x64ropped_message_events_count\x18\x03 \x01(\x05\x1a\xf7\x01\n\x04Link\x12\x10\n\x08trace_id\x18\x01 \x01(\t\x12\x0f\n\x07span_id\x18\x02 \x01(\t\x12;\n\x04type\x18\x03 \x01(\x0e\x32-.google.devtools.cloudtrace.v2.Span.Link.Type\x12\x42\n\nattributes\x18\x04 \x01(\x0b\x32..google.devtools.cloudtrace.v2.Span.Attributes\"K\n\x04Type\x12\x14\n\x10TYPE_UNSPECIFIED\x10\x00\x12\x15\n\x11\x43HILD_LINKED_SPAN\x10\x01\x12\x16\n\x12PARENT_LINKED_SPAN\x10\x02\x1a\\\n\x05Links\x12\x36\n\x04link\x18\x01 \x03(\x0b\x32(.google.devtools.cloudtrace.v2.Span.Link\x12\x1b\n\x13\x64ropped_links_count\x18\x02 \x01(\x05\"\x8e\x01\n\x0e\x41ttributeValue\x12H\n\x0cstring_value\x18\x01 \x01(\x0b\x32\x30.google.devtools.cloudtrace.v2.TruncatableStringH\x00\x12\x13\n\tint_value\x18\x02 \x01(\x03H\x00\x12\x14\n\nbool_value\x18\x03 \x01(\x08H\x00\x42\x07\n\x05value\"\x89\x05\n\nStackTrace\x12K\n\x0cstack_frames\x18\x01 \x01(\x0b\x32\x35.google.devtools.cloudtrace.v2.StackTrace.StackFrames\x12\x1b\n\x13stack_trace_hash_id\x18\x02 \x01(\x03\x1a\x9e\x03\n\nStackFrame\x12G\n\rfunction_name\x18\x01 \x01(\x0b\x32\x30.google.devtools.cloudtrace.v2.TruncatableString\x12P\n\x16original_function_name\x18\x02 \x01(\x0b\x32\x30.google.devtools.cloudtrace.v2.TruncatableString\x12\x43\n\tfile_name\x18\x03 \x01(\x0b\x32\x30.google.devtools.cloudtrace.v2.TruncatableString\x12\x13\n\x0bline_number\x18\x04 \x01(\x03\x12\x15\n\rcolumn_number\x18\x05 \x01(\x03\x12:\n\x0bload_module\x18\x06 \x01(\x0b\x32%.google.devtools.cloudtrace.v2.Module\x12H\n\x0esource_version\x18\x07 \x01(\x0b\x32\x30.google.devtools.cloudtrace.v2.TruncatableString\x1ap\n\x0bStackFrames\x12\x43\n\x05\x66rame\x18\x01 \x03(\x0b\x32\x34.google.devtools.cloudtrace.v2.StackTrace.StackFrame\x12\x1c\n\x14\x64ropped_frames_count\x18\x02 \x01(\x05\"\x8e\x01\n\x06Module\x12@\n\x06module\x18\x01 \x01(\x0b\x32\x30.google.devtools.cloudtrace.v2.TruncatableString\x12\x42\n\x08\x62uild_id\x18\x02 \x01(\x0b\x32\x30.google.devtools.cloudtrace.v2.TruncatableString\"@\n\x11TruncatableString\x12\r\n\x05value\x18\x01 \x01(\t\x12\x1c\n\x14truncated_byte_count\x18\x02 \x01(\x05\x42\x92\x01\n!com.google.devtools.cloudtrace.v2B\nTraceProtoP\x01ZGgoogle.golang.org/genproto/googleapis/devtools/cloudtrace/v2;cloudtrace\xaa\x02\x15Google.Cloud.Trace.V2b\x06proto3') + , + dependencies=[google_dot_api_dot_annotations__pb2.DESCRIPTOR,google_dot_protobuf_dot_timestamp__pb2.DESCRIPTOR,google_dot_protobuf_dot_wrappers__pb2.DESCRIPTOR,google_dot_rpc_dot_status__pb2.DESCRIPTOR,]) + + + +_SPAN_TIMEEVENT_MESSAGEEVENT_TYPE = _descriptor.EnumDescriptor( + name='Type', + full_name='google.devtools.cloudtrace.v2.Span.TimeEvent.MessageEvent.Type', + filename=None, + file=DESCRIPTOR, + values=[ + _descriptor.EnumValueDescriptor( + name='TYPE_UNSPECIFIED', index=0, number=0, + options=None, + type=None), + _descriptor.EnumValueDescriptor( + name='SENT', index=1, number=1, + options=None, + type=None), + _descriptor.EnumValueDescriptor( + name='RECEIVED', index=2, number=2, + options=None, + type=None), + ], + containing_type=None, + options=None, + serialized_start=1632, + serialized_end=1684, +) +_sym_db.RegisterEnumDescriptor(_SPAN_TIMEEVENT_MESSAGEEVENT_TYPE) + +_SPAN_LINK_TYPE = _descriptor.EnumDescriptor( + name='Type', + full_name='google.devtools.cloudtrace.v2.Span.Link.Type', + filename=None, + file=DESCRIPTOR, + values=[ + _descriptor.EnumValueDescriptor( + name='TYPE_UNSPECIFIED', index=0, number=0, + options=None, + type=None), + _descriptor.EnumValueDescriptor( + name='CHILD_LINKED_SPAN', index=1, number=1, + options=None, + type=None), + _descriptor.EnumValueDescriptor( + name='PARENT_LINKED_SPAN', index=2, number=2, + options=None, + type=None), + ], + containing_type=None, + options=None, + serialized_start=2023, + serialized_end=2098, +) +_sym_db.RegisterEnumDescriptor(_SPAN_LINK_TYPE) + + +_SPAN_ATTRIBUTES_ATTRIBUTEMAPENTRY = _descriptor.Descriptor( + name='AttributeMapEntry', + full_name='google.devtools.cloudtrace.v2.Span.Attributes.AttributeMapEntry', + filename=None, + file=DESCRIPTOR, + containing_type=None, + fields=[ + _descriptor.FieldDescriptor( + name='key', full_name='google.devtools.cloudtrace.v2.Span.Attributes.AttributeMapEntry.key', index=0, + number=1, type=9, cpp_type=9, label=1, + has_default_value=False, default_value=_b("").decode('utf-8'), + message_type=None, enum_type=None, containing_type=None, + is_extension=False, extension_scope=None, + options=None), + _descriptor.FieldDescriptor( + name='value', full_name='google.devtools.cloudtrace.v2.Span.Attributes.AttributeMapEntry.value', index=1, + number=2, type=11, cpp_type=10, label=1, + has_default_value=False, default_value=None, + message_type=None, enum_type=None, containing_type=None, + is_extension=False, extension_scope=None, + options=None), + ], + extensions=[ + ], + nested_types=[], + enum_types=[ + ], + options=_descriptor._ParseOptions(descriptor_pb2.MessageOptions(), _b('8\001')), + is_extendable=False, + syntax='proto3', + extension_ranges=[], + oneofs=[ + ], + serialized_start=985, + serialized_end=1083, +) + +_SPAN_ATTRIBUTES = _descriptor.Descriptor( + name='Attributes', + full_name='google.devtools.cloudtrace.v2.Span.Attributes', + filename=None, + file=DESCRIPTOR, + containing_type=None, + fields=[ + _descriptor.FieldDescriptor( + name='attribute_map', full_name='google.devtools.cloudtrace.v2.Span.Attributes.attribute_map', index=0, + number=1, type=11, cpp_type=10, label=3, + has_default_value=False, default_value=[], + message_type=None, enum_type=None, containing_type=None, + is_extension=False, extension_scope=None, + options=None), + _descriptor.FieldDescriptor( + name='dropped_attributes_count', full_name='google.devtools.cloudtrace.v2.Span.Attributes.dropped_attributes_count', index=1, + number=2, type=5, cpp_type=1, label=1, + has_default_value=False, default_value=0, + message_type=None, enum_type=None, containing_type=None, + is_extension=False, extension_scope=None, + options=None), + ], + extensions=[ + ], + nested_types=[_SPAN_ATTRIBUTES_ATTRIBUTEMAPENTRY, ], + enum_types=[ + ], + options=None, + is_extendable=False, + syntax='proto3', + extension_ranges=[], + oneofs=[ + ], + serialized_start=848, + serialized_end=1083, +) + +_SPAN_TIMEEVENT_ANNOTATION = _descriptor.Descriptor( + name='Annotation', + full_name='google.devtools.cloudtrace.v2.Span.TimeEvent.Annotation', + filename=None, + file=DESCRIPTOR, + containing_type=None, + fields=[ + _descriptor.FieldDescriptor( + name='description', full_name='google.devtools.cloudtrace.v2.Span.TimeEvent.Annotation.description', index=0, + number=1, type=11, cpp_type=10, label=1, + has_default_value=False, default_value=None, + message_type=None, enum_type=None, containing_type=None, + is_extension=False, extension_scope=None, + options=None), + _descriptor.FieldDescriptor( + name='attributes', full_name='google.devtools.cloudtrace.v2.Span.TimeEvent.Annotation.attributes', index=1, + number=2, type=11, cpp_type=10, label=1, + has_default_value=False, default_value=None, + message_type=None, enum_type=None, containing_type=None, + is_extension=False, extension_scope=None, + options=None), + ], + extensions=[ + ], + nested_types=[], + enum_types=[ + ], + options=None, + is_extendable=False, + syntax='proto3', + extension_ranges=[], + oneofs=[ + ], + serialized_start=1307, + serialized_end=1458, +) + +_SPAN_TIMEEVENT_MESSAGEEVENT = _descriptor.Descriptor( + name='MessageEvent', + full_name='google.devtools.cloudtrace.v2.Span.TimeEvent.MessageEvent', + filename=None, + file=DESCRIPTOR, + containing_type=None, + fields=[ + _descriptor.FieldDescriptor( + name='type', full_name='google.devtools.cloudtrace.v2.Span.TimeEvent.MessageEvent.type', index=0, + number=1, type=14, cpp_type=8, label=1, + has_default_value=False, default_value=0, + message_type=None, enum_type=None, containing_type=None, + is_extension=False, extension_scope=None, + options=None), + _descriptor.FieldDescriptor( + name='id', full_name='google.devtools.cloudtrace.v2.Span.TimeEvent.MessageEvent.id', index=1, + number=2, type=3, cpp_type=2, label=1, + has_default_value=False, default_value=0, + message_type=None, enum_type=None, containing_type=None, + is_extension=False, extension_scope=None, + options=None), + _descriptor.FieldDescriptor( + name='uncompressed_size_bytes', full_name='google.devtools.cloudtrace.v2.Span.TimeEvent.MessageEvent.uncompressed_size_bytes', index=2, + number=3, type=3, cpp_type=2, label=1, + has_default_value=False, default_value=0, + message_type=None, enum_type=None, containing_type=None, + is_extension=False, extension_scope=None, + options=None), + _descriptor.FieldDescriptor( + name='compressed_size_bytes', full_name='google.devtools.cloudtrace.v2.Span.TimeEvent.MessageEvent.compressed_size_bytes', index=3, + number=4, type=3, cpp_type=2, label=1, + has_default_value=False, default_value=0, + message_type=None, enum_type=None, containing_type=None, + is_extension=False, extension_scope=None, + options=None), + ], + extensions=[ + ], + nested_types=[], + enum_types=[ + _SPAN_TIMEEVENT_MESSAGEEVENT_TYPE, + ], + options=None, + is_extendable=False, + syntax='proto3', + extension_ranges=[], + oneofs=[ + ], + serialized_start=1461, + serialized_end=1684, +) + +_SPAN_TIMEEVENT = _descriptor.Descriptor( + name='TimeEvent', + full_name='google.devtools.cloudtrace.v2.Span.TimeEvent', + filename=None, + file=DESCRIPTOR, + containing_type=None, + fields=[ + _descriptor.FieldDescriptor( + name='time', full_name='google.devtools.cloudtrace.v2.Span.TimeEvent.time', index=0, + number=1, type=11, cpp_type=10, label=1, + has_default_value=False, default_value=None, + message_type=None, enum_type=None, containing_type=None, + is_extension=False, extension_scope=None, + options=None), + _descriptor.FieldDescriptor( + name='annotation', full_name='google.devtools.cloudtrace.v2.Span.TimeEvent.annotation', index=1, + number=2, type=11, cpp_type=10, label=1, + has_default_value=False, default_value=None, + message_type=None, enum_type=None, containing_type=None, + is_extension=False, extension_scope=None, + options=None), + _descriptor.FieldDescriptor( + name='message_event', full_name='google.devtools.cloudtrace.v2.Span.TimeEvent.message_event', index=2, + number=3, type=11, cpp_type=10, label=1, + has_default_value=False, default_value=None, + message_type=None, enum_type=None, containing_type=None, + is_extension=False, extension_scope=None, + options=None), + ], + extensions=[ + ], + nested_types=[_SPAN_TIMEEVENT_ANNOTATION, _SPAN_TIMEEVENT_MESSAGEEVENT, ], + enum_types=[ + ], + options=None, + is_extendable=False, + syntax='proto3', + extension_ranges=[], + oneofs=[ + _descriptor.OneofDescriptor( + name='value', full_name='google.devtools.cloudtrace.v2.Span.TimeEvent.value', + index=0, containing_type=None, fields=[]), + ], + serialized_start=1086, + serialized_end=1693, +) + +_SPAN_TIMEEVENTS = _descriptor.Descriptor( + name='TimeEvents', + full_name='google.devtools.cloudtrace.v2.Span.TimeEvents', + filename=None, + file=DESCRIPTOR, + containing_type=None, + fields=[ + _descriptor.FieldDescriptor( + name='time_event', full_name='google.devtools.cloudtrace.v2.Span.TimeEvents.time_event', index=0, + number=1, type=11, cpp_type=10, label=3, + has_default_value=False, default_value=[], + message_type=None, enum_type=None, containing_type=None, + is_extension=False, extension_scope=None, + options=None), + _descriptor.FieldDescriptor( + name='dropped_annotations_count', full_name='google.devtools.cloudtrace.v2.Span.TimeEvents.dropped_annotations_count', index=1, + number=2, type=5, cpp_type=1, label=1, + has_default_value=False, default_value=0, + message_type=None, enum_type=None, containing_type=None, + is_extension=False, extension_scope=None, + options=None), + _descriptor.FieldDescriptor( + name='dropped_message_events_count', full_name='google.devtools.cloudtrace.v2.Span.TimeEvents.dropped_message_events_count', index=2, + number=3, type=5, cpp_type=1, label=1, + has_default_value=False, default_value=0, + message_type=None, enum_type=None, containing_type=None, + is_extension=False, extension_scope=None, + options=None), + ], + extensions=[ + ], + nested_types=[], + enum_types=[ + ], + options=None, + is_extendable=False, + syntax='proto3', + extension_ranges=[], + oneofs=[ + ], + serialized_start=1696, + serialized_end=1848, +) + +_SPAN_LINK = _descriptor.Descriptor( + name='Link', + full_name='google.devtools.cloudtrace.v2.Span.Link', + filename=None, + file=DESCRIPTOR, + containing_type=None, + fields=[ + _descriptor.FieldDescriptor( + name='trace_id', full_name='google.devtools.cloudtrace.v2.Span.Link.trace_id', index=0, + number=1, type=9, cpp_type=9, label=1, + has_default_value=False, default_value=_b("").decode('utf-8'), + message_type=None, enum_type=None, containing_type=None, + is_extension=False, extension_scope=None, + options=None), + _descriptor.FieldDescriptor( + name='span_id', full_name='google.devtools.cloudtrace.v2.Span.Link.span_id', index=1, + number=2, type=9, cpp_type=9, label=1, + has_default_value=False, default_value=_b("").decode('utf-8'), + message_type=None, enum_type=None, containing_type=None, + is_extension=False, extension_scope=None, + options=None), + _descriptor.FieldDescriptor( + name='type', full_name='google.devtools.cloudtrace.v2.Span.Link.type', index=2, + number=3, type=14, cpp_type=8, label=1, + has_default_value=False, default_value=0, + message_type=None, enum_type=None, containing_type=None, + is_extension=False, extension_scope=None, + options=None), + _descriptor.FieldDescriptor( + name='attributes', full_name='google.devtools.cloudtrace.v2.Span.Link.attributes', index=3, + number=4, type=11, cpp_type=10, label=1, + has_default_value=False, default_value=None, + message_type=None, enum_type=None, containing_type=None, + is_extension=False, extension_scope=None, + options=None), + ], + extensions=[ + ], + nested_types=[], + enum_types=[ + _SPAN_LINK_TYPE, + ], + options=None, + is_extendable=False, + syntax='proto3', + extension_ranges=[], + oneofs=[ + ], + serialized_start=1851, + serialized_end=2098, +) + +_SPAN_LINKS = _descriptor.Descriptor( + name='Links', + full_name='google.devtools.cloudtrace.v2.Span.Links', + filename=None, + file=DESCRIPTOR, + containing_type=None, + fields=[ + _descriptor.FieldDescriptor( + name='link', full_name='google.devtools.cloudtrace.v2.Span.Links.link', index=0, + number=1, type=11, cpp_type=10, label=3, + has_default_value=False, default_value=[], + message_type=None, enum_type=None, containing_type=None, + is_extension=False, extension_scope=None, + options=None), + _descriptor.FieldDescriptor( + name='dropped_links_count', full_name='google.devtools.cloudtrace.v2.Span.Links.dropped_links_count', index=1, + number=2, type=5, cpp_type=1, label=1, + has_default_value=False, default_value=0, + message_type=None, enum_type=None, containing_type=None, + is_extension=False, extension_scope=None, + options=None), + ], + extensions=[ + ], + nested_types=[], + enum_types=[ + ], + options=None, + is_extendable=False, + syntax='proto3', + extension_ranges=[], + oneofs=[ + ], + serialized_start=2100, + serialized_end=2192, +) + +_SPAN = _descriptor.Descriptor( + name='Span', + full_name='google.devtools.cloudtrace.v2.Span', + filename=None, + file=DESCRIPTOR, + containing_type=None, + fields=[ + _descriptor.FieldDescriptor( + name='name', full_name='google.devtools.cloudtrace.v2.Span.name', index=0, + number=1, type=9, cpp_type=9, label=1, + has_default_value=False, default_value=_b("").decode('utf-8'), + message_type=None, enum_type=None, containing_type=None, + is_extension=False, extension_scope=None, + options=None), + _descriptor.FieldDescriptor( + name='span_id', full_name='google.devtools.cloudtrace.v2.Span.span_id', index=1, + number=2, type=9, cpp_type=9, label=1, + has_default_value=False, default_value=_b("").decode('utf-8'), + message_type=None, enum_type=None, containing_type=None, + is_extension=False, extension_scope=None, + options=None), + _descriptor.FieldDescriptor( + name='parent_span_id', full_name='google.devtools.cloudtrace.v2.Span.parent_span_id', index=2, + number=3, type=9, cpp_type=9, label=1, + has_default_value=False, default_value=_b("").decode('utf-8'), + message_type=None, enum_type=None, containing_type=None, + is_extension=False, extension_scope=None, + options=None), + _descriptor.FieldDescriptor( + name='display_name', full_name='google.devtools.cloudtrace.v2.Span.display_name', index=3, + number=4, type=11, cpp_type=10, label=1, + has_default_value=False, default_value=None, + message_type=None, enum_type=None, containing_type=None, + is_extension=False, extension_scope=None, + options=None), + _descriptor.FieldDescriptor( + name='start_time', full_name='google.devtools.cloudtrace.v2.Span.start_time', index=4, + number=5, type=11, cpp_type=10, label=1, + has_default_value=False, default_value=None, + message_type=None, enum_type=None, containing_type=None, + is_extension=False, extension_scope=None, + options=None), + _descriptor.FieldDescriptor( + name='end_time', full_name='google.devtools.cloudtrace.v2.Span.end_time', index=5, + number=6, type=11, cpp_type=10, label=1, + has_default_value=False, default_value=None, + message_type=None, enum_type=None, containing_type=None, + is_extension=False, extension_scope=None, + options=None), + _descriptor.FieldDescriptor( + name='attributes', full_name='google.devtools.cloudtrace.v2.Span.attributes', index=6, + number=7, type=11, cpp_type=10, label=1, + has_default_value=False, default_value=None, + message_type=None, enum_type=None, containing_type=None, + is_extension=False, extension_scope=None, + options=None), + _descriptor.FieldDescriptor( + name='stack_trace', full_name='google.devtools.cloudtrace.v2.Span.stack_trace', index=7, + number=8, type=11, cpp_type=10, label=1, + has_default_value=False, default_value=None, + message_type=None, enum_type=None, containing_type=None, + is_extension=False, extension_scope=None, + options=None), + _descriptor.FieldDescriptor( + name='time_events', full_name='google.devtools.cloudtrace.v2.Span.time_events', index=8, + number=9, type=11, cpp_type=10, label=1, + has_default_value=False, default_value=None, + message_type=None, enum_type=None, containing_type=None, + is_extension=False, extension_scope=None, + options=None), + _descriptor.FieldDescriptor( + name='links', full_name='google.devtools.cloudtrace.v2.Span.links', index=9, + number=10, type=11, cpp_type=10, label=1, + has_default_value=False, default_value=None, + message_type=None, enum_type=None, containing_type=None, + is_extension=False, extension_scope=None, + options=None), + _descriptor.FieldDescriptor( + name='status', full_name='google.devtools.cloudtrace.v2.Span.status', index=10, + number=11, type=11, cpp_type=10, label=1, + has_default_value=False, default_value=None, + message_type=None, enum_type=None, containing_type=None, + is_extension=False, extension_scope=None, + options=None), + _descriptor.FieldDescriptor( + name='same_process_as_parent_span', full_name='google.devtools.cloudtrace.v2.Span.same_process_as_parent_span', index=11, + number=12, type=11, cpp_type=10, label=1, + has_default_value=False, default_value=None, + message_type=None, enum_type=None, containing_type=None, + is_extension=False, extension_scope=None, + options=None), + _descriptor.FieldDescriptor( + name='child_span_count', full_name='google.devtools.cloudtrace.v2.Span.child_span_count', index=12, + number=13, type=11, cpp_type=10, label=1, + has_default_value=False, default_value=None, + message_type=None, enum_type=None, containing_type=None, + is_extension=False, extension_scope=None, + options=None), + ], + extensions=[ + ], + nested_types=[_SPAN_ATTRIBUTES, _SPAN_TIMEEVENT, _SPAN_TIMEEVENTS, _SPAN_LINK, _SPAN_LINKS, ], + enum_types=[ + ], + options=None, + is_extendable=False, + syntax='proto3', + extension_ranges=[], + oneofs=[ + ], + serialized_start=203, + serialized_end=2192, +) + + +_ATTRIBUTEVALUE = _descriptor.Descriptor( + name='AttributeValue', + full_name='google.devtools.cloudtrace.v2.AttributeValue', + filename=None, + file=DESCRIPTOR, + containing_type=None, + fields=[ + _descriptor.FieldDescriptor( + name='string_value', full_name='google.devtools.cloudtrace.v2.AttributeValue.string_value', index=0, + number=1, type=11, cpp_type=10, label=1, + has_default_value=False, default_value=None, + message_type=None, enum_type=None, containing_type=None, + is_extension=False, extension_scope=None, + options=None), + _descriptor.FieldDescriptor( + name='int_value', full_name='google.devtools.cloudtrace.v2.AttributeValue.int_value', index=1, + number=2, type=3, cpp_type=2, label=1, + has_default_value=False, default_value=0, + message_type=None, enum_type=None, containing_type=None, + is_extension=False, extension_scope=None, + options=None), + _descriptor.FieldDescriptor( + name='bool_value', full_name='google.devtools.cloudtrace.v2.AttributeValue.bool_value', index=2, + number=3, type=8, cpp_type=7, label=1, + has_default_value=False, default_value=False, + message_type=None, enum_type=None, containing_type=None, + is_extension=False, extension_scope=None, + options=None), + ], + extensions=[ + ], + nested_types=[], + enum_types=[ + ], + options=None, + is_extendable=False, + syntax='proto3', + extension_ranges=[], + oneofs=[ + _descriptor.OneofDescriptor( + name='value', full_name='google.devtools.cloudtrace.v2.AttributeValue.value', + index=0, containing_type=None, fields=[]), + ], + serialized_start=2195, + serialized_end=2337, +) + + +_STACKTRACE_STACKFRAME = _descriptor.Descriptor( + name='StackFrame', + full_name='google.devtools.cloudtrace.v2.StackTrace.StackFrame', + filename=None, + file=DESCRIPTOR, + containing_type=None, + fields=[ + _descriptor.FieldDescriptor( + name='function_name', full_name='google.devtools.cloudtrace.v2.StackTrace.StackFrame.function_name', index=0, + number=1, type=11, cpp_type=10, label=1, + has_default_value=False, default_value=None, + message_type=None, enum_type=None, containing_type=None, + is_extension=False, extension_scope=None, + options=None), + _descriptor.FieldDescriptor( + name='original_function_name', full_name='google.devtools.cloudtrace.v2.StackTrace.StackFrame.original_function_name', index=1, + number=2, type=11, cpp_type=10, label=1, + has_default_value=False, default_value=None, + message_type=None, enum_type=None, containing_type=None, + is_extension=False, extension_scope=None, + options=None), + _descriptor.FieldDescriptor( + name='file_name', full_name='google.devtools.cloudtrace.v2.StackTrace.StackFrame.file_name', index=2, + number=3, type=11, cpp_type=10, label=1, + has_default_value=False, default_value=None, + message_type=None, enum_type=None, containing_type=None, + is_extension=False, extension_scope=None, + options=None), + _descriptor.FieldDescriptor( + name='line_number', full_name='google.devtools.cloudtrace.v2.StackTrace.StackFrame.line_number', index=3, + number=4, type=3, cpp_type=2, label=1, + has_default_value=False, default_value=0, + message_type=None, enum_type=None, containing_type=None, + is_extension=False, extension_scope=None, + options=None), + _descriptor.FieldDescriptor( + name='column_number', full_name='google.devtools.cloudtrace.v2.StackTrace.StackFrame.column_number', index=4, + number=5, type=3, cpp_type=2, label=1, + has_default_value=False, default_value=0, + message_type=None, enum_type=None, containing_type=None, + is_extension=False, extension_scope=None, + options=None), + _descriptor.FieldDescriptor( + name='load_module', full_name='google.devtools.cloudtrace.v2.StackTrace.StackFrame.load_module', index=5, + number=6, type=11, cpp_type=10, label=1, + has_default_value=False, default_value=None, + message_type=None, enum_type=None, containing_type=None, + is_extension=False, extension_scope=None, + options=None), + _descriptor.FieldDescriptor( + name='source_version', full_name='google.devtools.cloudtrace.v2.StackTrace.StackFrame.source_version', index=6, + number=7, type=11, cpp_type=10, label=1, + has_default_value=False, default_value=None, + message_type=None, enum_type=None, containing_type=None, + is_extension=False, extension_scope=None, + options=None), + ], + extensions=[ + ], + nested_types=[], + enum_types=[ + ], + options=None, + is_extendable=False, + syntax='proto3', + extension_ranges=[], + oneofs=[ + ], + serialized_start=2461, + serialized_end=2875, +) + +_STACKTRACE_STACKFRAMES = _descriptor.Descriptor( + name='StackFrames', + full_name='google.devtools.cloudtrace.v2.StackTrace.StackFrames', + filename=None, + file=DESCRIPTOR, + containing_type=None, + fields=[ + _descriptor.FieldDescriptor( + name='frame', full_name='google.devtools.cloudtrace.v2.StackTrace.StackFrames.frame', index=0, + number=1, type=11, cpp_type=10, label=3, + has_default_value=False, default_value=[], + message_type=None, enum_type=None, containing_type=None, + is_extension=False, extension_scope=None, + options=None), + _descriptor.FieldDescriptor( + name='dropped_frames_count', full_name='google.devtools.cloudtrace.v2.StackTrace.StackFrames.dropped_frames_count', index=1, + number=2, type=5, cpp_type=1, label=1, + has_default_value=False, default_value=0, + message_type=None, enum_type=None, containing_type=None, + is_extension=False, extension_scope=None, + options=None), + ], + extensions=[ + ], + nested_types=[], + enum_types=[ + ], + options=None, + is_extendable=False, + syntax='proto3', + extension_ranges=[], + oneofs=[ + ], + serialized_start=2877, + serialized_end=2989, +) + +_STACKTRACE = _descriptor.Descriptor( + name='StackTrace', + full_name='google.devtools.cloudtrace.v2.StackTrace', + filename=None, + file=DESCRIPTOR, + containing_type=None, + fields=[ + _descriptor.FieldDescriptor( + name='stack_frames', full_name='google.devtools.cloudtrace.v2.StackTrace.stack_frames', index=0, + number=1, type=11, cpp_type=10, label=1, + has_default_value=False, default_value=None, + message_type=None, enum_type=None, containing_type=None, + is_extension=False, extension_scope=None, + options=None), + _descriptor.FieldDescriptor( + name='stack_trace_hash_id', full_name='google.devtools.cloudtrace.v2.StackTrace.stack_trace_hash_id', index=1, + number=2, type=3, cpp_type=2, label=1, + has_default_value=False, default_value=0, + message_type=None, enum_type=None, containing_type=None, + is_extension=False, extension_scope=None, + options=None), + ], + extensions=[ + ], + nested_types=[_STACKTRACE_STACKFRAME, _STACKTRACE_STACKFRAMES, ], + enum_types=[ + ], + options=None, + is_extendable=False, + syntax='proto3', + extension_ranges=[], + oneofs=[ + ], + serialized_start=2340, + serialized_end=2989, +) + + +_MODULE = _descriptor.Descriptor( + name='Module', + full_name='google.devtools.cloudtrace.v2.Module', + filename=None, + file=DESCRIPTOR, + containing_type=None, + fields=[ + _descriptor.FieldDescriptor( + name='module', full_name='google.devtools.cloudtrace.v2.Module.module', index=0, + number=1, type=11, cpp_type=10, label=1, + has_default_value=False, default_value=None, + message_type=None, enum_type=None, containing_type=None, + is_extension=False, extension_scope=None, + options=None), + _descriptor.FieldDescriptor( + name='build_id', full_name='google.devtools.cloudtrace.v2.Module.build_id', index=1, + number=2, type=11, cpp_type=10, label=1, + has_default_value=False, default_value=None, + message_type=None, enum_type=None, containing_type=None, + is_extension=False, extension_scope=None, + options=None), + ], + extensions=[ + ], + nested_types=[], + enum_types=[ + ], + options=None, + is_extendable=False, + syntax='proto3', + extension_ranges=[], + oneofs=[ + ], + serialized_start=2992, + serialized_end=3134, +) + + +_TRUNCATABLESTRING = _descriptor.Descriptor( + name='TruncatableString', + full_name='google.devtools.cloudtrace.v2.TruncatableString', + filename=None, + file=DESCRIPTOR, + containing_type=None, + fields=[ + _descriptor.FieldDescriptor( + name='value', full_name='google.devtools.cloudtrace.v2.TruncatableString.value', index=0, + number=1, type=9, cpp_type=9, label=1, + has_default_value=False, default_value=_b("").decode('utf-8'), + message_type=None, enum_type=None, containing_type=None, + is_extension=False, extension_scope=None, + options=None), + _descriptor.FieldDescriptor( + name='truncated_byte_count', full_name='google.devtools.cloudtrace.v2.TruncatableString.truncated_byte_count', index=1, + number=2, type=5, cpp_type=1, label=1, + has_default_value=False, default_value=0, + message_type=None, enum_type=None, containing_type=None, + is_extension=False, extension_scope=None, + options=None), + ], + extensions=[ + ], + nested_types=[], + enum_types=[ + ], + options=None, + is_extendable=False, + syntax='proto3', + extension_ranges=[], + oneofs=[ + ], + serialized_start=3136, + serialized_end=3200, +) + +_SPAN_ATTRIBUTES_ATTRIBUTEMAPENTRY.fields_by_name['value'].message_type = _ATTRIBUTEVALUE +_SPAN_ATTRIBUTES_ATTRIBUTEMAPENTRY.containing_type = _SPAN_ATTRIBUTES +_SPAN_ATTRIBUTES.fields_by_name['attribute_map'].message_type = _SPAN_ATTRIBUTES_ATTRIBUTEMAPENTRY +_SPAN_ATTRIBUTES.containing_type = _SPAN +_SPAN_TIMEEVENT_ANNOTATION.fields_by_name['description'].message_type = _TRUNCATABLESTRING +_SPAN_TIMEEVENT_ANNOTATION.fields_by_name['attributes'].message_type = _SPAN_ATTRIBUTES +_SPAN_TIMEEVENT_ANNOTATION.containing_type = _SPAN_TIMEEVENT +_SPAN_TIMEEVENT_MESSAGEEVENT.fields_by_name['type'].enum_type = _SPAN_TIMEEVENT_MESSAGEEVENT_TYPE +_SPAN_TIMEEVENT_MESSAGEEVENT.containing_type = _SPAN_TIMEEVENT +_SPAN_TIMEEVENT_MESSAGEEVENT_TYPE.containing_type = _SPAN_TIMEEVENT_MESSAGEEVENT +_SPAN_TIMEEVENT.fields_by_name['time'].message_type = google_dot_protobuf_dot_timestamp__pb2._TIMESTAMP +_SPAN_TIMEEVENT.fields_by_name['annotation'].message_type = _SPAN_TIMEEVENT_ANNOTATION +_SPAN_TIMEEVENT.fields_by_name['message_event'].message_type = _SPAN_TIMEEVENT_MESSAGEEVENT +_SPAN_TIMEEVENT.containing_type = _SPAN +_SPAN_TIMEEVENT.oneofs_by_name['value'].fields.append( + _SPAN_TIMEEVENT.fields_by_name['annotation']) +_SPAN_TIMEEVENT.fields_by_name['annotation'].containing_oneof = _SPAN_TIMEEVENT.oneofs_by_name['value'] +_SPAN_TIMEEVENT.oneofs_by_name['value'].fields.append( + _SPAN_TIMEEVENT.fields_by_name['message_event']) +_SPAN_TIMEEVENT.fields_by_name['message_event'].containing_oneof = _SPAN_TIMEEVENT.oneofs_by_name['value'] +_SPAN_TIMEEVENTS.fields_by_name['time_event'].message_type = _SPAN_TIMEEVENT +_SPAN_TIMEEVENTS.containing_type = _SPAN +_SPAN_LINK.fields_by_name['type'].enum_type = _SPAN_LINK_TYPE +_SPAN_LINK.fields_by_name['attributes'].message_type = _SPAN_ATTRIBUTES +_SPAN_LINK.containing_type = _SPAN +_SPAN_LINK_TYPE.containing_type = _SPAN_LINK +_SPAN_LINKS.fields_by_name['link'].message_type = _SPAN_LINK +_SPAN_LINKS.containing_type = _SPAN +_SPAN.fields_by_name['display_name'].message_type = _TRUNCATABLESTRING +_SPAN.fields_by_name['start_time'].message_type = google_dot_protobuf_dot_timestamp__pb2._TIMESTAMP +_SPAN.fields_by_name['end_time'].message_type = google_dot_protobuf_dot_timestamp__pb2._TIMESTAMP +_SPAN.fields_by_name['attributes'].message_type = _SPAN_ATTRIBUTES +_SPAN.fields_by_name['stack_trace'].message_type = _STACKTRACE +_SPAN.fields_by_name['time_events'].message_type = _SPAN_TIMEEVENTS +_SPAN.fields_by_name['links'].message_type = _SPAN_LINKS +_SPAN.fields_by_name['status'].message_type = google_dot_rpc_dot_status__pb2._STATUS +_SPAN.fields_by_name['same_process_as_parent_span'].message_type = google_dot_protobuf_dot_wrappers__pb2._BOOLVALUE +_SPAN.fields_by_name['child_span_count'].message_type = google_dot_protobuf_dot_wrappers__pb2._INT32VALUE +_ATTRIBUTEVALUE.fields_by_name['string_value'].message_type = _TRUNCATABLESTRING +_ATTRIBUTEVALUE.oneofs_by_name['value'].fields.append( + _ATTRIBUTEVALUE.fields_by_name['string_value']) +_ATTRIBUTEVALUE.fields_by_name['string_value'].containing_oneof = _ATTRIBUTEVALUE.oneofs_by_name['value'] +_ATTRIBUTEVALUE.oneofs_by_name['value'].fields.append( + _ATTRIBUTEVALUE.fields_by_name['int_value']) +_ATTRIBUTEVALUE.fields_by_name['int_value'].containing_oneof = _ATTRIBUTEVALUE.oneofs_by_name['value'] +_ATTRIBUTEVALUE.oneofs_by_name['value'].fields.append( + _ATTRIBUTEVALUE.fields_by_name['bool_value']) +_ATTRIBUTEVALUE.fields_by_name['bool_value'].containing_oneof = _ATTRIBUTEVALUE.oneofs_by_name['value'] +_STACKTRACE_STACKFRAME.fields_by_name['function_name'].message_type = _TRUNCATABLESTRING +_STACKTRACE_STACKFRAME.fields_by_name['original_function_name'].message_type = _TRUNCATABLESTRING +_STACKTRACE_STACKFRAME.fields_by_name['file_name'].message_type = _TRUNCATABLESTRING +_STACKTRACE_STACKFRAME.fields_by_name['load_module'].message_type = _MODULE +_STACKTRACE_STACKFRAME.fields_by_name['source_version'].message_type = _TRUNCATABLESTRING +_STACKTRACE_STACKFRAME.containing_type = _STACKTRACE +_STACKTRACE_STACKFRAMES.fields_by_name['frame'].message_type = _STACKTRACE_STACKFRAME +_STACKTRACE_STACKFRAMES.containing_type = _STACKTRACE +_STACKTRACE.fields_by_name['stack_frames'].message_type = _STACKTRACE_STACKFRAMES +_MODULE.fields_by_name['module'].message_type = _TRUNCATABLESTRING +_MODULE.fields_by_name['build_id'].message_type = _TRUNCATABLESTRING +DESCRIPTOR.message_types_by_name['Span'] = _SPAN +DESCRIPTOR.message_types_by_name['AttributeValue'] = _ATTRIBUTEVALUE +DESCRIPTOR.message_types_by_name['StackTrace'] = _STACKTRACE +DESCRIPTOR.message_types_by_name['Module'] = _MODULE +DESCRIPTOR.message_types_by_name['TruncatableString'] = _TRUNCATABLESTRING +_sym_db.RegisterFileDescriptor(DESCRIPTOR) + +Span = _reflection.GeneratedProtocolMessageType('Span', (_message.Message,), dict( + + Attributes = _reflection.GeneratedProtocolMessageType('Attributes', (_message.Message,), dict( + + AttributeMapEntry = _reflection.GeneratedProtocolMessageType('AttributeMapEntry', (_message.Message,), dict( + DESCRIPTOR = _SPAN_ATTRIBUTES_ATTRIBUTEMAPENTRY, + __module__ = 'google.devtools.cloudtrace_v2.proto.trace_pb2' + # @@protoc_insertion_point(class_scope:google.devtools.cloudtrace.v2.Span.Attributes.AttributeMapEntry) + )) + , + DESCRIPTOR = _SPAN_ATTRIBUTES, + __module__ = 'google.devtools.cloudtrace_v2.proto.trace_pb2' + , + __doc__ = """A set of attributes, each in the format ``[KEY]:[VALUE]``. + + + Attributes: + attribute_map: + The set of attributes. Each attribute's key can be up to 128 + bytes long. The value can be a string up to 256 bytes, an + integer, or the Boolean values ``true`` and ``false``. For + example: :: "/instance_id": "my-instance" + "/http/user_agent": "" "/http/request_bytes": 300 + "abc.com/myattribute": true + dropped_attributes_count: + The number of attributes that were discarded. Attributes can + be discarded because their keys are too long or because there + are too many attributes. If this value is 0 then all + attributes are valid. + """, + # @@protoc_insertion_point(class_scope:google.devtools.cloudtrace.v2.Span.Attributes) + )) + , + + TimeEvent = _reflection.GeneratedProtocolMessageType('TimeEvent', (_message.Message,), dict( + + Annotation = _reflection.GeneratedProtocolMessageType('Annotation', (_message.Message,), dict( + DESCRIPTOR = _SPAN_TIMEEVENT_ANNOTATION, + __module__ = 'google.devtools.cloudtrace_v2.proto.trace_pb2' + , + __doc__ = """Text annotation with a set of attributes. + + + Attributes: + description: + A user-supplied message describing the event. The maximum + length for the description is 256 bytes. + attributes: + A set of attributes on the annotation. There is a limit of 4 + attributes per Annotation. + """, + # @@protoc_insertion_point(class_scope:google.devtools.cloudtrace.v2.Span.TimeEvent.Annotation) + )) + , + + MessageEvent = _reflection.GeneratedProtocolMessageType('MessageEvent', (_message.Message,), dict( + DESCRIPTOR = _SPAN_TIMEEVENT_MESSAGEEVENT, + __module__ = 'google.devtools.cloudtrace_v2.proto.trace_pb2' + , + __doc__ = """An event describing a message sent/received between Spans. + + + Attributes: + type: + Type of MessageEvent. Indicates whether the message was sent + or received. + id: + An identifier for the MessageEvent's message that can be used + to match SENT and RECEIVED MessageEvents. It is recommended to + be unique within a Span. + uncompressed_size_bytes: + The number of uncompressed bytes sent or received. + compressed_size_bytes: + The number of compressed bytes sent or received. If missing + assumed to be the same size as uncompressed. + """, + # @@protoc_insertion_point(class_scope:google.devtools.cloudtrace.v2.Span.TimeEvent.MessageEvent) + )) + , + DESCRIPTOR = _SPAN_TIMEEVENT, + __module__ = 'google.devtools.cloudtrace_v2.proto.trace_pb2' + , + __doc__ = """A time-stamped annotation or message event in the Span. + + + Attributes: + time: + The timestamp indicating the time the event occurred. + value: + A ``TimeEvent`` can contain either an ``Annotation`` object or + a ``MessageEvent`` object, but not both. + annotation: + Text annotation with a set of attributes. + message_event: + An event describing a message sent/received between Spans. + """, + # @@protoc_insertion_point(class_scope:google.devtools.cloudtrace.v2.Span.TimeEvent) + )) + , + + TimeEvents = _reflection.GeneratedProtocolMessageType('TimeEvents', (_message.Message,), dict( + DESCRIPTOR = _SPAN_TIMEEVENTS, + __module__ = 'google.devtools.cloudtrace_v2.proto.trace_pb2' + , + __doc__ = """A collection of ``TimeEvent``\ s. A ``TimeEvent`` is a time-stamped + annotation on the span, consisting of either user-supplied key:value + pairs, or details of a message sent/received between Spans. + + + Attributes: + time_event: + A collection of ``TimeEvent``\ s. + dropped_annotations_count: + The number of dropped annotations in all the included time + events. If the value is 0, then no annotations were dropped. + dropped_message_events_count: + The number of dropped message events in all the included time + events. If the value is 0, then no message events were + dropped. + """, + # @@protoc_insertion_point(class_scope:google.devtools.cloudtrace.v2.Span.TimeEvents) + )) + , + + Link = _reflection.GeneratedProtocolMessageType('Link', (_message.Message,), dict( + DESCRIPTOR = _SPAN_LINK, + __module__ = 'google.devtools.cloudtrace_v2.proto.trace_pb2' + , + __doc__ = """A pointer from the current span to another span in the same trace or in + a different trace. For example, this can be used in batching operations, + where a single batch handler processes multiple requests from different + traces or when the handler receives a request from a different project. + + + Attributes: + trace_id: + ``TRACE_ID`` identifies a trace within a project. + span_id: + ``SPAN_ID`` identifies a span within a trace. + type: + The relationship of the current span relative to the linked + span. + attributes: + A set of attributes on the link. There is a limit of 32 + attributes per link. + """, + # @@protoc_insertion_point(class_scope:google.devtools.cloudtrace.v2.Span.Link) + )) + , + + Links = _reflection.GeneratedProtocolMessageType('Links', (_message.Message,), dict( + DESCRIPTOR = _SPAN_LINKS, + __module__ = 'google.devtools.cloudtrace_v2.proto.trace_pb2' + , + __doc__ = """A collection of links, which are references from this span to a span in + the same or different trace. + + + Attributes: + link: + A collection of links. + dropped_links_count: + The number of dropped links after the maximum size was + enforced. If this value is 0, then no links were dropped. + """, + # @@protoc_insertion_point(class_scope:google.devtools.cloudtrace.v2.Span.Links) + )) + , + DESCRIPTOR = _SPAN, + __module__ = 'google.devtools.cloudtrace_v2.proto.trace_pb2' + , + __doc__ = """A span represents a single operation within a trace. Spans can be nested + to form a trace tree. Often, a trace contains a root span that describes + the end-to-end latency, and one or more subspans for its sub-operations. + A trace can also contain multiple root spans, or none at all. Spans do + not need to be contiguous—there may be gaps or overlaps between spans in + a trace. + + + Attributes: + name: + The resource name of the span in the following format: :: + projects/[PROJECT_ID]/traces/[TRACE_ID]/spans/[SPAN_ID] + [TRACE\_ID] is a unique identifier for a trace within a + project. [SPAN\_ID] is a unique identifier for a span within a + trace, assigned when the span is created. + span_id: + The [SPAN\_ID] portion of the span's resource name. The ID is + a 16-character hexadecimal encoding of an 8-byte array. + parent_span_id: + The [SPAN\_ID] of this span's parent span. If this is a root + span, then this field must be empty. + display_name: + A description of the span's operation (up to 128 bytes). + Stackdriver Trace displays the description in the {% dynamic + print site\_values.console\_name %}. For example, the display + name can be a qualified method name or a file name and a line + number where the operation is called. A best practice is to + use the same display name within an application and at the + same call point. This makes it easier to correlate spans in + different traces. + start_time: + The start time of the span. On the client side, this is the + time kept by the local machine where the span execution + starts. On the server side, this is the time when the server's + application handler starts running. + end_time: + The end time of the span. On the client side, this is the time + kept by the local machine where the span execution ends. On + the server side, this is the time when the server application + handler stops running. + attributes: + A set of attributes on the span. There is a limit of 32 + attributes per span. + stack_trace: + Stack trace captured at the start of the span. + time_events: + The included time events. There can be up to 32 annotations + and 128 message events per span. + links: + A maximum of 128 links are allowed per Span. + status: + An optional final status for this span. + same_process_as_parent_span: + A highly recommended but not required flag that identifies + when a trace crosses a process boundary. True when the + parent\_span belongs to the same process as the current span. + child_span_count: + An optional number of child spans that were generated while + this span was active. If set, allows implementation to detect + missing child spans. + """, + # @@protoc_insertion_point(class_scope:google.devtools.cloudtrace.v2.Span) + )) +_sym_db.RegisterMessage(Span) +_sym_db.RegisterMessage(Span.Attributes) +_sym_db.RegisterMessage(Span.Attributes.AttributeMapEntry) +_sym_db.RegisterMessage(Span.TimeEvent) +_sym_db.RegisterMessage(Span.TimeEvent.Annotation) +_sym_db.RegisterMessage(Span.TimeEvent.MessageEvent) +_sym_db.RegisterMessage(Span.TimeEvents) +_sym_db.RegisterMessage(Span.Link) +_sym_db.RegisterMessage(Span.Links) + +AttributeValue = _reflection.GeneratedProtocolMessageType('AttributeValue', (_message.Message,), dict( + DESCRIPTOR = _ATTRIBUTEVALUE, + __module__ = 'google.devtools.cloudtrace_v2.proto.trace_pb2' + , + __doc__ = """The allowed types for [VALUE] in a ``[KEY]:[VALUE]`` attribute. + + + Attributes: + value: + The type of the value. + string_value: + A string up to 256 bytes long. + int_value: + A 64-bit signed integer. + bool_value: + A Boolean value represented by ``true`` or ``false``. + """, + # @@protoc_insertion_point(class_scope:google.devtools.cloudtrace.v2.AttributeValue) + )) +_sym_db.RegisterMessage(AttributeValue) + +StackTrace = _reflection.GeneratedProtocolMessageType('StackTrace', (_message.Message,), dict( + + StackFrame = _reflection.GeneratedProtocolMessageType('StackFrame', (_message.Message,), dict( + DESCRIPTOR = _STACKTRACE_STACKFRAME, + __module__ = 'google.devtools.cloudtrace_v2.proto.trace_pb2' + , + __doc__ = """Represents a single stack frame in a stack trace. + + + Attributes: + function_name: + The fully-qualified name that uniquely identifies the function + or method that is active in this frame (up to 1024 bytes). + original_function_name: + An un-mangled function name, if ``function_name`` is `mangled + `__. The name + can be fully-qualified (up to 1024 bytes). + file_name: + The name of the source file where the function call appears + (up to 256 bytes). + line_number: + The line number in ``file_name`` where the function call + appears. + column_number: + The column number where the function call appears, if + available. This is important in JavaScript because of its + anonymous functions. + load_module: + The binary module from where the code was loaded. + source_version: + The version of the deployed source code (up to 128 bytes). + """, + # @@protoc_insertion_point(class_scope:google.devtools.cloudtrace.v2.StackTrace.StackFrame) + )) + , + + StackFrames = _reflection.GeneratedProtocolMessageType('StackFrames', (_message.Message,), dict( + DESCRIPTOR = _STACKTRACE_STACKFRAMES, + __module__ = 'google.devtools.cloudtrace_v2.proto.trace_pb2' + , + __doc__ = """A collection of stack frames, which can be truncated. + + + Attributes: + frame: + Stack frames in this call stack. + dropped_frames_count: + The number of stack frames that were dropped because there + were too many stack frames. If this value is 0, then no stack + frames were dropped. + """, + # @@protoc_insertion_point(class_scope:google.devtools.cloudtrace.v2.StackTrace.StackFrames) + )) + , + DESCRIPTOR = _STACKTRACE, + __module__ = 'google.devtools.cloudtrace_v2.proto.trace_pb2' + , + __doc__ = """A call stack appearing in a trace. + + + Attributes: + stack_frames: + Stack frames in this stack trace. A maximum of 128 frames are + allowed. + stack_trace_hash_id: + The hash ID is used to conserve network bandwidth for + duplicate stack traces within a single trace. Often multiple + spans will have identical stack traces. The first occurrence + of a stack trace should contain both the ``stackFrame`` + content and a value in ``stackTraceHashId``. Subsequent spans + within the same request can refer to that stack trace by only + setting ``stackTraceHashId``. + """, + # @@protoc_insertion_point(class_scope:google.devtools.cloudtrace.v2.StackTrace) + )) +_sym_db.RegisterMessage(StackTrace) +_sym_db.RegisterMessage(StackTrace.StackFrame) +_sym_db.RegisterMessage(StackTrace.StackFrames) + +Module = _reflection.GeneratedProtocolMessageType('Module', (_message.Message,), dict( + DESCRIPTOR = _MODULE, + __module__ = 'google.devtools.cloudtrace_v2.proto.trace_pb2' + , + __doc__ = """Binary module. + + + Attributes: + module: + For example: main binary, kernel modules, and dynamic + libraries such as libc.so, sharedlib.so (up to 256 bytes). + build_id: + A unique identifier for the module, usually a hash of its + contents (up to 128 bytes). + """, + # @@protoc_insertion_point(class_scope:google.devtools.cloudtrace.v2.Module) + )) +_sym_db.RegisterMessage(Module) + +TruncatableString = _reflection.GeneratedProtocolMessageType('TruncatableString', (_message.Message,), dict( + DESCRIPTOR = _TRUNCATABLESTRING, + __module__ = 'google.devtools.cloudtrace_v2.proto.trace_pb2' + , + __doc__ = """Represents a string that might be shortened to a specified length. + + + Attributes: + value: + The shortened string. For example, if the original string was + 500 bytes long and the limit of the string was 128 bytes, then + this value contains the first 128 bytes of the 500-byte + string. Note that truncation always happens on the character + boundary, to ensure that truncated string is still valid UTF8. + In case of multi-byte characters, size of truncated string can + be less than truncation limit. + truncated_byte_count: + The number of bytes removed from the original string. If this + value is 0, then the string was not shortened. + """, + # @@protoc_insertion_point(class_scope:google.devtools.cloudtrace.v2.TruncatableString) + )) +_sym_db.RegisterMessage(TruncatableString) + + +DESCRIPTOR.has_options = True +DESCRIPTOR._options = _descriptor._ParseOptions(descriptor_pb2.FileOptions(), _b('\n!com.google.devtools.cloudtrace.v2B\nTraceProtoP\001ZGgoogle.golang.org/genproto/googleapis/devtools/cloudtrace/v2;cloudtrace\252\002\025Google.Cloud.Trace.V2')) +_SPAN_ATTRIBUTES_ATTRIBUTEMAPENTRY.has_options = True +_SPAN_ATTRIBUTES_ATTRIBUTEMAPENTRY._options = _descriptor._ParseOptions(descriptor_pb2.MessageOptions(), _b('8\001')) +try: + # THESE ELEMENTS WILL BE DEPRECATED. + # Please use the generated *_pb2_grpc.py files instead. + import grpc + from grpc.beta import implementations as beta_implementations + from grpc.beta import interfaces as beta_interfaces + from grpc.framework.common import cardinality + from grpc.framework.interfaces.face import utilities as face_utilities +except ImportError: + pass +# @@protoc_insertion_point(module_scope) diff --git a/trace/google/cloud/trace_v2/proto/trace_pb2_grpc.py b/trace/google/cloud/trace_v2/proto/trace_pb2_grpc.py new file mode 100644 index 000000000000..a89435267cb2 --- /dev/null +++ b/trace/google/cloud/trace_v2/proto/trace_pb2_grpc.py @@ -0,0 +1,3 @@ +# Generated by the gRPC Python protocol compiler plugin. DO NOT EDIT! +import grpc + diff --git a/trace/google/cloud/trace_v2/proto/tracing_pb2.py b/trace/google/cloud/trace_v2/proto/tracing_pb2.py new file mode 100644 index 000000000000..b0db2d6b2fe5 --- /dev/null +++ b/trace/google/cloud/trace_v2/proto/tracing_pb2.py @@ -0,0 +1,274 @@ +# Generated by the protocol buffer compiler. DO NOT EDIT! +# source: google/devtools/cloudtrace_v2/proto/tracing.proto + +import sys +_b=sys.version_info[0]<3 and (lambda x:x) or (lambda x:x.encode('latin1')) +from google.protobuf import descriptor as _descriptor +from google.protobuf import message as _message +from google.protobuf import reflection as _reflection +from google.protobuf import symbol_database as _symbol_database +from google.protobuf import descriptor_pb2 +# @@protoc_insertion_point(imports) + +_sym_db = _symbol_database.Default() + + +from google.api import annotations_pb2 as google_dot_api_dot_annotations__pb2 +from google.cloud.trace_v2.proto import trace_pb2 as google_dot_devtools_dot_cloudtrace__v2_dot_proto_dot_trace__pb2 +from google.protobuf import empty_pb2 as google_dot_protobuf_dot_empty__pb2 +from google.protobuf import timestamp_pb2 as google_dot_protobuf_dot_timestamp__pb2 + + +DESCRIPTOR = _descriptor.FileDescriptor( + name='google/devtools/cloudtrace_v2/proto/tracing.proto', + package='google.devtools.cloudtrace.v2', + syntax='proto3', + serialized_pb=_b('\n1google/devtools/cloudtrace_v2/proto/tracing.proto\x12\x1dgoogle.devtools.cloudtrace.v2\x1a\x1cgoogle/api/annotations.proto\x1a/google/devtools/cloudtrace_v2/proto/trace.proto\x1a\x1bgoogle/protobuf/empty.proto\x1a\x1fgoogle/protobuf/timestamp.proto\"Z\n\x16\x42\x61tchWriteSpansRequest\x12\x0c\n\x04name\x18\x01 \x01(\t\x12\x32\n\x05spans\x18\x02 \x03(\x0b\x32#.google.devtools.cloudtrace.v2.Span2\xb1\x02\n\x0cTraceService\x12\x94\x01\n\x0f\x42\x61tchWriteSpans\x12\x35.google.devtools.cloudtrace.v2.BatchWriteSpansRequest\x1a\x16.google.protobuf.Empty\"2\x82\xd3\xe4\x93\x02,\"\'/v2/{name=projects/*}/traces:batchWrite:\x01*\x12\x89\x01\n\nCreateSpan\x12#.google.devtools.cloudtrace.v2.Span\x1a#.google.devtools.cloudtrace.v2.Span\"1\x82\xd3\xe4\x93\x02+\x1a&/v2/{name=projects/*/traces/*/spans/*}:\x01*B\x94\x01\n!com.google.devtools.cloudtrace.v2B\x0cTracingProtoP\x01ZGgoogle.golang.org/genproto/googleapis/devtools/cloudtrace/v2;cloudtrace\xaa\x02\x15Google.Cloud.Trace.V2b\x06proto3') + , + dependencies=[google_dot_api_dot_annotations__pb2.DESCRIPTOR,google_dot_devtools_dot_cloudtrace__v2_dot_proto_dot_trace__pb2.DESCRIPTOR,google_dot_protobuf_dot_empty__pb2.DESCRIPTOR,google_dot_protobuf_dot_timestamp__pb2.DESCRIPTOR,]) + + + + +_BATCHWRITESPANSREQUEST = _descriptor.Descriptor( + name='BatchWriteSpansRequest', + full_name='google.devtools.cloudtrace.v2.BatchWriteSpansRequest', + filename=None, + file=DESCRIPTOR, + containing_type=None, + fields=[ + _descriptor.FieldDescriptor( + name='name', full_name='google.devtools.cloudtrace.v2.BatchWriteSpansRequest.name', index=0, + number=1, type=9, cpp_type=9, label=1, + has_default_value=False, default_value=_b("").decode('utf-8'), + message_type=None, enum_type=None, containing_type=None, + is_extension=False, extension_scope=None, + options=None), + _descriptor.FieldDescriptor( + name='spans', full_name='google.devtools.cloudtrace.v2.BatchWriteSpansRequest.spans', index=1, + number=2, type=11, cpp_type=10, label=3, + has_default_value=False, default_value=[], + message_type=None, enum_type=None, containing_type=None, + is_extension=False, extension_scope=None, + options=None), + ], + extensions=[ + ], + nested_types=[], + enum_types=[ + ], + options=None, + is_extendable=False, + syntax='proto3', + extension_ranges=[], + oneofs=[ + ], + serialized_start=225, + serialized_end=315, +) + +_BATCHWRITESPANSREQUEST.fields_by_name['spans'].message_type = google_dot_devtools_dot_cloudtrace__v2_dot_proto_dot_trace__pb2._SPAN +DESCRIPTOR.message_types_by_name['BatchWriteSpansRequest'] = _BATCHWRITESPANSREQUEST +_sym_db.RegisterFileDescriptor(DESCRIPTOR) + +BatchWriteSpansRequest = _reflection.GeneratedProtocolMessageType('BatchWriteSpansRequest', (_message.Message,), dict( + DESCRIPTOR = _BATCHWRITESPANSREQUEST, + __module__ = 'google.devtools.cloudtrace_v2.proto.tracing_pb2' + , + __doc__ = """The request message for the ``BatchWriteSpans`` method. + + + Attributes: + name: + Required. Name of the project where the spans belong. The + format is ``projects/PROJECT_ID``. + spans: + A collection of spans. + """, + # @@protoc_insertion_point(class_scope:google.devtools.cloudtrace.v2.BatchWriteSpansRequest) + )) +_sym_db.RegisterMessage(BatchWriteSpansRequest) + + +DESCRIPTOR.has_options = True +DESCRIPTOR._options = _descriptor._ParseOptions(descriptor_pb2.FileOptions(), _b('\n!com.google.devtools.cloudtrace.v2B\014TracingProtoP\001ZGgoogle.golang.org/genproto/googleapis/devtools/cloudtrace/v2;cloudtrace\252\002\025Google.Cloud.Trace.V2')) +try: + # THESE ELEMENTS WILL BE DEPRECATED. + # Please use the generated *_pb2_grpc.py files instead. + import grpc + from grpc.beta import implementations as beta_implementations + from grpc.beta import interfaces as beta_interfaces + from grpc.framework.common import cardinality + from grpc.framework.interfaces.face import utilities as face_utilities + + + class TraceServiceStub(object): + """This file describes an API for collecting and viewing traces and spans + within a trace. A Trace is a collection of spans corresponding to a single + operation or set of operations for an application. A span is an individual + timed event which forms a node of the trace tree. A single trace may + contain span(s) from multiple services. + """ + + def __init__(self, channel): + """Constructor. + + Args: + channel: A grpc.Channel. + """ + self.BatchWriteSpans = channel.unary_unary( + '/google.devtools.cloudtrace.v2.TraceService/BatchWriteSpans', + request_serializer=BatchWriteSpansRequest.SerializeToString, + response_deserializer=google_dot_protobuf_dot_empty__pb2.Empty.FromString, + ) + self.CreateSpan = channel.unary_unary( + '/google.devtools.cloudtrace.v2.TraceService/CreateSpan', + request_serializer=google_dot_devtools_dot_cloudtrace__v2_dot_proto_dot_trace__pb2.Span.SerializeToString, + response_deserializer=google_dot_devtools_dot_cloudtrace__v2_dot_proto_dot_trace__pb2.Span.FromString, + ) + + + class TraceServiceServicer(object): + """This file describes an API for collecting and viewing traces and spans + within a trace. A Trace is a collection of spans corresponding to a single + operation or set of operations for an application. A span is an individual + timed event which forms a node of the trace tree. A single trace may + contain span(s) from multiple services. + """ + + def BatchWriteSpans(self, request, context): + """Sends new spans to Stackdriver Trace or updates existing traces. If the + name of a trace that you send matches that of an existing trace, new spans + are added to the existing trace. Attempt to update existing spans results + undefined behavior. If the name does not match, a new trace is created + with given set of spans. + """ + context.set_code(grpc.StatusCode.UNIMPLEMENTED) + context.set_details('Method not implemented!') + raise NotImplementedError('Method not implemented!') + + def CreateSpan(self, request, context): + """Creates a new Span. + """ + context.set_code(grpc.StatusCode.UNIMPLEMENTED) + context.set_details('Method not implemented!') + raise NotImplementedError('Method not implemented!') + + + def add_TraceServiceServicer_to_server(servicer, server): + rpc_method_handlers = { + 'BatchWriteSpans': grpc.unary_unary_rpc_method_handler( + servicer.BatchWriteSpans, + request_deserializer=BatchWriteSpansRequest.FromString, + response_serializer=google_dot_protobuf_dot_empty__pb2.Empty.SerializeToString, + ), + 'CreateSpan': grpc.unary_unary_rpc_method_handler( + servicer.CreateSpan, + request_deserializer=google_dot_devtools_dot_cloudtrace__v2_dot_proto_dot_trace__pb2.Span.FromString, + response_serializer=google_dot_devtools_dot_cloudtrace__v2_dot_proto_dot_trace__pb2.Span.SerializeToString, + ), + } + generic_handler = grpc.method_handlers_generic_handler( + 'google.devtools.cloudtrace.v2.TraceService', rpc_method_handlers) + server.add_generic_rpc_handlers((generic_handler,)) + + + class BetaTraceServiceServicer(object): + """The Beta API is deprecated for 0.15.0 and later. + + It is recommended to use the GA API (classes and functions in this + file not marked beta) for all further purposes. This class was generated + only to ease transition from grpcio<0.15.0 to grpcio>=0.15.0.""" + """This file describes an API for collecting and viewing traces and spans + within a trace. A Trace is a collection of spans corresponding to a single + operation or set of operations for an application. A span is an individual + timed event which forms a node of the trace tree. A single trace may + contain span(s) from multiple services. + """ + def BatchWriteSpans(self, request, context): + """Sends new spans to Stackdriver Trace or updates existing traces. If the + name of a trace that you send matches that of an existing trace, new spans + are added to the existing trace. Attempt to update existing spans results + undefined behavior. If the name does not match, a new trace is created + with given set of spans. + """ + context.code(beta_interfaces.StatusCode.UNIMPLEMENTED) + def CreateSpan(self, request, context): + """Creates a new Span. + """ + context.code(beta_interfaces.StatusCode.UNIMPLEMENTED) + + + class BetaTraceServiceStub(object): + """The Beta API is deprecated for 0.15.0 and later. + + It is recommended to use the GA API (classes and functions in this + file not marked beta) for all further purposes. This class was generated + only to ease transition from grpcio<0.15.0 to grpcio>=0.15.0.""" + """This file describes an API for collecting and viewing traces and spans + within a trace. A Trace is a collection of spans corresponding to a single + operation or set of operations for an application. A span is an individual + timed event which forms a node of the trace tree. A single trace may + contain span(s) from multiple services. + """ + def BatchWriteSpans(self, request, timeout, metadata=None, with_call=False, protocol_options=None): + """Sends new spans to Stackdriver Trace or updates existing traces. If the + name of a trace that you send matches that of an existing trace, new spans + are added to the existing trace. Attempt to update existing spans results + undefined behavior. If the name does not match, a new trace is created + with given set of spans. + """ + raise NotImplementedError() + BatchWriteSpans.future = None + def CreateSpan(self, request, timeout, metadata=None, with_call=False, protocol_options=None): + """Creates a new Span. + """ + raise NotImplementedError() + CreateSpan.future = None + + + def beta_create_TraceService_server(servicer, pool=None, pool_size=None, default_timeout=None, maximum_timeout=None): + """The Beta API is deprecated for 0.15.0 and later. + + It is recommended to use the GA API (classes and functions in this + file not marked beta) for all further purposes. This function was + generated only to ease transition from grpcio<0.15.0 to grpcio>=0.15.0""" + request_deserializers = { + ('google.devtools.cloudtrace.v2.TraceService', 'BatchWriteSpans'): BatchWriteSpansRequest.FromString, + ('google.devtools.cloudtrace.v2.TraceService', 'CreateSpan'): google_dot_devtools_dot_cloudtrace__v2_dot_proto_dot_trace__pb2.Span.FromString, + } + response_serializers = { + ('google.devtools.cloudtrace.v2.TraceService', 'BatchWriteSpans'): google_dot_protobuf_dot_empty__pb2.Empty.SerializeToString, + ('google.devtools.cloudtrace.v2.TraceService', 'CreateSpan'): google_dot_devtools_dot_cloudtrace__v2_dot_proto_dot_trace__pb2.Span.SerializeToString, + } + method_implementations = { + ('google.devtools.cloudtrace.v2.TraceService', 'BatchWriteSpans'): face_utilities.unary_unary_inline(servicer.BatchWriteSpans), + ('google.devtools.cloudtrace.v2.TraceService', 'CreateSpan'): face_utilities.unary_unary_inline(servicer.CreateSpan), + } + server_options = beta_implementations.server_options(request_deserializers=request_deserializers, response_serializers=response_serializers, thread_pool=pool, thread_pool_size=pool_size, default_timeout=default_timeout, maximum_timeout=maximum_timeout) + return beta_implementations.server(method_implementations, options=server_options) + + + def beta_create_TraceService_stub(channel, host=None, metadata_transformer=None, pool=None, pool_size=None): + """The Beta API is deprecated for 0.15.0 and later. + + It is recommended to use the GA API (classes and functions in this + file not marked beta) for all further purposes. This function was + generated only to ease transition from grpcio<0.15.0 to grpcio>=0.15.0""" + request_serializers = { + ('google.devtools.cloudtrace.v2.TraceService', 'BatchWriteSpans'): BatchWriteSpansRequest.SerializeToString, + ('google.devtools.cloudtrace.v2.TraceService', 'CreateSpan'): google_dot_devtools_dot_cloudtrace__v2_dot_proto_dot_trace__pb2.Span.SerializeToString, + } + response_deserializers = { + ('google.devtools.cloudtrace.v2.TraceService', 'BatchWriteSpans'): google_dot_protobuf_dot_empty__pb2.Empty.FromString, + ('google.devtools.cloudtrace.v2.TraceService', 'CreateSpan'): google_dot_devtools_dot_cloudtrace__v2_dot_proto_dot_trace__pb2.Span.FromString, + } + cardinalities = { + 'BatchWriteSpans': cardinality.Cardinality.UNARY_UNARY, + 'CreateSpan': cardinality.Cardinality.UNARY_UNARY, + } + stub_options = beta_implementations.stub_options(host=host, metadata_transformer=metadata_transformer, request_serializers=request_serializers, response_deserializers=response_deserializers, thread_pool=pool, thread_pool_size=pool_size) + return beta_implementations.dynamic_stub(channel, 'google.devtools.cloudtrace.v2.TraceService', cardinalities, options=stub_options) +except ImportError: + pass +# @@protoc_insertion_point(module_scope) diff --git a/trace/google/cloud/trace_v2/proto/tracing_pb2_grpc.py b/trace/google/cloud/trace_v2/proto/tracing_pb2_grpc.py new file mode 100644 index 000000000000..609605f0014a --- /dev/null +++ b/trace/google/cloud/trace_v2/proto/tracing_pb2_grpc.py @@ -0,0 +1,77 @@ +# Generated by the gRPC Python protocol compiler plugin. DO NOT EDIT! +import grpc + +from google.cloud.trace_v2.proto import trace_pb2 as google_dot_devtools_dot_cloudtrace__v2_dot_proto_dot_trace__pb2 +from google.cloud.trace_v2.proto import tracing_pb2 as google_dot_devtools_dot_cloudtrace__v2_dot_proto_dot_tracing__pb2 +from google.protobuf import empty_pb2 as google_dot_protobuf_dot_empty__pb2 + + +class TraceServiceStub(object): + """This file describes an API for collecting and viewing traces and spans + within a trace. A Trace is a collection of spans corresponding to a single + operation or set of operations for an application. A span is an individual + timed event which forms a node of the trace tree. A single trace may + contain span(s) from multiple services. + """ + + def __init__(self, channel): + """Constructor. + + Args: + channel: A grpc.Channel. + """ + self.BatchWriteSpans = channel.unary_unary( + '/google.devtools.cloudtrace.v2.TraceService/BatchWriteSpans', + request_serializer=google_dot_devtools_dot_cloudtrace__v2_dot_proto_dot_tracing__pb2.BatchWriteSpansRequest.SerializeToString, + response_deserializer=google_dot_protobuf_dot_empty__pb2.Empty.FromString, + ) + self.CreateSpan = channel.unary_unary( + '/google.devtools.cloudtrace.v2.TraceService/CreateSpan', + request_serializer=google_dot_devtools_dot_cloudtrace__v2_dot_proto_dot_trace__pb2.Span.SerializeToString, + response_deserializer=google_dot_devtools_dot_cloudtrace__v2_dot_proto_dot_trace__pb2.Span.FromString, + ) + + +class TraceServiceServicer(object): + """This file describes an API for collecting and viewing traces and spans + within a trace. A Trace is a collection of spans corresponding to a single + operation or set of operations for an application. A span is an individual + timed event which forms a node of the trace tree. A single trace may + contain span(s) from multiple services. + """ + + def BatchWriteSpans(self, request, context): + """Sends new spans to Stackdriver Trace or updates existing traces. If the + name of a trace that you send matches that of an existing trace, new spans + are added to the existing trace. Attempt to update existing spans results + undefined behavior. If the name does not match, a new trace is created + with given set of spans. + """ + context.set_code(grpc.StatusCode.UNIMPLEMENTED) + context.set_details('Method not implemented!') + raise NotImplementedError('Method not implemented!') + + def CreateSpan(self, request, context): + """Creates a new Span. + """ + context.set_code(grpc.StatusCode.UNIMPLEMENTED) + context.set_details('Method not implemented!') + raise NotImplementedError('Method not implemented!') + + +def add_TraceServiceServicer_to_server(servicer, server): + rpc_method_handlers = { + 'BatchWriteSpans': grpc.unary_unary_rpc_method_handler( + servicer.BatchWriteSpans, + request_deserializer=google_dot_devtools_dot_cloudtrace__v2_dot_proto_dot_tracing__pb2.BatchWriteSpansRequest.FromString, + response_serializer=google_dot_protobuf_dot_empty__pb2.Empty.SerializeToString, + ), + 'CreateSpan': grpc.unary_unary_rpc_method_handler( + servicer.CreateSpan, + request_deserializer=google_dot_devtools_dot_cloudtrace__v2_dot_proto_dot_trace__pb2.Span.FromString, + response_serializer=google_dot_devtools_dot_cloudtrace__v2_dot_proto_dot_trace__pb2.Span.SerializeToString, + ), + } + generic_handler = grpc.method_handlers_generic_handler( + 'google.devtools.cloudtrace.v2.TraceService', rpc_method_handlers) + server.add_generic_rpc_handlers((generic_handler,)) diff --git a/trace/google/cloud/trace_v2/types.py b/trace/google/cloud/trace_v2/types.py new file mode 100644 index 000000000000..9400fe82f9ba --- /dev/null +++ b/trace/google/cloud/trace_v2/types.py @@ -0,0 +1,46 @@ +# Copyright 2017, Google LLC All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +from __future__ import absolute_import +import sys + +from google.api_core.protobuf_helpers import get_messages + +from google.api import http_pb2 +from google.cloud.trace_v2.proto import trace_pb2 +from google.cloud.trace_v2.proto import tracing_pb2 +from google.protobuf import any_pb2 +from google.protobuf import descriptor_pb2 +from google.protobuf import empty_pb2 +from google.protobuf import timestamp_pb2 +from google.protobuf import wrappers_pb2 +from google.rpc import status_pb2 + +names = [] +for module in ( + http_pb2, + trace_pb2, + tracing_pb2, + any_pb2, + descriptor_pb2, + empty_pb2, + timestamp_pb2, + wrappers_pb2, + status_pb2, ): + for name, message in get_messages(module).items(): + message.__module__ = 'google.cloud.trace_v2.types' + setattr(sys.modules[__name__], name, message) + names.append(name) + +__all__ = tuple(sorted(names)) diff --git a/trace/setup.py b/trace/setup.py index 134dfef8adcf..fbfb9f3ea2b5 100644 --- a/trace/setup.py +++ b/trace/setup.py @@ -40,10 +40,5 @@ namespace_packages=[ 'google', 'google.cloud', - 'google.cloud.gapic', - 'google.cloud.gapic.trace', - 'google.cloud.proto', - 'google.cloud.proto.devtools', - 'google.cloud.proto.devtools.cloudtrace', ], url='https://github.com/googleapis/googleapis') diff --git a/trace/tests/gapic/v1/test_trace_service_client_v1.py b/trace/tests/gapic/v1/test_trace_service_client_v1.py deleted file mode 100644 index 0d654ac40e7c..000000000000 --- a/trace/tests/gapic/v1/test_trace_service_client_v1.py +++ /dev/null @@ -1,177 +0,0 @@ -# Copyright 2017, Google LLC All rights reserved. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -"""Unit tests.""" - -import mock -import unittest - -from google.gax import errors - -from google.cloud.gapic.trace.v1 import trace_service_client -from google.cloud.proto.devtools.cloudtrace.v1 import trace_pb2 -from google.protobuf import empty_pb2 - - -class CustomException(Exception): - pass - - -class TestTraceServiceClient(unittest.TestCase): - @mock.patch('google.gax.config.create_stub', spec=True) - def test_patch_traces(self, mock_create_stub): - # Mock gRPC layer - grpc_stub = mock.Mock() - mock_create_stub.return_value = grpc_stub - - client = trace_service_client.TraceServiceClient() - - # Mock request - project_id = 'projectId-1969970175' - traces = trace_pb2.Traces() - - client.patch_traces(project_id, traces) - - grpc_stub.PatchTraces.assert_called_once() - args, kwargs = grpc_stub.PatchTraces.call_args - self.assertEqual(len(args), 2) - self.assertEqual(len(kwargs), 1) - self.assertIn('metadata', kwargs) - actual_request = args[0] - - expected_request = trace_pb2.PatchTracesRequest( - project_id=project_id, traces=traces) - self.assertEqual(expected_request, actual_request) - - @mock.patch('google.gax.config.API_ERRORS', (CustomException, )) - @mock.patch('google.gax.config.create_stub', spec=True) - def test_patch_traces_exception(self, mock_create_stub): - # Mock gRPC layer - grpc_stub = mock.Mock() - mock_create_stub.return_value = grpc_stub - - client = trace_service_client.TraceServiceClient() - - # Mock request - project_id = 'projectId-1969970175' - traces = trace_pb2.Traces() - - # Mock exception response - grpc_stub.PatchTraces.side_effect = CustomException() - - self.assertRaises(errors.GaxError, client.patch_traces, project_id, - traces) - - @mock.patch('google.gax.config.create_stub', spec=True) - def test_get_trace(self, mock_create_stub): - # Mock gRPC layer - grpc_stub = mock.Mock() - mock_create_stub.return_value = grpc_stub - - client = trace_service_client.TraceServiceClient() - - # Mock request - project_id = 'projectId-1969970175' - trace_id = 'traceId1270300245' - - # Mock response - project_id_2 = 'projectId2939242356' - trace_id_2 = 'traceId2987826376' - expected_response = trace_pb2.Trace( - project_id=project_id_2, trace_id=trace_id_2) - grpc_stub.GetTrace.return_value = expected_response - - response = client.get_trace(project_id, trace_id) - self.assertEqual(expected_response, response) - - grpc_stub.GetTrace.assert_called_once() - args, kwargs = grpc_stub.GetTrace.call_args - self.assertEqual(len(args), 2) - self.assertEqual(len(kwargs), 1) - self.assertIn('metadata', kwargs) - actual_request = args[0] - - expected_request = trace_pb2.GetTraceRequest( - project_id=project_id, trace_id=trace_id) - self.assertEqual(expected_request, actual_request) - - @mock.patch('google.gax.config.API_ERRORS', (CustomException, )) - @mock.patch('google.gax.config.create_stub', spec=True) - def test_get_trace_exception(self, mock_create_stub): - # Mock gRPC layer - grpc_stub = mock.Mock() - mock_create_stub.return_value = grpc_stub - - client = trace_service_client.TraceServiceClient() - - # Mock request - project_id = 'projectId-1969970175' - trace_id = 'traceId1270300245' - - # Mock exception response - grpc_stub.GetTrace.side_effect = CustomException() - - self.assertRaises(errors.GaxError, client.get_trace, project_id, - trace_id) - - @mock.patch('google.gax.config.create_stub', spec=True) - def test_list_traces(self, mock_create_stub): - # Mock gRPC layer - grpc_stub = mock.Mock() - mock_create_stub.return_value = grpc_stub - - client = trace_service_client.TraceServiceClient() - - # Mock request - project_id = 'projectId-1969970175' - - # Mock response - next_page_token = '' - traces_element = trace_pb2.Trace() - traces = [traces_element] - expected_response = trace_pb2.ListTracesResponse( - next_page_token=next_page_token, traces=traces) - grpc_stub.ListTraces.return_value = expected_response - - paged_list_response = client.list_traces(project_id) - resources = list(paged_list_response) - self.assertEqual(1, len(resources)) - self.assertEqual(expected_response.traces[0], resources[0]) - - grpc_stub.ListTraces.assert_called_once() - args, kwargs = grpc_stub.ListTraces.call_args - self.assertEqual(len(args), 2) - self.assertEqual(len(kwargs), 1) - self.assertIn('metadata', kwargs) - actual_request = args[0] - - expected_request = trace_pb2.ListTracesRequest(project_id=project_id) - self.assertEqual(expected_request, actual_request) - - @mock.patch('google.gax.config.API_ERRORS', (CustomException, )) - @mock.patch('google.gax.config.create_stub', spec=True) - def test_list_traces_exception(self, mock_create_stub): - # Mock gRPC layer - grpc_stub = mock.Mock() - mock_create_stub.return_value = grpc_stub - - client = trace_service_client.TraceServiceClient() - - # Mock request - project_id = 'projectId-1969970175' - - # Mock exception response - grpc_stub.ListTraces.side_effect = CustomException() - - paged_list_response = client.list_traces(project_id) - self.assertRaises(errors.GaxError, list, paged_list_response) diff --git a/trace/tests/unit/gapic/v1/test_trace_service_client_v1.py b/trace/tests/unit/gapic/v1/test_trace_service_client_v1.py new file mode 100644 index 000000000000..6a758928383b --- /dev/null +++ b/trace/tests/unit/gapic/v1/test_trace_service_client_v1.py @@ -0,0 +1,168 @@ +# Copyright 2017, Google LLC All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +"""Unit tests.""" + +import pytest + +from google.cloud import trace_v1 +from google.cloud.trace_v1.proto import trace_pb2 +from google.protobuf import empty_pb2 + + +class MultiCallableStub(object): + """Stub for the grpc.UnaryUnaryMultiCallable interface.""" + + def __init__(self, method, channel_stub): + self.method = method + self.channel_stub = channel_stub + + def __call__(self, request, timeout=None, metadata=None, credentials=None): + self.channel_stub.requests.append((self.method, request)) + + response = None + if self.channel_stub.responses: + response = self.channel_stub.responses.pop() + + if isinstance(response, Exception): + raise response + + if response: + return response + + +class ChannelStub(object): + """Stub for the grpc.Channel interface.""" + + def __init__(self, responses=[]): + self.responses = responses + self.requests = [] + + def unary_unary(self, + method, + request_serializer=None, + response_deserializer=None): + return MultiCallableStub(method, self) + + +class CustomException(Exception): + pass + + +class TestTraceServiceClient(object): + def test_patch_traces(self): + channel = ChannelStub() + client = trace_v1.TraceServiceClient(channel=channel) + + # Setup Request + project_id = 'projectId-1969970175' + traces = {} + + client.patch_traces(project_id, traces) + + assert len(channel.requests) == 1 + expected_request = trace_pb2.PatchTracesRequest( + project_id=project_id, traces=traces) + actual_request = channel.requests[0][1] + assert expected_request == actual_request + + def test_patch_traces_exception(self): + # Mock the API response + channel = ChannelStub(responses=[CustomException()]) + client = trace_v1.TraceServiceClient(channel=channel) + + # Setup request + project_id = 'projectId-1969970175' + traces = {} + + with pytest.raises(CustomException): + client.patch_traces(project_id, traces) + + def test_get_trace(self): + # Setup Expected Response + project_id_2 = 'projectId2939242356' + trace_id_2 = 'traceId2987826376' + expected_response = { + 'project_id': project_id_2, + 'trace_id': trace_id_2 + } + expected_response = trace_pb2.Trace(**expected_response) + + # Mock the API response + channel = ChannelStub(responses=[expected_response]) + client = trace_v1.TraceServiceClient(channel=channel) + + # Setup Request + project_id = 'projectId-1969970175' + trace_id = 'traceId1270300245' + + response = client.get_trace(project_id, trace_id) + assert expected_response == response + + assert len(channel.requests) == 1 + expected_request = trace_pb2.GetTraceRequest( + project_id=project_id, trace_id=trace_id) + actual_request = channel.requests[0][1] + assert expected_request == actual_request + + def test_get_trace_exception(self): + # Mock the API response + channel = ChannelStub(responses=[CustomException()]) + client = trace_v1.TraceServiceClient(channel=channel) + + # Setup request + project_id = 'projectId-1969970175' + trace_id = 'traceId1270300245' + + with pytest.raises(CustomException): + client.get_trace(project_id, trace_id) + + def test_list_traces(self): + # Setup Expected Response + next_page_token = '' + traces_element = {} + traces = [traces_element] + expected_response = { + 'next_page_token': next_page_token, + 'traces': traces + } + expected_response = trace_pb2.ListTracesResponse(**expected_response) + + # Mock the API response + channel = ChannelStub(responses=[expected_response]) + client = trace_v1.TraceServiceClient(channel=channel) + + # Setup Request + project_id = 'projectId-1969970175' + + paged_list_response = client.list_traces(project_id) + resources = list(paged_list_response) + assert len(resources) == 1 + + assert expected_response.traces[0] == resources[0] + + assert len(channel.requests) == 1 + expected_request = trace_pb2.ListTracesRequest(project_id=project_id) + actual_request = channel.requests[0][1] + assert expected_request == actual_request + + def test_list_traces_exception(self): + channel = ChannelStub(responses=[CustomException()]) + client = trace_v1.TraceServiceClient(channel=channel) + + # Setup request + project_id = 'projectId-1969970175' + + paged_list_response = client.list_traces(project_id) + with pytest.raises(CustomException): + list(paged_list_response) diff --git a/trace/tests/unit/gapic/v2/test_trace_service_client_v2.py b/trace/tests/unit/gapic/v2/test_trace_service_client_v2.py new file mode 100644 index 000000000000..688c4e1f4189 --- /dev/null +++ b/trace/tests/unit/gapic/v2/test_trace_service_client_v2.py @@ -0,0 +1,144 @@ +# Copyright 2017, Google LLC All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +"""Unit tests.""" + +import pytest + +from google.cloud import trace_v2 +from google.cloud.trace_v2.proto import trace_pb2 +from google.cloud.trace_v2.proto import tracing_pb2 +from google.protobuf import empty_pb2 +from google.protobuf import timestamp_pb2 + + +class MultiCallableStub(object): + """Stub for the grpc.UnaryUnaryMultiCallable interface.""" + + def __init__(self, method, channel_stub): + self.method = method + self.channel_stub = channel_stub + + def __call__(self, request, timeout=None, metadata=None, credentials=None): + self.channel_stub.requests.append((self.method, request)) + + response = None + if self.channel_stub.responses: + response = self.channel_stub.responses.pop() + + if isinstance(response, Exception): + raise response + + if response: + return response + + +class ChannelStub(object): + """Stub for the grpc.Channel interface.""" + + def __init__(self, responses=[]): + self.responses = responses + self.requests = [] + + def unary_unary(self, + method, + request_serializer=None, + response_deserializer=None): + return MultiCallableStub(method, self) + + +class CustomException(Exception): + pass + + +class TestTraceServiceClient(object): + def test_batch_write_spans(self): + channel = ChannelStub() + client = trace_v2.TraceServiceClient(channel=channel) + + # Setup Request + name = client.project_path('[PROJECT]') + spans = [] + + client.batch_write_spans(name, spans) + + assert len(channel.requests) == 1 + expected_request = tracing_pb2.BatchWriteSpansRequest( + name=name, spans=spans) + actual_request = channel.requests[0][1] + assert expected_request == actual_request + + def test_batch_write_spans_exception(self): + # Mock the API response + channel = ChannelStub(responses=[CustomException()]) + client = trace_v2.TraceServiceClient(channel=channel) + + # Setup request + name = client.project_path('[PROJECT]') + spans = [] + + with pytest.raises(CustomException): + client.batch_write_spans(name, spans) + + def test_create_span(self): + # Setup Expected Response + name_2 = 'name2-1052831874' + span_id_2 = 'spanId2-643891741' + parent_span_id = 'parentSpanId-1757797477' + expected_response = { + 'name': name_2, + 'span_id': span_id_2, + 'parent_span_id': parent_span_id + } + expected_response = trace_pb2.Span(**expected_response) + + # Mock the API response + channel = ChannelStub(responses=[expected_response]) + client = trace_v2.TraceServiceClient(channel=channel) + + # Setup Request + name = client.span_path('[PROJECT]', '[TRACE]', '[SPAN]') + span_id = 'spanId-2011840976' + display_name = {} + start_time = {} + end_time = {} + + response = client.create_span(name, span_id, display_name, start_time, + end_time) + assert expected_response == response + + assert len(channel.requests) == 1 + expected_request = trace_pb2.Span( + name=name, + span_id=span_id, + display_name=display_name, + start_time=start_time, + end_time=end_time) + actual_request = channel.requests[0][1] + assert expected_request == actual_request + + def test_create_span_exception(self): + # Mock the API response + channel = ChannelStub(responses=[CustomException()]) + client = trace_v2.TraceServiceClient(channel=channel) + + # Setup request + name = client.span_path('[PROJECT]', '[TRACE]', '[SPAN]') + span_id = 'spanId-2011840976' + display_name = {} + start_time = {} + end_time = {} + + with pytest.raises(CustomException): + client.create_span(name, span_id, display_name, start_time, + end_time) diff --git a/trace/tests/unit/test__gax.py b/trace/tests/unit/test__gax.py index 736dc8f654a9..ae8e18d98f2e 100644 --- a/trace/tests/unit/test__gax.py +++ b/trace/tests/unit/test__gax.py @@ -41,8 +41,8 @@ def test_constructor(self): self.assertIs(api.client, client) def test_patch_traces(self): - from google.cloud.gapic.trace.v1 import trace_service_client - from google.cloud.proto.devtools.cloudtrace.v1.trace_pb2 import ( + from google.cloud.trace_v1.gapic import trace_service_client + from google.cloud.trace_v1.proto.trace_pb2 import ( TraceSpan, Trace, Traces) from google.cloud.trace._gax import _traces_mapping_to_pb from google.cloud._helpers import _datetime_to_pb_timestamp @@ -103,7 +103,7 @@ def test_patch_traces(self): self.assertIsInstance(span, TraceSpan) def test_get_trace(self): - from google.cloud.gapic.trace.v1 import trace_service_client + from google.cloud.trace_v1.gapic import trace_service_client trace_id = 'test_trace_id' @@ -159,8 +159,8 @@ def test_list_traces_no_paging(self): from google.cloud._helpers import _rfc3339_to_datetime from google.cloud._helpers import UTC from google.cloud._testing import _GAXPageIterator - from google.cloud.gapic.trace.v1 import trace_service_client - from google.cloud.gapic.trace.v1.enums import ListTracesRequest as Enum + from google.cloud.trace_v1.gapic import trace_service_client + from google.cloud.trace_v1.gapic.enums import ListTracesRequest as Enum from google.gax import INITIAL_PAGE trace_id = 'test_trace_id' @@ -236,8 +236,8 @@ def test_list_traces_with_paging(self): from google.cloud._helpers import _rfc3339_to_datetime from google.cloud._helpers import UTC from google.cloud._testing import _GAXPageIterator - from google.cloud.gapic.trace.v1 import trace_service_client - from google.cloud.gapic.trace.v1.enums import ListTracesRequest as Enum + from google.cloud.trace_v1.gapic import trace_service_client + from google.cloud.trace_v1.gapic.enums import ListTracesRequest as Enum trace_id = 'test_trace_id' span_id = 1234 @@ -320,7 +320,7 @@ def _call_fut(*args, **kwargs): return _parse_trace_pb(*args, **kwargs) def test_registered_type(self): - from google.cloud.proto.devtools.cloudtrace.v1.trace_pb2 import ( + from google.cloud.trace_v1.proto.trace_pb2 import ( TraceSpan, Trace) from google.protobuf.timestamp_pb2 import Timestamp @@ -388,42 +388,24 @@ def test_it(self): credentials = object() client = mock.Mock(_credentials=credentials, spec=['_credentials']) - channels = [] - channel_args = [] generated_api_kwargs = [] - channel_obj = object() generated = object() - def make_channel(*args): - channel_args.append(args) - return channel_obj - - def generated_api(channel=None, **kwargs): - channels.append(channel) + def generated_api(**kwargs): generated_api_kwargs.append(kwargs) return generated host = 'foo.apis.invalid' generated_api.SERVICE_ADDRESS = host - patch_channel = mock.patch( - 'google.cloud.trace._gax.make_secure_channel', - new=make_channel) - patch_api = mock.patch( 'google.cloud.trace._gax.trace_service_client.TraceServiceClient', new=generated_api) with patch_api: - with patch_channel: - trace_api = self._call_fut(client) - - self.assertEqual(channels, [channel_obj]) - self.assertEqual(channel_args, - [(credentials, DEFAULT_USER_AGENT, host)]) + trace_api = self._call_fut(client) self.assertEqual(len(generated_api_kwargs), 1) - self.assertEqual(generated_api_kwargs[0]['lib_name'], 'gccl') self.assertIsInstance(trace_api, _TraceAPI) self.assertIs(trace_api._gax_api, generated) diff --git a/trace/tests/unit/test_client.py b/trace/tests/unit/test_client.py index 2cf227ba34c8..407df1406089 100644 --- a/trace/tests/unit/test_client.py +++ b/trace/tests/unit/test_client.py @@ -188,7 +188,7 @@ def list_traces( def test_list_traces_explicit(self): from google.cloud._helpers import _datetime_to_pb_timestamp - from google.cloud.gapic.trace.v1.enums import ListTracesRequest as Enum + from google.cloud.trace_v1.gapic.enums import ListTracesRequest as Enum from google.cloud.trace._gax import _TraceAPI from datetime import datetime