Class TraceServiceClient (0.22.1)

TraceServiceClient(
    transport=None,
    channel=None,
    credentials=None,
    client_config=None,
    client_info=None,
    client_options=None,
)

This file describes an API for collecting and viewing traces and spans within a trace. A Trace is a collection of spans corresponding to a single operation or set of operations for an application. A span is an individual timed event which forms a node of the trace tree. Spans for a single trace may span multiple services.

Methods

TraceServiceClient

TraceServiceClient(
    transport=None,
    channel=None,
    credentials=None,
    client_config=None,
    client_info=None,
    client_options=None,
)

Constructor.

Parameters
NameDescription
channel grpc.Channel

DEPRECATED. A Channel instance through which to make calls. This argument is mutually exclusive with credentials; providing both will raise an exception.

credentials google.auth.credentials.Credentials

The authorization credentials to attach to requests. These credentials identify this application to the service. If none are specified, the client will attempt to ascertain the credentials from the environment. This argument is mutually exclusive with providing a transport instance to transport; doing so will raise an exception.

client_config dict

DEPRECATED. A dictionary of call options for each method. If not specified, the default configuration is used.

client_info google.api_core.gapic_v1.client_info.ClientInfo

The client info used to send a user-agent string along with API requests. If None, then default info will be used. Generally, you only need to set this if you're developing your own client library.

client_options Union[dict, google.api_core.client_options.ClientOptions]

Client options used to set user options on the client. API Endpoint should be set through client_options.

from_service_account_file

from_service_account_file(filename, *args, **kwargs)

Creates an instance of this client using the provided credentials file.

Parameter
NameDescription
filename str

The path to the service account private key json file.

Returns
TypeDescription
TraceServiceClientThe constructed client.

from_service_account_json

from_service_account_json(filename, *args, **kwargs)

Creates an instance of this client using the provided credentials file.

Parameter
NameDescription
filename str

The path to the service account private key json file.

Returns
TypeDescription
TraceServiceClientThe constructed client.

get_trace

get_trace(project_id, trace_id, retry=<_MethodDefault._DEFAULT_VALUE: <object object>>, timeout=<_MethodDefault._DEFAULT_VALUE: <object object>>, metadata=None)

Gets a single trace by its ID.

.. rubric:: Example

from google.cloud import trace_v1

client = trace_v1.TraceServiceClient()

TODO: Initialize project_id:

project_id = ''

TODO: Initialize trace_id:

trace_id = ''

response = client.get_trace(project_id, trace_id)

Parameters
NameDescription
project_id str

ID of the Cloud project where the trace data is stored.

trace_id str

ID of the trace to return.

retry Optional[google.api_core.retry.Retry]

A retry object used to retry requests. If None is specified, requests will be retried using a default configuration.

timeout Optional[float]

The amount of time, in seconds, to wait for the request to complete. Note that if retry is specified, the timeout applies to each individual attempt.

metadata Optional[Sequence[Tuple[str, str]]]

Additional metadata that is provided to the method.

Exceptions
TypeDescription
google.api_core.exceptions.GoogleAPICallErrorIf the request failed for any reason.
google.api_core.exceptions.RetryErrorIf the request failed due to a retryable error and retry attempts failed.
ValueErrorIf the parameters are invalid.

list_traces

list_traces(project_id, view=None, page_size=None, start_time=None, end_time=None, filter_=None, order_by=None, retry=<_MethodDefault._DEFAULT_VALUE: <object object>>, timeout=<_MethodDefault._DEFAULT_VALUE: <object object>>, metadata=None)

Returns of a list of traces that match the specified filter conditions.

.. rubric:: Example

from google.cloud import trace_v1

client = trace_v1.TraceServiceClient()

TODO: Initialize project_id:

project_id = ''

Iterate over all results

for element in client.list_traces(project_id): ... # process element ... pass

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

Parameters
NameDescription
project_id str

ID of the Cloud project where the trace data is stored.

view 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, 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 Timestamp

end_time Union[dict, 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 Timestamp

filter_ str

An optional filter against labels for the request. By default, searches use prefix matching. To specify exact match, prepend a plus symbol (+) to the search term. Multiple terms are ANDed. Syntax: - root:NAME_PREFIX or NAME_PREFIX: Return traces where any root span starts with NAME_PREFIX. - +root:NAME or +NAME: Return traces where any root span's name is exactly NAME. - span:NAME_PREFIX: Return traces where any span starts with NAME_PREFIX. - +span:NAME: Return traces where any span's name is exactly NAME. - latency:DURATION: Return traces whose overall latency is greater or equal to than DURATION. Accepted units are nanoseconds (ns), milliseconds (ms), and seconds (s). Default is ms. For example, latency:24ms returns traces whose overall latency is greater than or equal to 24 milliseconds. - label:LABEL_KEY: Return all traces containing the specified label key (exact match, case-sensitive) regardless of the key:value pair's value (including empty values). - LABEL_KEY:VALUE_PREFIX: Return all traces containing the specified label key (exact match, case-sensitive) whose value starts with VALUE_PREFIX. Both a key and a value must be specified. - +LABEL_KEY:VALUE: Return all traces containing a key:value pair exactly matching the specified text. Both a key and a value must be specified. - method:VALUE: Equivalent to /http/method:VALUE. - url:VALUE: Equivalent to /http/url:VALUE.

order_by str

Field used to sort the returned traces. Optional. Can be one of the following: - trace_id - name (name field of root span in the trace) - duration (difference between end_time and start_time fields of the root span) - start (start_time field of the root span) Descending order can be specified by appending desc to the sort field (for example, name desc). Only one sort field is permitted.

retry Optional[google.api_core.retry.Retry]

A retry object used to retry requests. If None is specified, requests will be retried using a default configuration.

timeout Optional[float]

The amount of time, in seconds, to wait for the request to complete. Note that if retry is specified, the timeout applies to each individual attempt.

metadata Optional[Sequence[Tuple[str, str]]]

Additional metadata that is provided to the method.

Exceptions
TypeDescription
google.api_core.exceptions.GoogleAPICallErrorIf the request failed for any reason.
google.api_core.exceptions.RetryErrorIf the request failed due to a retryable error and retry attempts failed.
ValueErrorIf the parameters are invalid.

patch_traces

patch_traces(project_id, traces, retry=<_MethodDefault._DEFAULT_VALUE: <object object>>, timeout=<_MethodDefault._DEFAULT_VALUE: <object object>>, 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.

.. rubric:: Example

from google.cloud import trace_v1

client = trace_v1.TraceServiceClient()

TODO: Initialize project_id:

project_id = ''

TODO: Initialize traces:

traces = {}

client.patch_traces(project_id, traces)

Parameters
NameDescription
project_id str

ID of the Cloud project where the trace data is stored.

traces Union[dict, Traces]

The body of the message. If a dict is provided, it must be of the same form as the protobuf message 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.

timeout Optional[float]

The amount of time, in seconds, to wait for the request to complete. Note that if retry is specified, the timeout applies to each individual attempt.

metadata Optional[Sequence[Tuple[str, str]]]

Additional metadata that is provided to the method.

Exceptions
TypeDescription
google.api_core.exceptions.GoogleAPICallErrorIf the request failed for any reason.
google.api_core.exceptions.RetryErrorIf the request failed due to a retryable error and retry attempts failed.
ValueErrorIf the parameters are invalid.