Coverage for /pythoncovmergedfiles/medio/medio/usr/local/lib/python3.8/site-packages/google/cloud/logging_v2/types/log_entry.py: 100%
42 statements
« prev ^ index » next coverage.py v7.2.2, created at 2023-03-26 07:30 +0000
« prev ^ index » next coverage.py v7.2.2, created at 2023-03-26 07:30 +0000
1# -*- coding: utf-8 -*-
2# Copyright 2022 Google LLC
3#
4# Licensed under the Apache License, Version 2.0 (the "License");
5# you may not use this file except in compliance with the License.
6# You may obtain a copy of the License at
7#
8# http://www.apache.org/licenses/LICENSE-2.0
9#
10# Unless required by applicable law or agreed to in writing, software
11# distributed under the License is distributed on an "AS IS" BASIS,
12# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13# See the License for the specific language governing permissions and
14# limitations under the License.
15#
16from __future__ import annotations
18from typing import MutableMapping, MutableSequence
20import proto # type: ignore
22from google.api import monitored_resource_pb2 # type: ignore
23from google.logging.type import http_request_pb2 # type: ignore
24from google.logging.type import log_severity_pb2 # type: ignore
25from google.protobuf import any_pb2 # type: ignore
26from google.protobuf import struct_pb2 # type: ignore
27from google.protobuf import timestamp_pb2 # type: ignore
30__protobuf__ = proto.module(
31 package="google.logging.v2",
32 manifest={
33 "LogEntry",
34 "LogEntryOperation",
35 "LogEntrySourceLocation",
36 "LogSplit",
37 },
38)
41class LogEntry(proto.Message):
42 r"""An individual entry in a log.
44 This message has `oneof`_ fields (mutually exclusive fields).
45 For each oneof, at most one member field can be set at the same time.
46 Setting any member of the oneof automatically clears all other
47 members.
49 .. _oneof: https://proto-plus-python.readthedocs.io/en/stable/fields.html#oneofs-mutually-exclusive-fields
51 Attributes:
52 log_name (str):
53 Required. The resource name of the log to which this log
54 entry belongs:
56 ::
58 "projects/[PROJECT_ID]/logs/[LOG_ID]"
59 "organizations/[ORGANIZATION_ID]/logs/[LOG_ID]"
60 "billingAccounts/[BILLING_ACCOUNT_ID]/logs/[LOG_ID]"
61 "folders/[FOLDER_ID]/logs/[LOG_ID]"
63 A project number may be used in place of PROJECT_ID. The
64 project number is translated to its corresponding PROJECT_ID
65 internally and the ``log_name`` field will contain
66 PROJECT_ID in queries and exports.
68 ``[LOG_ID]`` must be URL-encoded within ``log_name``.
69 Example:
70 ``"organizations/1234567890/logs/cloudresourcemanager.googleapis.com%2Factivity"``.
72 ``[LOG_ID]`` must be less than 512 characters long and can
73 only include the following characters: upper and lower case
74 alphanumeric characters, forward-slash, underscore, hyphen,
75 and period.
77 For backward compatibility, if ``log_name`` begins with a
78 forward-slash, such as ``/projects/...``, then the log entry
79 is ingested as usual, but the forward-slash is removed.
80 Listing the log entry will not show the leading slash and
81 filtering for a log name with a leading slash will never
82 return any results.
83 resource (google.api.monitored_resource_pb2.MonitoredResource):
84 Required. The monitored resource that
85 produced this log entry.
86 Example: a log entry that reports a database
87 error would be associated with the monitored
88 resource designating the particular database
89 that reported the error.
90 proto_payload (google.protobuf.any_pb2.Any):
91 The log entry payload, represented as a
92 protocol buffer. Some Google Cloud Platform
93 services use this field for their log entry
94 payloads.
95 The following protocol buffer types are
96 supported; user-defined types are not supported:
98 "type.googleapis.com/google.cloud.audit.AuditLog"
99 "type.googleapis.com/google.appengine.logging.v1.RequestLog".
101 This field is a member of `oneof`_ ``payload``.
102 text_payload (str):
103 The log entry payload, represented as a
104 Unicode string (UTF-8).
106 This field is a member of `oneof`_ ``payload``.
107 json_payload (google.protobuf.struct_pb2.Struct):
108 The log entry payload, represented as a
109 structure that is expressed as a JSON object.
111 This field is a member of `oneof`_ ``payload``.
112 timestamp (google.protobuf.timestamp_pb2.Timestamp):
113 Optional. The time the event described by the log entry
114 occurred. This time is used to compute the log entry's age
115 and to enforce the logs retention period. If this field is
116 omitted in a new log entry, then Logging assigns it the
117 current time. Timestamps have nanosecond accuracy, but
118 trailing zeros in the fractional seconds might be omitted
119 when the timestamp is displayed.
121 Incoming log entries must have timestamps that don't exceed
122 the `logs retention
123 period <https://cloud.google.com/logging/quotas#logs_retention_periods>`__
124 in the past, and that don't exceed 24 hours in the future.
125 Log entries outside those time boundaries aren't ingested by
126 Logging.
127 receive_timestamp (google.protobuf.timestamp_pb2.Timestamp):
128 Output only. The time the log entry was
129 received by Logging.
130 severity (google.logging.type.log_severity_pb2.LogSeverity):
131 Optional. The severity of the log entry. The default value
132 is ``LogSeverity.DEFAULT``.
133 insert_id (str):
134 Optional. A unique identifier for the log entry. If you
135 provide a value, then Logging considers other log entries in
136 the same project, with the same ``timestamp``, and with the
137 same ``insert_id`` to be duplicates which are removed in a
138 single query result. However, there are no guarantees of
139 de-duplication in the export of logs.
141 If the ``insert_id`` is omitted when writing a log entry,
142 the Logging API assigns its own unique identifier in this
143 field.
145 In queries, the ``insert_id`` is also used to order log
146 entries that have the same ``log_name`` and ``timestamp``
147 values.
148 http_request (google.logging.type.http_request_pb2.HttpRequest):
149 Optional. Information about the HTTP request
150 associated with this log entry, if applicable.
151 labels (MutableMapping[str, str]):
152 Optional. A map of key, value pairs that provides additional
153 information about the log entry. The labels can be
154 user-defined or system-defined.
156 User-defined labels are arbitrary key, value pairs that you
157 can use to classify logs.
159 System-defined labels are defined by GCP services for
160 platform logs. They have two components - a service
161 namespace component and the attribute name. For example:
162 ``compute.googleapis.com/resource_name``.
164 Cloud Logging truncates label keys that exceed 512 B and
165 label values that exceed 64 KB upon their associated log
166 entry being written. The truncation is indicated by an
167 ellipsis at the end of the character string.
168 operation (google.cloud.logging_v2.types.LogEntryOperation):
169 Optional. Information about an operation
170 associated with the log entry, if applicable.
171 trace (str):
172 Optional. Resource name of the trace associated with the log
173 entry, if any. If it contains a relative resource name, the
174 name is assumed to be relative to
175 ``//tracing.googleapis.com``. Example:
176 ``projects/my-projectid/traces/06796866738c859f2f19b7cfb3214824``
177 span_id (str):
178 Optional. The span ID within the trace associated with the
179 log entry.
181 For Trace spans, this is the same format that the Trace API
182 v2 uses: a 16-character hexadecimal encoding of an 8-byte
183 array, such as ``000000000000004a``.
184 trace_sampled (bool):
185 Optional. The sampling decision of the trace associated with
186 the log entry.
188 True means that the trace resource name in the ``trace``
189 field was sampled for storage in a trace backend. False
190 means that the trace was not sampled for storage when this
191 log entry was written, or the sampling decision was unknown
192 at the time. A non-sampled ``trace`` value is still useful
193 as a request correlation identifier. The default is False.
194 source_location (google.cloud.logging_v2.types.LogEntrySourceLocation):
195 Optional. Source code location information
196 associated with the log entry, if any.
197 split (google.cloud.logging_v2.types.LogSplit):
198 Optional. Information indicating this
199 LogEntry is part of a sequence of multiple log
200 entries split from a single LogEntry.
201 """
203 log_name: str = proto.Field(
204 proto.STRING,
205 number=12,
206 )
207 resource: monitored_resource_pb2.MonitoredResource = proto.Field(
208 proto.MESSAGE,
209 number=8,
210 message=monitored_resource_pb2.MonitoredResource,
211 )
212 proto_payload: any_pb2.Any = proto.Field(
213 proto.MESSAGE,
214 number=2,
215 oneof="payload",
216 message=any_pb2.Any,
217 )
218 text_payload: str = proto.Field(
219 proto.STRING,
220 number=3,
221 oneof="payload",
222 )
223 json_payload: struct_pb2.Struct = proto.Field(
224 proto.MESSAGE,
225 number=6,
226 oneof="payload",
227 message=struct_pb2.Struct,
228 )
229 timestamp: timestamp_pb2.Timestamp = proto.Field(
230 proto.MESSAGE,
231 number=9,
232 message=timestamp_pb2.Timestamp,
233 )
234 receive_timestamp: timestamp_pb2.Timestamp = proto.Field(
235 proto.MESSAGE,
236 number=24,
237 message=timestamp_pb2.Timestamp,
238 )
239 severity: log_severity_pb2.LogSeverity = proto.Field(
240 proto.ENUM,
241 number=10,
242 enum=log_severity_pb2.LogSeverity,
243 )
244 insert_id: str = proto.Field(
245 proto.STRING,
246 number=4,
247 )
248 http_request: http_request_pb2.HttpRequest = proto.Field(
249 proto.MESSAGE,
250 number=7,
251 message=http_request_pb2.HttpRequest,
252 )
253 labels: MutableMapping[str, str] = proto.MapField(
254 proto.STRING,
255 proto.STRING,
256 number=11,
257 )
258 operation: "LogEntryOperation" = proto.Field(
259 proto.MESSAGE,
260 number=15,
261 message="LogEntryOperation",
262 )
263 trace: str = proto.Field(
264 proto.STRING,
265 number=22,
266 )
267 span_id: str = proto.Field(
268 proto.STRING,
269 number=27,
270 )
271 trace_sampled: bool = proto.Field(
272 proto.BOOL,
273 number=30,
274 )
275 source_location: "LogEntrySourceLocation" = proto.Field(
276 proto.MESSAGE,
277 number=23,
278 message="LogEntrySourceLocation",
279 )
280 split: "LogSplit" = proto.Field(
281 proto.MESSAGE,
282 number=35,
283 message="LogSplit",
284 )
287class LogEntryOperation(proto.Message):
288 r"""Additional information about a potentially long-running
289 operation with which a log entry is associated.
291 Attributes:
292 id (str):
293 Optional. An arbitrary operation identifier.
294 Log entries with the same identifier are assumed
295 to be part of the same operation.
296 producer (str):
297 Optional. An arbitrary producer identifier. The combination
298 of ``id`` and ``producer`` must be globally unique. Examples
299 for ``producer``: ``"MyDivision.MyBigCompany.com"``,
300 ``"github.com/MyProject/MyApplication"``.
301 first (bool):
302 Optional. Set this to True if this is the
303 first log entry in the operation.
304 last (bool):
305 Optional. Set this to True if this is the
306 last log entry in the operation.
307 """
309 id: str = proto.Field(
310 proto.STRING,
311 number=1,
312 )
313 producer: str = proto.Field(
314 proto.STRING,
315 number=2,
316 )
317 first: bool = proto.Field(
318 proto.BOOL,
319 number=3,
320 )
321 last: bool = proto.Field(
322 proto.BOOL,
323 number=4,
324 )
327class LogEntrySourceLocation(proto.Message):
328 r"""Additional information about the source code location that
329 produced the log entry.
331 Attributes:
332 file (str):
333 Optional. Source file name. Depending on the
334 runtime environment, this might be a simple name
335 or a fully-qualified name.
336 line (int):
337 Optional. Line within the source file.
338 1-based; 0 indicates no line number available.
339 function (str):
340 Optional. Human-readable name of the function or method
341 being invoked, with optional context such as the class or
342 package name. This information may be used in contexts such
343 as the logs viewer, where a file and line number are less
344 meaningful. The format can vary by language. For example:
345 ``qual.if.ied.Class.method`` (Java), ``dir/package.func``
346 (Go), ``function`` (Python).
347 """
349 file: str = proto.Field(
350 proto.STRING,
351 number=1,
352 )
353 line: int = proto.Field(
354 proto.INT64,
355 number=2,
356 )
357 function: str = proto.Field(
358 proto.STRING,
359 number=3,
360 )
363class LogSplit(proto.Message):
364 r"""Additional information used to correlate multiple log
365 entries. Used when a single LogEntry would exceed the Google
366 Cloud Logging size limit and is split across multiple log
367 entries.
369 Attributes:
370 uid (str):
371 A globally unique identifier for all log entries in a
372 sequence of split log entries. All log entries with the same
373 \|LogSplit.uid\| are assumed to be part of the same sequence
374 of split log entries.
375 index (int):
376 The index of this LogEntry in the sequence of split log
377 entries. Log entries are given \|index\| values 0, 1, ...,
378 n-1 for a sequence of n log entries.
379 total_splits (int):
380 The total number of log entries that the
381 original LogEntry was split into.
382 """
384 uid: str = proto.Field(
385 proto.STRING,
386 number=1,
387 )
388 index: int = proto.Field(
389 proto.INT32,
390 number=2,
391 )
392 total_splits: int = proto.Field(
393 proto.INT32,
394 number=3,
395 )
398__all__ = tuple(sorted(__protobuf__.manifest))