google-cloud-trace 0.39.0 → 0.41.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/AUTHENTICATION.md +3 -2
- data/CHANGELOG.md +49 -0
- data/CONTRIBUTING.md +4 -5
- data/LOGGING.md +1 -1
- data/OVERVIEW.md +1 -2
- data/lib/google-cloud-trace.rb +20 -12
- data/lib/google/cloud/trace.rb +18 -14
- data/lib/google/cloud/trace/async_reporter.rb +7 -6
- data/lib/google/cloud/trace/credentials.rb +2 -2
- data/lib/google/cloud/trace/errors.rb +2 -2
- data/lib/google/cloud/trace/faraday_middleware.rb +5 -7
- data/lib/google/cloud/trace/label_key.rb +1 -1
- data/lib/google/cloud/trace/middleware.rb +7 -8
- data/lib/google/cloud/trace/notifications.rb +13 -14
- data/lib/google/cloud/trace/patches/active_call_with_trace.rb +2 -2
- data/lib/google/cloud/trace/patches/call_with_trace.rb +2 -2
- data/lib/google/cloud/trace/rails.rb +2 -2
- data/lib/google/cloud/trace/result_set.rb +20 -12
- data/lib/google/cloud/trace/service.rb +37 -60
- data/lib/google/cloud/trace/span.rb +7 -7
- data/lib/google/cloud/trace/trace_record.rb +4 -5
- data/lib/google/cloud/trace/utils.rb +1 -1
- data/lib/google/cloud/trace/version.rb +1 -1
- metadata +23 -72
- data/lib/google/cloud/trace/v1.rb +0 -16
- data/lib/google/cloud/trace/v1/credentials.rb +0 -39
- data/lib/google/cloud/trace/v1/doc/google/devtools/cloudtrace/v1/trace.rb +0 -253
- data/lib/google/cloud/trace/v1/doc/google/protobuf/empty.rb +0 -29
- data/lib/google/cloud/trace/v1/doc/google/protobuf/timestamp.rb +0 -113
- data/lib/google/cloud/trace/v1/trace_service_client.rb +0 -425
- data/lib/google/cloud/trace/v1/trace_service_client_config.json +0 -41
- data/lib/google/cloud/trace/v2.rb +0 -123
- data/lib/google/cloud/trace/v2/credentials.rb +0 -39
- data/lib/google/cloud/trace/v2/doc/google/devtools/cloudtrace/v2/trace.rb +0 -356
- data/lib/google/cloud/trace/v2/doc/google/devtools/cloudtrace/v2/tracing.rb +0 -33
- data/lib/google/cloud/trace/v2/doc/google/protobuf/any.rb +0 -131
- data/lib/google/cloud/trace/v2/doc/google/protobuf/empty.rb +0 -29
- data/lib/google/cloud/trace/v2/doc/google/protobuf/timestamp.rb +0 -113
- data/lib/google/cloud/trace/v2/doc/google/protobuf/wrappers.rb +0 -34
- data/lib/google/cloud/trace/v2/doc/google/rpc/status.rb +0 -39
- data/lib/google/cloud/trace/v2/trace_service_client.rb +0 -418
- data/lib/google/cloud/trace/v2/trace_service_client_config.json +0 -36
- data/lib/google/devtools/cloudtrace/v1/trace_pb.rb +0 -82
- data/lib/google/devtools/cloudtrace/v1/trace_services_pb.rb +0 -58
- data/lib/google/devtools/cloudtrace/v2/trace_pb.rb +0 -142
- data/lib/google/devtools/cloudtrace/v2/tracing_pb.rb +0 -29
- data/lib/google/devtools/cloudtrace/v2/tracing_services_pb.rb +0 -53
@@ -1,16 +0,0 @@
|
|
1
|
-
# Copyright 2016 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
|
-
require "google/cloud/trace/v1/trace_service_client"
|
@@ -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
|
-
require "googleauth"
|
17
|
-
|
18
|
-
module Google
|
19
|
-
module Cloud
|
20
|
-
module Trace
|
21
|
-
module V1
|
22
|
-
class Credentials < Google::Auth::Credentials
|
23
|
-
SCOPE = ["https://www.googleapis.com/auth/cloud-platform"].freeze
|
24
|
-
PATH_ENV_VARS = %w(TRACE_CREDENTIALS
|
25
|
-
TRACE_KEYFILE
|
26
|
-
GOOGLE_CLOUD_CREDENTIALS
|
27
|
-
GOOGLE_CLOUD_KEYFILE
|
28
|
-
GCLOUD_KEYFILE)
|
29
|
-
JSON_ENV_VARS = %w(TRACE_CREDENTIALS_JSON
|
30
|
-
TRACE_KEYFILE_JSON
|
31
|
-
GOOGLE_CLOUD_CREDENTIALS_JSON
|
32
|
-
GOOGLE_CLOUD_KEYFILE_JSON
|
33
|
-
GCLOUD_KEYFILE_JSON)
|
34
|
-
DEFAULT_PATHS = ["~/.config/gcloud/application_default_credentials.json"]
|
35
|
-
end
|
36
|
-
end
|
37
|
-
end
|
38
|
-
end
|
39
|
-
end
|
@@ -1,253 +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 V1
|
20
|
-
# A trace describes how long it takes for an application to perform an
|
21
|
-
# operation. It consists of a set of spans, each of which represent a single
|
22
|
-
# timed event within the operation.
|
23
|
-
# @!attribute [rw] project_id
|
24
|
-
# @return [String]
|
25
|
-
# Project ID of the Cloud project where the trace data is stored.
|
26
|
-
# @!attribute [rw] trace_id
|
27
|
-
# @return [String]
|
28
|
-
# Globally unique identifier for the trace. This identifier is a 128-bit
|
29
|
-
# numeric value formatted as a 32-byte hex string. For example,
|
30
|
-
# `382d4f4c6b7bb2f4a972559d9085001d`.
|
31
|
-
# @!attribute [rw] spans
|
32
|
-
# @return [Array<Google::Devtools::Cloudtrace::V1::TraceSpan>]
|
33
|
-
# Collection of spans in the trace.
|
34
|
-
class Trace; end
|
35
|
-
|
36
|
-
# List of new or updated traces.
|
37
|
-
# @!attribute [rw] traces
|
38
|
-
# @return [Array<Google::Devtools::Cloudtrace::V1::Trace>]
|
39
|
-
# List of traces.
|
40
|
-
class Traces; end
|
41
|
-
|
42
|
-
# A span represents a single timed event within a trace. Spans can be nested
|
43
|
-
# and form a trace tree. Often, a trace contains a root span that describes the
|
44
|
-
# end-to-end latency of an operation and, optionally, one or more subspans for
|
45
|
-
# its suboperations. Spans do not need to be contiguous. There may be gaps
|
46
|
-
# between spans in a trace.
|
47
|
-
# @!attribute [rw] span_id
|
48
|
-
# @return [Integer]
|
49
|
-
# Identifier for the span. Must be a 64-bit integer other than 0 and
|
50
|
-
# unique within a trace. For example, `2205310701640571284`.
|
51
|
-
# @!attribute [rw] kind
|
52
|
-
# @return [Google::Devtools::Cloudtrace::V1::TraceSpan::SpanKind]
|
53
|
-
# Distinguishes between spans generated in a particular context. For example,
|
54
|
-
# two spans with the same name may be distinguished using `RPC_CLIENT`
|
55
|
-
# and `RPC_SERVER` to identify queueing latency associated with the span.
|
56
|
-
# @!attribute [rw] name
|
57
|
-
# @return [String]
|
58
|
-
# Name of the span. Must be less than 128 bytes. The span name is sanitized
|
59
|
-
# and displayed in the Stackdriver Trace tool in the
|
60
|
-
# Google Cloud Platform Console.
|
61
|
-
# The name may be a method name or some other per-call site name.
|
62
|
-
# For the same executable and the same call point, a best practice is
|
63
|
-
# to use a consistent name, which makes it easier to correlate
|
64
|
-
# cross-trace spans.
|
65
|
-
# @!attribute [rw] start_time
|
66
|
-
# @return [Google::Protobuf::Timestamp]
|
67
|
-
# Start time of the span in nanoseconds from the UNIX epoch.
|
68
|
-
# @!attribute [rw] end_time
|
69
|
-
# @return [Google::Protobuf::Timestamp]
|
70
|
-
# End time of the span in nanoseconds from the UNIX epoch.
|
71
|
-
# @!attribute [rw] parent_span_id
|
72
|
-
# @return [Integer]
|
73
|
-
# Optional. ID of the parent span, if any.
|
74
|
-
# @!attribute [rw] labels
|
75
|
-
# @return [Hash{String => String}]
|
76
|
-
# Collection of labels associated with the span. Label keys must be less than
|
77
|
-
# 128 bytes. Label values must be less than 16 kilobytes (10MB for
|
78
|
-
# `/stacktrace` values).
|
79
|
-
#
|
80
|
-
# Some predefined label keys exist, or you may create your own. When creating
|
81
|
-
# your own, we recommend the following formats:
|
82
|
-
#
|
83
|
-
# * `/category/product/key` for agents of well-known products (e.g.
|
84
|
-
# `/db/mongodb/read_size`).
|
85
|
-
# * `short_host/path/key` for domain-specific keys (e.g.
|
86
|
-
# `foo.com/myproduct/bar`)
|
87
|
-
#
|
88
|
-
# Predefined labels include:
|
89
|
-
#
|
90
|
-
# * `/agent`
|
91
|
-
# * `/component`
|
92
|
-
# * `/error/message`
|
93
|
-
# * `/error/name`
|
94
|
-
# * `/http/client_city`
|
95
|
-
# * `/http/client_country`
|
96
|
-
# * `/http/client_protocol`
|
97
|
-
# * `/http/client_region`
|
98
|
-
# * `/http/host`
|
99
|
-
# * `/http/method`
|
100
|
-
# * `/http/path`
|
101
|
-
# * `/http/redirected_url`
|
102
|
-
# * `/http/request/size`
|
103
|
-
# * `/http/response/size`
|
104
|
-
# * `/http/route`
|
105
|
-
# * `/http/status_code`
|
106
|
-
# * `/http/url`
|
107
|
-
# * `/http/user_agent`
|
108
|
-
# * `/pid`
|
109
|
-
# * `/stacktrace`
|
110
|
-
# * `/tid`
|
111
|
-
class TraceSpan
|
112
|
-
# Type of span. Can be used to specify additional relationships between spans
|
113
|
-
# in addition to a parent/child relationship.
|
114
|
-
module SpanKind
|
115
|
-
# Unspecified.
|
116
|
-
SPAN_KIND_UNSPECIFIED = 0
|
117
|
-
|
118
|
-
# Indicates that the span covers server-side handling of an RPC or other
|
119
|
-
# remote network request.
|
120
|
-
RPC_SERVER = 1
|
121
|
-
|
122
|
-
# Indicates that the span covers the client-side wrapper around an RPC or
|
123
|
-
# other remote request.
|
124
|
-
RPC_CLIENT = 2
|
125
|
-
end
|
126
|
-
end
|
127
|
-
|
128
|
-
# The request message for the `ListTraces` method. All fields are required
|
129
|
-
# unless specified.
|
130
|
-
# @!attribute [rw] project_id
|
131
|
-
# @return [String]
|
132
|
-
# Required. ID of the Cloud project where the trace data is stored.
|
133
|
-
# @!attribute [rw] view
|
134
|
-
# @return [Google::Devtools::Cloudtrace::V1::ListTracesRequest::ViewType]
|
135
|
-
# Optional. Type of data returned for traces in the list. Default is
|
136
|
-
# `MINIMAL`.
|
137
|
-
# @!attribute [rw] page_size
|
138
|
-
# @return [Integer]
|
139
|
-
# Optional. Maximum number of traces to return. If not specified or <= 0, the
|
140
|
-
# implementation selects a reasonable value. The implementation may
|
141
|
-
# return fewer traces than the requested page size.
|
142
|
-
# @!attribute [rw] page_token
|
143
|
-
# @return [String]
|
144
|
-
# Token identifying the page of results to return. If provided, use the
|
145
|
-
# value of the `next_page_token` field from a previous request.
|
146
|
-
# @!attribute [rw] start_time
|
147
|
-
# @return [Google::Protobuf::Timestamp]
|
148
|
-
# Start of the time interval (inclusive) during which the trace data was
|
149
|
-
# collected from the application.
|
150
|
-
# @!attribute [rw] end_time
|
151
|
-
# @return [Google::Protobuf::Timestamp]
|
152
|
-
# End of the time interval (inclusive) during which the trace data was
|
153
|
-
# collected from the application.
|
154
|
-
# @!attribute [rw] filter
|
155
|
-
# @return [String]
|
156
|
-
# Optional. A filter against labels for the request.
|
157
|
-
#
|
158
|
-
# By default, searches use prefix matching. To specify exact match, prepend
|
159
|
-
# a plus symbol (`+`) to the search term.
|
160
|
-
# Multiple terms are ANDed. Syntax:
|
161
|
-
#
|
162
|
-
# * `root:NAME_PREFIX` or `NAME_PREFIX`: Return traces where any root
|
163
|
-
# span starts with `NAME_PREFIX`.
|
164
|
-
# * `+root:NAME` or `+NAME`: Return traces where any root span's name is
|
165
|
-
# exactly `NAME`.
|
166
|
-
# * `span:NAME_PREFIX`: Return traces where any span starts with
|
167
|
-
# `NAME_PREFIX`.
|
168
|
-
# * `+span:NAME`: Return traces where any span's name is exactly
|
169
|
-
# `NAME`.
|
170
|
-
# * `latency:DURATION`: Return traces whose overall latency is
|
171
|
-
# greater or equal to than `DURATION`. Accepted units are nanoseconds
|
172
|
-
# (`ns`), milliseconds (`ms`), and seconds (`s`). Default is `ms`. For
|
173
|
-
# example, `latency:24ms` returns traces whose overall latency
|
174
|
-
# is greater than or equal to 24 milliseconds.
|
175
|
-
# * `label:LABEL_KEY`: Return all traces containing the specified
|
176
|
-
# label key (exact match, case-sensitive) regardless of the key:value
|
177
|
-
# pair's value (including empty values).
|
178
|
-
# * `LABEL_KEY:VALUE_PREFIX`: Return all traces containing the specified
|
179
|
-
# label key (exact match, case-sensitive) whose value starts with
|
180
|
-
# `VALUE_PREFIX`. Both a key and a value must be specified.
|
181
|
-
# * `+LABEL_KEY:VALUE`: Return all traces containing a key:value pair
|
182
|
-
# exactly matching the specified text. Both a key and a value must be
|
183
|
-
# specified.
|
184
|
-
# * `method:VALUE`: Equivalent to `/http/method:VALUE`.
|
185
|
-
# * `url:VALUE`: Equivalent to `/http/url:VALUE`.
|
186
|
-
# @!attribute [rw] order_by
|
187
|
-
# @return [String]
|
188
|
-
# Optional. Field used to sort the returned traces.
|
189
|
-
# Can be one of the following:
|
190
|
-
#
|
191
|
-
# * `trace_id`
|
192
|
-
# * `name` (`name` field of root span in the trace)
|
193
|
-
# * `duration` (difference between `end_time` and `start_time` fields of
|
194
|
-
# the root span)
|
195
|
-
# * `start` (`start_time` field of the root span)
|
196
|
-
#
|
197
|
-
# Descending order can be specified by appending `desc` to the sort field
|
198
|
-
# (for example, `name desc`).
|
199
|
-
#
|
200
|
-
# Only one sort field is permitted.
|
201
|
-
class ListTracesRequest
|
202
|
-
# Type of data returned for traces in the list.
|
203
|
-
module ViewType
|
204
|
-
# Default is `MINIMAL` if unspecified.
|
205
|
-
VIEW_TYPE_UNSPECIFIED = 0
|
206
|
-
|
207
|
-
# Minimal view of the trace record that contains only the project
|
208
|
-
# and trace IDs.
|
209
|
-
MINIMAL = 1
|
210
|
-
|
211
|
-
# Root span view of the trace record that returns the root spans along
|
212
|
-
# with the minimal trace data.
|
213
|
-
ROOTSPAN = 2
|
214
|
-
|
215
|
-
# Complete view of the trace record that contains the actual trace data.
|
216
|
-
# This is equivalent to calling the REST `get` or RPC `GetTrace` method
|
217
|
-
# using the ID of each listed trace.
|
218
|
-
COMPLETE = 3
|
219
|
-
end
|
220
|
-
end
|
221
|
-
|
222
|
-
# The response message for the `ListTraces` method.
|
223
|
-
# @!attribute [rw] traces
|
224
|
-
# @return [Array<Google::Devtools::Cloudtrace::V1::Trace>]
|
225
|
-
# List of trace records as specified by the view parameter.
|
226
|
-
# @!attribute [rw] next_page_token
|
227
|
-
# @return [String]
|
228
|
-
# If defined, indicates that there are more traces that match the request
|
229
|
-
# and that this value should be passed to the next request to continue
|
230
|
-
# retrieving additional traces.
|
231
|
-
class ListTracesResponse; end
|
232
|
-
|
233
|
-
# The request message for the `GetTrace` method.
|
234
|
-
# @!attribute [rw] project_id
|
235
|
-
# @return [String]
|
236
|
-
# Required. ID of the Cloud project where the trace data is stored.
|
237
|
-
# @!attribute [rw] trace_id
|
238
|
-
# @return [String]
|
239
|
-
# Required. ID of the trace to return.
|
240
|
-
class GetTraceRequest; end
|
241
|
-
|
242
|
-
# The request message for the `PatchTraces` method.
|
243
|
-
# @!attribute [rw] project_id
|
244
|
-
# @return [String]
|
245
|
-
# Required. ID of the Cloud project where the trace data is stored.
|
246
|
-
# @!attribute [rw] traces
|
247
|
-
# @return [Google::Devtools::Cloudtrace::V1::Traces]
|
248
|
-
# Required. The body of the message.
|
249
|
-
class PatchTracesRequest; end
|
250
|
-
end
|
251
|
-
end
|
252
|
-
end
|
253
|
-
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
|