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

feat: added support for span kind #28

Merged
merged 1 commit into from Aug 6, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
41 changes: 25 additions & 16 deletions google/cloud/trace_v1/gapic/trace_service_client_config.py
Expand Up @@ -2,35 +2,44 @@
"interfaces": {
"google.devtools.cloudtrace.v1.TraceService": {
"retry_codes": {
"idempotent": ["DEADLINE_EXCEEDED", "UNAVAILABLE"],
"non_idempotent": [],
"retry_policy_1_codes": ["UNAVAILABLE", "DEADLINE_EXCEEDED"],
"no_retry_codes": [],
},
"retry_params": {
"default": {
"retry_policy_1_params": {
"initial_retry_delay_millis": 100,
"retry_delay_multiplier": 1.2,
"max_retry_delay_millis": 1000,
"initial_rpc_timeout_millis": 20000,
"rpc_timeout_multiplier": 1.5,
"max_rpc_timeout_millis": 30000,
"initial_rpc_timeout_millis": 45000,
"rpc_timeout_multiplier": 1.0,
"max_rpc_timeout_millis": 45000,
"total_timeout_millis": 45000,
}
},
"no_retry_params": {
"initial_retry_delay_millis": 0,
"retry_delay_multiplier": 0.0,
"max_retry_delay_millis": 0,
"initial_rpc_timeout_millis": 0,
"rpc_timeout_multiplier": 1.0,
"max_rpc_timeout_millis": 0,
"total_timeout_millis": 0,
},
},
"methods": {
"PatchTraces": {
"timeout_millis": 60000,
"retry_codes_name": "idempotent",
"retry_params_name": "default",
"timeout_millis": 45000,
"retry_codes_name": "retry_policy_1_codes",
"retry_params_name": "retry_policy_1_params",
},
"ListTraces": {
"timeout_millis": 60000,
"retry_codes_name": "idempotent",
"retry_params_name": "default",
"timeout_millis": 45000,
"retry_codes_name": "retry_policy_1_codes",
"retry_params_name": "retry_policy_1_params",
},
"GetTrace": {
"timeout_millis": 60000,
"retry_codes_name": "idempotent",
"retry_params_name": "default",
"timeout_millis": 45000,
"retry_codes_name": "retry_policy_1_codes",
"retry_params_name": "retry_policy_1_params",
},
},
}
Expand Down
4 changes: 2 additions & 2 deletions google/cloud/trace_v1/proto/trace.proto
@@ -1,4 +1,4 @@
// Copyright 2019 Google LLC.
// Copyright 2020 Google LLC
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
Expand All @@ -16,12 +16,12 @@ 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";
import "google/api/annotations.proto";

option csharp_namespace = "Google.Cloud.Trace.V1";
option go_package = "google.golang.org/genproto/googleapis/devtools/cloudtrace/v1;cloudtrace";
Expand Down
6 changes: 3 additions & 3 deletions google/cloud/trace_v1/proto/trace_pb2.py

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

30 changes: 30 additions & 0 deletions google/cloud/trace_v2/gapic/enums.py
Expand Up @@ -20,6 +20,36 @@


class Span(object):
class SpanKind(enum.IntEnum):
"""
Type of span. Can be used to specify additional relationships between spans
in addition to a parent/child relationship.

Attributes:
SPAN_KIND_UNSPECIFIED (int): Unspecified. Do NOT use as default.
Implementations MAY assume SpanKind.INTERNAL to be default.
INTERNAL (int): Indicates that the span is used internally. Default value.
SERVER (int): Indicates that the span covers server-side handling of an RPC or other
remote network request.
CLIENT (int): Indicates that the span covers the client-side wrapper around an RPC or
other remote request.
PRODUCER (int): Indicates that the span describes producer sending a message to a broker.
Unlike client and server, there is no direct critical path latency
relationship between producer and consumer spans (e.g. publishing a
message to a pubsub service).
CONSUMER (int): Indicates that the span describes consumer receiving a message from a
broker. Unlike client and server, there is no direct critical path
latency relationship between producer and consumer spans (e.g. receiving
a message from a pubsub service subscription).
"""

SPAN_KIND_UNSPECIFIED = 0
INTERNAL = 1
SERVER = 2
CLIENT = 3
PRODUCER = 4
CONSUMER = 5

class TimeEvent(object):
class MessageEvent(object):
class Type(enum.IntEnum):
Expand Down
16 changes: 11 additions & 5 deletions google/cloud/trace_v2/gapic/trace_service_client.py
Expand Up @@ -225,6 +225,7 @@ def create_span(
status=None,
same_process_as_parent_span=None,
child_span_count=None,
span_kind=None,
retry=google.api_core.gapic_v1.method.DEFAULT,
timeout=google.api_core.gapic_v1.method.DEFAULT,
metadata=None,
Expand Down Expand Up @@ -254,7 +255,7 @@ def create_span(
>>> response = client.create_span(name, span_id, display_name, start_time, end_time)

Args:
name (str): The resource name of the span in the following format:
name (str): Required. The resource name of the span in the following format:

::

Expand All @@ -265,8 +266,8 @@ 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).
span_id (str): Required. The [SPAN_ID] portion of the span's resource name.
display_name (Union[dict, ~google.cloud.trace_v2.types.TruncatableString]): Required. 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
Expand All @@ -276,13 +277,13 @@ 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.TruncatableString`
start_time (Union[dict, ~google.cloud.trace_v2.types.Timestamp]): The start time of the span. On the client side, this is the time kept by
start_time (Union[dict, ~google.cloud.trace_v2.types.Timestamp]): 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.

If a dict is provided, it must be of the same form as the protobuf
message :class:`~google.cloud.trace_v2.types.Timestamp`
end_time (Union[dict, ~google.cloud.trace_v2.types.Timestamp]): The end time of the span. On the client side, this is the time kept by
end_time (Union[dict, ~google.cloud.trace_v2.types.Timestamp]): 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.

Expand Down Expand Up @@ -324,6 +325,10 @@ 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.Int32Value`
span_kind (~google.cloud.trace_v2.types.SpanKind): Optional. Distinguishes between spans generated in a particular
context. For example, two spans with the same name may be distinguished
using ``CLIENT`` (caller) and ``SERVER`` (callee) to identify an RPC
call.
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.
Expand Down Expand Up @@ -368,6 +373,7 @@ def create_span(
status=status,
same_process_as_parent_span=same_process_as_parent_span,
child_span_count=child_span_count,
span_kind=span_kind,
)
if metadata is None:
metadata = []
Expand Down
41 changes: 30 additions & 11 deletions google/cloud/trace_v2/gapic/trace_service_client_config.py
Expand Up @@ -2,30 +2,49 @@
"interfaces": {
"google.devtools.cloudtrace.v2.TraceService": {
"retry_codes": {
"idempotent": ["DEADLINE_EXCEEDED", "UNAVAILABLE"],
"non_idempotent": [],
"retry_policy_1_codes": ["UNAVAILABLE", "DEADLINE_EXCEEDED"],
"no_retry_codes": [],
"no_retry_1_codes": [],
},
"retry_params": {
"default": {
"retry_policy_1_params": {
"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,
"initial_rpc_timeout_millis": 120000,
"rpc_timeout_multiplier": 1.0,
"max_rpc_timeout_millis": 120000,
"total_timeout_millis": 120000,
}
},
"no_retry_params": {
"initial_retry_delay_millis": 0,
"retry_delay_multiplier": 0.0,
"max_retry_delay_millis": 0,
"initial_rpc_timeout_millis": 0,
"rpc_timeout_multiplier": 1.0,
"max_rpc_timeout_millis": 0,
"total_timeout_millis": 0,
},
"no_retry_1_params": {
"initial_retry_delay_millis": 0,
"retry_delay_multiplier": 0.0,
"max_retry_delay_millis": 0,
"initial_rpc_timeout_millis": 120000,
"rpc_timeout_multiplier": 1.0,
"max_rpc_timeout_millis": 120000,
"total_timeout_millis": 120000,
},
},
"methods": {
"CreateSpan": {
"timeout_millis": 60000,
"retry_codes_name": "idempotent",
"retry_params_name": "default",
"retry_codes_name": "retry_policy_1_codes",
"retry_params_name": "retry_policy_1_params",
},
"BatchWriteSpans": {
"timeout_millis": 60000,
"retry_codes_name": "non_idempotent",
"retry_params_name": "default",
"retry_codes_name": "no_retry_1_codes",
"retry_params_name": "no_retry_1_params",
},
},
}
Expand Down