diff --git a/trace/docs/conf.py b/trace/docs/conf.py new file mode 100644 index 000000000000..cd93635ce146 --- /dev/null +++ b/trace/docs/conf.py @@ -0,0 +1,310 @@ +# -*- coding: utf-8 -*- +# +# google-cloud-trace documentation build configuration file +# +# This file is execfile()d with the current directory set to its +# containing dir. +# +# Note that not all possible configuration values are present in this +# autogenerated file. +# +# All configuration values have a default; values that are commented out +# serve to show the default. + +import sys +import os +import shlex + +# If extensions (or modules to document with autodoc) are in another directory, +# add these directories to sys.path here. If the directory is relative to the +# documentation root, use os.path.abspath to make it absolute, like shown here. +sys.path.insert(0, os.path.abspath('..')) + +__version__ = '0.1.0' + +# -- General configuration ------------------------------------------------ + +# If your documentation needs a minimal Sphinx version, state it here. +#needs_sphinx = '1.0' + +# Add any Sphinx extension module names here, as strings. They can be +# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom +# ones. +extensions = [ + 'sphinx.ext.autodoc', + 'sphinx.ext.autosummary', + 'sphinx.ext.intersphinx', + 'sphinx.ext.coverage', + 'sphinx.ext.napoleon', + 'sphinx.ext.viewcode', +] + +# autodoc/autosummary flags +autoclass_content = 'both' +autodoc_default_flags = ['members'] +autosummary_generate = True + +# Add any paths that contain templates here, relative to this directory. +templates_path = ['_templates'] + +# The suffix(es) of source filenames. +# You can specify multiple suffix as a list of string: +# source_suffix = ['.rst', '.md'] +source_suffix = '.rst' + +# The encoding of source files. +#source_encoding = 'utf-8-sig' + +# The master toctree document. +master_doc = 'index' + +# General information about the project. +project = u'google-cloud-trace' +copyright = u'2017, Google' +author = u'Google APIs' + +# The version info for the project you're documenting, acts as replacement for +# |version| and |release|, also used in various other places throughout the +# built documents. +# +# The full version, including alpha/beta/rc tags. +release = __version__ +# The short X.Y version. +version = '.'.join(release.split('.')[0:2]) + +# The language for content autogenerated by Sphinx. Refer to documentation +# for a list of supported languages. +# +# This is also used if you do content translation via gettext catalogs. +# Usually you set "language" from the command line for these cases. +language = None + +# There are two options for replacing |today|: either, you set today to some +# non-false value, then it is used: +#today = '' +# Else, today_fmt is used as the format for a strftime call. +#today_fmt = '%B %d, %Y' + +# List of patterns, relative to source directory, that match files and +# directories to ignore when looking for source files. +exclude_patterns = ['_build'] + +# The reST default role (used for this markup: `text`) to use for all +# documents. +#default_role = None + +# If true, '()' will be appended to :func: etc. cross-reference text. +#add_function_parentheses = True + +# If true, the current module name will be prepended to all description +# unit titles (such as .. function::). +#add_module_names = True + +# If true, sectionauthor and moduleauthor directives will be shown in the +# output. They are ignored by default. +#show_authors = False + +# The name of the Pygments (syntax highlighting) style to use. +pygments_style = 'sphinx' + +# A list of ignored prefixes for module index sorting. +#modindex_common_prefix = [] + +# If true, keep warnings as "system message" paragraphs in the built documents. +#keep_warnings = False + +# If true, `todo` and `todoList` produce output, else they produce nothing. +todo_include_todos = True + +# -- Options for HTML output ---------------------------------------------- + +# The theme to use for HTML and HTML Help pages. See the documentation for +# a list of builtin themes. +html_theme = 'sphinx_rtd_theme' + +# Theme options are theme-specific and customize the look and feel of a theme +# further. For a list of options available for each theme, see the +# documentation. +#html_theme_options = {} + +# Add any paths that contain custom themes here, relative to this directory. +#html_theme_path = [] + +# The name for this set of Sphinx documents. If None, it defaults to +# " v documentation". +#html_title = None + +# A shorter title for the navigation bar. Default is the same as html_title. +#html_short_title = None + +# The name of an image file (relative to this directory) to place at the top +# of the sidebar. +#html_logo = None + +# The name of an image file (within the static path) to use as favicon of the +# docs. This file should be a Windows icon file (.ico) being 16x16 or 32x32 +# pixels large. +#html_favicon = None + +# Add any paths that contain custom static files (such as style sheets) here, +# relative to this directory. They are copied after the builtin static files, +# so a file named "default.css" will overwrite the builtin "default.css". +# html_static_path = [] + +# Add any extra paths that contain custom files (such as robots.txt or +# .htaccess) here, relative to this directory. These files are copied +# directly to the root of the documentation. +#html_extra_path = [] + +# If not '', a 'Last updated on:' timestamp is inserted at every page bottom, +# using the given strftime format. +#html_last_updated_fmt = '%b %d, %Y' + +# If true, SmartyPants will be used to convert quotes and dashes to +# typographically correct entities. +#html_use_smartypants = True + +# Custom sidebar templates, maps document names to template names. +#html_sidebars = {} + +# Additional templates that should be rendered to pages, maps page names to +# template names. +#html_additional_pages = {} + +# If false, no module index is generated. +#html_domain_indices = True + +# If false, no index is generated. +#html_use_index = True + +# If true, the index is split into individual pages for each letter. +#html_split_index = False + +# If true, links to the reST sources are added to the pages. +#html_show_sourcelink = True + +# If true, "Created using Sphinx" is shown in the HTML footer. Default is True. +#html_show_sphinx = True + +# If true, "(C) Copyright ..." is shown in the HTML footer. Default is True. +#html_show_copyright = True + +# If true, an OpenSearch description file will be output, and all pages will +# contain a tag referring to it. The value of this option must be the +# base URL from which the finished HTML is served. +#html_use_opensearch = '' + +# This is the file name suffix for HTML files (e.g. ".xhtml"). +#html_file_suffix = None + +# Language to be used for generating the HTML full-text search index. +# Sphinx supports the following languages: +# 'da', 'de', 'en', 'es', 'fi', 'fr', 'hu', 'it', 'ja' +# 'nl', 'no', 'pt', 'ro', 'ru', 'sv', 'tr' +#html_search_language = 'en' + +# A dictionary with options for the search language support, empty by default. +# Now only 'ja' uses this config value +#html_search_options = {'type': 'default'} + +# The name of a javascript file (relative to the configuration directory) that +# implements a search results scorer. If empty, the default will be used. +#html_search_scorer = 'scorer.js' + +# Output file base name for HTML help builder. +htmlhelp_basename = 'google-cloud-trace-doc' + +# -- Options for LaTeX output --------------------------------------------- + +latex_elements = { + # The paper size ('letterpaper' or 'a4paper'). + #'papersize': 'letterpaper', + + # The font size ('10pt', '11pt' or '12pt'). + #'pointsize': '10pt', + + # Additional stuff for the LaTeX preamble. + #'preamble': '', + + # Latex figure (float) alignment + #'figure_align': 'htbp', +} + +# Grouping the document tree into LaTeX files. List of tuples +# (source start file, target name, title, +# author, documentclass [howto, manual, or own class]). +latex_documents = [ + (master_doc, 'google-cloud-trace.tex', u'google-cloud-trace Documentation', + author, 'manual'), +] + +# The name of an image file (relative to this directory) to place at the top of +# the title page. +#latex_logo = None + +# For "manual" documents, if this is true, then toplevel headings are parts, +# not chapters. +#latex_use_parts = False + +# If true, show page references after internal links. +#latex_show_pagerefs = False + +# If true, show URL addresses after external links. +#latex_show_urls = False + +# Documents to append as an appendix to all manuals. +#latex_appendices = [] + +# If false, no module index is generated. +#latex_domain_indices = True + +# -- Options for manual page output --------------------------------------- + +# One entry per manual page. List of tuples +# (source start file, name, description, authors, manual section). +man_pages = [(master_doc, 'google-cloud-trace', + u'google-cloud-trace Documentation', [author], 1)] + +# If true, show URL addresses after external links. +#man_show_urls = False + +# -- Options for Texinfo output ------------------------------------------- + +# Grouping the document tree into Texinfo files. List of tuples +# (source start file, target name, title, author, +# dir menu entry, description, category) +texinfo_documents = [ + (master_doc, 'google-cloud-trace', u'google-cloud-trace Documentation', + author, 'google-cloud-trace', + 'GAPIC library for the {metadata.shortName} v2 service', 'APIs'), +] + +# Documents to append as an appendix to all manuals. +#texinfo_appendices = [] + +# If false, no module index is generated. +#texinfo_domain_indices = True + +# How to display URL addresses: 'footnote', 'no', or 'inline'. +#texinfo_show_urls = 'footnote' + +# If true, do not generate a @detailmenu in the "Top" node's menu. +#texinfo_no_detailmenu = False + +# Example configuration for intersphinx: refer to the Python standard library. +intersphinx_mapping = { + 'python': ('http://python.readthedocs.org/en/latest/', None), + 'gax': ('https://gax-python.readthedocs.org/en/latest/', None), +} + +# Napoleon settings +napoleon_google_docstring = True +napoleon_numpy_docstring = True +napoleon_include_private_with_doc = False +napoleon_include_special_with_doc = True +napoleon_use_admonition_for_examples = False +napoleon_use_admonition_for_notes = False +napoleon_use_admonition_for_references = False +napoleon_use_ivar = False +napoleon_use_param = True +napoleon_use_rtype = True diff --git a/trace/docs/gapic/v1/api.rst b/trace/docs/gapic/v1/api.rst new file mode 100644 index 000000000000..2de320c95966 --- /dev/null +++ b/trace/docs/gapic/v1/api.rst @@ -0,0 +1,6 @@ +Client for Stackdriver Trace API +================================ + +.. automodule:: google.cloud.trace_v1 + :members: + :inherited-members: \ No newline at end of file diff --git a/trace/docs/gapic/v1/types.rst b/trace/docs/gapic/v1/types.rst new file mode 100644 index 000000000000..e2c1a9b972b5 --- /dev/null +++ b/trace/docs/gapic/v1/types.rst @@ -0,0 +1,5 @@ +Types for Stackdriver Trace API Client +====================================== + +.. automodule:: google.cloud.trace_v1.types + :members: \ No newline at end of file diff --git a/trace/docs/gapic/v2/api.rst b/trace/docs/gapic/v2/api.rst new file mode 100644 index 000000000000..48f0d58d6308 --- /dev/null +++ b/trace/docs/gapic/v2/api.rst @@ -0,0 +1,6 @@ +Client for Stackdriver Trace API +================================ + +.. automodule:: google.cloud.trace_v2 + :members: + :inherited-members: \ No newline at end of file diff --git a/trace/docs/gapic/v2/types.rst b/trace/docs/gapic/v2/types.rst new file mode 100644 index 000000000000..071d7a5ad279 --- /dev/null +++ b/trace/docs/gapic/v2/types.rst @@ -0,0 +1,5 @@ +Types for Stackdriver Trace API Client +====================================== + +.. automodule:: google.cloud.trace_v2.types + :members: \ No newline at end of file diff --git a/trace/docs/index.rst b/trace/docs/index.rst new file mode 100644 index 000000000000..a5bd8bc1fc95 --- /dev/null +++ b/trace/docs/index.rst @@ -0,0 +1,102 @@ +Python Client for Stackdriver Trace API (`Alpha`_) +================================================== + +`Stackdriver Trace API`_: Sends application trace data to Stackdriver Trace for viewing. Trace data is +collected for all App Engine applications by default. Trace data from other +applications can be provided using this API. + +- `Client Library Documentation`_ +- `Product Documentation`_ + +.. _Alpha: https://github.com/GoogleCloudPlatform/google-cloud-python/blob/master/README.rst +.. _Stackdriver Trace API: https://cloud.google.com/trace +.. _Client Library Documentation: https://googlecloudplatform.github.io/google-cloud-python/stable/trace/usage.html +.. _Product Documentation: https://cloud.google.com/trace + +Quick Start +----------- + +In order to use this library, you first need to go through the following steps: + +1. `Select or create a Cloud Platform project.`_ +2. `Enable billing for your project.`_ +3. `Enable the Stackdriver Trace API.`_ +4. `Setup Authentication.`_ + +.. _Select or create a Cloud Platform project.: https://console.cloud.google.com/project +.. _Enable billing for your project.: https://cloud.google.com/billing/docs/how-to/modify-project#enable_billing_for_a_project +.. _Enable the Stackdriver Trace API.: https://cloud.google.com/trace +.. _Setup Authentication.: https://googlecloudplatform.github.io/google-cloud-python/stable/core/auth.html + +Installation +~~~~~~~~~~~~ + +Install this library in a `virtualenv`_ using pip. `virtualenv`_ is a tool to +create isolated Python environments. The basic problem it addresses is one of +dependencies and versions, and indirectly permissions. + +With `virtualenv`_, it's possible to install this library without needing system +install permissions, and without clashing with the installed system +dependencies. + +.. _`virtualenv`: https://virtualenv.pypa.io/en/latest/ + + +Mac/Linux +^^^^^^^^^ + +.. code-block:: console + + pip install virtualenv + virtualenv + source /bin/activate + /bin/pip install google-cloud-trace + + +Windows +^^^^^^^ + +.. code-block:: console + + pip install virtualenv + virtualenv + \Scripts\activate + \Scripts\pip.exe install google-cloud-trace + +Preview +~~~~~~~ + +TraceServiceClient +^^^^^^^^^^^^^^^^^^ + +.. code:: py + + from google.cloud import trace_v2 + + client = trace_v2.TraceServiceClient() + + name = client.project_path('[PROJECT]') + spans = [] + + client.batch_write_spans(name, spans) + +Next Steps +~~~~~~~~~~ + +- Read the `Client Library Documentation`_ for Stackdriver Trace API + API to see other available methods on the client. +- Read the `Stackdriver Trace API Product documentation`_ to learn + more about the product and see How-to Guides. +- View this `repository’s main README`_ to see the full list of Cloud + APIs that we cover. + +.. _Stackdriver Trace API Product documentation: https://cloud.google.com/trace +.. _repository’s main README: https://github.com/GoogleCloudPlatform/google-cloud-python/blob/master/README.rst + +Api Reference +------------- +.. toctree:: + :maxdepth: 2 + + gapic/v2/api + gapic/v2/types \ No newline at end of file diff --git a/trace/google/cloud/trace/_gax.py b/trace/google/cloud/trace/_gapic.py similarity index 96% rename from trace/google/cloud/trace/_gax.py rename to trace/google/cloud/trace/_gapic.py index 531700c843c5..a0933240ea97 100644 --- a/trace/google/cloud/trace/_gax.py +++ b/trace/google/cloud/trace/_gapic.py @@ -12,7 +12,7 @@ # See the License for the specific language governing permissions and # limitations under the License. -"""GAX Wrapper for interacting with the Stackdriver Trace API.""" +"""Wrapper for interacting with the Stackdriver Trace API.""" from google.api_core.gapic_v1 import method from google.cloud._helpers import _datetime_to_pb_timestamp @@ -33,16 +33,15 @@ class _TraceAPI(object): cloudtrace.v2 Args: - gax_api (~google.cloud.trace_v2.gapic.trace_service_client. - TraceServiceClient): Required. API object used to make GAX - requests. + gapic (~google.cloud.trace_v2.gapic.trace_service_client. + TraceServiceClient): Required. API object used to make RPCs. client (~google.cloud.trace_v2.client.Client): Required. The client that owns this API object. """ - def __init__(self, gax_api, client): - self._gax_api = gax_api + def __init__(self, gapic_api, client): + self._gapic_api = gapic_api self.client = client def batch_write_spans(self, @@ -84,7 +83,7 @@ def batch_write_spans(self, span_pb = _dict_mapping_to_pb(span_mapping, 'Span') spans_pb_list.append(span_pb) - self._gax_api.batch_write_spans( + self._gapic_api.batch_write_spans( name=name, spans=spans_pb_list, retry=retry, @@ -225,7 +224,7 @@ def create_span(self, child_span_count = _value_to_pb( child_span_count, 'Int32Value') - return self._gax_api.create_span( + return self._gapic_api.create_span( name=name, span_id=span_id, display_name=display_name, @@ -305,16 +304,16 @@ def _value_to_pb(value, proto_type): return data_type_pb -def make_gax_trace_api(client): +def make_trace_api(client): """ - Create an instance of the GAX Trace API. + Create an instance of the gapic Trace API. Args: client (:class:`~google.cloud.trace_v2.client.Client`): The client that holds configuration details. Returns: - A :class:`~google.cloud.trace_v2._gax._TraceAPI` instance with the + A :class:`~google.cloud.trace_v2._gapic._TraceAPI` instance with the proper configurations. """ generated = trace_service_client.TraceServiceClient() diff --git a/trace/google/cloud/trace/client.py b/trace/google/cloud/trace/client.py index 4cf3014c6201..b2fa39450bf8 100644 --- a/trace/google/cloud/trace/client.py +++ b/trace/google/cloud/trace/client.py @@ -14,7 +14,7 @@ """Client for interacting with the Stackdriver Trace API.""" -from google.cloud.trace._gax import make_gax_trace_api +from google.cloud.trace._gapic import make_trace_api from google.cloud.client import ClientWithProject @@ -49,7 +49,7 @@ def trace_api(self): https://cloud.google.com/trace/docs/reference/v2/rpc/google.devtools. cloudtrace.v2 """ - self._trace_api = make_gax_trace_api(self) + self._trace_api = make_trace_api(self) return self._trace_api def batch_write_spans(self, diff --git a/trace/google/cloud/trace/v1/_gax.py b/trace/google/cloud/trace/v1/_gapic.py similarity index 77% rename from trace/google/cloud/trace/v1/_gax.py rename to trace/google/cloud/trace/v1/_gapic.py index fbbafbf79ffe..d4b7179b4024 100644 --- a/trace/google/cloud/trace/v1/_gax.py +++ b/trace/google/cloud/trace/v1/_gapic.py @@ -12,13 +12,10 @@ # See the License for the specific language governing permissions and # limitations under the License. -"""GAX Wrapper for interacting with the Stackdriver Trace API.""" +"""Wrapper for interacting with the Stackdriver Trace API.""" -from google.api_core import page_iterator 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.protobuf.json_format import MessageToDict from google.protobuf.json_format import ParseDict @@ -32,50 +29,40 @@ class _TraceAPI(object): cloudtrace.v1 Args: - gax_api (~google.cloud.trace_v1.gapic.trace_service_client. - TraceServiceClient): Required. API object used to make GAX - requests. - + gapic_api (~google.cloud.trace_v1.gapic.trace_service_client. + TraceServiceClient): Required. API object used to make RPCs. client (~google.cloud.trace.client.Client): The client that owns this API object. """ - def __init__(self, gax_api, client): - self._gax_api = gax_api + def __init__(self, gapic_api, client): + self._gapic_api = gapic_api self.client = client - def patch_traces(self, project_id, traces, options=None): + def patch_traces(self, project_id, traces): """ Sends new traces to Stackdriver Trace or updates existing traces. Args: project_id (Optional[str]): ID of the Cloud project where the trace data is stored. - traces (dict): Required. The traces to be patched in the API call. - - options (Optional[~google.gax.CallOptions]): Overrides the default - settings for this call, e.g, timeout, retries etc. """ traces_pb = _traces_mapping_to_pb(traces) - self._gax_api.patch_traces(project_id, traces_pb, options) + self._gapic_api.patch_traces(project_id, traces_pb) - def get_trace(self, project_id, trace_id, options=None): + def get_trace(self, project_id, trace_id): """ Gets a single trace by its ID. Args: trace_id (str): ID of the trace to return. - project_id (str): Required. ID of the Cloud project where the trace data is stored. - options (Optional[~google.gax.CallOptions]): Overrides the default - settings for this call, e.g, timeout, retries etc. - Returns: A Trace dict. """ - trace_pb = self._gax_api.get_trace(project_id, trace_id, options) + trace_pb = self._gapic_api.get_trace(project_id, trace_id) trace_mapping = _parse_trace_pb(trace_pb) return trace_mapping @@ -125,21 +112,17 @@ def list_traces( A :class:`~google.api_core.page_iterator.Iterator` of traces that match the specified filter conditions. """ - if page_token is None: - page_token = INITIAL_PAGE - options = CallOptions(page_token=page_token) - page_iter = self._gax_api.list_traces( + page_iter = self._gapic_api.list_traces( project_id=project_id, view=view, page_size=page_size, start_time=start_time, end_time=end_time, filter_=filter_, - order_by=order_by, - options=options) - item_to_value = _item_to_mapping - return page_iterator._GAXIterator( - self.client, page_iter, item_to_value) + order_by=order_by) + page_iter._item_to_value = _item_to_mapping + page_iter.next_page_token = page_token + return page_iter def _parse_trace_pb(trace_pb): @@ -161,7 +144,7 @@ def _parse_trace_pb(trace_pb): def _item_to_mapping(iterator, trace_pb): """ - Helper callable function for the GAXIterator + Helper callable function for the page iterator Args: iterator(~google.api_core.page_iterator.Iterator): The iterator that is @@ -174,17 +157,17 @@ def _item_to_mapping(iterator, trace_pb): return mapping -def make_gax_trace_api(client): +def make_trace_api(client): """ - Create an instance of the GAX Trace API. + Create an instance of the gapic Trace API. Args: client (~google.cloud.trace.client.Client): The client that holds configuration details. Returns: - A :class:`~google.cloud.trace._gax._TraceAPI` instance with the proper - configurations. + A :class:`~google.cloud.trace._gapic._TraceAPI` instance with the + proper configurations. """ generated = trace_service_client.TraceServiceClient() return _TraceAPI(generated, client) diff --git a/trace/google/cloud/trace/v1/client.py b/trace/google/cloud/trace/v1/client.py index bb668d4897c2..43b406c8793f 100644 --- a/trace/google/cloud/trace/v1/client.py +++ b/trace/google/cloud/trace/v1/client.py @@ -14,7 +14,7 @@ """Client for interacting with the Stackdriver Trace API.""" -from google.cloud.trace.v1._gax import make_gax_trace_api +from google.cloud.trace.v1._gapic import make_trace_api from google.cloud.client import ClientWithProject from google.cloud._helpers import _datetime_to_pb_timestamp @@ -51,10 +51,10 @@ def trace_api(self): https://cloud.google.com/trace/docs/reference/v1/rpc/google.devtools. cloudtrace.v1 """ - self._trace_api = make_gax_trace_api(self) + self._trace_api = make_trace_api(self) return self._trace_api - def patch_traces(self, traces, project_id=None, options=None): + def patch_traces(self, traces, project_id=None): """Sends new traces to Stackdriver Trace or updates existing traces. Args: @@ -62,19 +62,15 @@ def patch_traces(self, traces, project_id=None, options=None): project_id (Optional[str]): ID of the Cloud project where the trace data is stored. - - options (Optional[~google.gax.CallOptions]): Overrides the default - settings for this call, e.g, timeout, retries etc. """ if project_id is None: project_id = self.project self.trace_api.patch_traces( project_id=project_id, - traces=traces, - options=options) + traces=traces) - def get_trace(self, trace_id, project_id=None, options=None): + def get_trace(self, trace_id, project_id=None): """ Gets a single trace by its ID. @@ -84,9 +80,6 @@ def get_trace(self, trace_id, project_id=None, options=None): project_id (str): Required. ID of the Cloud project where the trace data is stored. - options (Optional[~google.gax.CallOptions]): Overrides the default - settings for this call, e.g, timeout, retries etc. - Returns: A Trace dict. """ @@ -95,8 +88,7 @@ def get_trace(self, trace_id, project_id=None, options=None): return self.trace_api.get_trace( project_id=project_id, - trace_id=trace_id, - options=options) + trace_id=trace_id) def list_traces( self, diff --git a/trace/google/cloud/trace_v1/__init__.py b/trace/google/cloud/trace_v1/__init__.py index f6df7d72495b..6a56286c926a 100644 --- a/trace/google/cloud/trace_v1/__init__.py +++ b/trace/google/cloud/trace_v1/__init__.py @@ -1,10 +1,10 @@ -# Copyright 2017, Google LLC All rights reserved. +# Copyright 2018 Google LLC # # 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 +# https://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, @@ -27,4 +27,5 @@ class TraceServiceClient(trace_service_client.TraceServiceClient): __all__ = ( 'enums', 'types', - 'TraceServiceClient', ) + 'TraceServiceClient', +) diff --git a/trace/google/cloud/trace_v1/gapic/enums.py b/trace/google/cloud/trace_v1/gapic/enums.py index 72b374960d7a..e8fc36fdd5c7 100644 --- a/trace/google/cloud/trace_v1/gapic/enums.py +++ b/trace/google/cloud/trace_v1/gapic/enums.py @@ -1,10 +1,10 @@ -# Copyright 2017, Google LLC All rights reserved. +# Copyright 2018 Google LLC # # 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 +# https://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, diff --git a/trace/google/cloud/trace_v1/gapic/trace_service_client.py b/trace/google/cloud/trace_v1/gapic/trace_service_client.py index 06026ad93561..14088633c570 100644 --- a/trace/google/cloud/trace_v1/gapic/trace_service_client.py +++ b/trace/google/cloud/trace_v1/gapic/trace_service_client.py @@ -1,25 +1,16 @@ -# Copyright 2017, Google LLC All rights reserved. +# Copyright 2018 Google LLC # # 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 +# https://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 @@ -57,11 +48,12 @@ class TraceServiceClient(object): _DEFAULT_SCOPES = ( 'https://www.googleapis.com/auth/cloud-platform', 'https://www.googleapis.com/auth/trace.append', - 'https://www.googleapis.com/auth/trace.readonly', ) + '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') + # method configuration in the client_config dictionary. + _INTERFACE_NAME = 'google.devtools.cloudtrace.v1.TraceService' def __init__(self, channel=None, @@ -72,68 +64,81 @@ def __init__(self, Args: channel (grpc.Channel): A ``Channel`` instance through - which to make calls. If specified, then the ``credentials`` - argument is ignored. + which to make calls. This argument is mutually exclusive + with ``credentials``; providing both will raise an exception. 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_config (dict): A dictionary of call options for each + method. If not specified, the default configuration is used. 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 both `channel` and `credentials` are specified, raise an + # exception (channels come with credentials baked in already). if channel is not None and credentials is not None: raise ValueError( - 'channel and credentials arguments to {} are mutually ' - 'exclusive.'.format(self.__class__.__name__)) + 'The `channel` and `credentials` arguments to {} are mutually ' + 'exclusive.'.format(self.__class__.__name__), ) + # Create the channel. if channel is None: channel = google.api_core.grpc_helpers.create_channel( self.SERVICE_ADDRESS, credentials=credentials, - scopes=self._DEFAULT_SCOPES) + scopes=self._DEFAULT_SCOPES, + ) + # Create the gRPC stubs. 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] + # Parse out the default settings for retry and timeout for each RPC + # from the client configuration. + # (Ordinarily, these are the defaults specified in the `*_config.py` + # file next to this one.) method_configs = google.api_core.gapic_v1.config.parse_method_configs( - interface_config) + client_config['interfaces'][self._INTERFACE_NAME], ) + # Write the "inner API call" methods to the class. + # These are wrapped versions of the gRPC stub methods, with retry and + # timeout configuration applied, called by the public methods on + # this class. 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) + 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) + 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) + 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): + timeout=google.api_core.gapic_v1.method.DEFAULT, + metadata=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 @@ -162,6 +167,8 @@ def patch_traces(self, 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. + metadata (Optional[Sequence[Tuple[str, str]]]): Additional metadata + that is provided to the method. Raises: google.api_core.exceptions.GoogleAPICallError: If the request @@ -170,15 +177,22 @@ def patch_traces(self, to a retryable error and retry attempts failed. ValueError: If the parameters are invalid. """ + if metadata is None: + metadata = [] + metadata = list(metadata) request = trace_pb2.PatchTracesRequest( - project_id=project_id, traces=traces) - self._patch_traces(request, retry=retry, timeout=timeout) + project_id=project_id, + traces=traces, + ) + self._patch_traces( + request, retry=retry, timeout=timeout, metadata=metadata) def get_trace(self, project_id, trace_id, retry=google.api_core.gapic_v1.method.DEFAULT, - timeout=google.api_core.gapic_v1.method.DEFAULT): + timeout=google.api_core.gapic_v1.method.DEFAULT, + metadata=None): """ Gets a single trace by its ID. @@ -201,6 +215,8 @@ def get_trace(self, 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. + metadata (Optional[Sequence[Tuple[str, str]]]): Additional metadata + that is provided to the method. Returns: A :class:`~google.cloud.trace_v1.types.Trace` instance. @@ -212,9 +228,15 @@ def get_trace(self, to a retryable error and retry attempts failed. ValueError: If the parameters are invalid. """ + if metadata is None: + metadata = [] + metadata = list(metadata) request = trace_pb2.GetTraceRequest( - project_id=project_id, trace_id=trace_id) - return self._get_trace(request, retry=retry, timeout=timeout) + project_id=project_id, + trace_id=trace_id, + ) + return self._get_trace( + request, retry=retry, timeout=timeout, metadata=metadata) def list_traces(self, project_id, @@ -225,7 +247,8 @@ def list_traces(self, filter_=None, order_by=None, retry=google.api_core.gapic_v1.method.DEFAULT, - timeout=google.api_core.gapic_v1.method.DEFAULT): + timeout=google.api_core.gapic_v1.method.DEFAULT, + metadata=None): """ Returns of a list of traces that match the specified filter conditions. @@ -330,6 +353,8 @@ def list_traces(self, 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. + metadata (Optional[Sequence[Tuple[str, str]]]): Additional metadata + that is provided to the method. Returns: A :class:`~google.gax.PageIterator` instance. By default, this @@ -344,6 +369,9 @@ def list_traces(self, to a retryable error and retry attempts failed. ValueError: If the parameters are invalid. """ + if metadata is None: + metadata = [] + metadata = list(metadata) request = trace_pb2.ListTracesRequest( project_id=project_id, view=view, @@ -351,13 +379,18 @@ def list_traces(self, start_time=start_time, end_time=end_time, filter=filter_, - order_by=order_by) + order_by=order_by, + ) iterator = google.api_core.page_iterator.GRPCIterator( client=None, method=functools.partial( - self._list_traces, retry=retry, timeout=timeout), + self._list_traces, + retry=retry, + timeout=timeout, + metadata=metadata), request=request, items_field='traces', request_token_field='page_token', - response_token_field='next_page_token') + response_token_field='next_page_token', + ) return iterator diff --git a/trace/google/cloud/trace_v1/proto/trace_pb2.py b/trace/google/cloud/trace_v1/proto/trace_pb2.py index a4a61928cade..552c25a0d7ad 100644 --- a/trace/google/cloud/trace_v1/proto/trace_pb2.py +++ b/trace/google/cloud/trace_v1/proto/trace_pb2.py @@ -22,9 +22,10 @@ name='google/devtools/cloudtrace_v1/proto/trace.proto', package='google.devtools.cloudtrace.v1', syntax='proto3', - 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') + 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\xaa\x01\n!com.google.devtools.cloudtrace.v1B\nTraceProtoP\x01ZGgoogle.golang.org/genproto/googleapis/devtools/cloudtrace/v1;cloudtrace\xaa\x02\x15Google.Cloud.Trace.V1\xca\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) @@ -487,7 +488,6 @@ 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, @@ -718,7 +718,7 @@ DESCRIPTOR.has_options = True -DESCRIPTOR._options = _descriptor._ParseOptions(descriptor_pb2.FileOptions(), _b('\n!com.google.devtools.cloudtrace.v1B\nTraceProtoP\001ZGgoogle.golang.org/genproto/googleapis/devtools/cloudtrace/v1;cloudtrace\252\002\025Google.Cloud.Trace.V1')) +DESCRIPTOR._options = _descriptor._ParseOptions(descriptor_pb2.FileOptions(), _b('\n!com.google.devtools.cloudtrace.v1B\nTraceProtoP\001ZGgoogle.golang.org/genproto/googleapis/devtools/cloudtrace/v1;cloudtrace\252\002\025Google.Cloud.Trace.V1\312\002\025Google\\Cloud\\Trace\\V1')) _TRACESPAN_LABELSENTRY.has_options = True _TRACESPAN_LABELSENTRY._options = _descriptor._ParseOptions(descriptor_pb2.MessageOptions(), _b('8\001')) try: diff --git a/trace/google/cloud/trace_v1/proto/trace_pb2_grpc.py b/trace/google/cloud/trace_v1/proto/trace_pb2_grpc.py index cfffb915f550..23b408dea77f 100644 --- a/trace/google/cloud/trace_v1/proto/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 -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 +import google.devtools.cloudtrace_v1.proto.trace_pb2 as google_dot_devtools_dot_cloudtrace__v1_dot_proto_dot_trace__pb2 +import google.protobuf.empty_pb2 as google_dot_protobuf_dot_empty__pb2 class TraceServiceStub(object): diff --git a/trace/google/cloud/trace_v1/types.py b/trace/google/cloud/trace_v1/types.py index a013582829dd..49c585823c5a 100644 --- a/trace/google/cloud/trace_v1/types.py +++ b/trace/google/cloud/trace_v1/types.py @@ -1,10 +1,10 @@ -# Copyright 2017, Google LLC All rights reserved. +# Copyright 2018 Google LLC # # 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 +# https://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, @@ -29,7 +29,8 @@ trace_pb2, descriptor_pb2, empty_pb2, - timestamp_pb2, ): + timestamp_pb2, +): for name, message in get_messages(module).items(): message.__module__ = 'google.cloud.trace_v1.types' setattr(sys.modules[__name__], name, message) diff --git a/trace/google/cloud/trace_v2/__init__.py b/trace/google/cloud/trace_v2/__init__.py index 2adf1e60ad9e..a4de34e0d002 100644 --- a/trace/google/cloud/trace_v2/__init__.py +++ b/trace/google/cloud/trace_v2/__init__.py @@ -1,10 +1,10 @@ -# Copyright 2017, Google LLC All rights reserved. +# Copyright 2018 Google LLC # # 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 +# https://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, @@ -27,4 +27,5 @@ class TraceServiceClient(trace_service_client.TraceServiceClient): __all__ = ( 'enums', 'types', - 'TraceServiceClient',) + 'TraceServiceClient', +) diff --git a/trace/google/cloud/trace_v2/gapic/enums.py b/trace/google/cloud/trace_v2/gapic/enums.py index bc2ee7fbe601..e9b3e633feb5 100644 --- a/trace/google/cloud/trace_v2/gapic/enums.py +++ b/trace/google/cloud/trace_v2/gapic/enums.py @@ -1,10 +1,10 @@ -# Copyright 2017, Google LLC All rights reserved. +# Copyright 2018 Google LLC # # 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 +# https://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, diff --git a/trace/google/cloud/trace_v2/gapic/trace_service_client.py b/trace/google/cloud/trace_v2/gapic/trace_service_client.py index cbebd9063dce..7d5e5ad40c5f 100644 --- a/trace/google/cloud/trace_v2/gapic/trace_service_client.py +++ b/trace/google/cloud/trace_v2/gapic/trace_service_client.py @@ -1,25 +1,16 @@ -# Copyright 2017, Google LLC All rights reserved. +# Copyright 2018 Google LLC # # 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 +# https://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 @@ -58,27 +49,30 @@ class TraceServiceClient(object): # this service _DEFAULT_SCOPES = ( 'https://www.googleapis.com/auth/cloud-platform', - 'https://www.googleapis.com/auth/trace.append', ) + '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') + # 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 a fully-qualified project string.""" return google.api_core.path_template.expand( 'projects/{project}', - project=project, ) + project=project, + ) @classmethod def span_path(cls, project, trace, span): - """Returns a fully-qualified span resource name string.""" + """Return a fully-qualified span string.""" return google.api_core.path_template.expand( 'projects/{project}/traces/{trace}/spans/{span}', project=project, trace=trace, - span=span, ) + span=span, + ) def __init__(self, channel=None, @@ -89,69 +83,78 @@ def __init__(self, Args: channel (grpc.Channel): A ``Channel`` instance through - which to make calls. If specified, then the ``credentials`` - argument is ignored. + which to make calls. This argument is mutually exclusive + with ``credentials``; providing both will raise an exception. 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_config (dict): A dictionary of call options for each + method. If not specified, the default configuration is used. 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 both `channel` and `credentials` are specified, raise an + # exception (channels come with credentials baked in already). if channel is not None and credentials is not None: raise ValueError( - 'channel and credentials arguments to {} are mutually ' - 'exclusive.'.format(self.__class__.__name__)) + 'The `channel` and `credentials` arguments to {} are mutually ' + 'exclusive.'.format(self.__class__.__name__), ) + # Create the channel. if channel is None: channel = google.api_core.grpc_helpers.create_channel( self.SERVICE_ADDRESS, credentials=credentials, - scopes=self._DEFAULT_SCOPES) + scopes=self._DEFAULT_SCOPES, + ) + # Create the gRPC stubs. 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] + # Parse out the default settings for retry and timeout for each RPC + # from the client configuration. + # (Ordinarily, these are the defaults specified in the `*_config.py` + # file next to this one.) method_configs = google.api_core.gapic_v1.config.parse_method_configs( - interface_config) + client_config['interfaces'][self._INTERFACE_NAME], ) + # Write the "inner API call" methods to the class. + # These are wrapped versions of the gRPC stub methods, with retry and + # timeout configuration applied, called by the public methods on + # this class. 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) + 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) + 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): + timeout=google.api_core.gapic_v1.method.DEFAULT, + metadata=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. + Sends new spans to new or existing traces. You cannot update + existing spans. Example: >>> from google.cloud import trace_v2 @@ -164,9 +167,10 @@ def batch_write_spans(self, >>> 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. + name (str): Required. The 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 list of new spans. The span names must not match existing + spans, or the results are undefined. 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 @@ -175,6 +179,8 @@ def batch_write_spans(self, 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. + metadata (Optional[Sequence[Tuple[str, str]]]): Additional metadata + that is provided to the method. Raises: google.api_core.exceptions.GoogleAPICallError: If the request @@ -183,8 +189,15 @@ def batch_write_spans(self, 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) + if metadata is None: + metadata = [] + metadata = list(metadata) + request = tracing_pb2.BatchWriteSpansRequest( + name=name, + spans=spans, + ) + self._batch_write_spans( + request, retry=retry, timeout=timeout, metadata=metadata) def create_span(self, name, @@ -201,9 +214,10 @@ def create_span(self, 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): + timeout=google.api_core.gapic_v1.method.DEFAULT, + metadata=None): """ - Creates a new Span. + Creates a new span. Example: >>> from google.cloud import trace_v2 @@ -225,11 +239,12 @@ def create_span(self, 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. + [TRACE_ID] is a unique identifier for a trace within a project; + it is a 32-character hexadecimal encoding of a 16-byte array. + + [SPAN_ID] is a unique identifier for a span within a trace; it + is a 16-character hexadecimal encoding of an 8-byte array. 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 %}. @@ -251,26 +266,27 @@ def create_span(self, 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 + attributes (Union[dict, ~google.cloud.trace_v2.types.Attributes]): A set of attributes on the span. You can have up to 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 + time_events (Union[dict, ~google.cloud.trace_v2.types.TimeEvents]): A set of time events. You can have 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. + links (Union[dict, ~google.cloud.trace_v2.types.Links]): Links associated with the span. You can have up to 128 links 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. + same_process_as_parent_span (Union[dict, ~google.cloud.trace_v2.types.BoolValue]): (Optional) Set this parameter to indicate whether this span is in + the same process as its parent. If you do not set this parameter, + Stackdriver Trace is unable to take advantage of this helpful + information. 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 @@ -283,6 +299,8 @@ def create_span(self, 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. + metadata (Optional[Sequence[Tuple[str, str]]]): Additional metadata + that is provided to the method. Returns: A :class:`~google.cloud.trace_v2.types.Span` instance. @@ -294,6 +312,9 @@ def create_span(self, to a retryable error and retry attempts failed. ValueError: If the parameters are invalid. """ + if metadata is None: + metadata = [] + metadata = list(metadata) request = trace_pb2.Span( name=name, span_id=span_id, @@ -307,5 +328,7 @@ def create_span(self, 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) + child_span_count=child_span_count, + ) + return self._create_span( + request, retry=retry, timeout=timeout, metadata=metadata) diff --git a/trace/google/cloud/trace_v2/proto/trace_pb2.py b/trace/google/cloud/trace_v2/proto/trace_pb2.py index dd64c42d0d3d..001b5624ce33 100644 --- a/trace/google/cloud/trace_v2/proto/trace_pb2.py +++ b/trace/google/cloud/trace_v2/proto/trace_pb2.py @@ -24,9 +24,10 @@ 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') + 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\xaa\x01\n!com.google.devtools.cloudtrace.v2B\nTraceProtoP\x01ZGgoogle.golang.org/genproto/googleapis/devtools/cloudtrace/v2;cloudtrace\xaa\x02\x15Google.Cloud.Trace.V2\xca\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,]) +_sym_db.RegisterFileDescriptor(DESCRIPTOR) @@ -875,7 +876,6 @@ 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( @@ -925,7 +925,7 @@ 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 + A set of attributes on the annotation. You can have up to 4 attributes per Annotation. """, # @@protoc_insertion_point(class_scope:google.devtools.cloudtrace.v2.Span.TimeEvent.Annotation) @@ -1013,14 +1013,14 @@ Attributes: trace_id: - ``TRACE_ID`` identifies a trace within a project. + The [TRACE\_ID] for a trace within a project. span_id: - ``SPAN_ID`` identifies a span within a trace. + The [SPAN\_ID] for 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 + A set of attributes on the link. You have have up to 32 attributes per link. """, # @@protoc_insertion_point(class_scope:google.devtools.cloudtrace.v2.Span.Link) @@ -1061,11 +1061,12 @@ 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. + project; it is a 32-character hexadecimal encoding of a + 16-byte array. [SPAN\_ID] is a unique identifier for a span + within a trace; it is a 16-character hexadecimal encoding of + an 8-byte array. 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. + The [SPAN\_ID] portion of the span's resource name. parent_span_id: The [SPAN\_ID] of this span's parent span. If this is a root span, then this field must be empty. @@ -1089,21 +1090,23 @@ 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 + A set of attributes on the span. You can have up to 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. + A set of time events. You can have up to 32 annotations and + 128 message events per span. links: - A maximum of 128 links are allowed per Span. + Links associated with the span. You can have up to 128 links + 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. + (Optional) Set this parameter to indicate whether this span is + in the same process as its parent. If you do not set this + parameter, Stackdriver Trace is unable to take advantage of + this helpful information. child_span_count: An optional number of child spans that were generated while this span was active. If set, allows implementation to detect @@ -1249,13 +1252,12 @@ 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. + The shortened string. For example, if the original string is + 500 bytes long and the limit of the string is 128 bytes, then + ``value`` contains the first 128 bytes of the 500-byte string. + Truncation always happens on a UTF8 character boundary. If + there are multi-byte characters in the string, then the length + of the shortened string might be less than the size limit. truncated_byte_count: The number of bytes removed from the original string. If this value is 0, then the string was not shortened. @@ -1266,7 +1268,7 @@ 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')) +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\312\002\025Google\\Cloud\\Trace\\V2')) _SPAN_ATTRIBUTES_ATTRIBUTEMAPENTRY.has_options = True _SPAN_ATTRIBUTES_ATTRIBUTEMAPENTRY._options = _descriptor._ParseOptions(descriptor_pb2.MessageOptions(), _b('8\001')) try: diff --git a/trace/google/cloud/trace_v2/proto/tracing_pb2.py b/trace/google/cloud/trace_v2/proto/tracing_pb2.py index b0db2d6b2fe5..6b7789c73e26 100644 --- a/trace/google/cloud/trace_v2/proto/tracing_pb2.py +++ b/trace/google/cloud/trace_v2/proto/tracing_pb2.py @@ -23,9 +23,10 @@ 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') + 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\xaf\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\x87\x01\n\nCreateSpan\x12#.google.devtools.cloudtrace.v2.Span\x1a#.google.devtools.cloudtrace.v2.Span\"/\x82\xd3\xe4\x93\x02)\"$/v2/{name=projects/*/traces/*}/spans:\x01*B\xac\x01\n!com.google.devtools.cloudtrace.v2B\x0cTracingProtoP\x01ZGgoogle.golang.org/genproto/googleapis/devtools/cloudtrace/v2;cloudtrace\xaa\x02\x15Google.Cloud.Trace.V2\xca\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,]) +_sym_db.RegisterFileDescriptor(DESCRIPTOR) @@ -69,21 +70,21 @@ _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``. + Required. The name of the project where the spans belong. The + format is ``projects/[PROJECT_ID]``. spans: - A collection of spans. + A list of new spans. The span names must not match existing + spans, or the results are undefined. """, # @@protoc_insertion_point(class_scope:google.devtools.cloudtrace.v2.BatchWriteSpansRequest) )) @@ -91,7 +92,7 @@ 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')) +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\312\002\025Google\\Cloud\\Trace\\V2')) try: # THESE ELEMENTS WILL BE DEPRECATED. # Please use the generated *_pb2_grpc.py files instead. @@ -137,18 +138,15 @@ class TraceServiceServicer(object): """ 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. + """Sends new spans to new or existing traces. You cannot update + existing 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. + """Creates a new span. """ context.set_code(grpc.StatusCode.UNIMPLEMENTED) context.set_details('Method not implemented!') @@ -186,15 +184,12 @@ class BetaTraceServiceServicer(object): 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. + """Sends new spans to new or existing traces. You cannot update + existing spans. """ context.code(beta_interfaces.StatusCode.UNIMPLEMENTED) def CreateSpan(self, request, context): - """Creates a new Span. + """Creates a new span. """ context.code(beta_interfaces.StatusCode.UNIMPLEMENTED) @@ -212,16 +207,13 @@ class BetaTraceServiceStub(object): 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. + """Sends new spans to new or existing traces. You cannot update + existing spans. """ raise NotImplementedError() BatchWriteSpans.future = None def CreateSpan(self, request, timeout, metadata=None, with_call=False, protocol_options=None): - """Creates a new Span. + """Creates a new span. """ raise NotImplementedError() CreateSpan.future = None diff --git a/trace/google/cloud/trace_v2/proto/tracing_pb2_grpc.py b/trace/google/cloud/trace_v2/proto/tracing_pb2_grpc.py index 609605f0014a..045558a4d3b2 100644 --- a/trace/google/cloud/trace_v2/proto/tracing_pb2_grpc.py +++ b/trace/google/cloud/trace_v2/proto/tracing_pb2_grpc.py @@ -1,9 +1,9 @@ # 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 +import google.devtools.cloudtrace_v2.proto.trace_pb2 as google_dot_devtools_dot_cloudtrace__v2_dot_proto_dot_trace__pb2 +import google.devtools.cloudtrace_v2.proto.tracing_pb2 as google_dot_devtools_dot_cloudtrace__v2_dot_proto_dot_tracing__pb2 +import google.protobuf.empty_pb2 as google_dot_protobuf_dot_empty__pb2 class TraceServiceStub(object): @@ -41,18 +41,15 @@ class TraceServiceServicer(object): """ 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. + """Sends new spans to new or existing traces. You cannot update + existing 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. + """Creates a new span. """ context.set_code(grpc.StatusCode.UNIMPLEMENTED) context.set_details('Method not implemented!') diff --git a/trace/google/cloud/trace_v2/types.py b/trace/google/cloud/trace_v2/types.py index 9400fe82f9ba..d7ae84583c7c 100644 --- a/trace/google/cloud/trace_v2/types.py +++ b/trace/google/cloud/trace_v2/types.py @@ -1,10 +1,10 @@ -# Copyright 2017, Google LLC All rights reserved. +# Copyright 2018 Google LLC # # 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 +# https://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, @@ -37,7 +37,8 @@ empty_pb2, timestamp_pb2, wrappers_pb2, - status_pb2, ): + status_pb2, +): for name, message in get_messages(module).items(): message.__module__ = 'google.cloud.trace_v2.types' setattr(sys.modules[__name__], name, message) diff --git a/trace/tests/system/gapic/v1/test_system_trace_service_v1.py b/trace/tests/system/gapic/v1/test_system_trace_service_v1.py new file mode 100644 index 000000000000..746028842b55 --- /dev/null +++ b/trace/tests/system/gapic/v1/test_system_trace_service_v1.py @@ -0,0 +1,30 @@ +# Copyright 2018 Google LLC +# +# 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 +# +# https://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. + +import os +import time + +from google.cloud import trace_v1 +from google.cloud.trace_v1 import enums +from google.cloud.trace_v1.proto import trace_pb2 +from google.protobuf import timestamp_pb2 + + +class TestSystemTraceService(object): + def test_list_traces(self): + project_id = os.environ['PROJECT_ID'] + + client = trace_v1.TraceServiceClient() + project_id_2 = project_id + response = client.list_traces(project_id_2) diff --git a/trace/tests/system/gapic/v2/test_system_trace_service_v2.py b/trace/tests/system/gapic/v2/test_system_trace_service_v2.py new file mode 100644 index 000000000000..9953fae59d91 --- /dev/null +++ b/trace/tests/system/gapic/v2/test_system_trace_service_v2.py @@ -0,0 +1,30 @@ +# Copyright 2018 Google LLC +# +# 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 +# +# https://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. + +import os +import time + +from google.cloud import trace_v2 +from google.cloud.trace_v2.proto import trace_pb2 +from google.cloud.trace_v2.proto import tracing_pb2 + + +class TestSystemTraceService(object): + def test_batch_write_spans(self): + project_id = os.environ['PROJECT_ID'] + + client = trace_v2.TraceServiceClient() + name = client.project_path(project_id) + spans = [] + client.batch_write_spans(name, spans) 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 index 6a758928383b..b734d684da0a 100644 --- a/trace/tests/unit/gapic/v1/test_trace_service_client_v1.py +++ b/trace/tests/unit/gapic/v1/test_trace_service_client_v1.py @@ -1,10 +1,10 @@ -# Copyright 2017, Google LLC All rights reserved. +# Copyright 2018 Google LLC # # 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 +# https://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, 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 index 688c4e1f4189..27b52330d96f 100644 --- a/trace/tests/unit/gapic/v2/test_trace_service_client_v2.py +++ b/trace/tests/unit/gapic/v2/test_trace_service_client_v2.py @@ -1,10 +1,10 @@ -# Copyright 2017, Google LLC All rights reserved. +# Copyright 2018 Google LLC # # 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 +# https://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, diff --git a/trace/tests/unit/v1/test__gax_v1.py b/trace/tests/unit/v1/test__gax_v1.py index 6fb23976d0cb..6d6667bb855b 100644 --- a/trace/tests/unit/v1/test__gax_v1.py +++ b/trace/tests/unit/v1/test__gax_v1.py @@ -17,34 +17,43 @@ import mock +from google.api_core import grpc_helpers class _Base(object): project = 'PROJECT' - def _make_one(self, *args, **kw): - return self._get_target_class()(*args, **kw) + def _make_one(self, gapic_client=None, handwritten_client=None): + from google.cloud.trace_v1.gapic import trace_service_client + channel = grpc_helpers.ChannelStub() + if gapic_client is None: + gapic_client = trace_service_client.TraceServiceClient(channel=channel) + if handwritten_client is None: + handwritten_client = mock.Mock() + api = self._get_target_class()(gapic_client, handwritten_client) + return channel, api class Test__TraceAPI(_Base, unittest.TestCase): @staticmethod def _get_target_class(): - from google.cloud.trace.v1._gax import _TraceAPI + from google.cloud.trace.v1._gapic import _TraceAPI return _TraceAPI def test_constructor(self): - gax_api = object() - client = object() - api = self._make_one(gax_api, client) - self.assertIs(api._gax_api, gax_api) - self.assertIs(api.client, client) + from google.cloud.trace_v1.gapic import trace_service_client + channel = grpc_helpers.ChannelStub() + gapic_client = trace_service_client.TraceServiceClient(channel=channel) + _, api = self._make_one(gapic_client, mock.sentinel.client) + self.assertIs(api._gapic_api, gapic_client) + self.assertIs(api.client, mock.sentinel.client) def test_patch_traces(self): 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.v1._gax import _traces_mapping_to_pb + from google.cloud.trace.v1._gapic import _traces_mapping_to_pb from google.cloud._helpers import _datetime_to_pb_timestamp trace_id = 'test_trace_id' @@ -72,14 +81,14 @@ def test_patch_traces(self): traces_pb = _traces_mapping_to_pb(traces) - gax_api = mock.Mock(spec=trace_service_client.TraceServiceClient) - api = self._make_one(gax_api, None) + gapic_api = mock.Mock(spec=trace_service_client.TraceServiceClient) + _, api = self._make_one(gapic_api, None) api.patch_traces(project_id=self.project, traces=traces) - gax_api.patch_traces.assert_called_with(self.project, traces_pb, None) + gapic_api.patch_traces.assert_called_with(self.project, traces_pb) - call_args = gax_api.patch_traces.call_args[0] - self.assertEqual(len(call_args), 3) + call_args = gapic_api.patch_traces.call_args[0] + self.assertEqual(len(call_args), 2) traces_called = call_args[1] self.assertEqual(len(traces_called.traces), 1) trace = traces_called.traces[0] @@ -107,15 +116,15 @@ def test_get_trace(self): trace_id = 'test_trace_id' - gax_api = mock.Mock(spec=trace_service_client.TraceServiceClient) - api = self._make_one(gax_api, None) - patch = mock.patch('google.cloud.trace.v1._gax._parse_trace_pb', + gapic_api = mock.Mock(spec=trace_service_client.TraceServiceClient) + _, api = self._make_one(gapic_api, None) + patch = mock.patch('google.cloud.trace.v1._gapic._parse_trace_pb', return_value='fake_pb_result') with patch: api.get_trace(project_id=self.project, trace_id=trace_id) - gax_api.get_trace.assert_called_with(self.project, trace_id, None) + gapic_api.get_trace.assert_called_with(self.project, trace_id) def _make_trace_pb( self, @@ -127,7 +136,7 @@ def _make_trace_pb( end_time, parent_span_id, labels): - from google.cloud.trace.v1._gax import _traces_mapping_to_pb + from google.cloud.trace.v1._gapic import _traces_mapping_to_pb span_kind = 2 @@ -155,89 +164,13 @@ def _make_trace_pb( trace_pb = traces_pb.traces return trace_pb - 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.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' - span_id = 1234 - span_name = 'test_span_name' - span_kind = 'RPC_CLIENT' - parent_span_id = 123 - start_ts = datetime.datetime.utcnow() - end_ts = datetime.datetime.utcnow() - labels = { - '/http/status_code': '200', - '/component': 'HTTP load balancer', - } - size = 10 - view_type = Enum.ViewType.COMPLETE - - trace_pb = self._make_trace_pb( - self.project, - trace_id, - span_id, - span_name, - start_ts.isoformat() + 'Z', - end_ts.isoformat() + 'Z', - parent_span_id, - labels) - - response = _GAXPageIterator(trace_pb) - gax_api = mock.Mock(spec=trace_service_client.TraceServiceClient) - gax_api.list_traces.return_value = response - api = self._make_one(gax_api, None) - - iterator = api.list_traces( - project_id=self.project, - view=view_type, - page_size=size) - - traces = list(iterator) - - self.assertEqual(len(traces), 1) - trace = traces[0] - - self.assertEqual(len(trace['spans']), 1) - span = trace['spans'][0] - - self.assertEqual(trace['projectId'], self.project) - self.assertEqual(trace['traceId'], trace_id) - - self.assertEqual(span['spanId'], str(span_id)) - self.assertEqual(span['name'], span_name) - - self.assertEqual( - _rfc3339_to_datetime(span['startTime']), - start_ts.replace(tzinfo=UTC)) - self.assertEqual( - _rfc3339_to_datetime(span['endTime']), - end_ts.replace(tzinfo=UTC)) - self.assertEqual(span['kind'], span_kind) - self.assertEqual(span['parentSpanId'], str(parent_span_id)) - self.assertEqual(span['labels'], labels) - - call_args = gax_api.list_traces.call_args[1] - - self.assertEqual(call_args['project_id'], self.project) - self.assertEqual(call_args['view'], view_type) - self.assertEqual(call_args['page_size'], size) - self.assertIsNone(call_args['start_time']) - self.assertIsNone(call_args['end_time']) - self.assertIsNone(call_args['filter_']) - self.assertIsNone(call_args['order_by']) - self.assertEqual(call_args['options'].page_token, INITIAL_PAGE) - - def test_list_traces_with_paging(self): + def test_list_traces(self): + from google.api_core.page_iterator import GRPCIterator from google.cloud._helpers import _rfc3339_to_datetime from google.cloud._helpers import UTC - from google.cloud._testing import _GAXPageIterator from google.cloud.trace_v1.gapic import trace_service_client from google.cloud.trace_v1.gapic.enums import ListTracesRequest as Enum + from google.cloud.trace_v1.proto import trace_pb2 trace_id = 'test_trace_id' span_id = 1234 @@ -264,11 +197,11 @@ def test_list_traces_with_paging(self): parent_span_id, labels) - response = _GAXPageIterator(trace_pb) - gax_api = mock.Mock(spec=trace_service_client.TraceServiceClient) - gax_api.list_traces.return_value = response - api = self._make_one(gax_api, None) + gapic_api = mock.Mock(spec=trace_service_client.TraceServiceClient) + gapic_api.list_traces = mock.create_autospec(gapic_api.list_traces) + channel, api = self._make_one() + channel.ListTraces.response = trace_pb2.ListTracesResponse(traces=[trace_pb[0]]) iterator = api.list_traces( project_id=self.project, view=view_type, @@ -299,23 +232,23 @@ def test_list_traces_with_paging(self): self.assertEqual(span['parentSpanId'], str(parent_span_id)) self.assertEqual(span['labels'], labels) - call_args = gax_api.list_traces.call_args[1] + self.assertEqual(len(channel.ListTraces.requests), 1) + request = channel.ListTraces.requests[0] - self.assertEqual(call_args['project_id'], self.project) - self.assertEqual(call_args['view'], view_type) - self.assertEqual(call_args['page_size'], size) - self.assertIsNone(call_args['start_time']) - self.assertIsNone(call_args['end_time']) - self.assertIsNone(call_args['filter_']) - self.assertIsNone(call_args['order_by']) - self.assertEqual(call_args['options'].page_token, token) + self.assertEqual(request.project_id, self.project) + self.assertEqual(request.view, view_type) + self.assertEqual(request.page_size, size) + self.assertEqual(request.start_time.ToDatetime(), datetime.datetime(1970, 1, 1, 0, 0)) + self.assertEqual(request.end_time.ToDatetime(), datetime.datetime(1970, 1, 1, 0, 0)) + self.assertEqual(request.filter, '') + self.assertEqual(request.order_by, '') class Test__parse_trace_pb(unittest.TestCase): @staticmethod def _call_fut(*args, **kwargs): - from google.cloud.trace.v1._gax import _parse_trace_pb + from google.cloud.trace.v1._gapic import _parse_trace_pb return _parse_trace_pb(*args, **kwargs) @@ -366,7 +299,7 @@ def test_registered_type(self): self.assertEqual(parse_result, expected_result) - @mock.patch('google.cloud.trace.v1._gax.MessageToDict', + @mock.patch('google.cloud.trace.v1._gapic.MessageToDict', side_effect=TypeError) def test_unregistered_type(self, msg_to_dict_mock): trace_pb = mock.Mock(spec=['HasField']) @@ -375,15 +308,15 @@ def test_unregistered_type(self, msg_to_dict_mock): self._call_fut(trace_pb) -class Test_make_gax_trace_api(unittest.TestCase): +class Test_make_trace_api(unittest.TestCase): def _call_fut(self, client): - from google.cloud.trace.v1._gax import make_gax_trace_api + from google.cloud.trace.v1._gapic import make_trace_api - return make_gax_trace_api(client) + return make_trace_api(client) def test_it(self): - from google.cloud.trace.v1._gax import _TraceAPI + from google.cloud.trace.v1._gapic import _TraceAPI from google.cloud._http import DEFAULT_USER_AGENT credentials = object() @@ -399,7 +332,7 @@ def generated_api(**kwargs): generated_api.SERVICE_ADDRESS = host patch_api = mock.patch( - 'google.cloud.trace.v1._gax.trace_service_client.TraceServiceClient', + 'google.cloud.trace.v1._gapic.trace_service_client.TraceServiceClient', new=generated_api) with patch_api: @@ -408,5 +341,5 @@ def generated_api(**kwargs): self.assertEqual(len(generated_api_kwargs), 1) self.assertIsInstance(trace_api, _TraceAPI) - self.assertIs(trace_api._gax_api, generated) + self.assertIs(trace_api._gapic_api, generated) self.assertIs(trace_api.client, client) diff --git a/trace/tests/unit/v1/test_client_v1.py b/trace/tests/unit/v1/test_client_v1.py index e57725870d92..a5fb8e62bccb 100644 --- a/trace/tests/unit/v1/test_client_v1.py +++ b/trace/tests/unit/v1/test_client_v1.py @@ -53,7 +53,7 @@ def make_api(client_obj): client = self._make_one(project=self.project, credentials=credentials) patch = mock.patch( - 'google.cloud.trace.v1.client.make_gax_trace_api', + 'google.cloud.trace.v1.client.make_trace_api', new=make_api) with patch: @@ -63,7 +63,7 @@ def make_api(client_obj): self.assertEqual(clients, [client]) def test_patch_traces_default(self): - from google.cloud.trace.v1._gax import _TraceAPI + from google.cloud.trace.v1._gapic import _TraceAPI credentials = _make_credentials() client = self._make_one(project=self.project, credentials=credentials) @@ -71,18 +71,17 @@ def test_patch_traces_default(self): mock_trace_api = mock.Mock(spec=_TraceAPI) mock_trace_api.patch_traces = mock.Mock() - patch = mock.patch('google.cloud.trace.v1.client.make_gax_trace_api', return_value=mock_trace_api) + patch = mock.patch('google.cloud.trace.v1.client.make_trace_api', return_value=mock_trace_api) with patch: client.patch_traces(traces=traces) mock_trace_api.patch_traces.assert_called_with( - options=None, project_id='PROJECT', traces='fake_traces_for_test') def test_patch_traces_explicit(self): - from google.cloud.trace.v1._gax import _TraceAPI + from google.cloud.trace.v1._gapic import _TraceAPI credentials = _make_credentials() client = self._make_one(project=self.project, credentials=credentials) @@ -90,7 +89,7 @@ def test_patch_traces_explicit(self): mock_trace_api = mock.Mock(spec=_TraceAPI) mock_trace_api.patch_traces = mock.Mock() - patch = mock.patch('google.cloud.trace.v1.client.make_gax_trace_api', return_value=mock_trace_api) + patch = mock.patch('google.cloud.trace.v1.client.make_trace_api', return_value=mock_trace_api) with patch: client.patch_traces( @@ -98,12 +97,11 @@ def test_patch_traces_explicit(self): traces=traces) mock_trace_api.patch_traces.assert_called_with( - options=None, project_id='PROJECT', traces='fake_traces_for_test') def test_get_trace_default(self): - from google.cloud.trace.v1._gax import _TraceAPI + from google.cloud.trace.v1._gapic import _TraceAPI def get_trace(trace_id, project_id=None, options=None): _get_trace_called_with = (trace_id, project_id, options) @@ -115,7 +113,7 @@ def get_trace(trace_id, project_id=None, options=None): mock_trace_api = mock.Mock(spec=_TraceAPI) mock_trace_api.get_trace = get_trace - patch = mock.patch('google.cloud.trace.v1.client.make_gax_trace_api', + patch = mock.patch('google.cloud.trace.v1.client.make_trace_api', return_value=mock_trace_api) with patch: @@ -125,7 +123,7 @@ def get_trace(trace_id, project_id=None, options=None): (trace_id, self.project, None)) def test_get_trace_explicit(self): - from google.cloud.trace.v1._gax import _TraceAPI + from google.cloud.trace.v1._gapic import _TraceAPI def get_trace(trace_id, project_id=None, options=None): _get_trace_called_with = (trace_id, project_id, options) @@ -137,7 +135,7 @@ def get_trace(trace_id, project_id=None, options=None): mock_trace_api = mock.Mock(spec=_TraceAPI) mock_trace_api.get_trace = get_trace - patch = mock.patch('google.cloud.trace.v1.client.make_gax_trace_api', + patch = mock.patch('google.cloud.trace.v1.client.make_trace_api', return_value=mock_trace_api) with patch: @@ -149,7 +147,7 @@ def get_trace(trace_id, project_id=None, options=None): (trace_id, self.project, None)) def test_list_traces_default(self): - from google.cloud.trace.v1._gax import _TraceAPI + from google.cloud.trace.v1._gapic import _TraceAPI def list_traces( project_id, @@ -176,7 +174,7 @@ def list_traces( mock_trace_api = mock.Mock(spec=_TraceAPI) mock_trace_api.list_traces = list_traces - patch = mock.patch('google.cloud.trace.v1.client.make_gax_trace_api', + patch = mock.patch('google.cloud.trace.v1.client.make_trace_api', return_value=mock_trace_api) with patch: @@ -189,7 +187,7 @@ def list_traces( def test_list_traces_explicit(self): from google.cloud._helpers import _datetime_to_pb_timestamp from google.cloud.trace_v1.gapic.enums import ListTracesRequest as Enum - from google.cloud.trace.v1._gax import _TraceAPI + from google.cloud.trace.v1._gapic import _TraceAPI from datetime import datetime @@ -218,7 +216,7 @@ def list_traces( mock_trace_api = mock.Mock(spec=_TraceAPI) mock_trace_api.list_traces = list_traces - patch = mock.patch('google.cloud.trace.v1.client.make_gax_trace_api', + patch = mock.patch('google.cloud.trace.v1.client.make_trace_api', return_value=mock_trace_api) view = Enum.ViewType.COMPLETE diff --git a/trace/tests/unit/v2/test__gax_v2.py b/trace/tests/unit/v2/test__gax_v2.py index f3278acc3459..5766f6232493 100644 --- a/trace/tests/unit/v2/test__gax_v2.py +++ b/trace/tests/unit/v2/test__gax_v2.py @@ -145,21 +145,21 @@ class Test__TraceAPI(_Base, unittest.TestCase): @staticmethod def _get_target_class(): - from google.cloud.trace._gax import _TraceAPI + from google.cloud.trace._gapic import _TraceAPI return _TraceAPI def test_constructor(self): - gax_api = object() + gapic_api = object() client = object() - api = self._make_one(gax_api, client) - self.assertIs(api._gax_api, gax_api) + api = self._make_one(gapic_api, client) + self.assertIs(api._gapic_api, gapic_api) self.assertIs(api.client, client) def test_batch_write_spans(self): from google.cloud.trace_v2.gapic import trace_service_client from google.cloud.trace_v2.proto.trace_pb2 import Span - from google.cloud.trace._gax import _dict_mapping_to_pb + from google.cloud.trace._gapic import _dict_mapping_to_pb spans = { 'spans': [ @@ -185,13 +185,13 @@ def test_batch_write_spans(self): spans_pb_list = [_dict_mapping_to_pb(spans['spans'][0], 'Span')] project_name = 'projects/{}'.format(self.project) - gax_api = mock.Mock(spec=trace_service_client.TraceServiceClient) - api = self._make_one(gax_api, None) + gapic_api = mock.Mock(spec=trace_service_client.TraceServiceClient) + api = self._make_one(gapic_api, None) retry = mock.Mock() timeout = mock.Mock() api.batch_write_spans(project_name, spans, retry, timeout) - gax_api.batch_write_spans.assert_called_with( + gapic_api.batch_write_spans.assert_called_with( name=project_name, spans=spans_pb_list, retry=retry, @@ -199,11 +199,11 @@ def test_batch_write_spans(self): def test_create_span_default(self): from google.cloud.trace_v2.gapic import trace_service_client - from google.cloud.trace._gax import _dict_mapping_to_pb + from google.cloud.trace._gapic import _dict_mapping_to_pb from google.cloud._helpers import _datetime_to_pb_timestamp - gax_api = mock.Mock(spec=trace_service_client.TraceServiceClient) - api = self._make_one(gax_api, None) + gapic_api = mock.Mock(spec=trace_service_client.TraceServiceClient) + api = self._make_one(gapic_api, None) api.create_span( name=self.span_name, span_id=self.span_id, @@ -216,7 +216,7 @@ def test_create_span_default(self): start_time_pb = _datetime_to_pb_timestamp(self.start_time) end_time_pb = _datetime_to_pb_timestamp(self.end_time) - gax_api.create_span.assert_called_with( + gapic_api.create_span.assert_called_with( name=self.span_name, span_id=self.span_id, display_name=display_name_pb, @@ -233,15 +233,15 @@ def test_create_span_default(self): def test_create_span_explicit(self): from google.cloud._helpers import _datetime_to_pb_timestamp - from google.cloud.trace._gax import ( + from google.cloud.trace._gapic import ( _dict_mapping_to_pb, _span_attrs_to_pb, _status_mapping_to_pb, _value_to_pb) from google.cloud.trace_v2.gapic import trace_service_client - gax_api = mock.Mock(spec=trace_service_client.TraceServiceClient) - api = self._make_one(gax_api, None) + gapic_api = mock.Mock(spec=trace_service_client.TraceServiceClient) + api = self._make_one(gapic_api, None) api.create_span( name=self.span_name, span_id=self.span_id, @@ -271,7 +271,7 @@ def test_create_span_explicit(self): child_span_count_pb = _value_to_pb( self.child_span_count, 'Int32Value') - gax_api.create_span.assert_called_with( + gapic_api.create_span.assert_called_with( name=self.span_name, span_id=self.span_id, display_name=display_name_pb, @@ -287,15 +287,15 @@ def test_create_span_explicit(self): child_span_count=child_span_count_pb) -class Test_make_gax_trace_api(unittest.TestCase): +class Test_make_trace_api(unittest.TestCase): def _call_fut(self, client): - from google.cloud.trace._gax import make_gax_trace_api + from google.cloud.trace._gapic import make_trace_api - return make_gax_trace_api(client) + return make_trace_api(client) def test_it(self): - from google.cloud.trace._gax import _TraceAPI + from google.cloud.trace._gapic import _TraceAPI from google.cloud._http import DEFAULT_USER_AGENT credentials = object() @@ -311,7 +311,7 @@ def generated_api(**kwargs): generated_api.SERVICE_ADDRESS = host patch_api = mock.patch( - 'google.cloud.trace._gax.trace_service_client.TraceServiceClient', + 'google.cloud.trace._gapic.trace_service_client.TraceServiceClient', new=generated_api) with patch_api: @@ -320,5 +320,5 @@ def generated_api(**kwargs): self.assertEqual(len(generated_api_kwargs), 1) self.assertIsInstance(trace_api, _TraceAPI) - self.assertIs(trace_api._gax_api, generated) + self.assertIs(trace_api._gapic_api, generated) self.assertIs(trace_api.client, client) diff --git a/trace/tests/unit/v2/test_client_v2.py b/trace/tests/unit/v2/test_client_v2.py index 30df6d9f0988..fbbef2c30b68 100644 --- a/trace/tests/unit/v2/test_client_v2.py +++ b/trace/tests/unit/v2/test_client_v2.py @@ -53,7 +53,7 @@ def make_api(client_obj): client = self._make_one(project=self.project, credentials=credentials) patch = mock.patch( - 'google.cloud.trace.client.make_gax_trace_api', + 'google.cloud.trace.client.make_trace_api', new=make_api) with patch: @@ -63,7 +63,7 @@ def make_api(client_obj): self.assertEqual(clients, [client]) def test_batch_write_spans(self): - from google.cloud.trace._gax import _TraceAPI + from google.cloud.trace._gapic import _TraceAPI credentials = _make_credentials() client = self._make_one(project=self.project, credentials=credentials) @@ -73,7 +73,7 @@ def test_batch_write_spans(self): mock_trace_api = mock.Mock(spec=_TraceAPI) mock_trace_api.patch_traces = mock.Mock() patch = mock.patch( - 'google.cloud.trace.client.make_gax_trace_api', + 'google.cloud.trace.client.make_trace_api', return_value=mock_trace_api) with patch: @@ -86,7 +86,7 @@ def test_batch_write_spans(self): timeout=None) def test_create_span(self): - from google.cloud.trace._gax import _TraceAPI + from google.cloud.trace._gapic import _TraceAPI credentials = _make_credentials() client = self._make_one(project=self.project, credentials=credentials) @@ -107,7 +107,7 @@ def test_create_span(self): mock_trace_api = mock.Mock(spec=_TraceAPI) mock_trace_api.patch_traces = mock.Mock() patch = mock.patch( - 'google.cloud.trace.client.make_gax_trace_api', + 'google.cloud.trace.client.make_trace_api', return_value=mock_trace_api) with patch: