Skip to content
This repository was archived by the owner on Dec 31, 2023. It is now read-only.

Commit 92cb4fa

Browse files
feat: Add Cloud Trace v2 retry defaults for BatchWriteSpans (#294)
* feat: Add Cloud Trace v2 retry defaults for BatchWriteSpans PiperOrigin-RevId: 504068544 Source-Link: googleapis/googleapis@685d359 Source-Link: https://github.com/googleapis/googleapis-gen/commit/43aa9dacfc417b625ad8be1bed2a9fc36c277db6 Copy-Tag: eyJwIjoiLmdpdGh1Yi8uT3dsQm90LnlhbWwiLCJoIjoiNDNhYTlkYWNmYzQxN2I2MjVhZDhiZTFiZWQyYTlmYzM2YzI3N2RiNiJ9 * 🦉 Updates from OwlBot post-processor See https://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md Co-authored-by: Owl Bot <gcf-owl-bot[bot]@users.noreply.github.com>
1 parent cb53612 commit 92cb4fa

File tree

9 files changed

+123
-92
lines changed

9 files changed

+123
-92
lines changed

google/cloud/trace_v2/services/trace_service/async_client.py

Lines changed: 33 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -54,12 +54,13 @@
5454

5555

5656
class TraceServiceAsyncClient:
57-
"""This file describes an API for collecting and viewing traces
58-
and spans within a trace. A Trace is a collection of spans
59-
corresponding to a single operation or set of operations for an
60-
application. A span is an individual timed event which forms a
61-
node of the trace tree. A single trace may contain span(s) from
62-
multiple services.
57+
"""Service for collecting and viewing traces and spans within a
58+
trace.
59+
A trace is a collection of spans corresponding to a single
60+
operation or a set of operations in an application.
61+
A span is an individual timed event which forms a node of the
62+
trace tree. A single trace can contain spans from multiple
63+
services.
6364
"""
6465

6566
_client: TraceServiceClient
@@ -229,8 +230,8 @@ async def batch_write_spans(
229230
timeout: Union[float, object] = gapic_v1.method.DEFAULT,
230231
metadata: Sequence[Tuple[str, str]] = (),
231232
) -> None:
232-
r"""Sends new spans to new or existing traces. You cannot
233-
update existing spans.
233+
r"""Batch writes new spans to new or existing traces. You
234+
cannot update existing spans.
234235
235236
.. code-block:: python
236237
@@ -274,7 +275,8 @@ async def sample_batch_write_spans():
274275
spans (:class:`MutableSequence[google.cloud.trace_v2.types.Span]`):
275276
Required. A list of new spans. The
276277
span names must not match existing
277-
spans, or the results are undefined.
278+
spans, otherwise the results are
279+
undefined.
278280
279281
This corresponds to the ``spans`` field
280282
on the ``request`` instance; if ``request`` is provided, this
@@ -308,6 +310,16 @@ async def sample_batch_write_spans():
308310
# and friendly error handling.
309311
rpc = gapic_v1.method_async.wrap_method(
310312
self._client._transport.batch_write_spans,
313+
default_retry=retries.Retry(
314+
initial=0.1,
315+
maximum=30.0,
316+
multiplier=2,
317+
predicate=retries.if_exception_type(
318+
core_exceptions.DeadlineExceeded,
319+
core_exceptions.ServiceUnavailable,
320+
),
321+
deadline=120.0,
322+
),
311323
default_timeout=120.0,
312324
client_info=DEFAULT_CLIENT_INFO,
313325
)
@@ -369,10 +381,11 @@ async def sample_create_span():
369381
within a trace. Spans can be nested to form a trace
370382
tree. Often, a trace contains a root span that describes
371383
the end-to-end latency, and one or more subspans for its
372-
sub-operations. A trace can also contain multiple root
373-
spans, or none at all. Spans do not need to be
374-
contiguous&mdash;there may be gaps or overlaps between
375-
spans in a trace.
384+
sub-operations.
385+
386+
A trace can also contain multiple root spans, or none at
387+
all. Spans do not need to be contiguous&mdash;there
388+
might be gaps or overlaps between spans in a trace.
376389
retry (google.api_core.retry.Retry): Designation of what errors, if any,
377390
should be retried.
378391
timeout (float): The timeout for this request.
@@ -386,11 +399,13 @@ async def sample_create_span():
386399
form a trace tree. Often, a trace
387400
contains a root span that describes the
388401
end-to-end latency, and one or more
389-
subspans for its sub-operations. A trace
390-
can also contain multiple root spans, or
391-
none at all. Spans do not need to be
392-
contiguous&mdash;there may be gaps or
393-
overlaps between spans in a trace.
402+
subspans for its sub-operations.
403+
404+
A trace can also contain multiple root
405+
spans, or none at all. Spans do not need
406+
to be contiguous&mdash;there might be
407+
gaps or overlaps between spans in a
408+
trace.
394409
395410
"""
396411
# Create or coerce a protobuf request object.

google/cloud/trace_v2/services/trace_service/client.py

Lines changed: 23 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -92,12 +92,13 @@ def get_transport_class(
9292

9393

9494
class TraceServiceClient(metaclass=TraceServiceClientMeta):
95-
"""This file describes an API for collecting and viewing traces
96-
and spans within a trace. A Trace is a collection of spans
97-
corresponding to a single operation or set of operations for an
98-
application. A span is an individual timed event which forms a
99-
node of the trace tree. A single trace may contain span(s) from
100-
multiple services.
95+
"""Service for collecting and viewing traces and spans within a
96+
trace.
97+
A trace is a collection of spans corresponding to a single
98+
operation or a set of operations in an application.
99+
A span is an individual timed event which forms a node of the
100+
trace tree. A single trace can contain spans from multiple
101+
services.
101102
"""
102103

103104
@staticmethod
@@ -458,8 +459,8 @@ def batch_write_spans(
458459
timeout: Union[float, object] = gapic_v1.method.DEFAULT,
459460
metadata: Sequence[Tuple[str, str]] = (),
460461
) -> None:
461-
r"""Sends new spans to new or existing traces. You cannot
462-
update existing spans.
462+
r"""Batch writes new spans to new or existing traces. You
463+
cannot update existing spans.
463464
464465
.. code-block:: python
465466
@@ -503,7 +504,8 @@ def sample_batch_write_spans():
503504
spans (MutableSequence[google.cloud.trace_v2.types.Span]):
504505
Required. A list of new spans. The
505506
span names must not match existing
506-
spans, or the results are undefined.
507+
spans, otherwise the results are
508+
undefined.
507509
508510
This corresponds to the ``spans`` field
509511
on the ``request`` instance; if ``request`` is provided, this
@@ -598,10 +600,11 @@ def sample_create_span():
598600
within a trace. Spans can be nested to form a trace
599601
tree. Often, a trace contains a root span that describes
600602
the end-to-end latency, and one or more subspans for its
601-
sub-operations. A trace can also contain multiple root
602-
spans, or none at all. Spans do not need to be
603-
contiguous&mdash;there may be gaps or overlaps between
604-
spans in a trace.
603+
sub-operations.
604+
605+
A trace can also contain multiple root spans, or none at
606+
all. Spans do not need to be contiguous&mdash;there
607+
might be gaps or overlaps between spans in a trace.
605608
retry (google.api_core.retry.Retry): Designation of what errors, if any,
606609
should be retried.
607610
timeout (float): The timeout for this request.
@@ -615,11 +618,13 @@ def sample_create_span():
615618
form a trace tree. Often, a trace
616619
contains a root span that describes the
617620
end-to-end latency, and one or more
618-
subspans for its sub-operations. A trace
619-
can also contain multiple root spans, or
620-
none at all. Spans do not need to be
621-
contiguous&mdash;there may be gaps or
622-
overlaps between spans in a trace.
621+
subspans for its sub-operations.
622+
623+
A trace can also contain multiple root
624+
spans, or none at all. Spans do not need
625+
to be contiguous&mdash;there might be
626+
gaps or overlaps between spans in a
627+
trace.
623628
624629
"""
625630
# Create or coerce a protobuf request object.

google/cloud/trace_v2/services/trace_service/transports/base.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,16 @@ def _prep_wrapped_messages(self, client_info):
128128
self._wrapped_methods = {
129129
self.batch_write_spans: gapic_v1.method.wrap_method(
130130
self.batch_write_spans,
131+
default_retry=retries.Retry(
132+
initial=0.1,
133+
maximum=30.0,
134+
multiplier=2,
135+
predicate=retries.if_exception_type(
136+
core_exceptions.DeadlineExceeded,
137+
core_exceptions.ServiceUnavailable,
138+
),
139+
deadline=120.0,
140+
),
131141
default_timeout=120.0,
132142
client_info=client_info,
133143
),

google/cloud/trace_v2/services/trace_service/transports/grpc.py

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -31,12 +31,13 @@
3131
class TraceServiceGrpcTransport(TraceServiceTransport):
3232
"""gRPC backend transport for TraceService.
3333
34-
This file describes an API for collecting and viewing traces
35-
and spans within a trace. A Trace is a collection of spans
36-
corresponding to a single operation or set of operations for an
37-
application. A span is an individual timed event which forms a
38-
node of the trace tree. A single trace may contain span(s) from
39-
multiple services.
34+
Service for collecting and viewing traces and spans within a
35+
trace.
36+
A trace is a collection of spans corresponding to a single
37+
operation or a set of operations in an application.
38+
A span is an individual timed event which forms a node of the
39+
trace tree. A single trace can contain spans from multiple
40+
services.
4041
4142
This class defines the same methods as the primary client, so the
4243
primary client can load the underlying transport implementation
@@ -240,8 +241,8 @@ def batch_write_spans(
240241
) -> Callable[[tracing.BatchWriteSpansRequest], empty_pb2.Empty]:
241242
r"""Return a callable for the batch write spans method over gRPC.
242243
243-
Sends new spans to new or existing traces. You cannot
244-
update existing spans.
244+
Batch writes new spans to new or existing traces. You
245+
cannot update existing spans.
245246
246247
Returns:
247248
Callable[[~.BatchWriteSpansRequest],

google/cloud/trace_v2/services/trace_service/transports/grpc_asyncio.py

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -32,12 +32,13 @@
3232
class TraceServiceGrpcAsyncIOTransport(TraceServiceTransport):
3333
"""gRPC AsyncIO backend transport for TraceService.
3434
35-
This file describes an API for collecting and viewing traces
36-
and spans within a trace. A Trace is a collection of spans
37-
corresponding to a single operation or set of operations for an
38-
application. A span is an individual timed event which forms a
39-
node of the trace tree. A single trace may contain span(s) from
40-
multiple services.
35+
Service for collecting and viewing traces and spans within a
36+
trace.
37+
A trace is a collection of spans corresponding to a single
38+
operation or a set of operations in an application.
39+
A span is an individual timed event which forms a node of the
40+
trace tree. A single trace can contain spans from multiple
41+
services.
4142
4243
This class defines the same methods as the primary client, so the
4344
primary client can load the underlying transport implementation
@@ -243,8 +244,8 @@ def batch_write_spans(
243244
) -> Callable[[tracing.BatchWriteSpansRequest], Awaitable[empty_pb2.Empty]]:
244245
r"""Return a callable for the batch write spans method over gRPC.
245246
246-
Sends new spans to new or existing traces. You cannot
247-
update existing spans.
247+
Batch writes new spans to new or existing traces. You
248+
cannot update existing spans.
248249
249250
Returns:
250251
Callable[[~.BatchWriteSpansRequest],

google/cloud/trace_v2/types/trace.py

Lines changed: 35 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -36,37 +36,36 @@ class Span(proto.Message):
3636
r"""A span represents a single operation within a trace. Spans
3737
can be nested to form a trace tree. Often, a trace contains a
3838
root span that describes the end-to-end latency, and one or more
39-
subspans for its sub-operations. A trace can also contain
40-
multiple root spans, or none at all. Spans do not need to be
41-
contiguous&mdash;there may be gaps or overlaps between spans in
42-
a trace.
39+
subspans for its sub-operations.
40+
41+
A trace can also contain multiple root spans, or none at all.
42+
Spans do not need to be contiguous&mdash;there might be gaps or
43+
overlaps between spans in a trace.
4344
4445
Attributes:
4546
name (str):
4647
Required. The resource name of the span in the following
4748
format:
4849
49-
::
50-
51-
projects/[PROJECT_ID]/traces/[TRACE_ID]/spans/[SPAN_ID]
50+
- ``projects/[PROJECT_ID]/traces/[TRACE_ID]/spans/[SPAN_ID]``
5251
53-
[TRACE_ID] is a unique identifier for a trace within a
52+
``[TRACE_ID]`` is a unique identifier for a trace within a
5453
project; it is a 32-character hexadecimal encoding of a
55-
16-byte array.
54+
16-byte array. It should not be zero.
5655
57-
[SPAN_ID] is a unique identifier for a span within a trace;
58-
it is a 16-character hexadecimal encoding of an 8-byte
59-
array.
56+
``[SPAN_ID]`` is a unique identifier for a span within a
57+
trace; it is a 16-character hexadecimal encoding of an
58+
8-byte array. It should not be zero. .
6059
span_id (str):
61-
Required. The [SPAN_ID] portion of the span's resource name.
60+
Required. The ``[SPAN_ID]`` portion of the span's resource
61+
name.
6262
parent_span_id (str):
63-
The [SPAN_ID] of this span's parent span. If this is a root
64-
span, then this field must be empty.
63+
The ``[SPAN_ID]`` of this span's parent span. If this is a
64+
root span, then this field must be empty.
6565
display_name (google.cloud.trace_v2.types.TruncatableString):
6666
Required. A description of the span's
67-
operation (up to 128 bytes). Stackdriver Trace
68-
displays the description in the Google Cloud
69-
Platform Console.
67+
operation (up to 128 bytes). Cloud Trace
68+
displays the description in the Cloud console.
7069
For example, the display name can be a qualified
7170
method name or a file name and a line number
7271
where the operation is called. A best practice
@@ -103,9 +102,9 @@ class Span(proto.Message):
103102
same_process_as_parent_span (google.protobuf.wrappers_pb2.BoolValue):
104103
Optional. Set this parameter to indicate
105104
whether this span is in the same process as its
106-
parent. If you do not set this parameter,
107-
Stackdriver Trace is unable to take advantage of
108-
this helpful information.
105+
parent. If you do not set this parameter, Trace
106+
is unable to take advantage of this helpful
107+
information.
109108
child_span_count (google.protobuf.wrappers_pb2.Int32Value):
110109
Optional. The number of child spans that were
111110
generated while this span was active. If set,
@@ -160,13 +159,13 @@ class SpanKind(proto.Enum):
160159
CONSUMER = 5
161160

162161
class Attributes(proto.Message):
163-
r"""A set of attributes, each in the format ``[KEY]:[VALUE]``.
162+
r"""A set of attributes as key-value pairs.
164163
165164
Attributes:
166165
attribute_map (MutableMapping[str, google.cloud.trace_v2.types.AttributeValue]):
167-
The set of attributes. Each attribute's key can be up to 128
166+
A set of attributes. Each attribute's key can be up to 128
168167
bytes long. The value can be a string up to 256 bytes, a
169-
signed 64-bit integer, or the Boolean values ``true`` and
168+
signed 64-bit integer, or the boolean values ``true`` or
170169
``false``. For example:
171170
172171
::
@@ -250,17 +249,16 @@ class MessageEvent(proto.Message):
250249
Type of MessageEvent. Indicates whether the
251250
message was sent or received.
252251
id (int):
253-
An identifier for the MessageEvent's message
254-
that can be used to match SENT and RECEIVED
255-
MessageEvents. It is recommended to be unique
256-
within a Span.
252+
An identifier for the MessageEvent's message that can be
253+
used to match ``SENT`` and ``RECEIVED`` MessageEvents.
257254
uncompressed_size_bytes (int):
258255
The number of uncompressed bytes sent or
259256
received.
260257
compressed_size_bytes (int):
261258
The number of compressed bytes sent or
262-
received. If missing assumed to be the same size
263-
as uncompressed.
259+
received. If missing, the compressed size is
260+
assumed to be the same size as the uncompressed
261+
size.
264262
"""
265263

266264
class Type(proto.Enum):
@@ -355,15 +353,15 @@ class Link(proto.Message):
355353
356354
Attributes:
357355
trace_id (str):
358-
The [TRACE_ID] for a trace within a project.
356+
The ``[TRACE_ID]`` for a trace within a project.
359357
span_id (str):
360-
The [SPAN_ID] for a span within a trace.
358+
The ``[SPAN_ID]`` for a span within a trace.
361359
type (google.cloud.trace_v2.types.Span.Link.Type):
362360
The relationship of the current span relative
363361
to the linked span.
364362
attributes (google.cloud.trace_v2.types.Span.Attributes):
365-
A set of attributes on the link. You have
366-
have up to 32 attributes per link.
363+
A set of attributes on the link. Up to 32
364+
attributes can be specified per link.
367365
"""
368366

369367
class Type(proto.Enum):
@@ -496,7 +494,7 @@ class Links(proto.Message):
496494

497495

498496
class AttributeValue(proto.Message):
499-
r"""The allowed types for [VALUE] in a ``[KEY]:[VALUE]`` attribute.
497+
r"""The allowed types for ``[VALUE]`` in a ``[KEY]:[VALUE]`` attribute.
500498
501499
This message has `oneof`_ fields (mutually exclusive fields).
502500
For each oneof, at most one member field can be set at the same time.
@@ -567,7 +565,8 @@ class StackFrame(proto.Message):
567565
in this frame (up to 1024 bytes).
568566
original_function_name (google.cloud.trace_v2.types.TruncatableString):
569567
An un-mangled function name, if ``function_name`` is
570-
`mangled <http://www.avabodh.com/cxxin/namemangling.html>`__.
568+
mangled. To get information about name mangling, run `this
569+
search <https://www.google.com/search?q=cxx+name+mangling>`__.
571570
The name can be fully-qualified (up to 1024 bytes).
572571
file_name (google.cloud.trace_v2.types.TruncatableString):
573572
The name of the source file where the

0 commit comments

Comments
 (0)