diff --git a/trace/docs/conf.py b/trace/docs/conf.py index 38a225821c83..7e5c9d1b4f87 100644 --- a/trace/docs/conf.py +++ b/trace/docs/conf.py @@ -164,7 +164,7 @@ # 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 = [] +html_static_path = ["_static"] # Add any extra paths that contain custom files (such as robots.txt or # .htaccess) here, relative to this directory. These files are copied diff --git a/trace/google/cloud/trace_v1/__init__.py b/trace/google/cloud/trace_v1/__init__.py index 5af055f3da5f..c0a11689a6be 100644 --- a/trace/google/cloud/trace_v1/__init__.py +++ b/trace/google/cloud/trace_v1/__init__.py @@ -16,12 +16,23 @@ from __future__ import absolute_import +import sys +import warnings from google.cloud.trace_v1 import types from google.cloud.trace_v1.gapic import enums from google.cloud.trace_v1.gapic import trace_service_client +if sys.version_info[:2] == (2, 7): + message = ( + "A future version of this library will drop support for Python 2.7." + "More details about Python 2 support for Google Cloud Client Libraries" + "can be found at https://cloud.google.com/python/docs/python2-sunset/" + ) + warnings.warn(message, DeprecationWarning) + + class TraceServiceClient(trace_service_client.TraceServiceClient): __doc__ = trace_service_client.TraceServiceClient.__doc__ enums = enums 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 394965726520..3e1af53d4a62 100644 --- a/trace/google/cloud/trace_v1/gapic/trace_service_client.py +++ b/trace/google/cloud/trace_v1/gapic/trace_service_client.py @@ -191,20 +191,21 @@ def __init__( self._inner_api_calls = {} # Service calls - def patch_traces( + def list_traces( self, project_id, - traces, + view=None, + page_size=None, + start_time=None, + end_time=None, + filter_=None, + order_by=None, retry=google.api_core.gapic_v1.method.DEFAULT, timeout=google.api_core.gapic_v1.method.DEFAULT, 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 - in the existing trace and its spans are overwritten by the provided values, - and any new fields provided are merged with the existing trace data. If the - ID does not match, a new trace is created. + Returns of a list of traces that match the specified filter conditions. Example: >>> from google.cloud import trace_v1 @@ -214,17 +215,82 @@ def patch_traces( >>> # TODO: Initialize `project_id`: >>> project_id = '' >>> - >>> # TODO: Initialize `traces`: - >>> traces = {} + >>> # Iterate over all results + >>> for element in client.list_traces(project_id): + ... # process element + ... pass >>> - >>> client.patch_traces(project_id, traces) + >>> + >>> # Alternatively: + >>> + >>> # Iterate over results one page at a time + >>> for page in client.list_traces(project_id).pages: + ... for element in page: + ... # process element + ... pass Args: - project_id (str): ID of the Cloud project where the trace data is stored. - traces (Union[dict, ~google.cloud.trace_v1.types.Traces]): The body of the message. + project_id (str): Required. ID of the Cloud project where the trace data is stored. + view (~google.cloud.trace_v1.types.ViewType): Optional. Type of data returned for traces in the list. Default is + ``MINIMAL``. + page_size (int): The maximum number of resources contained in the + underlying API response. If page streaming is performed per- + resource, this parameter does not affect the return value. If page + streaming is performed per-page, this determines the maximum number + of resources in a page. + start_time (Union[dict, ~google.cloud.trace_v1.types.Timestamp]): Start of the time interval (inclusive) during which the trace data was + collected from the application. If a dict is provided, it must be of the same form as the protobuf - message :class:`~google.cloud.trace_v1.types.Traces` + message :class:`~google.cloud.trace_v1.types.Timestamp` + end_time (Union[dict, ~google.cloud.trace_v1.types.Timestamp]): End of the time interval (inclusive) during which the trace data was + collected from the application. + + If a dict is provided, it must be of the same form as the protobuf + message :class:`~google.cloud.trace_v1.types.Timestamp` + filter_ (str): Optional. A filter against labels for the request. + + By default, searches use prefix matching. To specify exact match, + prepend a plus symbol (``+``) to the search term. Multiple terms are + ANDed. Syntax: + + - ``root:NAME_PREFIX`` or ``NAME_PREFIX``: Return traces where any root + span starts with ``NAME_PREFIX``. + - ``+root:NAME`` or ``+NAME``: Return traces where any root span's name + is exactly ``NAME``. + - ``span:NAME_PREFIX``: Return traces where any span starts with + ``NAME_PREFIX``. + - ``+span:NAME``: Return traces where any span's name is exactly + ``NAME``. + - ``latency:DURATION``: Return traces whose overall latency is greater + or equal to than ``DURATION``. Accepted units are nanoseconds + (``ns``), milliseconds (``ms``), and seconds (``s``). Default is + ``ms``. For example, ``latency:24ms`` returns traces whose overall + latency is greater than or equal to 24 milliseconds. + - ``label:LABEL_KEY``: Return all traces containing the specified label + key (exact match, case-sensitive) regardless of the key:value pair's + value (including empty values). + - ``LABEL_KEY:VALUE_PREFIX``: Return all traces containing the + specified label key (exact match, case-sensitive) whose value starts + with ``VALUE_PREFIX``. Both a key and a value must be specified. + - ``+LABEL_KEY:VALUE``: Return all traces containing a key:value pair + exactly matching the specified text. Both a key and a value must be + specified. + - ``method:VALUE``: Equivalent to ``/http/method:VALUE``. + - ``url:VALUE``: Equivalent to ``/http/url:VALUE``. + order_by (str): Optional. Field used to sort the returned traces. Can be one of the + following: + + - ``trace_id`` + - ``name`` (``name`` field of root span in the trace) + - ``duration`` (difference between ``end_time`` and ``start_time`` + fields of the root span) + - ``start`` (``start_time`` field of the root span) + + Descending order can be specified by appending ``desc`` to the sort + field (for example, ``name desc``). + + Only one sort field is permitted. retry (Optional[google.api_core.retry.Retry]): A retry object used to retry requests. If ``None`` is specified, requests will be retried using a default configuration. @@ -234,6 +300,12 @@ def patch_traces( metadata (Optional[Sequence[Tuple[str, str]]]): Additional metadata that is provided to the method. + Returns: + A :class:`~google.api_core.page_iterator.PageIterator` instance. + An iterable of :class:`~google.cloud.trace_v1.types.Trace` instances. + You can also iterate over the pages of the response + using its `pages` property. + Raises: google.api_core.exceptions.GoogleAPICallError: If the request failed for any reason. @@ -242,17 +314,25 @@ def patch_traces( ValueError: If the parameters are invalid. """ # Wrap the transport method to add retry and timeout logic. - if "patch_traces" not in self._inner_api_calls: + if "list_traces" not in self._inner_api_calls: self._inner_api_calls[ - "patch_traces" + "list_traces" ] = google.api_core.gapic_v1.method.wrap_method( - self.transport.patch_traces, - default_retry=self._method_configs["PatchTraces"].retry, - default_timeout=self._method_configs["PatchTraces"].timeout, + self.transport.list_traces, + default_retry=self._method_configs["ListTraces"].retry, + default_timeout=self._method_configs["ListTraces"].timeout, client_info=self._client_info, ) - request = trace_pb2.PatchTracesRequest(project_id=project_id, traces=traces,) + request = trace_pb2.ListTracesRequest( + project_id=project_id, + view=view, + page_size=page_size, + start_time=start_time, + end_time=end_time, + filter=filter_, + order_by=order_by, + ) if metadata is None: metadata = [] metadata = list(metadata) @@ -266,9 +346,20 @@ def patch_traces( ) metadata.append(routing_metadata) - self._inner_api_calls["patch_traces"]( - request, retry=retry, timeout=timeout, metadata=metadata + iterator = google.api_core.page_iterator.GRPCIterator( + client=None, + method=functools.partial( + self._inner_api_calls["list_traces"], + retry=retry, + timeout=timeout, + metadata=metadata, + ), + request=request, + items_field="traces", + request_token_field="page_token", + response_token_field="next_page_token", ) + return iterator def get_trace( self, @@ -295,8 +386,8 @@ def get_trace( >>> response = client.get_trace(project_id, trace_id) Args: - project_id (str): ID of the Cloud project where the trace data is stored. - trace_id (str): ID of the trace to return. + project_id (str): Required. ID of the Cloud project where the trace data is stored. + trace_id (str): Required. ID of the trace to return. retry (Optional[google.api_core.retry.Retry]): A retry object used to retry requests. If ``None`` is specified, requests will be retried using a default configuration. @@ -332,21 +423,20 @@ def get_trace( request, retry=retry, timeout=timeout, metadata=metadata ) - def list_traces( + def patch_traces( self, project_id, - view=None, - page_size=None, - start_time=None, - end_time=None, - filter_=None, - order_by=None, + traces, retry=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. + Sends new traces to Stackdriver Trace or updates existing traces. If the ID + of a trace that you send matches that of an existing trace, any fields + in the existing trace and its spans are overwritten by the provided values, + and any new fields provided are merged with the existing trace data. If the + ID does not match, a new trace is created. Example: >>> from google.cloud import trace_v1 @@ -356,82 +446,17 @@ def list_traces( >>> # TODO: Initialize `project_id`: >>> project_id = '' >>> - >>> # Iterate over all results - >>> for element in client.list_traces(project_id): - ... # process element - ... pass - >>> - >>> - >>> # Alternatively: + >>> # TODO: Initialize `traces`: + >>> traces = {} >>> - >>> # Iterate over results one page at a time - >>> for page in client.list_traces(project_id).pages: - ... for element in page: - ... # process element - ... pass + >>> client.patch_traces(project_id, traces) Args: - project_id (str): ID of the Cloud project where the trace data is stored. - view (~google.cloud.trace_v1.types.ViewType): Type of data returned for traces in the list. Optional. Default is - ``MINIMAL``. - page_size (int): The maximum number of resources contained in the - underlying API response. If page streaming is performed per- - resource, this parameter does not affect the return value. If page - streaming is performed per-page, this determines the maximum number - of resources in a page. - start_time (Union[dict, ~google.cloud.trace_v1.types.Timestamp]): Start of the time interval (inclusive) during which the trace data was - collected from the application. - - If a dict is provided, it must be of the same form as the protobuf - message :class:`~google.cloud.trace_v1.types.Timestamp` - end_time (Union[dict, ~google.cloud.trace_v1.types.Timestamp]): End of the time interval (inclusive) during which the trace data was - collected from the application. + project_id (str): Required. ID of the Cloud project where the trace data is stored. + traces (Union[dict, ~google.cloud.trace_v1.types.Traces]): Required. The body of the message. If a dict is provided, it must be of the same form as the protobuf - message :class:`~google.cloud.trace_v1.types.Timestamp` - filter_ (str): An optional filter against labels for the request. - - By default, searches use prefix matching. To specify exact match, - prepend a plus symbol (``+``) to the search term. Multiple terms are - ANDed. Syntax: - - - ``root:NAME_PREFIX`` or ``NAME_PREFIX``: Return traces where any root - span starts with ``NAME_PREFIX``. - - ``+root:NAME`` or ``+NAME``: Return traces where any root span's name - is exactly ``NAME``. - - ``span:NAME_PREFIX``: Return traces where any span starts with - ``NAME_PREFIX``. - - ``+span:NAME``: Return traces where any span's name is exactly - ``NAME``. - - ``latency:DURATION``: Return traces whose overall latency is greater - or equal to than ``DURATION``. Accepted units are nanoseconds - (``ns``), milliseconds (``ms``), and seconds (``s``). Default is - ``ms``. For example, ``latency:24ms`` returns traces whose overall - latency is greater than or equal to 24 milliseconds. - - ``label:LABEL_KEY``: Return all traces containing the specified label - key (exact match, case-sensitive) regardless of the key:value pair's - value (including empty values). - - ``LABEL_KEY:VALUE_PREFIX``: Return all traces containing the - specified label key (exact match, case-sensitive) whose value starts - with ``VALUE_PREFIX``. Both a key and a value must be specified. - - ``+LABEL_KEY:VALUE``: Return all traces containing a key:value pair - exactly matching the specified text. Both a key and a value must be - specified. - - ``method:VALUE``: Equivalent to ``/http/method:VALUE``. - - ``url:VALUE``: Equivalent to ``/http/url:VALUE``. - order_by (str): Field used to sort the returned traces. Optional. Can be one of the - following: - - - ``trace_id`` - - ``name`` (``name`` field of root span in the trace) - - ``duration`` (difference between ``end_time`` and ``start_time`` - fields of the root span) - - ``start`` (``start_time`` field of the root span) - - Descending order can be specified by appending ``desc`` to the sort - field (for example, ``name desc``). - - Only one sort field is permitted. + message :class:`~google.cloud.trace_v1.types.Traces` retry (Optional[google.api_core.retry.Retry]): A retry object used to retry requests. If ``None`` is specified, requests will be retried using a default configuration. @@ -441,12 +466,6 @@ def list_traces( metadata (Optional[Sequence[Tuple[str, str]]]): Additional metadata that is provided to the method. - Returns: - A :class:`~google.api_core.page_iterator.PageIterator` instance. - An iterable of :class:`~google.cloud.trace_v1.types.Trace` instances. - You can also iterate over the pages of the response - using its `pages` property. - Raises: google.api_core.exceptions.GoogleAPICallError: If the request failed for any reason. @@ -455,25 +474,17 @@ def list_traces( ValueError: If the parameters are invalid. """ # Wrap the transport method to add retry and timeout logic. - if "list_traces" not in self._inner_api_calls: + if "patch_traces" not in self._inner_api_calls: self._inner_api_calls[ - "list_traces" + "patch_traces" ] = google.api_core.gapic_v1.method.wrap_method( - self.transport.list_traces, - default_retry=self._method_configs["ListTraces"].retry, - default_timeout=self._method_configs["ListTraces"].timeout, + self.transport.patch_traces, + default_retry=self._method_configs["PatchTraces"].retry, + default_timeout=self._method_configs["PatchTraces"].timeout, client_info=self._client_info, ) - request = trace_pb2.ListTracesRequest( - project_id=project_id, - view=view, - page_size=page_size, - start_time=start_time, - end_time=end_time, - filter=filter_, - order_by=order_by, - ) + request = trace_pb2.PatchTracesRequest(project_id=project_id, traces=traces,) if metadata is None: metadata = [] metadata = list(metadata) @@ -487,17 +498,6 @@ def list_traces( ) metadata.append(routing_metadata) - iterator = google.api_core.page_iterator.GRPCIterator( - client=None, - method=functools.partial( - self._inner_api_calls["list_traces"], - retry=retry, - timeout=timeout, - metadata=metadata, - ), - request=request, - items_field="traces", - request_token_field="page_token", - response_token_field="next_page_token", + self._inner_api_calls["patch_traces"]( + request, retry=retry, timeout=timeout, metadata=metadata ) - return iterator diff --git a/trace/google/cloud/trace_v1/gapic/trace_service_client_config.py b/trace/google/cloud/trace_v1/gapic/trace_service_client_config.py index 5982fcd7cbe8..023c8e66c788 100644 --- a/trace/google/cloud/trace_v1/gapic/trace_service_client_config.py +++ b/trace/google/cloud/trace_v1/gapic/trace_service_client_config.py @@ -8,16 +8,16 @@ "retry_params": { "default": { "initial_retry_delay_millis": 100, - "retry_delay_multiplier": 1.2, - "max_retry_delay_millis": 1000, + "retry_delay_multiplier": 1.3, + "max_retry_delay_millis": 60000, "initial_rpc_timeout_millis": 20000, - "rpc_timeout_multiplier": 1.5, - "max_rpc_timeout_millis": 30000, - "total_timeout_millis": 45000, + "rpc_timeout_multiplier": 1.0, + "max_rpc_timeout_millis": 20000, + "total_timeout_millis": 600000, } }, "methods": { - "PatchTraces": { + "ListTraces": { "timeout_millis": 60000, "retry_codes_name": "idempotent", "retry_params_name": "default", @@ -27,9 +27,9 @@ "retry_codes_name": "idempotent", "retry_params_name": "default", }, - "ListTraces": { + "PatchTraces": { "timeout_millis": 60000, - "retry_codes_name": "idempotent", + "retry_codes_name": "non_idempotent", "retry_params_name": "default", }, }, diff --git a/trace/google/cloud/trace_v1/gapic/transports/trace_service_grpc_transport.py b/trace/google/cloud/trace_v1/gapic/transports/trace_service_grpc_transport.py index caab89f084d2..63239085778e 100644 --- a/trace/google/cloud/trace_v1/gapic/transports/trace_service_grpc_transport.py +++ b/trace/google/cloud/trace_v1/gapic/transports/trace_service_grpc_transport.py @@ -112,21 +112,17 @@ def channel(self): return self._channel @property - def patch_traces(self): - """Return the gRPC stub for :meth:`TraceServiceClient.patch_traces`. + def list_traces(self): + """Return the gRPC stub for :meth:`TraceServiceClient.list_traces`. - Sends new traces to Stackdriver Trace or updates existing traces. If the ID - of a trace that you send matches that of an existing trace, any fields - in the existing trace and its spans are overwritten by the provided values, - and any new fields provided are merged with the existing trace data. If the - ID does not match, a new trace is created. + Returns of a list of traces that match the specified filter conditions. Returns: Callable: A callable which accepts the appropriate deserialized request object and returns a deserialized response object. """ - return self._stubs["trace_service_stub"].PatchTraces + return self._stubs["trace_service_stub"].ListTraces @property def get_trace(self): @@ -142,14 +138,18 @@ def get_trace(self): return self._stubs["trace_service_stub"].GetTrace @property - def list_traces(self): - """Return the gRPC stub for :meth:`TraceServiceClient.list_traces`. + def patch_traces(self): + """Return the gRPC stub for :meth:`TraceServiceClient.patch_traces`. - Returns of a list of traces that match the specified filter conditions. + Sends new traces to Stackdriver Trace or updates existing traces. If the ID + of a trace that you send matches that of an existing trace, any fields + in the existing trace and its spans are overwritten by the provided values, + and any new fields provided are merged with the existing trace data. If the + ID does not match, a new trace is created. Returns: Callable: A callable which accepts the appropriate deserialized request object and returns a deserialized response object. """ - return self._stubs["trace_service_stub"].ListTraces + return self._stubs["trace_service_stub"].PatchTraces diff --git a/trace/google/cloud/trace_v1/proto/trace.proto b/trace/google/cloud/trace_v1/proto/trace.proto index 16af3a6ecb6e..00cc14db309e 100644 --- a/trace/google/cloud/trace_v1/proto/trace.proto +++ b/trace/google/cloud/trace_v1/proto/trace.proto @@ -1,4 +1,4 @@ -// Copyright 2017 Google Inc. +// Copyright 2019 Google LLC. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -17,6 +17,9 @@ syntax = "proto3"; package google.devtools.cloudtrace.v1; import "google/api/annotations.proto"; +import "google/api/client.proto"; +import "google/api/field_behavior.proto"; +import "google/api/resource.proto"; import "google/protobuf/empty.proto"; import "google/protobuf/timestamp.proto"; @@ -33,11 +36,18 @@ option php_namespace = "Google\\Cloud\\Trace\\V1"; // timed event which forms a node of the trace tree. Spans for a single trace // may span multiple services. service TraceService { + option (google.api.default_host) = "cloudtrace.googleapis.com"; + option (google.api.oauth_scopes) = + "https://www.googleapis.com/auth/cloud-platform," + "https://www.googleapis.com/auth/trace.append," + "https://www.googleapis.com/auth/trace.readonly"; + // Returns of a list of traces that match the specified filter conditions. rpc ListTraces(ListTracesRequest) returns (ListTracesResponse) { option (google.api.http) = { get: "/v1/projects/{project_id}/traces" }; + option (google.api.method_signature) = "project_id"; } // Gets a single trace by its ID. @@ -45,6 +55,7 @@ service TraceService { option (google.api.http) = { get: "/v1/projects/{project_id}/traces/{trace_id}" }; + option (google.api.method_signature) = "project_id,trace_id"; } // Sends new traces to Stackdriver Trace or updates existing traces. If the ID @@ -57,6 +68,7 @@ service TraceService { patch: "/v1/projects/{project_id}/traces" body: "traces" }; + option (google.api.method_signature) = "project_id,traces"; } } @@ -68,7 +80,8 @@ message Trace { string project_id = 1; // Globally unique identifier for the trace. This identifier is a 128-bit - // numeric value formatted as a 32-byte hex string. + // numeric value formatted as a 32-byte hex string. For example, + // `382d4f4c6b7bb2f4a972559d9085001d`. string trace_id = 2; // Collection of spans in the trace. @@ -103,7 +116,7 @@ message TraceSpan { } // Identifier for the span. Must be a 64-bit integer other than 0 and - // unique within a trace. + // unique within a trace. For example, `2205310701640571284`. fixed64 span_id = 1; // Distinguishes between spans generated in a particular context. For example, @@ -113,7 +126,7 @@ message TraceSpan { // Name of the span. Must be less than 128 bytes. The span name is sanitized // and displayed in the Stackdriver Trace tool in the - // {% dynamic print site_values.console_name %}. + // Google Cloud Platform Console. // The name may be a method name or some other per-call site name. // For the same executable and the same call point, a best practice is // to use a consistent name, which makes it easier to correlate @@ -126,8 +139,8 @@ message TraceSpan { // End time of the span in nanoseconds from the UNIX epoch. google.protobuf.Timestamp end_time = 5; - // ID of the parent span, if any. Optional. - fixed64 parent_span_id = 6; + // Optional. ID of the parent span, if any. + fixed64 parent_span_id = 6 [(google.api.field_behavior) = OPTIONAL]; // Collection of labels associated with the span. Label keys must be less than // 128 bytes. Label values must be less than 16 kilobytes (10MB for @@ -189,20 +202,20 @@ message ListTracesRequest { COMPLETE = 3; } - // ID of the Cloud project where the trace data is stored. - string project_id = 1; + // Required. ID of the Cloud project where the trace data is stored. + string project_id = 1 [(google.api.field_behavior) = REQUIRED]; - // Type of data returned for traces in the list. Optional. Default is + // Optional. Type of data returned for traces in the list. Default is // `MINIMAL`. - ViewType view = 2; + ViewType view = 2 [(google.api.field_behavior) = OPTIONAL]; - // Maximum number of traces to return. If not specified or <= 0, the + // Optional. Maximum number of traces to return. If not specified or <= 0, the // implementation selects a reasonable value. The implementation may - // return fewer traces than the requested page size. Optional. - int32 page_size = 3; + // return fewer traces than the requested page size. + int32 page_size = 3 [(google.api.field_behavior) = OPTIONAL]; // Token identifying the page of results to return. If provided, use the - // value of the `next_page_token` field from a previous request. Optional. + // value of the `next_page_token` field from a previous request. string page_token = 4; // Start of the time interval (inclusive) during which the trace data was @@ -213,7 +226,7 @@ message ListTracesRequest { // collected from the application. google.protobuf.Timestamp end_time = 6; - // An optional filter against labels for the request. + // Optional. A filter against labels for the request. // // By default, searches use prefix matching. To specify exact match, prepend // a plus symbol (`+`) to the search term. @@ -243,9 +256,9 @@ message ListTracesRequest { // specified. // * `method:VALUE`: Equivalent to `/http/method:VALUE`. // * `url:VALUE`: Equivalent to `/http/url:VALUE`. - string filter = 7; + string filter = 7 [(google.api.field_behavior) = OPTIONAL]; - // Field used to sort the returned traces. Optional. + // Optional. Field used to sort the returned traces. // Can be one of the following: // // * `trace_id` @@ -258,12 +271,12 @@ message ListTracesRequest { // (for example, `name desc`). // // Only one sort field is permitted. - string order_by = 8; + string order_by = 8 [(google.api.field_behavior) = OPTIONAL]; } // The response message for the `ListTraces` method. message ListTracesResponse { - // List of trace records returned. + // List of trace records as specified by the view parameter. repeated Trace traces = 1; // If defined, indicates that there are more traces that match the request @@ -274,18 +287,18 @@ message ListTracesResponse { // The request message for the `GetTrace` method. message GetTraceRequest { - // ID of the Cloud project where the trace data is stored. - string project_id = 1; + // Required. ID of the Cloud project where the trace data is stored. + string project_id = 1 [(google.api.field_behavior) = REQUIRED]; - // ID of the trace to return. - string trace_id = 2; + // Required. ID of the trace to return. + string trace_id = 2 [(google.api.field_behavior) = REQUIRED]; } // The request message for the `PatchTraces` method. message PatchTracesRequest { - // ID of the Cloud project where the trace data is stored. - string project_id = 1; + // Required. ID of the Cloud project where the trace data is stored. + string project_id = 1 [(google.api.field_behavior) = REQUIRED]; - // The body of the message. - Traces traces = 2; + // Required. The body of the message. + Traces traces = 2 [(google.api.field_behavior) = REQUIRED]; } diff --git a/trace/google/cloud/trace_v1/proto/trace_pb2.py b/trace/google/cloud/trace_v1/proto/trace_pb2.py index b38ce92bc436..bbd1d7f1c54b 100644 --- a/trace/google/cloud/trace_v1/proto/trace_pb2.py +++ b/trace/google/cloud/trace_v1/proto/trace_pb2.py @@ -16,6 +16,9 @@ from google.api import annotations_pb2 as google_dot_api_dot_annotations__pb2 +from google.api import client_pb2 as google_dot_api_dot_client__pb2 +from google.api import field_behavior_pb2 as google_dot_api_dot_field__behavior__pb2 +from google.api import resource_pb2 as google_dot_api_dot_resource__pb2 from google.protobuf import empty_pb2 as google_dot_protobuf_dot_empty__pb2 from google.protobuf import timestamp_pb2 as google_dot_protobuf_dot_timestamp__pb2 @@ -28,10 +31,13 @@ "\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" ), 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' + '\n/google/devtools/cloudtrace_v1/proto/trace.proto\x12\x1dgoogle.devtools.cloudtrace.v1\x1a\x1cgoogle/api/annotations.proto\x1a\x17google/api/client.proto\x1a\x1fgoogle/api/field_behavior.proto\x1a\x19google/api/resource.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"\xa2\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\x1b\n\x0eparent_span_id\x18\x06 \x01(\x06\x42\x03\xe0\x41\x01\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"\x80\x03\n\x11ListTracesRequest\x12\x17\n\nproject_id\x18\x01 \x01(\tB\x03\xe0\x41\x02\x12L\n\x04view\x18\x02 \x01(\x0e\x32\x39.google.devtools.cloudtrace.v1.ListTracesRequest.ViewTypeB\x03\xe0\x41\x01\x12\x16\n\tpage_size\x18\x03 \x01(\x05\x42\x03\xe0\x41\x01\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\x13\n\x06\x66ilter\x18\x07 \x01(\tB\x03\xe0\x41\x01\x12\x15\n\x08order_by\x18\x08 \x01(\tB\x03\xe0\x41\x01"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"A\n\x0fGetTraceRequest\x12\x17\n\nproject_id\x18\x01 \x01(\tB\x03\xe0\x41\x02\x12\x15\n\x08trace_id\x18\x02 \x01(\tB\x03\xe0\x41\x02"i\n\x12PatchTracesRequest\x12\x17\n\nproject_id\x18\x01 \x01(\tB\x03\xe0\x41\x02\x12:\n\x06traces\x18\x02 \x01(\x0b\x32%.google.devtools.cloudtrace.v1.TracesB\x03\xe0\x41\x02\x32\xb5\x05\n\x0cTraceService\x12\xa8\x01\n\nListTraces\x12\x30.google.devtools.cloudtrace.v1.ListTracesRequest\x1a\x31.google.devtools.cloudtrace.v1.ListTracesResponse"5\x82\xd3\xe4\x93\x02"\x12 /v1/projects/{project_id}/traces\xda\x41\nproject_id\x12\xab\x01\n\x08GetTrace\x12..google.devtools.cloudtrace.v1.GetTraceRequest\x1a$.google.devtools.cloudtrace.v1.Trace"I\x82\xd3\xe4\x93\x02-\x12+/v1/projects/{project_id}/traces/{trace_id}\xda\x41\x13project_id,trace_id\x12\x9e\x01\n\x0bPatchTraces\x12\x31.google.devtools.cloudtrace.v1.PatchTracesRequest\x1a\x16.google.protobuf.Empty"D\x82\xd3\xe4\x93\x02*2 /v1/projects/{project_id}/traces:\x06traces\xda\x41\x11project_id,traces\x1a\xaa\x01\xca\x41\x19\x63loudtrace.googleapis.com\xd2\x41\x8a\x01https://www.googleapis.com/auth/cloud-platform,https://www.googleapis.com/auth/trace.append,https://www.googleapis.com/auth/trace.readonlyB\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_api_dot_client__pb2.DESCRIPTOR, + google_dot_api_dot_field__behavior__pb2.DESCRIPTOR, + google_dot_api_dot_resource__pb2.DESCRIPTOR, google_dot_protobuf_dot_empty__pb2.DESCRIPTOR, google_dot_protobuf_dot_timestamp__pb2.DESCRIPTOR, ], @@ -60,8 +66,8 @@ ], containing_type=None, serialized_options=None, - serialized_start=687, - serialized_end=756, + serialized_start=777, + serialized_end=846, ) _sym_db.RegisterEnumDescriptor(_TRACESPAN_SPANKIND) @@ -90,8 +96,8 @@ ], containing_type=None, serialized_options=None, - serialized_start=1040, - serialized_end=1118, + serialized_start=1155, + serialized_end=1233, ) _sym_db.RegisterEnumDescriptor(_LISTTRACESREQUEST_VIEWTYPE) @@ -166,8 +172,8 @@ syntax="proto3", extension_ranges=[], oneofs=[], - serialized_start=174, - serialized_end=276, + serialized_start=259, + serialized_end=361, ) @@ -205,8 +211,8 @@ syntax="proto3", extension_ranges=[], oneofs=[], - serialized_start=278, - serialized_end=340, + serialized_start=363, + serialized_end=425, ) @@ -262,8 +268,8 @@ syntax="proto3", extension_ranges=[], oneofs=[], - serialized_start=640, - serialized_end=685, + serialized_start=730, + serialized_end=775, ) _TRACESPAN = _descriptor.Descriptor( @@ -378,7 +384,7 @@ containing_type=None, is_extension=False, extension_scope=None, - serialized_options=None, + serialized_options=_b("\340A\001"), file=DESCRIPTOR, ), _descriptor.FieldDescriptor( @@ -408,8 +414,8 @@ syntax="proto3", extension_ranges=[], oneofs=[], - serialized_start=343, - serialized_end=756, + serialized_start=428, + serialized_end=846, ) @@ -435,7 +441,7 @@ containing_type=None, is_extension=False, extension_scope=None, - serialized_options=None, + serialized_options=_b("\340A\002"), file=DESCRIPTOR, ), _descriptor.FieldDescriptor( @@ -453,7 +459,7 @@ containing_type=None, is_extension=False, extension_scope=None, - serialized_options=None, + serialized_options=_b("\340A\001"), file=DESCRIPTOR, ), _descriptor.FieldDescriptor( @@ -471,7 +477,7 @@ containing_type=None, is_extension=False, extension_scope=None, - serialized_options=None, + serialized_options=_b("\340A\001"), file=DESCRIPTOR, ), _descriptor.FieldDescriptor( @@ -543,7 +549,7 @@ containing_type=None, is_extension=False, extension_scope=None, - serialized_options=None, + serialized_options=_b("\340A\001"), file=DESCRIPTOR, ), _descriptor.FieldDescriptor( @@ -561,7 +567,7 @@ containing_type=None, is_extension=False, extension_scope=None, - serialized_options=None, + serialized_options=_b("\340A\001"), file=DESCRIPTOR, ), ], @@ -573,8 +579,8 @@ syntax="proto3", extension_ranges=[], oneofs=[], - serialized_start=759, - serialized_end=1118, + serialized_start=849, + serialized_end=1233, ) @@ -630,8 +636,8 @@ syntax="proto3", extension_ranges=[], oneofs=[], - serialized_start=1120, - serialized_end=1219, + serialized_start=1235, + serialized_end=1334, ) @@ -657,7 +663,7 @@ containing_type=None, is_extension=False, extension_scope=None, - serialized_options=None, + serialized_options=_b("\340A\002"), file=DESCRIPTOR, ), _descriptor.FieldDescriptor( @@ -675,7 +681,7 @@ containing_type=None, is_extension=False, extension_scope=None, - serialized_options=None, + serialized_options=_b("\340A\002"), file=DESCRIPTOR, ), ], @@ -687,8 +693,8 @@ syntax="proto3", extension_ranges=[], oneofs=[], - serialized_start=1221, - serialized_end=1276, + serialized_start=1336, + serialized_end=1401, ) @@ -714,7 +720,7 @@ containing_type=None, is_extension=False, extension_scope=None, - serialized_options=None, + serialized_options=_b("\340A\002"), file=DESCRIPTOR, ), _descriptor.FieldDescriptor( @@ -732,7 +738,7 @@ containing_type=None, is_extension=False, extension_scope=None, - serialized_options=None, + serialized_options=_b("\340A\002"), file=DESCRIPTOR, ), ], @@ -744,8 +750,8 @@ syntax="proto3", extension_ranges=[], oneofs=[], - serialized_start=1278, - serialized_end=1373, + serialized_start=1403, + serialized_end=1508, ) _TRACE.fields_by_name["spans"].message_type = _TRACESPAN @@ -796,7 +802,8 @@ stored. trace_id: Globally unique identifier for the trace. This identifier is a - 128-bit numeric value formatted as a 32-byte hex string. + 128-bit numeric value formatted as a 32-byte hex string. For + example, ``382d4f4c6b7bb2f4a972559d9085001d``. spans: Collection of spans in the trace. """, @@ -848,7 +855,8 @@ Attributes: span_id: Identifier for the span. Must be a 64-bit integer other than 0 - and unique within a trace. + and unique within a trace. For example, + ``2205310701640571284``. kind: Distinguishes between spans generated in a particular context. For example, two spans with the same name may be distinguished @@ -857,17 +865,17 @@ name: Name of the span. Must be less than 128 bytes. The span name is sanitized and displayed in the Stackdriver Trace tool in - the {% dynamic print site\_values.console\_name %}. The name - may be a method name or some other per-call site name. For the - same executable and the same call point, a best practice is to - use a consistent name, which makes it easier to correlate - cross-trace spans. + the Google Cloud Platform Console. The name may be a method + name or some other per-call site name. For the same executable + and the same call point, a best practice is to use a + consistent name, which makes it easier to correlate cross- + trace spans. start_time: Start time of the span in nanoseconds from the UNIX epoch. end_time: End time of the span in nanoseconds from the UNIX epoch. parent_span_id: - ID of the parent span, if any. Optional. + Optional. ID of the parent span, if any. labels: Collection of labels associated with the span. Label keys must be less than 128 bytes. Label values must be less than 16 @@ -906,19 +914,20 @@ Attributes: project_id: - ID of the Cloud project where the trace data is stored. + Required. ID of the Cloud project where the trace data is + stored. view: - Type of data returned for traces in the list. Optional. + Optional. Type of data returned for traces in the list. Default is ``MINIMAL``. page_size: - Maximum number of traces to return. If not specified or <= 0, - the implementation selects a reasonable value. The + Optional. Maximum number of traces to return. If not specified + or <= 0, the implementation selects a reasonable value. The implementation may return fewer traces than the requested page - size. Optional. + size. page_token: Token identifying the page of results to return. If provided, use the value of the ``next_page_token`` field from a previous - request. Optional. + request. start_time: Start of the time interval (inclusive) during which the trace data was collected from the application. @@ -926,7 +935,7 @@ End of the time interval (inclusive) during which the trace data was collected from the application. filter: - An optional filter against labels for the request. By + Optional. A filter against labels for the request. By default, searches use prefix matching. To specify exact match, prepend a plus symbol (``+``) to the search term. Multiple terms are ANDed. Syntax: - ``root:NAME_PREFIX`` or @@ -954,7 +963,7 @@ ``/http/method:VALUE``. - ``url:VALUE``: Equivalent to ``/http/url:VALUE``. order_by: - Field used to sort the returned traces. Optional. Can be one + Optional. Field used to sort the returned traces. Can be one of the following: - ``trace_id`` - ``name`` (``name`` field of root span in the trace) - ``duration`` (difference between ``end_time`` and ``start_time`` fields of the root span) - @@ -979,7 +988,7 @@ Attributes: traces: - List of trace records returned. + List of trace records as specified by the view parameter. next_page_token: If defined, indicates that there are more traces that match the request and that this value should be passed to the next @@ -1001,9 +1010,10 @@ Attributes: project_id: - ID of the Cloud project where the trace data is stored. + Required. ID of the Cloud project where the trace data is + stored. trace_id: - ID of the trace to return. + Required. ID of the trace to return. """, # @@protoc_insertion_point(class_scope:google.devtools.cloudtrace.v1.GetTraceRequest) ), @@ -1021,9 +1031,10 @@ Attributes: project_id: - ID of the Cloud project where the trace data is stored. + Required. ID of the Cloud project where the trace data is + stored. traces: - The body of the message. + Required. The body of the message. """, # @@protoc_insertion_point(class_scope:google.devtools.cloudtrace.v1.PatchTracesRequest) ), @@ -1033,15 +1044,27 @@ DESCRIPTOR._options = None _TRACESPAN_LABELSENTRY._options = None +_TRACESPAN.fields_by_name["parent_span_id"]._options = None +_LISTTRACESREQUEST.fields_by_name["project_id"]._options = None +_LISTTRACESREQUEST.fields_by_name["view"]._options = None +_LISTTRACESREQUEST.fields_by_name["page_size"]._options = None +_LISTTRACESREQUEST.fields_by_name["filter"]._options = None +_LISTTRACESREQUEST.fields_by_name["order_by"]._options = None +_GETTRACEREQUEST.fields_by_name["project_id"]._options = None +_GETTRACEREQUEST.fields_by_name["trace_id"]._options = None +_PATCHTRACESREQUEST.fields_by_name["project_id"]._options = None +_PATCHTRACESREQUEST.fields_by_name["traces"]._options = None _TRACESERVICE = _descriptor.ServiceDescriptor( name="TraceService", full_name="google.devtools.cloudtrace.v1.TraceService", file=DESCRIPTOR, index=0, - serialized_options=None, - serialized_start=1376, - serialized_end=1841, + serialized_options=_b( + "\312A\031cloudtrace.googleapis.com\322A\212\001https://www.googleapis.com/auth/cloud-platform,https://www.googleapis.com/auth/trace.append,https://www.googleapis.com/auth/trace.readonly" + ), + serialized_start=1511, + serialized_end=2204, methods=[ _descriptor.MethodDescriptor( name="ListTraces", @@ -1051,7 +1074,7 @@ input_type=_LISTTRACESREQUEST, output_type=_LISTTRACESRESPONSE, serialized_options=_b( - '\202\323\344\223\002"\022 /v1/projects/{project_id}/traces' + '\202\323\344\223\002"\022 /v1/projects/{project_id}/traces\332A\nproject_id' ), ), _descriptor.MethodDescriptor( @@ -1062,7 +1085,7 @@ input_type=_GETTRACEREQUEST, output_type=_TRACE, serialized_options=_b( - "\202\323\344\223\002-\022+/v1/projects/{project_id}/traces/{trace_id}" + "\202\323\344\223\002-\022+/v1/projects/{project_id}/traces/{trace_id}\332A\023project_id,trace_id" ), ), _descriptor.MethodDescriptor( @@ -1073,7 +1096,7 @@ input_type=_PATCHTRACESREQUEST, output_type=google_dot_protobuf_dot_empty__pb2._EMPTY, serialized_options=_b( - "\202\323\344\223\002*2 /v1/projects/{project_id}/traces:\006traces" + "\202\323\344\223\002*2 /v1/projects/{project_id}/traces:\006traces\332A\021project_id,traces" ), ), ], diff --git a/trace/google/cloud/trace_v2/__init__.py b/trace/google/cloud/trace_v2/__init__.py index 0678603445f7..474880ac694c 100644 --- a/trace/google/cloud/trace_v2/__init__.py +++ b/trace/google/cloud/trace_v2/__init__.py @@ -16,12 +16,23 @@ from __future__ import absolute_import +import sys +import warnings from google.cloud.trace_v2 import types from google.cloud.trace_v2.gapic import enums from google.cloud.trace_v2.gapic import trace_service_client +if sys.version_info[:2] == (2, 7): + message = ( + "A future version of this library will drop support for Python 2.7." + "More details about Python 2 support for Google Cloud Client Libraries" + "can be found at https://cloud.google.com/python/docs/python2-sunset/" + ) + warnings.warn(message, DeprecationWarning) + + class TraceServiceClient(trace_service_client.TraceServiceClient): __doc__ = trace_service_client.TraceServiceClient.__doc__ enums = enums 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 de2f3c088d2d..1e7fa7e245fa 100644 --- a/trace/google/cloud/trace_v2/gapic/trace_service_client.py +++ b/trace/google/cloud/trace_v2/gapic/trace_service_client.py @@ -87,16 +87,6 @@ def project_path(cls, project): "projects/{project}", project=project, ) - @classmethod - def span_path(cls, project, trace, span): - """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, - ) - def __init__( self, transport=None, @@ -237,7 +227,7 @@ def batch_write_spans( Args: 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 (list[Union[dict, ~google.cloud.trace_v2.types.Span]]): Required. 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 @@ -314,7 +304,8 @@ def create_span( >>> >>> client = trace_v2.TraceServiceClient() >>> - >>> name = client.span_path('[PROJECT]', '[TRACE]', '[SPAN]') + >>> # TODO: Initialize `name`: + >>> name = '' >>> >>> # TODO: Initialize `span_id`: >>> span_id = '' @@ -343,13 +334,13 @@ def create_span( [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. - display_name (Union[dict, ~google.cloud.trace_v2.types.TruncatableString]): A description of the span's operation (up to 128 bytes). Stackdriver - Trace displays the description in the {% dynamic print - site\_values.console\_name %}. For example, the display name can be a - qualified method name or a file name and a line number where the - operation is called. A best practice is to use the same display name - within an application and at the same call point. This makes it easier - to correlate spans in different traces. + 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 + Google Cloud Platform Console. + For example, the display name can be a qualified method name or a file name + and a line number where the operation is called. A best practice is to use + the same display name within an application and at the same call point. + This makes it easier to correlate spans in different traces. If a dict is provided, it must be of the same form as the protobuf message :class:`~google.cloud.trace_v2.types.TruncatableString` @@ -385,18 +376,18 @@ def create_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. + status (Union[dict, ~google.cloud.trace_v2.types.Status]): Optional. The 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]): (Optional) Set this parameter to indicate whether this span is in + 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 + child_span_count (Union[dict, ~google.cloud.trace_v2.types.Int32Value]): Optional. The number of child spans that were generated while this span was active. If set, allows implementation to detect missing child spans. If a dict is provided, it must be of the same form as the protobuf diff --git a/trace/google/cloud/trace_v2/gapic/trace_service_client_config.py b/trace/google/cloud/trace_v2/gapic/trace_service_client_config.py index 778912910db8..c785a1e475f4 100644 --- a/trace/google/cloud/trace_v2/gapic/trace_service_client_config.py +++ b/trace/google/cloud/trace_v2/gapic/trace_service_client_config.py @@ -8,12 +8,12 @@ "retry_params": { "default": { "initial_retry_delay_millis": 100, - "retry_delay_multiplier": 1.2, - "max_retry_delay_millis": 1000, - "initial_rpc_timeout_millis": 30000, - "rpc_timeout_multiplier": 1.5, - "max_rpc_timeout_millis": 60000, - "total_timeout_millis": 120000, + "retry_delay_multiplier": 1.3, + "max_retry_delay_millis": 60000, + "initial_rpc_timeout_millis": 20000, + "rpc_timeout_multiplier": 1.0, + "max_rpc_timeout_millis": 20000, + "total_timeout_millis": 600000, } }, "methods": { @@ -24,7 +24,7 @@ }, "CreateSpan": { "timeout_millis": 60000, - "retry_codes_name": "idempotent", + "retry_codes_name": "non_idempotent", "retry_params_name": "default", }, }, diff --git a/trace/google/cloud/trace_v2/proto/trace.proto b/trace/google/cloud/trace_v2/proto/trace.proto index d9fbe663b38a..f5e628329b3c 100644 --- a/trace/google/cloud/trace_v2/proto/trace.proto +++ b/trace/google/cloud/trace_v2/proto/trace.proto @@ -1,4 +1,4 @@ -// Copyright 2017 Google Inc. +// Copyright 2019 Google LLC. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -17,6 +17,8 @@ syntax = "proto3"; package google.devtools.cloudtrace.v2; import "google/api/annotations.proto"; +import "google/api/field_behavior.proto"; +import "google/api/resource.proto"; import "google/protobuf/timestamp.proto"; import "google/protobuf/wrappers.proto"; import "google/rpc/status.proto"; @@ -35,11 +37,16 @@ option php_namespace = "Google\\Cloud\\Trace\\V2"; // or none at all. Spans do not need to be contiguous—there may be // gaps or overlaps between spans in a trace. message Span { + option (google.api.resource) = { + type: "cloudtrace.googleapis.com/Span" + pattern: "projects/{project}/traces/{trace}/spans/{span}" + }; + // A set of attributes, each in the format `[KEY]:[VALUE]`. message Attributes { // The set of attributes. Each attribute's key can be up to 128 bytes - // long. The value can be a string up to 256 bytes, an integer, or the - // Boolean values `true` and `false`. For example: + // long. The value can be a string up to 256 bytes, a signed 64-bit integer, + // or the Boolean values `true` and `false`. For example: // // "/instance_id": "my-instance" // "/http/user_agent": "" @@ -179,10 +186,10 @@ message Span { // // [SPAN_ID] is a unique identifier for a span within a trace; it // is a 16-character hexadecimal encoding of an 8-byte array. - string name = 1; + string name = 1 [(google.api.field_behavior) = REQUIRED]; // The [SPAN_ID] portion of the span's resource name. - string span_id = 2; + string span_id = 2 [(google.api.field_behavior) = REQUIRED]; // The [SPAN_ID] of this span's parent span. If this is a root span, // then this field must be empty. @@ -190,22 +197,24 @@ message Span { // A description of the span's operation (up to 128 bytes). // Stackdriver Trace displays the description in the - // {% dynamic print site_values.console_name %}. + // Google Cloud Platform Console. // For example, the display name can be a qualified method name or a file name // and a line number where the operation is called. A best practice is to use // the same display name within an application and at the same call point. // This makes it easier to correlate spans in different traces. - TruncatableString display_name = 4; + TruncatableString display_name = 4 [(google.api.field_behavior) = REQUIRED]; // The start time of the span. On the client side, this is the time kept by // the local machine where the span execution starts. On the server side, this // is the time when the server's application handler starts running. - google.protobuf.Timestamp start_time = 5; + google.protobuf.Timestamp start_time = 5 + [(google.api.field_behavior) = REQUIRED]; // The end time of the span. On the client side, this is the time kept by // the local machine where the span execution ends. On the server side, this // is the time when the server application handler stops running. - google.protobuf.Timestamp end_time = 6; + google.protobuf.Timestamp end_time = 6 + [(google.api.field_behavior) = REQUIRED]; // A set of attributes on the span. You can have up to 32 attributes per // span. @@ -221,18 +230,18 @@ message Span { // Links associated with the span. You can have up to 128 links per Span. Links links = 10; - // An optional final status for this span. - google.rpc.Status status = 11; + // Optional. The final status for this span. + google.rpc.Status status = 11 [(google.api.field_behavior) = OPTIONAL]; - // (Optional) Set this parameter to indicate whether this span is in + // 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. - google.protobuf.BoolValue same_process_as_parent_span = 12; + google.protobuf.BoolValue same_process_as_parent_span = 12 [(google.api.field_behavior) = OPTIONAL]; - // An optional number of child spans that were generated while this span + // Optional. The number of child spans that were generated while this span // was active. If set, allows implementation to detect missing child spans. - google.protobuf.Int32Value child_span_count = 13; + google.protobuf.Int32Value child_span_count = 13 [(google.api.field_behavior) = OPTIONAL]; } // The allowed types for [VALUE] in a `[KEY]:[VALUE]` attribute. diff --git a/trace/google/cloud/trace_v2/proto/trace_pb2.py b/trace/google/cloud/trace_v2/proto/trace_pb2.py index 22825ebdb550..4a117d94f01a 100644 --- a/trace/google/cloud/trace_v2/proto/trace_pb2.py +++ b/trace/google/cloud/trace_v2/proto/trace_pb2.py @@ -16,6 +16,8 @@ from google.api import annotations_pb2 as google_dot_api_dot_annotations__pb2 +from google.api import field_behavior_pb2 as google_dot_api_dot_field__behavior__pb2 +from google.api import resource_pb2 as google_dot_api_dot_resource__pb2 from google.protobuf import timestamp_pb2 as google_dot_protobuf_dot_timestamp__pb2 from google.protobuf import wrappers_pb2 as google_dot_protobuf_dot_wrappers__pb2 from google.rpc import status_pb2 as google_dot_rpc_dot_status__pb2 @@ -29,10 +31,12 @@ "\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" ), 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' + '\n/google/devtools/cloudtrace_v2/proto/trace.proto\x12\x1dgoogle.devtools.cloudtrace.v2\x1a\x1cgoogle/api/annotations.proto\x1a\x1fgoogle/api/field_behavior.proto\x1a\x19google/api/resource.proto\x1a\x1fgoogle/protobuf/timestamp.proto\x1a\x1egoogle/protobuf/wrappers.proto\x1a\x17google/rpc/status.proto"\xc2\x10\n\x04Span\x12\x11\n\x04name\x18\x01 \x01(\tB\x03\xe0\x41\x02\x12\x14\n\x07span_id\x18\x02 \x01(\tB\x03\xe0\x41\x02\x12\x16\n\x0eparent_span_id\x18\x03 \x01(\t\x12K\n\x0c\x64isplay_name\x18\x04 \x01(\x0b\x32\x30.google.devtools.cloudtrace.v2.TruncatableStringB\x03\xe0\x41\x02\x12\x33\n\nstart_time\x18\x05 \x01(\x0b\x32\x1a.google.protobuf.TimestampB\x03\xe0\x41\x02\x12\x31\n\x08\x65nd_time\x18\x06 \x01(\x0b\x32\x1a.google.protobuf.TimestampB\x03\xe0\x41\x02\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.StatusB\x03\xe0\x41\x01\x12\x44\n\x1bsame_process_as_parent_span\x18\x0c \x01(\x0b\x32\x1a.google.protobuf.BoolValueB\x03\xe0\x41\x01\x12:\n\x10\x63hild_span_count\x18\r \x01(\x0b\x32\x1b.google.protobuf.Int32ValueB\x03\xe0\x41\x01\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:S\xea\x41P\n\x1e\x63loudtrace.googleapis.com/Span\x12.projects/{project}/traces/{trace}/spans/{span}"\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_api_dot_field__behavior__pb2.DESCRIPTOR, + google_dot_api_dot_resource__pb2.DESCRIPTOR, google_dot_protobuf_dot_timestamp__pb2.DESCRIPTOR, google_dot_protobuf_dot_wrappers__pb2.DESCRIPTOR, google_dot_rpc_dot_status__pb2.DESCRIPTOR, @@ -62,8 +66,8 @@ ], containing_type=None, serialized_options=None, - serialized_start=1632, - serialized_end=1684, + serialized_start=1732, + serialized_end=1784, ) _sym_db.RegisterEnumDescriptor(_SPAN_TIMEEVENT_MESSAGEEVENT_TYPE) @@ -97,8 +101,8 @@ ], containing_type=None, serialized_options=None, - serialized_start=2023, - serialized_end=2098, + serialized_start=2123, + serialized_end=2198, ) _sym_db.RegisterEnumDescriptor(_SPAN_LINK_TYPE) @@ -155,8 +159,8 @@ syntax="proto3", extension_ranges=[], oneofs=[], - serialized_start=985, - serialized_end=1083, + serialized_start=1085, + serialized_end=1183, ) _SPAN_ATTRIBUTES = _descriptor.Descriptor( @@ -211,8 +215,8 @@ syntax="proto3", extension_ranges=[], oneofs=[], - serialized_start=848, - serialized_end=1083, + serialized_start=948, + serialized_end=1183, ) _SPAN_TIMEEVENT_ANNOTATION = _descriptor.Descriptor( @@ -267,8 +271,8 @@ syntax="proto3", extension_ranges=[], oneofs=[], - serialized_start=1307, - serialized_end=1458, + serialized_start=1407, + serialized_end=1558, ) _SPAN_TIMEEVENT_MESSAGEEVENT = _descriptor.Descriptor( @@ -359,8 +363,8 @@ syntax="proto3", extension_ranges=[], oneofs=[], - serialized_start=1461, - serialized_end=1684, + serialized_start=1561, + serialized_end=1784, ) _SPAN_TIMEEVENT = _descriptor.Descriptor( @@ -441,8 +445,8 @@ fields=[], ), ], - serialized_start=1086, - serialized_end=1693, + serialized_start=1186, + serialized_end=1793, ) _SPAN_TIMEEVENTS = _descriptor.Descriptor( @@ -515,8 +519,8 @@ syntax="proto3", extension_ranges=[], oneofs=[], - serialized_start=1696, - serialized_end=1848, + serialized_start=1796, + serialized_end=1948, ) _SPAN_LINK = _descriptor.Descriptor( @@ -607,8 +611,8 @@ syntax="proto3", extension_ranges=[], oneofs=[], - serialized_start=1851, - serialized_end=2098, + serialized_start=1951, + serialized_end=2198, ) _SPAN_LINKS = _descriptor.Descriptor( @@ -663,8 +667,8 @@ syntax="proto3", extension_ranges=[], oneofs=[], - serialized_start=2100, - serialized_end=2192, + serialized_start=2200, + serialized_end=2292, ) _SPAN = _descriptor.Descriptor( @@ -689,7 +693,7 @@ containing_type=None, is_extension=False, extension_scope=None, - serialized_options=None, + serialized_options=_b("\340A\002"), file=DESCRIPTOR, ), _descriptor.FieldDescriptor( @@ -707,7 +711,7 @@ containing_type=None, is_extension=False, extension_scope=None, - serialized_options=None, + serialized_options=_b("\340A\002"), file=DESCRIPTOR, ), _descriptor.FieldDescriptor( @@ -743,7 +747,7 @@ containing_type=None, is_extension=False, extension_scope=None, - serialized_options=None, + serialized_options=_b("\340A\002"), file=DESCRIPTOR, ), _descriptor.FieldDescriptor( @@ -761,7 +765,7 @@ containing_type=None, is_extension=False, extension_scope=None, - serialized_options=None, + serialized_options=_b("\340A\002"), file=DESCRIPTOR, ), _descriptor.FieldDescriptor( @@ -779,7 +783,7 @@ containing_type=None, is_extension=False, extension_scope=None, - serialized_options=None, + serialized_options=_b("\340A\002"), file=DESCRIPTOR, ), _descriptor.FieldDescriptor( @@ -869,7 +873,7 @@ containing_type=None, is_extension=False, extension_scope=None, - serialized_options=None, + serialized_options=_b("\340A\001"), file=DESCRIPTOR, ), _descriptor.FieldDescriptor( @@ -887,7 +891,7 @@ containing_type=None, is_extension=False, extension_scope=None, - serialized_options=None, + serialized_options=_b("\340A\001"), file=DESCRIPTOR, ), _descriptor.FieldDescriptor( @@ -905,7 +909,7 @@ containing_type=None, is_extension=False, extension_scope=None, - serialized_options=None, + serialized_options=_b("\340A\001"), file=DESCRIPTOR, ), ], @@ -918,13 +922,15 @@ _SPAN_LINKS, ], enum_types=[], - serialized_options=None, + serialized_options=_b( + "\352AP\n\036cloudtrace.googleapis.com/Span\022.projects/{project}/traces/{trace}/spans/{span}" + ), is_extendable=False, syntax="proto3", extension_ranges=[], oneofs=[], - serialized_start=203, - serialized_end=2192, + serialized_start=263, + serialized_end=2377, ) @@ -1006,8 +1012,8 @@ fields=[], ), ], - serialized_start=2195, - serialized_end=2337, + serialized_start=2380, + serialized_end=2522, ) @@ -1153,8 +1159,8 @@ syntax="proto3", extension_ranges=[], oneofs=[], - serialized_start=2461, - serialized_end=2875, + serialized_start=2646, + serialized_end=3060, ) _STACKTRACE_STACKFRAMES = _descriptor.Descriptor( @@ -1209,8 +1215,8 @@ syntax="proto3", extension_ranges=[], oneofs=[], - serialized_start=2877, - serialized_end=2989, + serialized_start=3062, + serialized_end=3174, ) _STACKTRACE = _descriptor.Descriptor( @@ -1265,8 +1271,8 @@ syntax="proto3", extension_ranges=[], oneofs=[], - serialized_start=2340, - serialized_end=2989, + serialized_start=2525, + serialized_end=3174, ) @@ -1322,8 +1328,8 @@ syntax="proto3", extension_ranges=[], oneofs=[], - serialized_start=2992, - serialized_end=3134, + serialized_start=3177, + serialized_end=3319, ) @@ -1379,8 +1385,8 @@ syntax="proto3", extension_ranges=[], oneofs=[], - serialized_start=3136, - serialized_end=3200, + serialized_start=3321, + serialized_end=3385, ) _SPAN_ATTRIBUTES_ATTRIBUTEMAPENTRY.fields_by_name[ @@ -1513,9 +1519,9 @@ Attributes: attribute_map: The set of attributes. Each attribute's key can be up to 128 - bytes long. The value can be a string up to 256 bytes, an - integer, or the Boolean values ``true`` and ``false``. For - example: :: "/instance_id": "my-instance" + bytes long. The value can be a string up to 256 bytes, a + signed 64-bit integer, or the Boolean values ``true`` and + ``false``. For example: :: "/instance_id": "my-instance" "/http/user_agent": "" "/http/request_bytes": 300 "abc.com/myattribute": true dropped_attributes_count: @@ -1694,13 +1700,12 @@ span, then this field must be empty. display_name: A description of the span's operation (up to 128 bytes). - Stackdriver Trace displays the description in the {% dynamic - print site\_values.console\_name %}. For example, the display - name can be a qualified method name or a file name and a line - number where the operation is called. A best practice is to - use the same display name within an application and at the - same call point. This makes it easier to correlate spans in - different traces. + Stackdriver Trace displays the description in the Google Cloud + Platform Console. For example, the display name can be a + qualified method name or a file name and a line number where + the operation is called. A best practice is to use the same + display name within an application and at the same call point. + This makes it easier to correlate spans in different traces. start_time: The start time of the span. On the client side, this is the time kept by the local machine where the span execution @@ -1723,14 +1728,14 @@ Links associated with the span. You can have up to 128 links per Span. status: - An optional final status for this span. + Optional. The final status for this span. same_process_as_parent_span: - (Optional) Set this parameter to indicate whether this span is + 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 + Optional. The number of child spans that were generated while this span was active. If set, allows implementation to detect missing child spans. """, @@ -1906,4 +1911,13 @@ DESCRIPTOR._options = None _SPAN_ATTRIBUTES_ATTRIBUTEMAPENTRY._options = None +_SPAN.fields_by_name["name"]._options = None +_SPAN.fields_by_name["span_id"]._options = None +_SPAN.fields_by_name["display_name"]._options = None +_SPAN.fields_by_name["start_time"]._options = None +_SPAN.fields_by_name["end_time"]._options = None +_SPAN.fields_by_name["status"]._options = None +_SPAN.fields_by_name["same_process_as_parent_span"]._options = None +_SPAN.fields_by_name["child_span_count"]._options = None +_SPAN._options = None # @@protoc_insertion_point(module_scope) diff --git a/trace/google/cloud/trace_v2/proto/tracing.proto b/trace/google/cloud/trace_v2/proto/tracing.proto index 2990d4606a6b..966a817917d9 100644 --- a/trace/google/cloud/trace_v2/proto/tracing.proto +++ b/trace/google/cloud/trace_v2/proto/tracing.proto @@ -1,4 +1,4 @@ -// Copyright 2017 Google Inc. +// Copyright 2019 Google LLC. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -11,12 +11,16 @@ // 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. +// syntax = "proto3"; package google.devtools.cloudtrace.v2; import "google/api/annotations.proto"; +import "google/api/client.proto"; +import "google/api/field_behavior.proto"; +import "google/api/resource.proto"; import "google/devtools/cloudtrace/v2/trace.proto"; import "google/protobuf/empty.proto"; import "google/protobuf/timestamp.proto"; @@ -34,6 +38,11 @@ option php_namespace = "Google\\Cloud\\Trace\\V2"; // timed event which forms a node of the trace tree. A single trace may // contain span(s) from multiple services. service TraceService { + option (google.api.default_host) = "cloudtrace.googleapis.com"; + option (google.api.oauth_scopes) = + "https://www.googleapis.com/auth/cloud-platform," + "https://www.googleapis.com/auth/trace.append"; + // Sends new spans to new or existing traces. You cannot update // existing spans. rpc BatchWriteSpans(BatchWriteSpansRequest) returns (google.protobuf.Empty) { @@ -41,12 +50,13 @@ service TraceService { post: "/v2/{name=projects/*}/traces:batchWrite" body: "*" }; + option (google.api.method_signature) = "name,spans"; } // Creates a new span. rpc CreateSpan(Span) returns (Span) { option (google.api.http) = { - post: "/v2/{name=projects/*/traces/*}/spans" + post: "/v2/{name=projects/*/traces/*/spans/*}" body: "*" }; } @@ -56,9 +66,14 @@ service TraceService { message BatchWriteSpansRequest { // Required. The name of the project where the spans belong. The format is // `projects/[PROJECT_ID]`. - string name = 1; + string name = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "cloudresourcemanager.googleapis.com/Project" + } + ]; - // A list of new spans. The span names must not match existing + // Required. A list of new spans. The span names must not match existing // spans, or the results are undefined. - repeated Span spans = 2; + repeated Span spans = 2 [(google.api.field_behavior) = REQUIRED]; } diff --git a/trace/google/cloud/trace_v2/proto/tracing_pb2.py b/trace/google/cloud/trace_v2/proto/tracing_pb2.py index fa3989d8f725..4bcd957e7d73 100644 --- a/trace/google/cloud/trace_v2/proto/tracing_pb2.py +++ b/trace/google/cloud/trace_v2/proto/tracing_pb2.py @@ -16,6 +16,9 @@ from google.api import annotations_pb2 as google_dot_api_dot_annotations__pb2 +from google.api import client_pb2 as google_dot_api_dot_client__pb2 +from google.api import field_behavior_pb2 as google_dot_api_dot_field__behavior__pb2 +from google.api import resource_pb2 as google_dot_api_dot_resource__pb2 from google.cloud.trace_v2.proto import ( trace_pb2 as google_dot_devtools_dot_cloudtrace__v2_dot_proto_dot_trace__pb2, ) @@ -31,10 +34,13 @@ "\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" ), 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' + '\n1google/devtools/cloudtrace_v2/proto/tracing.proto\x12\x1dgoogle.devtools.cloudtrace.v2\x1a\x1cgoogle/api/annotations.proto\x1a\x17google/api/client.proto\x1a\x1fgoogle/api/field_behavior.proto\x1a\x19google/api/resource.proto\x1a/google/devtools/cloudtrace_v2/proto/trace.proto\x1a\x1bgoogle/protobuf/empty.proto\x1a\x1fgoogle/protobuf/timestamp.proto"\x94\x01\n\x16\x42\x61tchWriteSpansRequest\x12\x41\n\x04name\x18\x01 \x01(\tB3\xe0\x41\x02\xfa\x41-\n+cloudresourcemanager.googleapis.com/Project\x12\x37\n\x05spans\x18\x02 \x03(\x0b\x32#.google.devtools.cloudtrace.v2.SpanB\x03\xe0\x41\x02\x32\xba\x03\n\x0cTraceService\x12\xa1\x01\n\x0f\x42\x61tchWriteSpans\x12\x35.google.devtools.cloudtrace.v2.BatchWriteSpansRequest\x1a\x16.google.protobuf.Empty"?\x82\xd3\xe4\x93\x02,"\'/v2/{name=projects/*}/traces:batchWrite:\x01*\xda\x41\nname,spans\x12\x89\x01\n\nCreateSpan\x12#.google.devtools.cloudtrace.v2.Span\x1a#.google.devtools.cloudtrace.v2.Span"1\x82\xd3\xe4\x93\x02+"&/v2/{name=projects/*/traces/*/spans/*}:\x01*\x1az\xca\x41\x19\x63loudtrace.googleapis.com\xd2\x41[https://www.googleapis.com/auth/cloud-platform,https://www.googleapis.com/auth/trace.appendB\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_api_dot_client__pb2.DESCRIPTOR, + google_dot_api_dot_field__behavior__pb2.DESCRIPTOR, + google_dot_api_dot_resource__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, @@ -64,7 +70,9 @@ containing_type=None, is_extension=False, extension_scope=None, - serialized_options=None, + serialized_options=_b( + "\340A\002\372A-\n+cloudresourcemanager.googleapis.com/Project" + ), file=DESCRIPTOR, ), _descriptor.FieldDescriptor( @@ -82,7 +90,7 @@ containing_type=None, is_extension=False, extension_scope=None, - serialized_options=None, + serialized_options=_b("\340A\002"), file=DESCRIPTOR, ), ], @@ -94,8 +102,8 @@ syntax="proto3", extension_ranges=[], oneofs=[], - serialized_start=225, - serialized_end=315, + serialized_start=311, + serialized_end=459, ) _BATCHWRITESPANSREQUEST.fields_by_name[ @@ -118,8 +126,8 @@ Required. The name of the project where the spans belong. The format is ``projects/[PROJECT_ID]``. spans: - A list of new spans. The span names must not match existing - spans, or the results are undefined. + Required. 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) ), @@ -128,15 +136,19 @@ DESCRIPTOR._options = None +_BATCHWRITESPANSREQUEST.fields_by_name["name"]._options = None +_BATCHWRITESPANSREQUEST.fields_by_name["spans"]._options = None _TRACESERVICE = _descriptor.ServiceDescriptor( name="TraceService", full_name="google.devtools.cloudtrace.v2.TraceService", file=DESCRIPTOR, index=0, - serialized_options=None, - serialized_start=318, - serialized_end=621, + serialized_options=_b( + "\312A\031cloudtrace.googleapis.com\322A[https://www.googleapis.com/auth/cloud-platform,https://www.googleapis.com/auth/trace.append" + ), + serialized_start=462, + serialized_end=904, methods=[ _descriptor.MethodDescriptor( name="BatchWriteSpans", @@ -146,7 +158,7 @@ input_type=_BATCHWRITESPANSREQUEST, output_type=google_dot_protobuf_dot_empty__pb2._EMPTY, serialized_options=_b( - "\202\323\344\223\002,\"'/v2/{name=projects/*}/traces:batchWrite:\001*" + "\202\323\344\223\002,\"'/v2/{name=projects/*}/traces:batchWrite:\001*\332A\nname,spans" ), ), _descriptor.MethodDescriptor( @@ -157,7 +169,7 @@ input_type=google_dot_devtools_dot_cloudtrace__v2_dot_proto_dot_trace__pb2._SPAN, output_type=google_dot_devtools_dot_cloudtrace__v2_dot_proto_dot_trace__pb2._SPAN, serialized_options=_b( - '\202\323\344\223\002)"$/v2/{name=projects/*/traces/*}/spans:\001*' + '\202\323\344\223\002+"&/v2/{name=projects/*/traces/*/spans/*}:\001*' ), ), ], diff --git a/trace/synth.metadata b/trace/synth.metadata index 9f6b3ef84a5d..ba87b6341691 100644 --- a/trace/synth.metadata +++ b/trace/synth.metadata @@ -1,19 +1,19 @@ { - "updateTime": "2019-11-12T13:44:02.252326Z", + "updateTime": "2020-01-08T13:34:12.157097Z", "sources": [ { "generator": { "name": "artman", - "version": "0.41.1", - "dockerImage": "googleapis/artman@sha256:545c758c76c3f779037aa259023ec3d1ef2d57d2c8cd00a222cb187d63ceac5e" + "version": "0.43.0", + "dockerImage": "googleapis/artman@sha256:264654a37596a44b0668b8ce6ac41082d713f6ee150b3fc6425fa78cc64e4f20" } }, { "git": { "name": "googleapis", "remote": "https://github.com/googleapis/googleapis.git", - "sha": "f69562be0608904932bdcfbc5ad8b9a22d9dceb8", - "internalRef": "279774957" + "sha": "08b488e0660c59842a7dee0e3e2b65d9e3a514a9", + "internalRef": "288625007" } }, { 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 3bbef437e65b..a2601fb1848d 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 @@ -61,8 +61,16 @@ class CustomException(Exception): class TestTraceServiceClient(object): - def test_patch_traces(self): - channel = ChannelStub() + def test_list_traces(self): + # Setup Expected Response + next_page_token = "" + traces_element = {} + traces = [traces_element] + expected_response = {"next_page_token": next_page_token, "traces": traces} + expected_response = trace_pb2.ListTracesResponse(**expected_response) + + # Mock the API response + channel = ChannelStub(responses=[expected_response]) patch = mock.patch("google.api_core.grpc_helpers.create_channel") with patch as create_channel: create_channel.return_value = channel @@ -70,19 +78,19 @@ def test_patch_traces(self): # Setup Request project_id = "projectId-1969970175" - traces = {} - client.patch_traces(project_id, traces) + paged_list_response = client.list_traces(project_id) + resources = list(paged_list_response) + assert len(resources) == 1 + + assert expected_response.traces[0] == resources[0] assert len(channel.requests) == 1 - expected_request = trace_pb2.PatchTracesRequest( - project_id=project_id, traces=traces - ) + expected_request = trace_pb2.ListTracesRequest(project_id=project_id) actual_request = channel.requests[0][1] assert expected_request == actual_request - def test_patch_traces_exception(self): - # Mock the API response + def test_list_traces_exception(self): channel = ChannelStub(responses=[CustomException()]) patch = mock.patch("google.api_core.grpc_helpers.create_channel") with patch as create_channel: @@ -91,10 +99,10 @@ def test_patch_traces_exception(self): # Setup request project_id = "projectId-1969970175" - traces = {} + paged_list_response = client.list_traces(project_id) with pytest.raises(CustomException): - client.patch_traces(project_id, traces) + list(paged_list_response) def test_get_trace(self): # Setup Expected Response @@ -139,16 +147,8 @@ def test_get_trace_exception(self): with pytest.raises(CustomException): client.get_trace(project_id, trace_id) - def test_list_traces(self): - # Setup Expected Response - next_page_token = "" - traces_element = {} - traces = [traces_element] - expected_response = {"next_page_token": next_page_token, "traces": traces} - expected_response = trace_pb2.ListTracesResponse(**expected_response) - - # Mock the API response - channel = ChannelStub(responses=[expected_response]) + def test_patch_traces(self): + channel = ChannelStub() patch = mock.patch("google.api_core.grpc_helpers.create_channel") with patch as create_channel: create_channel.return_value = channel @@ -156,19 +156,19 @@ def test_list_traces(self): # Setup Request project_id = "projectId-1969970175" + traces = {} - paged_list_response = client.list_traces(project_id) - resources = list(paged_list_response) - assert len(resources) == 1 - - assert expected_response.traces[0] == resources[0] + client.patch_traces(project_id, traces) assert len(channel.requests) == 1 - expected_request = trace_pb2.ListTracesRequest(project_id=project_id) + expected_request = trace_pb2.PatchTracesRequest( + project_id=project_id, traces=traces + ) actual_request = channel.requests[0][1] assert expected_request == actual_request - def test_list_traces_exception(self): + def test_patch_traces_exception(self): + # Mock the API response channel = ChannelStub(responses=[CustomException()]) patch = mock.patch("google.api_core.grpc_helpers.create_channel") with patch as create_channel: @@ -177,7 +177,7 @@ def test_list_traces_exception(self): # Setup request project_id = "projectId-1969970175" + traces = {} - paged_list_response = client.list_traces(project_id) with pytest.raises(CustomException): - list(paged_list_response) + client.patch_traces(project_id, traces) 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 e8df09a8de37..69c087966bd0 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 @@ -116,7 +116,7 @@ def test_create_span(self): client = trace_v2.TraceServiceClient() # Setup Request - name = client.span_path("[PROJECT]", "[TRACE]", "[SPAN]") + name = "name3373707" span_id = "spanId-2011840976" display_name = {} start_time = {} @@ -145,7 +145,7 @@ def test_create_span_exception(self): client = trace_v2.TraceServiceClient() # Setup request - name = client.span_path("[PROJECT]", "[TRACE]", "[SPAN]") + name = "name3373707" span_id = "spanId-2011840976" display_name = {} start_time = {}