google-cloud-trace 0.39.0 → 0.41.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (48) hide show
  1. checksums.yaml +4 -4
  2. data/AUTHENTICATION.md +3 -2
  3. data/CHANGELOG.md +49 -0
  4. data/CONTRIBUTING.md +4 -5
  5. data/LOGGING.md +1 -1
  6. data/OVERVIEW.md +1 -2
  7. data/lib/google-cloud-trace.rb +20 -12
  8. data/lib/google/cloud/trace.rb +18 -14
  9. data/lib/google/cloud/trace/async_reporter.rb +7 -6
  10. data/lib/google/cloud/trace/credentials.rb +2 -2
  11. data/lib/google/cloud/trace/errors.rb +2 -2
  12. data/lib/google/cloud/trace/faraday_middleware.rb +5 -7
  13. data/lib/google/cloud/trace/label_key.rb +1 -1
  14. data/lib/google/cloud/trace/middleware.rb +7 -8
  15. data/lib/google/cloud/trace/notifications.rb +13 -14
  16. data/lib/google/cloud/trace/patches/active_call_with_trace.rb +2 -2
  17. data/lib/google/cloud/trace/patches/call_with_trace.rb +2 -2
  18. data/lib/google/cloud/trace/rails.rb +2 -2
  19. data/lib/google/cloud/trace/result_set.rb +20 -12
  20. data/lib/google/cloud/trace/service.rb +37 -60
  21. data/lib/google/cloud/trace/span.rb +7 -7
  22. data/lib/google/cloud/trace/trace_record.rb +4 -5
  23. data/lib/google/cloud/trace/utils.rb +1 -1
  24. data/lib/google/cloud/trace/version.rb +1 -1
  25. metadata +23 -72
  26. data/lib/google/cloud/trace/v1.rb +0 -16
  27. data/lib/google/cloud/trace/v1/credentials.rb +0 -39
  28. data/lib/google/cloud/trace/v1/doc/google/devtools/cloudtrace/v1/trace.rb +0 -253
  29. data/lib/google/cloud/trace/v1/doc/google/protobuf/empty.rb +0 -29
  30. data/lib/google/cloud/trace/v1/doc/google/protobuf/timestamp.rb +0 -113
  31. data/lib/google/cloud/trace/v1/trace_service_client.rb +0 -425
  32. data/lib/google/cloud/trace/v1/trace_service_client_config.json +0 -41
  33. data/lib/google/cloud/trace/v2.rb +0 -123
  34. data/lib/google/cloud/trace/v2/credentials.rb +0 -39
  35. data/lib/google/cloud/trace/v2/doc/google/devtools/cloudtrace/v2/trace.rb +0 -356
  36. data/lib/google/cloud/trace/v2/doc/google/devtools/cloudtrace/v2/tracing.rb +0 -33
  37. data/lib/google/cloud/trace/v2/doc/google/protobuf/any.rb +0 -131
  38. data/lib/google/cloud/trace/v2/doc/google/protobuf/empty.rb +0 -29
  39. data/lib/google/cloud/trace/v2/doc/google/protobuf/timestamp.rb +0 -113
  40. data/lib/google/cloud/trace/v2/doc/google/protobuf/wrappers.rb +0 -34
  41. data/lib/google/cloud/trace/v2/doc/google/rpc/status.rb +0 -39
  42. data/lib/google/cloud/trace/v2/trace_service_client.rb +0 -418
  43. data/lib/google/cloud/trace/v2/trace_service_client_config.json +0 -36
  44. data/lib/google/devtools/cloudtrace/v1/trace_pb.rb +0 -82
  45. data/lib/google/devtools/cloudtrace/v1/trace_services_pb.rb +0 -58
  46. data/lib/google/devtools/cloudtrace/v2/trace_pb.rb +0 -142
  47. data/lib/google/devtools/cloudtrace/v2/tracing_pb.rb +0 -29
  48. data/lib/google/devtools/cloudtrace/v2/tracing_services_pb.rb +0 -53
@@ -1,33 +0,0 @@
1
- # Copyright 2020 Google LLC
2
- #
3
- # Licensed under the Apache License, Version 2.0 (the "License");
4
- # you may not use this file except in compliance with the License.
5
- # You may obtain a copy of the License at
6
- #
7
- # https://www.apache.org/licenses/LICENSE-2.0
8
- #
9
- # Unless required by applicable law or agreed to in writing, software
10
- # distributed under the License is distributed on an "AS IS" BASIS,
11
- # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
- # See the License for the specific language governing permissions and
13
- # limitations under the License.
14
-
15
-
16
- module Google
17
- module Devtools
18
- module Cloudtrace
19
- module V2
20
- # The request message for the `BatchWriteSpans` method.
21
- # @!attribute [rw] name
22
- # @return [String]
23
- # Required. The name of the project where the spans belong. The format is
24
- # `projects/[PROJECT_ID]`.
25
- # @!attribute [rw] spans
26
- # @return [Array<Google::Devtools::Cloudtrace::V2::Span>]
27
- # Required. A list of new spans. The span names must not match existing
28
- # spans, or the results are undefined.
29
- class BatchWriteSpansRequest; end
30
- end
31
- end
32
- end
33
- end
@@ -1,131 +0,0 @@
1
- # Copyright 2020 Google LLC
2
- #
3
- # Licensed under the Apache License, Version 2.0 (the "License");
4
- # you may not use this file except in compliance with the License.
5
- # You may obtain a copy of the License at
6
- #
7
- # https://www.apache.org/licenses/LICENSE-2.0
8
- #
9
- # Unless required by applicable law or agreed to in writing, software
10
- # distributed under the License is distributed on an "AS IS" BASIS,
11
- # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
- # See the License for the specific language governing permissions and
13
- # limitations under the License.
14
-
15
-
16
- module Google
17
- module Protobuf
18
- # `Any` contains an arbitrary serialized protocol buffer message along with a
19
- # URL that describes the type of the serialized message.
20
- #
21
- # Protobuf library provides support to pack/unpack Any values in the form
22
- # of utility functions or additional generated methods of the Any type.
23
- #
24
- # Example 1: Pack and unpack a message in C++.
25
- #
26
- # Foo foo = ...;
27
- # Any any;
28
- # any.PackFrom(foo);
29
- # ...
30
- # if (any.UnpackTo(&foo)) {
31
- # ...
32
- # }
33
- #
34
- # Example 2: Pack and unpack a message in Java.
35
- #
36
- # Foo foo = ...;
37
- # Any any = Any.pack(foo);
38
- # ...
39
- # if (any.is(Foo.class)) {
40
- # foo = any.unpack(Foo.class);
41
- # }
42
- #
43
- # Example 3: Pack and unpack a message in Python.
44
- #
45
- # foo = Foo(...)
46
- # any = Any()
47
- # any.Pack(foo)
48
- # ...
49
- # if any.Is(Foo.DESCRIPTOR):
50
- # any.Unpack(foo)
51
- # ...
52
- #
53
- # Example 4: Pack and unpack a message in Go
54
- #
55
- # foo := &pb.Foo{...}
56
- # any, err := ptypes.MarshalAny(foo)
57
- # ...
58
- # foo := &pb.Foo{}
59
- # if err := ptypes.UnmarshalAny(any, foo); err != nil {
60
- # ...
61
- # }
62
- #
63
- # The pack methods provided by protobuf library will by default use
64
- # 'type.googleapis.com/full.type.name' as the type URL and the unpack
65
- # methods only use the fully qualified type name after the last '/'
66
- # in the type URL, for example "foo.bar.com/x/y.z" will yield type
67
- # name "y.z".
68
- #
69
- #
70
- # = JSON
71
- #
72
- # The JSON representation of an `Any` value uses the regular
73
- # representation of the deserialized, embedded message, with an
74
- # additional field `@type` which contains the type URL. Example:
75
- #
76
- # package google.profile;
77
- # message Person {
78
- # string first_name = 1;
79
- # string last_name = 2;
80
- # }
81
- #
82
- # {
83
- # "@type": "type.googleapis.com/google.profile.Person",
84
- # "firstName": <string>,
85
- # "lastName": <string>
86
- # }
87
- #
88
- # If the embedded message type is well-known and has a custom JSON
89
- # representation, that representation will be embedded adding a field
90
- # `value` which holds the custom JSON in addition to the `@type`
91
- # field. Example (for message {Google::Protobuf::Duration}):
92
- #
93
- # {
94
- # "@type": "type.googleapis.com/google.protobuf.Duration",
95
- # "value": "1.212s"
96
- # }
97
- # @!attribute [rw] type_url
98
- # @return [String]
99
- # A URL/resource name that uniquely identifies the type of the serialized
100
- # protocol buffer message. This string must contain at least
101
- # one "/" character. The last segment of the URL's path must represent
102
- # the fully qualified name of the type (as in
103
- # `path/google.protobuf.Duration`). The name should be in a canonical form
104
- # (e.g., leading "." is not accepted).
105
- #
106
- # In practice, teams usually precompile into the binary all types that they
107
- # expect it to use in the context of Any. However, for URLs which use the
108
- # scheme `http`, `https`, or no scheme, one can optionally set up a type
109
- # server that maps type URLs to message definitions as follows:
110
- #
111
- # * If no scheme is provided, `https` is assumed.
112
- # * An HTTP GET on the URL must yield a {Google::Protobuf::Type}
113
- # value in binary format, or produce an error.
114
- # * Applications are allowed to cache lookup results based on the
115
- # URL, or have them precompiled into a binary to avoid any
116
- # lookup. Therefore, binary compatibility needs to be preserved
117
- # on changes to types. (Use versioned type names to manage
118
- # breaking changes.)
119
- #
120
- # Note: this functionality is not currently available in the official
121
- # protobuf release, and it is not used for type URLs beginning with
122
- # type.googleapis.com.
123
- #
124
- # Schemes other than `http`, `https` (or the empty scheme) might be
125
- # used with implementation specific semantics.
126
- # @!attribute [rw] value
127
- # @return [String]
128
- # Must be a valid serialized protocol buffer of the above specified type.
129
- class Any; end
130
- end
131
- end
@@ -1,29 +0,0 @@
1
- # Copyright 2020 Google LLC
2
- #
3
- # Licensed under the Apache License, Version 2.0 (the "License");
4
- # you may not use this file except in compliance with the License.
5
- # You may obtain a copy of the License at
6
- #
7
- # https://www.apache.org/licenses/LICENSE-2.0
8
- #
9
- # Unless required by applicable law or agreed to in writing, software
10
- # distributed under the License is distributed on an "AS IS" BASIS,
11
- # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
- # See the License for the specific language governing permissions and
13
- # limitations under the License.
14
-
15
-
16
- module Google
17
- module Protobuf
18
- # A generic empty message that you can re-use to avoid defining duplicated
19
- # empty messages in your APIs. A typical example is to use it as the request
20
- # or the response type of an API method. For instance:
21
- #
22
- # service Foo {
23
- # rpc Bar(google.protobuf.Empty) returns (google.protobuf.Empty);
24
- # }
25
- #
26
- # The JSON representation for `Empty` is empty JSON object `{}`.
27
- class Empty; end
28
- end
29
- end
@@ -1,113 +0,0 @@
1
- # Copyright 2020 Google LLC
2
- #
3
- # Licensed under the Apache License, Version 2.0 (the "License");
4
- # you may not use this file except in compliance with the License.
5
- # You may obtain a copy of the License at
6
- #
7
- # https://www.apache.org/licenses/LICENSE-2.0
8
- #
9
- # Unless required by applicable law or agreed to in writing, software
10
- # distributed under the License is distributed on an "AS IS" BASIS,
11
- # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
- # See the License for the specific language governing permissions and
13
- # limitations under the License.
14
-
15
-
16
- module Google
17
- module Protobuf
18
- # A Timestamp represents a point in time independent of any time zone or local
19
- # calendar, encoded as a count of seconds and fractions of seconds at
20
- # nanosecond resolution. The count is relative to an epoch at UTC midnight on
21
- # January 1, 1970, in the proleptic Gregorian calendar which extends the
22
- # Gregorian calendar backwards to year one.
23
- #
24
- # All minutes are 60 seconds long. Leap seconds are "smeared" so that no leap
25
- # second table is needed for interpretation, using a [24-hour linear
26
- # smear](https://developers.google.com/time/smear).
27
- #
28
- # The range is from 0001-01-01T00:00:00Z to 9999-12-31T23:59:59.999999999Z. By
29
- # restricting to that range, we ensure that we can convert to and from [RFC
30
- # 3339](https://www.ietf.org/rfc/rfc3339.txt) date strings.
31
- #
32
- # = Examples
33
- #
34
- # Example 1: Compute Timestamp from POSIX `time()`.
35
- #
36
- # Timestamp timestamp;
37
- # timestamp.set_seconds(time(NULL));
38
- # timestamp.set_nanos(0);
39
- #
40
- # Example 2: Compute Timestamp from POSIX `gettimeofday()`.
41
- #
42
- # struct timeval tv;
43
- # gettimeofday(&tv, NULL);
44
- #
45
- # Timestamp timestamp;
46
- # timestamp.set_seconds(tv.tv_sec);
47
- # timestamp.set_nanos(tv.tv_usec * 1000);
48
- #
49
- # Example 3: Compute Timestamp from Win32 `GetSystemTimeAsFileTime()`.
50
- #
51
- # FILETIME ft;
52
- # GetSystemTimeAsFileTime(&ft);
53
- # UINT64 ticks = (((UINT64)ft.dwHighDateTime) << 32) | ft.dwLowDateTime;
54
- #
55
- # // A Windows tick is 100 nanoseconds. Windows epoch 1601-01-01T00:00:00Z
56
- # // is 11644473600 seconds before Unix epoch 1970-01-01T00:00:00Z.
57
- # Timestamp timestamp;
58
- # timestamp.set_seconds((INT64) ((ticks / 10000000) - 11644473600LL));
59
- # timestamp.set_nanos((INT32) ((ticks % 10000000) * 100));
60
- #
61
- # Example 4: Compute Timestamp from Java `System.currentTimeMillis()`.
62
- #
63
- # long millis = System.currentTimeMillis();
64
- #
65
- # Timestamp timestamp = Timestamp.newBuilder().setSeconds(millis / 1000)
66
- # .setNanos((int) ((millis % 1000) * 1000000)).build();
67
- #
68
- #
69
- # Example 5: Compute Timestamp from current time in Python.
70
- #
71
- # timestamp = Timestamp()
72
- # timestamp.GetCurrentTime()
73
- #
74
- # = JSON Mapping
75
- #
76
- # In JSON format, the Timestamp type is encoded as a string in the
77
- # [RFC 3339](https://www.ietf.org/rfc/rfc3339.txt) format. That is, the
78
- # format is "\\{year}-\\{month}-\\{day}T\\{hour}:\\{min}:\\{sec}[.\\{frac_sec}]Z"
79
- # where \\{year} is always expressed using four digits while \\{month}, \\{day},
80
- # \\{hour}, \\{min}, and \\{sec} are zero-padded to two digits each. The fractional
81
- # seconds, which can go up to 9 digits (i.e. up to 1 nanosecond resolution),
82
- # are optional. The "Z" suffix indicates the timezone ("UTC"); the timezone
83
- # is required. A proto3 JSON serializer should always use UTC (as indicated by
84
- # "Z") when printing the Timestamp type and a proto3 JSON parser should be
85
- # able to accept both UTC and other timezones (as indicated by an offset).
86
- #
87
- # For example, "2017-01-15T01:30:15.01Z" encodes 15.01 seconds past
88
- # 01:30 UTC on January 15, 2017.
89
- #
90
- # In JavaScript, one can convert a Date object to this format using the
91
- # standard
92
- # [toISOString()](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/toISOString)
93
- # method. In Python, a standard `datetime.datetime` object can be converted
94
- # to this format using
95
- # [`strftime`](https://docs.python.org/2/library/time.html#time.strftime) with
96
- # the time format spec '%Y-%m-%dT%H:%M:%S.%fZ'. Likewise, in Java, one can use
97
- # the Joda Time's [`ISODateTimeFormat.dateTime()`](
98
- # http://www.joda.org/joda-time/apidocs/org/joda/time/format/ISODateTimeFormat.html#dateTime%2D%2D
99
- # ) to obtain a formatter capable of generating timestamps in this format.
100
- # @!attribute [rw] seconds
101
- # @return [Integer]
102
- # Represents seconds of UTC time since Unix epoch
103
- # 1970-01-01T00:00:00Z. Must be from 0001-01-01T00:00:00Z to
104
- # 9999-12-31T23:59:59Z inclusive.
105
- # @!attribute [rw] nanos
106
- # @return [Integer]
107
- # Non-negative fractions of a second at nanosecond resolution. Negative
108
- # second values with fractions must still have non-negative nanos values
109
- # that count forward in time. Must be from 0 to 999,999,999
110
- # inclusive.
111
- class Timestamp; end
112
- end
113
- end
@@ -1,34 +0,0 @@
1
- # Copyright 2020 Google LLC
2
- #
3
- # Licensed under the Apache License, Version 2.0 (the "License");
4
- # you may not use this file except in compliance with the License.
5
- # You may obtain a copy of the License at
6
- #
7
- # https://www.apache.org/licenses/LICENSE-2.0
8
- #
9
- # Unless required by applicable law or agreed to in writing, software
10
- # distributed under the License is distributed on an "AS IS" BASIS,
11
- # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
- # See the License for the specific language governing permissions and
13
- # limitations under the License.
14
-
15
-
16
- module Google
17
- module Protobuf
18
- # Wrapper message for `int32`.
19
- #
20
- # The JSON representation for `Int32Value` is JSON number.
21
- # @!attribute [rw] value
22
- # @return [Integer]
23
- # The int32 value.
24
- class Int32Value; end
25
-
26
- # Wrapper message for `bool`.
27
- #
28
- # The JSON representation for `BoolValue` is JSON `true` and `false`.
29
- # @!attribute [rw] value
30
- # @return [true, false]
31
- # The bool value.
32
- class BoolValue; end
33
- end
34
- end
@@ -1,39 +0,0 @@
1
- # Copyright 2020 Google LLC
2
- #
3
- # Licensed under the Apache License, Version 2.0 (the "License");
4
- # you may not use this file except in compliance with the License.
5
- # You may obtain a copy of the License at
6
- #
7
- # https://www.apache.org/licenses/LICENSE-2.0
8
- #
9
- # Unless required by applicable law or agreed to in writing, software
10
- # distributed under the License is distributed on an "AS IS" BASIS,
11
- # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
- # See the License for the specific language governing permissions and
13
- # limitations under the License.
14
-
15
-
16
- module Google
17
- module Rpc
18
- # The `Status` type defines a logical error model that is suitable for
19
- # different programming environments, including REST APIs and RPC APIs. It is
20
- # used by [gRPC](https://github.com/grpc). Each `Status` message contains
21
- # three pieces of data: error code, error message, and error details.
22
- #
23
- # You can find out more about this error model and how to work with it in the
24
- # [API Design Guide](https://cloud.google.com/apis/design/errors).
25
- # @!attribute [rw] code
26
- # @return [Integer]
27
- # The status code, which should be an enum value of {Google::Rpc::Code}.
28
- # @!attribute [rw] message
29
- # @return [String]
30
- # A developer-facing error message, which should be in English. Any
31
- # user-facing error message should be localized and sent in the
32
- # {Google::Rpc::Status#details} field, or localized by the client.
33
- # @!attribute [rw] details
34
- # @return [Array<Google::Protobuf::Any>]
35
- # A list of messages that carry the error details. There is a common set of
36
- # message types for APIs to use.
37
- class Status; end
38
- end
39
- end
@@ -1,418 +0,0 @@
1
- # Copyright 2020 Google LLC
2
- #
3
- # Licensed under the Apache License, Version 2.0 (the "License");
4
- # you may not use this file except in compliance with the License.
5
- # You may obtain a copy of the License at
6
- #
7
- # https://www.apache.org/licenses/LICENSE-2.0
8
- #
9
- # Unless required by applicable law or agreed to in writing, software
10
- # distributed under the License is distributed on an "AS IS" BASIS,
11
- # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
- # See the License for the specific language governing permissions and
13
- # limitations under the License.
14
- #
15
- # EDITING INSTRUCTIONS
16
- # This file was generated from the file
17
- # https://github.com/googleapis/googleapis/blob/master/google/devtools/cloudtrace/v2/tracing.proto,
18
- # and updates to that file get reflected here through a refresh process.
19
- # For the short term, the refresh process will only be runnable by Google
20
- # engineers.
21
-
22
-
23
- require "json"
24
- require "pathname"
25
-
26
- require "google/gax"
27
-
28
- require "google/devtools/cloudtrace/v2/tracing_pb"
29
- require "google/cloud/trace/v2/credentials"
30
- require "google/cloud/trace/version"
31
-
32
- module Google
33
- module Cloud
34
- module Trace
35
- module V2
36
- # This file describes an API for collecting and viewing traces and spans
37
- # within a trace. A Trace is a collection of spans corresponding to a single
38
- # operation or set of operations for an application. A span is an individual
39
- # timed event which forms a node of the trace tree. A single trace may
40
- # contain span(s) from multiple services.
41
- #
42
- # @!attribute [r] trace_service_stub
43
- # @return [Google::Devtools::Cloudtrace::V2::TraceService::Stub]
44
- class TraceServiceClient
45
- # @private
46
- attr_reader :trace_service_stub
47
-
48
- # The default address of the service.
49
- SERVICE_ADDRESS = "cloudtrace.googleapis.com".freeze
50
-
51
- # The default port of the service.
52
- DEFAULT_SERVICE_PORT = 443
53
-
54
- # The default set of gRPC interceptors.
55
- GRPC_INTERCEPTORS = []
56
-
57
- DEFAULT_TIMEOUT = 30
58
-
59
- # The scopes needed to make gRPC calls to all of the methods defined in
60
- # this service.
61
- ALL_SCOPES = [
62
- "https://www.googleapis.com/auth/cloud-platform",
63
- "https://www.googleapis.com/auth/trace.append"
64
- ].freeze
65
-
66
-
67
- PROJECT_PATH_TEMPLATE = Google::Gax::PathTemplate.new(
68
- "projects/{project}"
69
- )
70
-
71
- private_constant :PROJECT_PATH_TEMPLATE
72
-
73
- SPAN_PATH_TEMPLATE = Google::Gax::PathTemplate.new(
74
- "projects/{project}/traces/{trace}/spans/{span}"
75
- )
76
-
77
- private_constant :SPAN_PATH_TEMPLATE
78
-
79
- # Returns a fully-qualified project resource name string.
80
- # @param project [String]
81
- # @return [String]
82
- def self.project_path project
83
- PROJECT_PATH_TEMPLATE.render(
84
- :"project" => project
85
- )
86
- end
87
-
88
- # Returns a fully-qualified span resource name string.
89
- # @param project [String]
90
- # @param trace [String]
91
- # @param span [String]
92
- # @return [String]
93
- def self.span_path project, trace, span
94
- SPAN_PATH_TEMPLATE.render(
95
- :"project" => project,
96
- :"trace" => trace,
97
- :"span" => span
98
- )
99
- end
100
-
101
- # @param credentials [Google::Auth::Credentials, String, Hash, GRPC::Core::Channel, GRPC::Core::ChannelCredentials, Proc]
102
- # Provides the means for authenticating requests made by the client. This parameter can
103
- # be many types.
104
- # A `Google::Auth::Credentials` uses a the properties of its represented keyfile for
105
- # authenticating requests made by this client.
106
- # A `String` will be treated as the path to the keyfile to be used for the construction of
107
- # credentials for this client.
108
- # A `Hash` will be treated as the contents of a keyfile to be used for the construction of
109
- # credentials for this client.
110
- # A `GRPC::Core::Channel` will be used to make calls through.
111
- # A `GRPC::Core::ChannelCredentials` for the setting up the RPC client. The channel credentials
112
- # should already be composed with a `GRPC::Core::CallCredentials` object.
113
- # A `Proc` will be used as an updater_proc for the Grpc channel. The proc transforms the
114
- # metadata for requests, generally, to give OAuth credentials.
115
- # @param scopes [Array<String>]
116
- # The OAuth scopes for this service. This parameter is ignored if
117
- # an updater_proc is supplied.
118
- # @param client_config [Hash]
119
- # A Hash for call options for each method. See
120
- # Google::Gax#construct_settings for the structure of
121
- # this data. Falls back to the default config if not specified
122
- # or the specified config is missing data points.
123
- # @param timeout [Numeric]
124
- # The default timeout, in seconds, for calls made through this client.
125
- # @param metadata [Hash]
126
- # Default metadata to be sent with each request. This can be overridden on a per call basis.
127
- # @param service_address [String]
128
- # Override for the service hostname, or `nil` to leave as the default.
129
- # @param service_port [Integer]
130
- # Override for the service port, or `nil` to leave as the default.
131
- # @param exception_transformer [Proc]
132
- # An optional proc that intercepts any exceptions raised during an API call to inject
133
- # custom error handling.
134
- def initialize \
135
- credentials: nil,
136
- scopes: ALL_SCOPES,
137
- client_config: {},
138
- timeout: DEFAULT_TIMEOUT,
139
- metadata: nil,
140
- service_address: nil,
141
- service_port: nil,
142
- exception_transformer: nil,
143
- lib_name: nil,
144
- lib_version: ""
145
- # These require statements are intentionally placed here to initialize
146
- # the gRPC module only when it's required.
147
- # See https://github.com/googleapis/toolkit/issues/446
148
- require "google/gax/grpc"
149
- require "google/devtools/cloudtrace/v2/tracing_services_pb"
150
-
151
- credentials ||= Google::Cloud::Trace::V2::Credentials.default
152
-
153
- if credentials.is_a?(String) || credentials.is_a?(Hash)
154
- updater_proc = Google::Cloud::Trace::V2::Credentials.new(credentials).updater_proc
155
- end
156
- if credentials.is_a?(GRPC::Core::Channel)
157
- channel = credentials
158
- end
159
- if credentials.is_a?(GRPC::Core::ChannelCredentials)
160
- chan_creds = credentials
161
- end
162
- if credentials.is_a?(Proc)
163
- updater_proc = credentials
164
- end
165
- if credentials.is_a?(Google::Auth::Credentials)
166
- updater_proc = credentials.updater_proc
167
- end
168
-
169
- package_version = Google::Cloud::Trace::VERSION
170
-
171
- google_api_client = "gl-ruby/#{RUBY_VERSION}"
172
- google_api_client << " #{lib_name}/#{lib_version}" if lib_name
173
- google_api_client << " gapic/#{package_version} gax/#{Google::Gax::VERSION}"
174
- google_api_client << " grpc/#{GRPC::VERSION}"
175
- google_api_client.freeze
176
-
177
- headers = { :"x-goog-api-client" => google_api_client }
178
- if credentials.respond_to?(:quota_project_id) && credentials.quota_project_id
179
- headers[:"x-goog-user-project"] = credentials.quota_project_id
180
- end
181
- headers.merge!(metadata) unless metadata.nil?
182
- client_config_file = Pathname.new(__dir__).join(
183
- "trace_service_client_config.json"
184
- )
185
- defaults = client_config_file.open do |f|
186
- Google::Gax.construct_settings(
187
- "google.devtools.cloudtrace.v2.TraceService",
188
- JSON.parse(f.read),
189
- client_config,
190
- Google::Gax::Grpc::STATUS_CODE_NAMES,
191
- timeout,
192
- errors: Google::Gax::Grpc::API_ERRORS,
193
- metadata: headers
194
- )
195
- end
196
-
197
- # Allow overriding the service path/port in subclasses.
198
- service_path = service_address || self.class::SERVICE_ADDRESS
199
- port = service_port || self.class::DEFAULT_SERVICE_PORT
200
- interceptors = self.class::GRPC_INTERCEPTORS
201
- @trace_service_stub = Google::Gax::Grpc.create_stub(
202
- service_path,
203
- port,
204
- chan_creds: chan_creds,
205
- channel: channel,
206
- updater_proc: updater_proc,
207
- scopes: scopes,
208
- interceptors: interceptors,
209
- &Google::Devtools::Cloudtrace::V2::TraceService::Stub.method(:new)
210
- )
211
-
212
- @create_span = Google::Gax.create_api_call(
213
- @trace_service_stub.method(:create_span),
214
- defaults["create_span"],
215
- exception_transformer: exception_transformer,
216
- params_extractor: proc do |request|
217
- {'name' => request.name}
218
- end
219
- )
220
- @batch_write_spans = Google::Gax.create_api_call(
221
- @trace_service_stub.method(:batch_write_spans),
222
- defaults["batch_write_spans"],
223
- exception_transformer: exception_transformer,
224
- params_extractor: proc do |request|
225
- {'name' => request.name}
226
- end
227
- )
228
- end
229
-
230
- # Service calls
231
-
232
- # Creates a new span.
233
- #
234
- # @param name [String]
235
- # Required. The resource name of the span in the following format:
236
- #
237
- # projects/[PROJECT_ID]/traces/[TRACE_ID]/spans/[SPAN_ID]
238
- #
239
- # [TRACE_ID] is a unique identifier for a trace within a project;
240
- # it is a 32-character hexadecimal encoding of a 16-byte array.
241
- #
242
- # [SPAN_ID] is a unique identifier for a span within a trace; it
243
- # is a 16-character hexadecimal encoding of an 8-byte array.
244
- # @param span_id [String]
245
- # Required. The [SPAN_ID] portion of the span's resource name.
246
- # @param display_name [Google::Devtools::Cloudtrace::V2::TruncatableString | Hash]
247
- # Required. A description of the span's operation (up to 128 bytes).
248
- # Stackdriver Trace displays the description in the
249
- # Google Cloud Platform Console.
250
- # For example, the display name can be a qualified method name or a file name
251
- # and a line number where the operation is called. A best practice is to use
252
- # the same display name within an application and at the same call point.
253
- # This makes it easier to correlate spans in different traces.
254
- # A hash of the same form as `Google::Devtools::Cloudtrace::V2::TruncatableString`
255
- # can also be provided.
256
- # @param start_time [Google::Protobuf::Timestamp | Hash]
257
- # Required. The start time of the span. On the client side, this is the time kept by
258
- # the local machine where the span execution starts. On the server side, this
259
- # is the time when the server's application handler starts running.
260
- # A hash of the same form as `Google::Protobuf::Timestamp`
261
- # can also be provided.
262
- # @param end_time [Google::Protobuf::Timestamp | Hash]
263
- # Required. The end time of the span. On the client side, this is the time kept by
264
- # the local machine where the span execution ends. On the server side, this
265
- # is the time when the server application handler stops running.
266
- # A hash of the same form as `Google::Protobuf::Timestamp`
267
- # can also be provided.
268
- # @param parent_span_id [String]
269
- # The [SPAN_ID] of this span's parent span. If this is a root span,
270
- # then this field must be empty.
271
- # @param attributes [Google::Devtools::Cloudtrace::V2::Span::Attributes | Hash]
272
- # A set of attributes on the span. You can have up to 32 attributes per
273
- # span.
274
- # A hash of the same form as `Google::Devtools::Cloudtrace::V2::Span::Attributes`
275
- # can also be provided.
276
- # @param stack_trace [Google::Devtools::Cloudtrace::V2::StackTrace | Hash]
277
- # Stack trace captured at the start of the span.
278
- # A hash of the same form as `Google::Devtools::Cloudtrace::V2::StackTrace`
279
- # can also be provided.
280
- # @param time_events [Google::Devtools::Cloudtrace::V2::Span::TimeEvents | Hash]
281
- # A set of time events. You can have up to 32 annotations and 128 message
282
- # events per span.
283
- # A hash of the same form as `Google::Devtools::Cloudtrace::V2::Span::TimeEvents`
284
- # can also be provided.
285
- # @param links [Google::Devtools::Cloudtrace::V2::Span::Links | Hash]
286
- # Links associated with the span. You can have up to 128 links per Span.
287
- # A hash of the same form as `Google::Devtools::Cloudtrace::V2::Span::Links`
288
- # can also be provided.
289
- # @param status [Google::Rpc::Status | Hash]
290
- # Optional. The final status for this span.
291
- # A hash of the same form as `Google::Rpc::Status`
292
- # can also be provided.
293
- # @param same_process_as_parent_span [Google::Protobuf::BoolValue | Hash]
294
- # Optional. Set this parameter to indicate whether this span is in
295
- # the same process as its parent. If you do not set this parameter,
296
- # Stackdriver Trace is unable to take advantage of this helpful
297
- # information.
298
- # A hash of the same form as `Google::Protobuf::BoolValue`
299
- # can also be provided.
300
- # @param child_span_count [Google::Protobuf::Int32Value | Hash]
301
- # Optional. The number of child spans that were generated while this span
302
- # was active. If set, allows implementation to detect missing child spans.
303
- # A hash of the same form as `Google::Protobuf::Int32Value`
304
- # can also be provided.
305
- # @param span_kind [Google::Devtools::Cloudtrace::V2::Span::SpanKind]
306
- # Optional. Distinguishes between spans generated in a particular context. For example,
307
- # two spans with the same name may be distinguished using `CLIENT` (caller)
308
- # and `SERVER` (callee) to identify an RPC call.
309
- # @param options [Google::Gax::CallOptions]
310
- # Overrides the default settings for this call, e.g, timeout,
311
- # retries, etc.
312
- # @yield [result, operation] Access the result along with the RPC operation
313
- # @yieldparam result [Google::Devtools::Cloudtrace::V2::Span]
314
- # @yieldparam operation [GRPC::ActiveCall::Operation]
315
- # @return [Google::Devtools::Cloudtrace::V2::Span]
316
- # @raise [Google::Gax::GaxError] if the RPC is aborted.
317
- # @example
318
- # require "google/cloud/trace"
319
- #
320
- # trace_client = Google::Cloud::Trace.new(version: :v2)
321
- # formatted_name = Google::Cloud::Trace::V2::TraceServiceClient.span_path("[PROJECT]", "[TRACE]", "[SPAN]")
322
- #
323
- # # TODO: Initialize `span_id`:
324
- # span_id = ''
325
- #
326
- # # TODO: Initialize `display_name`:
327
- # display_name = {}
328
- #
329
- # # TODO: Initialize `start_time`:
330
- # start_time = {}
331
- #
332
- # # TODO: Initialize `end_time`:
333
- # end_time = {}
334
- # response = trace_client.create_span(formatted_name, span_id, display_name, start_time, end_time)
335
-
336
- def create_span \
337
- name,
338
- span_id,
339
- display_name,
340
- start_time,
341
- end_time,
342
- parent_span_id: nil,
343
- attributes: nil,
344
- stack_trace: nil,
345
- time_events: nil,
346
- links: nil,
347
- status: nil,
348
- same_process_as_parent_span: nil,
349
- child_span_count: nil,
350
- span_kind: nil,
351
- options: nil,
352
- &block
353
- req = {
354
- name: name,
355
- span_id: span_id,
356
- display_name: display_name,
357
- start_time: start_time,
358
- end_time: end_time,
359
- parent_span_id: parent_span_id,
360
- attributes: attributes,
361
- stack_trace: stack_trace,
362
- time_events: time_events,
363
- links: links,
364
- status: status,
365
- same_process_as_parent_span: same_process_as_parent_span,
366
- child_span_count: child_span_count,
367
- span_kind: span_kind
368
- }.delete_if { |_, v| v.nil? }
369
- req = Google::Gax::to_proto(req, Google::Devtools::Cloudtrace::V2::Span)
370
- @create_span.call(req, options, &block)
371
- end
372
-
373
- # Sends new spans to new or existing traces. You cannot update
374
- # existing spans.
375
- #
376
- # @param name [String]
377
- # Required. The name of the project where the spans belong. The format is
378
- # `projects/[PROJECT_ID]`.
379
- # @param spans [Array<Google::Devtools::Cloudtrace::V2::Span | Hash>]
380
- # Required. A list of new spans. The span names must not match existing
381
- # spans, or the results are undefined.
382
- # A hash of the same form as `Google::Devtools::Cloudtrace::V2::Span`
383
- # can also be provided.
384
- # @param options [Google::Gax::CallOptions]
385
- # Overrides the default settings for this call, e.g, timeout,
386
- # retries, etc.
387
- # @yield [result, operation] Access the result along with the RPC operation
388
- # @yieldparam result []
389
- # @yieldparam operation [GRPC::ActiveCall::Operation]
390
- # @raise [Google::Gax::GaxError] if the RPC is aborted.
391
- # @example
392
- # require "google/cloud/trace"
393
- #
394
- # trace_client = Google::Cloud::Trace.new(version: :v2)
395
- # formatted_name = Google::Cloud::Trace::V2::TraceServiceClient.project_path("[PROJECT]")
396
- #
397
- # # TODO: Initialize `spans`:
398
- # spans = []
399
- # trace_client.batch_write_spans(formatted_name, spans)
400
-
401
- def batch_write_spans \
402
- name,
403
- spans,
404
- options: nil,
405
- &block
406
- req = {
407
- name: name,
408
- spans: spans
409
- }.delete_if { |_, v| v.nil? }
410
- req = Google::Gax::to_proto(req, Google::Devtools::Cloudtrace::V2::BatchWriteSpansRequest)
411
- @batch_write_spans.call(req, options, &block)
412
- nil
413
- end
414
- end
415
- end
416
- end
417
- end
418
- end