google-cloud-logging 1.2.3 → 1.3.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (33) hide show
  1. checksums.yaml +5 -5
  2. data/lib/google-cloud-logging.rb +13 -10
  3. data/lib/google/cloud/logging.rb +41 -17
  4. data/lib/google/cloud/logging/async_writer.rb +5 -2
  5. data/lib/google/cloud/logging/credentials.rb +31 -15
  6. data/lib/google/cloud/logging/entry.rb +13 -0
  7. data/lib/google/cloud/logging/entry/http_request.rb +35 -12
  8. data/lib/google/cloud/logging/logger.rb +14 -0
  9. data/lib/google/cloud/logging/middleware.rb +1 -1
  10. data/lib/google/cloud/logging/project.rb +55 -8
  11. data/lib/google/cloud/logging/rails.rb +1 -1
  12. data/lib/google/cloud/logging/service.rb +8 -27
  13. data/lib/google/cloud/logging/v2/config_service_v2_client.rb +360 -93
  14. data/lib/google/cloud/logging/v2/config_service_v2_client_config.json +43 -8
  15. data/lib/google/cloud/logging/v2/doc/google/api/distribution.rb +172 -0
  16. data/lib/google/cloud/logging/v2/doc/google/api/metric.rb +187 -0
  17. data/lib/google/cloud/logging/v2/doc/google/api/monitored_resource.rb +4 -4
  18. data/lib/google/cloud/logging/v2/doc/google/logging/type/http_request.rb +4 -1
  19. data/lib/google/cloud/logging/v2/doc/google/logging/v2/log_entry.rb +13 -6
  20. data/lib/google/cloud/logging/v2/doc/google/logging/v2/logging.rb +55 -21
  21. data/lib/google/cloud/logging/v2/doc/google/logging/v2/logging_config.rb +185 -23
  22. data/lib/google/cloud/logging/v2/doc/google/logging/v2/logging_metrics.rb +89 -5
  23. data/lib/google/cloud/logging/v2/doc/google/protobuf/any.rb +12 -2
  24. data/lib/google/cloud/logging/v2/doc/google/protobuf/duration.rb +14 -1
  25. data/lib/google/cloud/logging/v2/doc/google/protobuf/field_mask.rb +223 -0
  26. data/lib/google/cloud/logging/v2/doc/google/protobuf/timestamp.rb +26 -1
  27. data/lib/google/cloud/logging/v2/doc/overview.rb +67 -0
  28. data/lib/google/cloud/logging/v2/logging_service_v2_client.rb +116 -91
  29. data/lib/google/cloud/logging/v2/logging_service_v2_client_config.json +12 -11
  30. data/lib/google/cloud/logging/v2/metrics_service_v2_client.rb +87 -76
  31. data/lib/google/cloud/logging/v2/metrics_service_v2_client_config.json +9 -8
  32. data/lib/google/cloud/logging/version.rb +1 -1
  33. metadata +11 -7
@@ -14,9 +14,29 @@
14
14
 
15
15
  module Google
16
16
  module Logging
17
+ ##
18
+ # # Stackdriver Logging API Contents
19
+ #
20
+ # | Class | Description |
21
+ # | ----- | ----------- |
22
+ # | [LoggingServiceV2Client][] | The Stackdriver Logging API lets you write log entries and manage your logs, log sinks and logs-based metrics. |
23
+ # | [ConfigServiceV2Client][] | The Stackdriver Logging API lets you write log entries and manage your logs, log sinks and logs-based metrics. |
24
+ # | [MetricsServiceV2Client][] | The Stackdriver Logging API lets you write log entries and manage your logs, log sinks and logs-based metrics. |
25
+ # | [Data Types][] | Data types for Google::Cloud::Logging::V2 |
26
+ #
27
+ # [LoggingServiceV2Client]: https://googlecloudplatform.github.io/google-cloud-ruby/#/docs/google-cloud-logging/latest/google/logging/v2/loggingservicev2client
28
+ # [ConfigServiceV2Client]: https://googlecloudplatform.github.io/google-cloud-ruby/#/docs/google-cloud-logging/latest/google/logging/v2/configservicev2client
29
+ # [MetricsServiceV2Client]: https://googlecloudplatform.github.io/google-cloud-ruby/#/docs/google-cloud-logging/latest/google/logging/v2/metricsservicev2client
30
+ # [Data Types]: https://googlecloudplatform.github.io/google-cloud-ruby/#/docs/google-cloud-logging/latest/google/logging/v2/datatypes
31
+ #
17
32
  module V2
18
33
  # Describes a logs-based metric. The value of the metric is the
19
34
  # number of log entries that match a logs filter in a given time interval.
35
+ #
36
+ # A logs-based metric can also be used to extract values from logs and create a
37
+ # a distribution of the values. The distribution records the statistics of the
38
+ # extracted values along with an optional histogram of the values as specified
39
+ # by the bucket options.
20
40
  # @!attribute [rw] name
21
41
  # @return [String]
22
42
  # Required. The client-assigned metric identifier.
@@ -29,7 +49,7 @@ module Google
29
49
  # first character of the name.
30
50
  #
31
51
  # The metric identifier in this field must not be
32
- # {URL-encoded}[https://en.wikipedia.org/wiki/Percent-encoding].
52
+ # [URL-encoded](https://en.wikipedia.org/wiki/Percent-encoding).
33
53
  # However, when the metric identifier appears as the +[METRIC_ID]+
34
54
  # part of a +metric_name+ API parameter, then the metric identifier
35
55
  # must be URL-encoded. Example:
@@ -39,18 +59,82 @@ module Google
39
59
  # Optional. A description of this metric, which is used in documentation.
40
60
  # @!attribute [rw] filter
41
61
  # @return [String]
42
- # Required. An {advanced logs filter}[https://cloud.google.com/logging/docs/view/advanced_filters]
62
+ # Required. An [advanced logs filter](https://cloud.google.com/logging/docs/view/advanced_filters)
43
63
  # which is used to match log entries.
44
64
  # Example:
45
65
  #
46
66
  # "resource.type=gae_app AND severity>=ERROR"
47
67
  #
48
68
  # The maximum length of the filter is 20000 characters.
69
+ # @!attribute [rw] metric_descriptor
70
+ # @return [Google::Api::MetricDescriptor]
71
+ # Optional. The metric descriptor associated with the logs-based metric.
72
+ # If unspecified, it uses a default metric descriptor with a DELTA metric
73
+ # kind, INT64 value type, with no labels and a unit of "1". Such a metric
74
+ # counts the number of log entries matching the +filter+ expression.
75
+ #
76
+ # The +name+, +type+, and +description+ fields in the +metric_descriptor+
77
+ # are output only, and is constructed using the +name+ and +description+
78
+ # field in the LogMetric.
79
+ #
80
+ # To create a logs-based metric that records a distribution of log values, a
81
+ # DELTA metric kind with a DISTRIBUTION value type must be used along with
82
+ # a +value_extractor+ expression in the LogMetric.
83
+ #
84
+ # Each label in the metric descriptor must have a matching label
85
+ # name as the key and an extractor expression as the value in the
86
+ # +label_extractors+ map.
87
+ #
88
+ # The +metric_kind+ and +value_type+ fields in the +metric_descriptor+ cannot
89
+ # be updated once initially configured. New labels can be added in the
90
+ # +metric_descriptor+, but existing labels cannot be modified except for
91
+ # their description.
92
+ # @!attribute [rw] value_extractor
93
+ # @return [String]
94
+ # Optional. A +value_extractor+ is required when using a distribution
95
+ # logs-based metric to extract the values to record from a log entry.
96
+ # Two functions are supported for value extraction: +EXTRACT(field)+ or
97
+ # +REGEXP_EXTRACT(field, regex)+. The argument are:
98
+ # 1. field: The name of the log entry field from which the value is to be
99
+ # extracted.
100
+ # 2. regex: A regular expression using the Google RE2 syntax
101
+ # (https://github.com/google/re2/wiki/Syntax) with a single capture
102
+ # group to extract data from the specified log entry field. The value
103
+ # of the field is converted to a string before applying the regex.
104
+ # It is an error to specify a regex that does not include exactly one
105
+ # capture group.
106
+ #
107
+ # The result of the extraction must be convertible to a double type, as the
108
+ # distribution always records double values. If either the extraction or
109
+ # the conversion to double fails, then those values are not recorded in the
110
+ # distribution.
111
+ #
112
+ # Example: +REGEXP_EXTRACT(jsonPayload.request, ".*quantity=(\d+).*")+
113
+ # @!attribute [rw] label_extractors
114
+ # @return [Hash{String => String}]
115
+ # Optional. A map from a label key string to an extractor expression which is
116
+ # used to extract data from a log entry field and assign as the label value.
117
+ # Each label key specified in the LabelDescriptor must have an associated
118
+ # extractor expression in this map. The syntax of the extractor expression
119
+ # is the same as for the +value_extractor+ field.
120
+ #
121
+ # The extracted value is converted to the type defined in the label
122
+ # descriptor. If the either the extraction or the type conversion fails,
123
+ # the label will have a default value. The default value for a string
124
+ # label is an empty string, for an integer label its 0, and for a boolean
125
+ # label its +false+.
126
+ #
127
+ # Note that there are upper bounds on the maximum number of labels and the
128
+ # number of active time series that are allowed in a project.
129
+ # @!attribute [rw] bucket_options
130
+ # @return [Google::Api::Distribution::BucketOptions]
131
+ # Optional. The +bucket_options+ are required when the logs-based metric is
132
+ # using a DISTRIBUTION value type and it describes the bucket boundaries
133
+ # used to create a histogram of the extracted values.
49
134
  # @!attribute [rw] version
50
135
  # @return [Google::Logging::V2::LogMetric::ApiVersion]
51
- # Output only. The API version that created or updated this metric.
52
- # The version also dictates the syntax of the filter expression. When a value
53
- # for this field is missing, the default value of V2 should be assumed.
136
+ # Deprecated. The API version that created or updated this metric.
137
+ # The v2 format is used by default and cannot be changed.
54
138
  class LogMetric
55
139
  # Stackdriver Logging API version.
56
140
  module ApiVersion
@@ -49,6 +49,16 @@ module Google
49
49
  # any.Unpack(foo)
50
50
  # ...
51
51
  #
52
+ # Example 4: Pack and unpack a message in Go
53
+ #
54
+ # foo := &pb.Foo{...}
55
+ # any, err := ptypes.MarshalAny(foo)
56
+ # ...
57
+ # foo := &pb.Foo{}
58
+ # if err := ptypes.UnmarshalAny(any, foo); err != nil {
59
+ # ...
60
+ # }
61
+ #
52
62
  # The pack methods provided by protobuf library will by default use
53
63
  # 'type.googleapis.com/full.type.name' as the type URL and the unpack
54
64
  # methods only use the fully qualified type name after the last '/'
@@ -77,7 +87,7 @@ module Google
77
87
  # If the embedded message type is well-known and has a custom JSON
78
88
  # representation, that representation will be embedded adding a field
79
89
  # +value+ which holds the custom JSON in addition to the +@type+
80
- # field. Example (for message Google::Protobuf::Duration):
90
+ # field. Example (for message {Google::Protobuf::Duration}):
81
91
  #
82
92
  # {
83
93
  # "@type": "type.googleapis.com/google.protobuf.Duration",
@@ -96,7 +106,7 @@ module Google
96
106
  # qualified name of the type (as in +path/google.protobuf.Duration+).
97
107
  # The name should be in a canonical form (e.g., leading "." is
98
108
  # not accepted).
99
- # * An HTTP GET on the URL must yield a Google::Protobuf::Type
109
+ # * An HTTP GET on the URL must yield a {Google::Protobuf::Type}
100
110
  # value in binary format, or produce an error.
101
111
  # * Applications are allowed to cache lookup results based on the
102
112
  # URL, or have them precompiled into a binary to avoid any
@@ -21,6 +21,8 @@ module Google
21
21
  # two Timestamp values is a Duration and it can be added or subtracted
22
22
  # from a Timestamp. Range is approximately +-10,000 years.
23
23
  #
24
+ # = Examples
25
+ #
24
26
  # Example 1: Compute Duration from two Timestamps in pseudo code.
25
27
  #
26
28
  # Timestamp start = ...;
@@ -60,10 +62,21 @@ module Google
60
62
  # td = datetime.timedelta(days=3, minutes=10)
61
63
  # duration = Duration()
62
64
  # duration.FromTimedelta(td)
65
+ #
66
+ # = JSON Mapping
67
+ #
68
+ # In JSON format, the Duration type is encoded as a string rather than an
69
+ # object, where the string ends in the suffix "s" (indicating seconds) and
70
+ # is preceded by the number of seconds, with nanoseconds expressed as
71
+ # fractional seconds. For example, 3 seconds with 0 nanoseconds should be
72
+ # encoded in JSON format as "3s", while 3 seconds and 1 nanosecond should
73
+ # be expressed in JSON format as "3.000000001s", and 3 seconds and 1
74
+ # microsecond should be expressed in JSON format as "3.000001s".
63
75
  # @!attribute [rw] seconds
64
76
  # @return [Integer]
65
77
  # Signed seconds of the span of time. Must be from -315,576,000,000
66
- # to +315,576,000,000 inclusive.
78
+ # to +315,576,000,000 inclusive. Note: these bounds are computed from:
79
+ # 60 sec/min * 60 min/hr * 24 hr/day * 365.25 days/year * 10000 years
67
80
  # @!attribute [rw] nanos
68
81
  # @return [Integer]
69
82
  # Signed fractions of a second at nanosecond resolution of the span
@@ -0,0 +1,223 @@
1
+ # Copyright 2017, Google Inc. All rights reserved.
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
+ # http://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
+ module Google
16
+ module Protobuf
17
+ # +FieldMask+ represents a set of symbolic field paths, for example:
18
+ #
19
+ # paths: "f.a"
20
+ # paths: "f.b.d"
21
+ #
22
+ # Here +f+ represents a field in some root message, +a+ and +b+
23
+ # fields in the message found in +f+, and +d+ a field found in the
24
+ # message in +f.b+.
25
+ #
26
+ # Field masks are used to specify a subset of fields that should be
27
+ # returned by a get operation or modified by an update operation.
28
+ # Field masks also have a custom JSON encoding (see below).
29
+ #
30
+ # = Field Masks in Projections
31
+ #
32
+ # When used in the context of a projection, a response message or
33
+ # sub-message is filtered by the API to only contain those fields as
34
+ # specified in the mask. For example, if the mask in the previous
35
+ # example is applied to a response message as follows:
36
+ #
37
+ # f {
38
+ # a : 22
39
+ # b {
40
+ # d : 1
41
+ # x : 2
42
+ # }
43
+ # y : 13
44
+ # }
45
+ # z: 8
46
+ #
47
+ # The result will not contain specific values for fields x,y and z
48
+ # (their value will be set to the default, and omitted in proto text
49
+ # output):
50
+ #
51
+ #
52
+ # f {
53
+ # a : 22
54
+ # b {
55
+ # d : 1
56
+ # }
57
+ # }
58
+ #
59
+ # A repeated field is not allowed except at the last position of a
60
+ # paths string.
61
+ #
62
+ # If a FieldMask object is not present in a get operation, the
63
+ # operation applies to all fields (as if a FieldMask of all fields
64
+ # had been specified).
65
+ #
66
+ # Note that a field mask does not necessarily apply to the
67
+ # top-level response message. In case of a REST get operation, the
68
+ # field mask applies directly to the response, but in case of a REST
69
+ # list operation, the mask instead applies to each individual message
70
+ # in the returned resource list. In case of a REST custom method,
71
+ # other definitions may be used. Where the mask applies will be
72
+ # clearly documented together with its declaration in the API. In
73
+ # any case, the effect on the returned resource/resources is required
74
+ # behavior for APIs.
75
+ #
76
+ # = Field Masks in Update Operations
77
+ #
78
+ # A field mask in update operations specifies which fields of the
79
+ # targeted resource are going to be updated. The API is required
80
+ # to only change the values of the fields as specified in the mask
81
+ # and leave the others untouched. If a resource is passed in to
82
+ # describe the updated values, the API ignores the values of all
83
+ # fields not covered by the mask.
84
+ #
85
+ # If a repeated field is specified for an update operation, the existing
86
+ # repeated values in the target resource will be overwritten by the new values.
87
+ # Note that a repeated field is only allowed in the last position of a +paths+
88
+ # string.
89
+ #
90
+ # If a sub-message is specified in the last position of the field mask for an
91
+ # update operation, then the existing sub-message in the target resource is
92
+ # overwritten. Given the target message:
93
+ #
94
+ # f {
95
+ # b {
96
+ # d : 1
97
+ # x : 2
98
+ # }
99
+ # c : 1
100
+ # }
101
+ #
102
+ # And an update message:
103
+ #
104
+ # f {
105
+ # b {
106
+ # d : 10
107
+ # }
108
+ # }
109
+ #
110
+ # then if the field mask is:
111
+ #
112
+ # paths: "f.b"
113
+ #
114
+ # then the result will be:
115
+ #
116
+ # f {
117
+ # b {
118
+ # d : 10
119
+ # }
120
+ # c : 1
121
+ # }
122
+ #
123
+ # However, if the update mask was:
124
+ #
125
+ # paths: "f.b.d"
126
+ #
127
+ # then the result would be:
128
+ #
129
+ # f {
130
+ # b {
131
+ # d : 10
132
+ # x : 2
133
+ # }
134
+ # c : 1
135
+ # }
136
+ #
137
+ # In order to reset a field's value to the default, the field must
138
+ # be in the mask and set to the default value in the provided resource.
139
+ # Hence, in order to reset all fields of a resource, provide a default
140
+ # instance of the resource and set all fields in the mask, or do
141
+ # not provide a mask as described below.
142
+ #
143
+ # If a field mask is not present on update, the operation applies to
144
+ # all fields (as if a field mask of all fields has been specified).
145
+ # Note that in the presence of schema evolution, this may mean that
146
+ # fields the client does not know and has therefore not filled into
147
+ # the request will be reset to their default. If this is unwanted
148
+ # behavior, a specific service may require a client to always specify
149
+ # a field mask, producing an error if not.
150
+ #
151
+ # As with get operations, the location of the resource which
152
+ # describes the updated values in the request message depends on the
153
+ # operation kind. In any case, the effect of the field mask is
154
+ # required to be honored by the API.
155
+ #
156
+ # == Considerations for HTTP REST
157
+ #
158
+ # The HTTP kind of an update operation which uses a field mask must
159
+ # be set to PATCH instead of PUT in order to satisfy HTTP semantics
160
+ # (PUT must only be used for full updates).
161
+ #
162
+ # = JSON Encoding of Field Masks
163
+ #
164
+ # In JSON, a field mask is encoded as a single string where paths are
165
+ # separated by a comma. Fields name in each path are converted
166
+ # to/from lower-camel naming conventions.
167
+ #
168
+ # As an example, consider the following message declarations:
169
+ #
170
+ # message Profile {
171
+ # User user = 1;
172
+ # Photo photo = 2;
173
+ # }
174
+ # message User {
175
+ # string display_name = 1;
176
+ # string address = 2;
177
+ # }
178
+ #
179
+ # In proto a field mask for +Profile+ may look as such:
180
+ #
181
+ # mask {
182
+ # paths: "user.display_name"
183
+ # paths: "photo"
184
+ # }
185
+ #
186
+ # In JSON, the same mask is represented as below:
187
+ #
188
+ # {
189
+ # mask: "user.displayName,photo"
190
+ # }
191
+ #
192
+ # = Field Masks and Oneof Fields
193
+ #
194
+ # Field masks treat fields in oneofs just as regular fields. Consider the
195
+ # following message:
196
+ #
197
+ # message SampleMessage {
198
+ # oneof test_oneof {
199
+ # string name = 4;
200
+ # SubMessage sub_message = 9;
201
+ # }
202
+ # }
203
+ #
204
+ # The field mask can be:
205
+ #
206
+ # mask {
207
+ # paths: "name"
208
+ # }
209
+ #
210
+ # Or:
211
+ #
212
+ # mask {
213
+ # paths: "sub_message"
214
+ # }
215
+ #
216
+ # Note that oneof type names ("test_oneof" in this case) cannot be used in
217
+ # paths.
218
+ # @!attribute [rw] paths
219
+ # @return [Array<String>]
220
+ # The set of field mask paths.
221
+ class FieldMask; end
222
+ end
223
+ end
@@ -24,7 +24,9 @@ module Google
24
24
  # 0001-01-01T00:00:00Z to 9999-12-31T23:59:59.999999999Z.
25
25
  # By restricting to that range, we ensure that we can convert to
26
26
  # and from RFC 3339 date strings.
27
- # See {https://www.ietf.org/rfc/rfc3339.txt}[https://www.ietf.org/rfc/rfc3339.txt].
27
+ # See [https://www.ietf.org/rfc/rfc3339.txt](https://www.ietf.org/rfc/rfc3339.txt).
28
+ #
29
+ # = Examples
28
30
  #
29
31
  # Example 1: Compute Timestamp from POSIX +time()+.
30
32
  #
@@ -65,6 +67,29 @@ module Google
65
67
  #
66
68
  # timestamp = Timestamp()
67
69
  # timestamp.GetCurrentTime()
70
+ #
71
+ # = JSON Mapping
72
+ #
73
+ # In JSON format, the Timestamp type is encoded as a string in the
74
+ # [RFC 3339](https://www.ietf.org/rfc/rfc3339.txt) format. That is, the
75
+ # format is "{year}-{month}-{day}T{hour}:{min}:{sec}[.{frac_sec}]Z"
76
+ # where {year} is always expressed using four digits while {month}, {day},
77
+ # {hour}, {min}, and {sec} are zero-padded to two digits each. The fractional
78
+ # seconds, which can go up to 9 digits (i.e. up to 1 nanosecond resolution),
79
+ # are optional. The "Z" suffix indicates the timezone ("UTC"); the timezone
80
+ # is required, though only UTC (as indicated by "Z") is presently supported.
81
+ #
82
+ # For example, "2017-01-15T01:30:15.01Z" encodes 15.01 seconds past
83
+ # 01:30 UTC on January 15, 2017.
84
+ #
85
+ # In JavaScript, one can convert a Date object to this format using the
86
+ # standard [toISOString()](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/toISOString]
87
+ # method. In Python, a standard +datetime.datetime+ object can be converted
88
+ # to this format using [+strftime+](https://docs.python.org/2/library/time.html#time.strftime)
89
+ # with the time format spec '%Y-%m-%dT%H:%M:%S.%fZ'. Likewise, in Java, one
90
+ # can use the Joda Time's [+ISODateTimeFormat.dateTime()+](
91
+ # http://joda-time.sourceforge.net/apidocs/org/joda/time/format/ISODateTimeFormat.html#dateTime())
92
+ # to obtain a formatter capable of generating timestamps in this format.
68
93
  # @!attribute [rw] seconds
69
94
  # @return [Integer]
70
95
  # Represents seconds of UTC time since Unix epoch