google-cloud-logging 3.11.2__tar.gz → 3.11.4__tar.gz
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.
- {google_cloud_logging-3.11.2/google_cloud_logging.egg-info → google_cloud_logging-3.11.4}/PKG-INFO +2 -1
- {google_cloud_logging-3.11.2 → google_cloud_logging-3.11.4}/google/cloud/logging/gapic_version.py +1 -1
- {google_cloud_logging-3.11.2 → google_cloud_logging-3.11.4}/google/cloud/logging_v2/_gapic.py +5 -1
- {google_cloud_logging-3.11.2 → google_cloud_logging-3.11.4}/google/cloud/logging_v2/gapic_version.py +1 -1
- {google_cloud_logging-3.11.2 → google_cloud_logging-3.11.4}/google/cloud/logging_v2/handlers/_helpers.py +22 -2
- {google_cloud_logging-3.11.2 → google_cloud_logging-3.11.4}/google/cloud/logging_v2/logger.py +42 -3
- {google_cloud_logging-3.11.2 → google_cloud_logging-3.11.4/google_cloud_logging.egg-info}/PKG-INFO +2 -1
- {google_cloud_logging-3.11.2 → google_cloud_logging-3.11.4}/google_cloud_logging.egg-info/requires.txt +3 -0
- {google_cloud_logging-3.11.2 → google_cloud_logging-3.11.4}/setup.py +1 -0
- {google_cloud_logging-3.11.2 → google_cloud_logging-3.11.4}/tests/unit/handlers/test__helpers.py +37 -14
- {google_cloud_logging-3.11.2 → google_cloud_logging-3.11.4}/tests/unit/handlers/test_handlers.py +4 -3
- {google_cloud_logging-3.11.2 → google_cloud_logging-3.11.4}/tests/unit/handlers/test_structured_log.py +4 -3
- {google_cloud_logging-3.11.2 → google_cloud_logging-3.11.4}/tests/unit/test__gapic.py +17 -0
- {google_cloud_logging-3.11.2 → google_cloud_logging-3.11.4}/LICENSE +0 -0
- {google_cloud_logging-3.11.2 → google_cloud_logging-3.11.4}/MANIFEST.in +0 -0
- {google_cloud_logging-3.11.2 → google_cloud_logging-3.11.4}/README.rst +0 -0
- {google_cloud_logging-3.11.2 → google_cloud_logging-3.11.4}/google/cloud/logging/__init__.py +0 -0
- {google_cloud_logging-3.11.2 → google_cloud_logging-3.11.4}/google/cloud/logging/handlers/__init__.py +0 -0
- {google_cloud_logging-3.11.2 → google_cloud_logging-3.11.4}/google/cloud/logging/handlers/middleware/__init__.py +0 -0
- {google_cloud_logging-3.11.2 → google_cloud_logging-3.11.4}/google/cloud/logging/handlers/transports/__init__.py +0 -0
- {google_cloud_logging-3.11.2 → google_cloud_logging-3.11.4}/google/cloud/logging/py.typed +0 -0
- {google_cloud_logging-3.11.2 → google_cloud_logging-3.11.4}/google/cloud/logging_v2/__init__.py +0 -0
- {google_cloud_logging-3.11.2 → google_cloud_logging-3.11.4}/google/cloud/logging_v2/_helpers.py +0 -0
- {google_cloud_logging-3.11.2 → google_cloud_logging-3.11.4}/google/cloud/logging_v2/_http.py +0 -0
- {google_cloud_logging-3.11.2 → google_cloud_logging-3.11.4}/google/cloud/logging_v2/_instrumentation.py +0 -0
- {google_cloud_logging-3.11.2 → google_cloud_logging-3.11.4}/google/cloud/logging_v2/client.py +0 -0
- {google_cloud_logging-3.11.2 → google_cloud_logging-3.11.4}/google/cloud/logging_v2/entries.py +0 -0
- {google_cloud_logging-3.11.2 → google_cloud_logging-3.11.4}/google/cloud/logging_v2/gapic_metadata.json +0 -0
- {google_cloud_logging-3.11.2 → google_cloud_logging-3.11.4}/google/cloud/logging_v2/handlers/__init__.py +0 -0
- {google_cloud_logging-3.11.2 → google_cloud_logging-3.11.4}/google/cloud/logging_v2/handlers/_monitored_resources.py +0 -0
- {google_cloud_logging-3.11.2 → google_cloud_logging-3.11.4}/google/cloud/logging_v2/handlers/app_engine.py +0 -0
- {google_cloud_logging-3.11.2 → google_cloud_logging-3.11.4}/google/cloud/logging_v2/handlers/container_engine.py +0 -0
- {google_cloud_logging-3.11.2 → google_cloud_logging-3.11.4}/google/cloud/logging_v2/handlers/handlers.py +0 -0
- {google_cloud_logging-3.11.2 → google_cloud_logging-3.11.4}/google/cloud/logging_v2/handlers/middleware/__init__.py +0 -0
- {google_cloud_logging-3.11.2 → google_cloud_logging-3.11.4}/google/cloud/logging_v2/handlers/middleware/request.py +0 -0
- {google_cloud_logging-3.11.2 → google_cloud_logging-3.11.4}/google/cloud/logging_v2/handlers/structured_log.py +0 -0
- {google_cloud_logging-3.11.2 → google_cloud_logging-3.11.4}/google/cloud/logging_v2/handlers/transports/__init__.py +0 -0
- {google_cloud_logging-3.11.2 → google_cloud_logging-3.11.4}/google/cloud/logging_v2/handlers/transports/background_thread.py +0 -0
- {google_cloud_logging-3.11.2 → google_cloud_logging-3.11.4}/google/cloud/logging_v2/handlers/transports/base.py +0 -0
- {google_cloud_logging-3.11.2 → google_cloud_logging-3.11.4}/google/cloud/logging_v2/handlers/transports/sync.py +0 -0
- {google_cloud_logging-3.11.2 → google_cloud_logging-3.11.4}/google/cloud/logging_v2/metric.py +0 -0
- {google_cloud_logging-3.11.2 → google_cloud_logging-3.11.4}/google/cloud/logging_v2/py.typed +0 -0
- {google_cloud_logging-3.11.2 → google_cloud_logging-3.11.4}/google/cloud/logging_v2/resource.py +0 -0
- {google_cloud_logging-3.11.2 → google_cloud_logging-3.11.4}/google/cloud/logging_v2/services/__init__.py +0 -0
- {google_cloud_logging-3.11.2 → google_cloud_logging-3.11.4}/google/cloud/logging_v2/services/config_service_v2/__init__.py +0 -0
- {google_cloud_logging-3.11.2 → google_cloud_logging-3.11.4}/google/cloud/logging_v2/services/config_service_v2/async_client.py +0 -0
- {google_cloud_logging-3.11.2 → google_cloud_logging-3.11.4}/google/cloud/logging_v2/services/config_service_v2/client.py +0 -0
- {google_cloud_logging-3.11.2 → google_cloud_logging-3.11.4}/google/cloud/logging_v2/services/config_service_v2/pagers.py +0 -0
- {google_cloud_logging-3.11.2 → google_cloud_logging-3.11.4}/google/cloud/logging_v2/services/config_service_v2/transports/__init__.py +0 -0
- {google_cloud_logging-3.11.2 → google_cloud_logging-3.11.4}/google/cloud/logging_v2/services/config_service_v2/transports/base.py +0 -0
- {google_cloud_logging-3.11.2 → google_cloud_logging-3.11.4}/google/cloud/logging_v2/services/config_service_v2/transports/grpc.py +0 -0
- {google_cloud_logging-3.11.2 → google_cloud_logging-3.11.4}/google/cloud/logging_v2/services/config_service_v2/transports/grpc_asyncio.py +0 -0
- {google_cloud_logging-3.11.2 → google_cloud_logging-3.11.4}/google/cloud/logging_v2/services/logging_service_v2/__init__.py +0 -0
- {google_cloud_logging-3.11.2 → google_cloud_logging-3.11.4}/google/cloud/logging_v2/services/logging_service_v2/async_client.py +0 -0
- {google_cloud_logging-3.11.2 → google_cloud_logging-3.11.4}/google/cloud/logging_v2/services/logging_service_v2/client.py +0 -0
- {google_cloud_logging-3.11.2 → google_cloud_logging-3.11.4}/google/cloud/logging_v2/services/logging_service_v2/pagers.py +0 -0
- {google_cloud_logging-3.11.2 → google_cloud_logging-3.11.4}/google/cloud/logging_v2/services/logging_service_v2/transports/__init__.py +0 -0
- {google_cloud_logging-3.11.2 → google_cloud_logging-3.11.4}/google/cloud/logging_v2/services/logging_service_v2/transports/base.py +0 -0
- {google_cloud_logging-3.11.2 → google_cloud_logging-3.11.4}/google/cloud/logging_v2/services/logging_service_v2/transports/grpc.py +0 -0
- {google_cloud_logging-3.11.2 → google_cloud_logging-3.11.4}/google/cloud/logging_v2/services/logging_service_v2/transports/grpc_asyncio.py +0 -0
- {google_cloud_logging-3.11.2 → google_cloud_logging-3.11.4}/google/cloud/logging_v2/services/metrics_service_v2/__init__.py +0 -0
- {google_cloud_logging-3.11.2 → google_cloud_logging-3.11.4}/google/cloud/logging_v2/services/metrics_service_v2/async_client.py +0 -0
- {google_cloud_logging-3.11.2 → google_cloud_logging-3.11.4}/google/cloud/logging_v2/services/metrics_service_v2/client.py +0 -0
- {google_cloud_logging-3.11.2 → google_cloud_logging-3.11.4}/google/cloud/logging_v2/services/metrics_service_v2/pagers.py +0 -0
- {google_cloud_logging-3.11.2 → google_cloud_logging-3.11.4}/google/cloud/logging_v2/services/metrics_service_v2/transports/__init__.py +0 -0
- {google_cloud_logging-3.11.2 → google_cloud_logging-3.11.4}/google/cloud/logging_v2/services/metrics_service_v2/transports/base.py +0 -0
- {google_cloud_logging-3.11.2 → google_cloud_logging-3.11.4}/google/cloud/logging_v2/services/metrics_service_v2/transports/grpc.py +0 -0
- {google_cloud_logging-3.11.2 → google_cloud_logging-3.11.4}/google/cloud/logging_v2/services/metrics_service_v2/transports/grpc_asyncio.py +0 -0
- {google_cloud_logging-3.11.2 → google_cloud_logging-3.11.4}/google/cloud/logging_v2/sink.py +0 -0
- {google_cloud_logging-3.11.2 → google_cloud_logging-3.11.4}/google/cloud/logging_v2/types/__init__.py +0 -0
- {google_cloud_logging-3.11.2 → google_cloud_logging-3.11.4}/google/cloud/logging_v2/types/log_entry.py +0 -0
- {google_cloud_logging-3.11.2 → google_cloud_logging-3.11.4}/google/cloud/logging_v2/types/logging.py +0 -0
- {google_cloud_logging-3.11.2 → google_cloud_logging-3.11.4}/google/cloud/logging_v2/types/logging_config.py +0 -0
- {google_cloud_logging-3.11.2 → google_cloud_logging-3.11.4}/google/cloud/logging_v2/types/logging_metrics.py +0 -0
- {google_cloud_logging-3.11.2 → google_cloud_logging-3.11.4}/google_cloud_logging.egg-info/SOURCES.txt +0 -0
- {google_cloud_logging-3.11.2 → google_cloud_logging-3.11.4}/google_cloud_logging.egg-info/dependency_links.txt +0 -0
- {google_cloud_logging-3.11.2 → google_cloud_logging-3.11.4}/google_cloud_logging.egg-info/not-zip-safe +0 -0
- {google_cloud_logging-3.11.2 → google_cloud_logging-3.11.4}/google_cloud_logging.egg-info/top_level.txt +0 -0
- {google_cloud_logging-3.11.2 → google_cloud_logging-3.11.4}/setup.cfg +0 -0
- {google_cloud_logging-3.11.2 → google_cloud_logging-3.11.4}/tests/__init__.py +0 -0
- {google_cloud_logging-3.11.2 → google_cloud_logging-3.11.4}/tests/performance/noxfile.py +0 -0
- {google_cloud_logging-3.11.2 → google_cloud_logging-3.11.4}/tests/performance/test_performance.py +0 -0
- {google_cloud_logging-3.11.2 → google_cloud_logging-3.11.4}/tests/system/gapic/v2/test_system_logging_service_v2_v2.py +0 -0
- {google_cloud_logging-3.11.2 → google_cloud_logging-3.11.4}/tests/system/test_system.py +0 -0
- {google_cloud_logging-3.11.2 → google_cloud_logging-3.11.4}/tests/unit/__init__.py +0 -0
- {google_cloud_logging-3.11.2 → google_cloud_logging-3.11.4}/tests/unit/gapic/__init__.py +0 -0
- {google_cloud_logging-3.11.2 → google_cloud_logging-3.11.4}/tests/unit/gapic/logging_v2/__init__.py +0 -0
- {google_cloud_logging-3.11.2 → google_cloud_logging-3.11.4}/tests/unit/gapic/logging_v2/test_config_service_v2.py +0 -0
- {google_cloud_logging-3.11.2 → google_cloud_logging-3.11.4}/tests/unit/gapic/logging_v2/test_logging_service_v2.py +0 -0
- {google_cloud_logging-3.11.2 → google_cloud_logging-3.11.4}/tests/unit/gapic/logging_v2/test_metrics_service_v2.py +0 -0
- {google_cloud_logging-3.11.2 → google_cloud_logging-3.11.4}/tests/unit/handlers/__init__.py +0 -0
- {google_cloud_logging-3.11.2 → google_cloud_logging-3.11.4}/tests/unit/handlers/middleware/test_request.py +0 -0
- {google_cloud_logging-3.11.2 → google_cloud_logging-3.11.4}/tests/unit/handlers/test__monitored_resources.py +0 -0
- {google_cloud_logging-3.11.2 → google_cloud_logging-3.11.4}/tests/unit/handlers/test_app_engine.py +0 -0
- {google_cloud_logging-3.11.2 → google_cloud_logging-3.11.4}/tests/unit/handlers/test_container_engine.py +0 -0
- {google_cloud_logging-3.11.2 → google_cloud_logging-3.11.4}/tests/unit/handlers/transports/__init__.py +0 -0
- {google_cloud_logging-3.11.2 → google_cloud_logging-3.11.4}/tests/unit/handlers/transports/test_background_thread.py +0 -0
- {google_cloud_logging-3.11.2 → google_cloud_logging-3.11.4}/tests/unit/handlers/transports/test_base.py +0 -0
- {google_cloud_logging-3.11.2 → google_cloud_logging-3.11.4}/tests/unit/handlers/transports/test_sync.py +0 -0
- {google_cloud_logging-3.11.2 → google_cloud_logging-3.11.4}/tests/unit/test__helpers.py +0 -0
- {google_cloud_logging-3.11.2 → google_cloud_logging-3.11.4}/tests/unit/test__http.py +0 -0
- {google_cloud_logging-3.11.2 → google_cloud_logging-3.11.4}/tests/unit/test__instrumentation.py +0 -0
- {google_cloud_logging-3.11.2 → google_cloud_logging-3.11.4}/tests/unit/test_client.py +0 -0
- {google_cloud_logging-3.11.2 → google_cloud_logging-3.11.4}/tests/unit/test_entries.py +0 -0
- {google_cloud_logging-3.11.2 → google_cloud_logging-3.11.4}/tests/unit/test_logger.py +0 -0
- {google_cloud_logging-3.11.2 → google_cloud_logging-3.11.4}/tests/unit/test_logging_shim.py +0 -0
- {google_cloud_logging-3.11.2 → google_cloud_logging-3.11.4}/tests/unit/test_metric.py +0 -0
- {google_cloud_logging-3.11.2 → google_cloud_logging-3.11.4}/tests/unit/test_packaging.py +0 -0
- {google_cloud_logging-3.11.2 → google_cloud_logging-3.11.4}/tests/unit/test_sink.py +0 -0
{google_cloud_logging-3.11.2/google_cloud_logging.egg-info → google_cloud_logging-3.11.4}/PKG-INFO
RENAMED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: google-cloud-logging
|
|
3
|
-
Version: 3.11.
|
|
3
|
+
Version: 3.11.4
|
|
4
4
|
Summary: Stackdriver Logging API client library
|
|
5
5
|
Home-page: https://github.com/googleapis/python-logging
|
|
6
6
|
Author: Google LLC
|
|
@@ -31,6 +31,7 @@ Requires-Dist: grpc-google-iam-v1<1.0.0dev,>=0.12.4
|
|
|
31
31
|
Requires-Dist: opentelemetry-api>=1.9.0
|
|
32
32
|
Requires-Dist: proto-plus<2.0.0dev,>=1.22.0
|
|
33
33
|
Requires-Dist: proto-plus<2.0.0dev,>=1.22.2; python_version >= "3.11"
|
|
34
|
+
Requires-Dist: proto-plus<2.0.0dev,>=1.25.0; python_version >= "3.13"
|
|
34
35
|
Requires-Dist: protobuf!=4.21.0,!=4.21.1,!=4.21.2,!=4.21.3,!=4.21.4,!=4.21.5,<6.0.0dev,>=3.20.2
|
|
35
36
|
|
|
36
37
|
Python Client for Cloud Logging
|
{google_cloud_logging-3.11.2 → google_cloud_logging-3.11.4}/google/cloud/logging_v2/_gapic.py
RENAMED
|
@@ -30,6 +30,7 @@ from google.cloud.logging_v2.types import LogEntry as LogEntryPB
|
|
|
30
30
|
|
|
31
31
|
from google.protobuf.json_format import MessageToDict
|
|
32
32
|
from google.protobuf.json_format import ParseDict
|
|
33
|
+
from google.protobuf.json_format import ParseError
|
|
33
34
|
|
|
34
35
|
from google.cloud.logging_v2._helpers import entry_from_resource
|
|
35
36
|
from google.cloud.logging_v2.sink import Sink
|
|
@@ -151,7 +152,10 @@ class _LoggingAPI(object):
|
|
|
151
152
|
Useful for checking whether the logging API endpoints are working
|
|
152
153
|
properly before sending valuable data.
|
|
153
154
|
"""
|
|
154
|
-
|
|
155
|
+
try:
|
|
156
|
+
log_entry_pbs = [_log_entry_mapping_to_pb(entry) for entry in entries]
|
|
157
|
+
except ParseError as e:
|
|
158
|
+
raise ValueError(f"Invalid log entry: {str(e)}") from e
|
|
155
159
|
|
|
156
160
|
request = WriteLogEntriesRequest(
|
|
157
161
|
log_name=logger_name,
|
|
@@ -174,13 +174,22 @@ def _parse_xcloud_trace(header):
|
|
|
174
174
|
Args:
|
|
175
175
|
header (str): the string extracted from the X_CLOUD_TRACE header
|
|
176
176
|
Returns:
|
|
177
|
-
Tuple[Optional[
|
|
177
|
+
Tuple[Optional[str], Optional[str], bool]:
|
|
178
178
|
The trace_id, span_id and trace_sampled extracted from the header
|
|
179
179
|
Each field will be None if not found.
|
|
180
180
|
"""
|
|
181
181
|
trace_id = span_id = None
|
|
182
182
|
trace_sampled = False
|
|
183
|
-
|
|
183
|
+
|
|
184
|
+
# As per the format described at https://cloud.google.com/trace/docs/trace-context#legacy-http-header
|
|
185
|
+
# "X-Cloud-Trace-Context: TRACE_ID[/SPAN_ID][;o=OPTIONS]"
|
|
186
|
+
# for example:
|
|
187
|
+
# "X-Cloud-Trace-Context: 105445aa7843bc8bf206b12000100000/1;o=1"
|
|
188
|
+
#
|
|
189
|
+
# We expect:
|
|
190
|
+
# * trace_id (optional, 128-bit hex string): "105445aa7843bc8bf206b12000100000"
|
|
191
|
+
# * span_id (optional, 16-bit hex string): "0000000000000001" (needs to be converted into 16 bit hex string)
|
|
192
|
+
# * trace_sampled (optional, bool): true
|
|
184
193
|
if header:
|
|
185
194
|
try:
|
|
186
195
|
regex = r"([\w-]+)?(\/?([\w-]+))?(;?o=(\d))?"
|
|
@@ -188,6 +197,17 @@ def _parse_xcloud_trace(header):
|
|
|
188
197
|
trace_id = match.group(1)
|
|
189
198
|
span_id = match.group(3)
|
|
190
199
|
trace_sampled = match.group(5) == "1"
|
|
200
|
+
|
|
201
|
+
# Convert the span ID to 16-bit hexadecimal instead of decimal
|
|
202
|
+
try:
|
|
203
|
+
span_id_int = int(span_id)
|
|
204
|
+
if span_id_int > 0 and span_id_int < 2**64:
|
|
205
|
+
span_id = f"{span_id_int:016x}"
|
|
206
|
+
else:
|
|
207
|
+
span_id = None
|
|
208
|
+
except (ValueError, TypeError):
|
|
209
|
+
span_id = None
|
|
210
|
+
|
|
191
211
|
except IndexError:
|
|
192
212
|
pass
|
|
193
213
|
return trace_id, span_id, trace_sampled
|
{google_cloud_logging-3.11.2 → google_cloud_logging-3.11.4}/google/cloud/logging_v2/logger.py
RENAMED
|
@@ -162,6 +162,7 @@ class Logger(object):
|
|
|
162
162
|
|
|
163
163
|
api_repr = entry.to_api_repr()
|
|
164
164
|
entries = [api_repr]
|
|
165
|
+
|
|
165
166
|
if google.cloud.logging_v2._instrumentation_emitted is False:
|
|
166
167
|
entries = _add_instrumentation(entries, **kw)
|
|
167
168
|
google.cloud.logging_v2._instrumentation_emitted = True
|
|
@@ -200,18 +201,38 @@ class Logger(object):
|
|
|
200
201
|
self._do_log(client, TextEntry, text, **kw)
|
|
201
202
|
|
|
202
203
|
def log_struct(self, info, *, client=None, **kw):
|
|
203
|
-
"""
|
|
204
|
+
"""Logs a dictionary message.
|
|
204
205
|
|
|
205
206
|
See
|
|
206
207
|
https://cloud.google.com/logging/docs/reference/v2/rest/v2/entries/write
|
|
207
208
|
|
|
209
|
+
The message must be able to be serializable to a Protobuf Struct.
|
|
210
|
+
It must be a dictionary of strings to one of the following:
|
|
211
|
+
|
|
212
|
+
- :class:`str`
|
|
213
|
+
- :class:`int`
|
|
214
|
+
- :class:`float`
|
|
215
|
+
- :class:`bool`
|
|
216
|
+
- :class:`list[str|float|int|bool|list|dict|None]`
|
|
217
|
+
- :class:`dict[str, str|float|int|bool|list|dict|None]`
|
|
218
|
+
|
|
219
|
+
For more details on Protobuf structs, see https://protobuf.dev/reference/protobuf/google.protobuf/#value.
|
|
220
|
+
If the provided dictionary cannot be serialized into a Protobuf struct,
|
|
221
|
+
it will not be logged, and a :class:`ValueError` will be raised.
|
|
222
|
+
|
|
208
223
|
Args:
|
|
209
|
-
info (dict):
|
|
224
|
+
info (dict[str, str|float|int|bool|list|dict|None]):
|
|
225
|
+
the log entry information.
|
|
210
226
|
client (Optional[~logging_v2.client.Client]):
|
|
211
227
|
The client to use. If not passed, falls back to the
|
|
212
228
|
``client`` stored on the current sink.
|
|
213
229
|
kw (Optional[dict]): additional keyword arguments for the entry.
|
|
214
230
|
See :class:`~logging_v2.entries.LogEntry`.
|
|
231
|
+
|
|
232
|
+
Raises:
|
|
233
|
+
ValueError:
|
|
234
|
+
if the dictionary message provided cannot be serialized into a Protobuf
|
|
235
|
+
struct.
|
|
215
236
|
"""
|
|
216
237
|
for field in _STRUCT_EXTRACTABLE_FIELDS:
|
|
217
238
|
# attempt to copy relevant fields from the payload into the LogEntry body
|
|
@@ -405,8 +426,22 @@ class Batch(object):
|
|
|
405
426
|
def log_struct(self, info, **kw):
|
|
406
427
|
"""Add a struct entry to be logged during :meth:`commit`.
|
|
407
428
|
|
|
429
|
+
The message must be able to be serializable to a Protobuf Struct.
|
|
430
|
+
It must be a dictionary of strings to one of the following:
|
|
431
|
+
|
|
432
|
+
- :class:`str`
|
|
433
|
+
- :class:`int`
|
|
434
|
+
- :class:`float`
|
|
435
|
+
- :class:`bool`
|
|
436
|
+
- :class:`list[str|float|int|bool|list|dict|None]`
|
|
437
|
+
- :class:`dict[str, str|float|int|bool|list|dict|None]`
|
|
438
|
+
|
|
439
|
+
For more details on Protobuf structs, see https://protobuf.dev/reference/protobuf/google.protobuf/#value.
|
|
440
|
+
If the provided dictionary cannot be serialized into a Protobuf struct,
|
|
441
|
+
it will not be logged, and a :class:`ValueError` will be raised during :meth:`commit`.
|
|
442
|
+
|
|
408
443
|
Args:
|
|
409
|
-
info (dict): The struct entry,
|
|
444
|
+
info (dict[str, str|float|int|bool|list|dict|None]): The struct entry,
|
|
410
445
|
kw (Optional[dict]): Additional keyword arguments for the entry.
|
|
411
446
|
See :class:`~logging_v2.entries.LogEntry`.
|
|
412
447
|
"""
|
|
@@ -451,6 +486,10 @@ class Batch(object):
|
|
|
451
486
|
Whether a batch's valid entries should be written even
|
|
452
487
|
if some other entry failed due to a permanent error such
|
|
453
488
|
as INVALID_ARGUMENT or PERMISSION_DENIED.
|
|
489
|
+
|
|
490
|
+
Raises:
|
|
491
|
+
ValueError:
|
|
492
|
+
if one of the messages in the batch cannot be successfully parsed.
|
|
454
493
|
"""
|
|
455
494
|
if client is None:
|
|
456
495
|
client = self.client
|
{google_cloud_logging-3.11.2 → google_cloud_logging-3.11.4/google_cloud_logging.egg-info}/PKG-INFO
RENAMED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: google-cloud-logging
|
|
3
|
-
Version: 3.11.
|
|
3
|
+
Version: 3.11.4
|
|
4
4
|
Summary: Stackdriver Logging API client library
|
|
5
5
|
Home-page: https://github.com/googleapis/python-logging
|
|
6
6
|
Author: Google LLC
|
|
@@ -31,6 +31,7 @@ Requires-Dist: grpc-google-iam-v1<1.0.0dev,>=0.12.4
|
|
|
31
31
|
Requires-Dist: opentelemetry-api>=1.9.0
|
|
32
32
|
Requires-Dist: proto-plus<2.0.0dev,>=1.22.0
|
|
33
33
|
Requires-Dist: proto-plus<2.0.0dev,>=1.22.2; python_version >= "3.11"
|
|
34
|
+
Requires-Dist: proto-plus<2.0.0dev,>=1.25.0; python_version >= "3.13"
|
|
34
35
|
Requires-Dist: protobuf!=4.21.0,!=4.21.1,!=4.21.2,!=4.21.3,!=4.21.4,!=4.21.5,<6.0.0dev,>=3.20.2
|
|
35
36
|
|
|
36
37
|
Python Client for Cloud Logging
|
|
@@ -47,6 +47,7 @@ dependencies = [
|
|
|
47
47
|
"opentelemetry-api >= 1.9.0",
|
|
48
48
|
"proto-plus >= 1.22.0, <2.0.0dev",
|
|
49
49
|
"proto-plus >= 1.22.2, <2.0.0dev; python_version>='3.11'",
|
|
50
|
+
"proto-plus >= 1.25.0, <2.0.0dev; python_version>='3.13'",
|
|
50
51
|
"protobuf>=3.20.2,<6.0.0dev,!=4.21.0,!=4.21.1,!=4.21.2,!=4.21.3,!=4.21.4,!=4.21.5",
|
|
51
52
|
]
|
|
52
53
|
url = "https://github.com/googleapis/python-logging"
|
{google_cloud_logging-3.11.2 → google_cloud_logging-3.11.4}/tests/unit/handlers/test__helpers.py
RENAMED
|
@@ -25,9 +25,13 @@ from tests.unit.handlers import (
|
|
|
25
25
|
|
|
26
26
|
_FLASK_TRACE_ID = "flask0id"
|
|
27
27
|
_FLASK_SPAN_ID = "span0flask"
|
|
28
|
+
_FLASK_SPAN_ID_XCTC_DEC = "12345"
|
|
29
|
+
_FLASK_SPAN_ID_XCTC_HEX = "3039".zfill(16)
|
|
28
30
|
_FLASK_HTTP_REQUEST = {"requestUrl": "https://flask.palletsprojects.com/en/1.1.x/"}
|
|
29
31
|
_DJANGO_TRACE_ID = "django0id"
|
|
30
32
|
_DJANGO_SPAN_ID = "span0django"
|
|
33
|
+
_DJANGO_SPAN_ID_XCTC_DEC = "54321"
|
|
34
|
+
_DJANGO_SPAN_ID_XCTC_HEX = "d431".zfill(16)
|
|
31
35
|
_DJANGO_HTTP_REQUEST = {"requestUrl": "https://www.djangoproject.com/"}
|
|
32
36
|
|
|
33
37
|
|
|
@@ -64,8 +68,9 @@ class Test_get_request_data_from_flask(unittest.TestCase):
|
|
|
64
68
|
def test_xcloud_header(self):
|
|
65
69
|
flask_trace_header = "X_CLOUD_TRACE_CONTEXT"
|
|
66
70
|
expected_trace_id = _FLASK_TRACE_ID
|
|
67
|
-
|
|
68
|
-
|
|
71
|
+
input_span_id = _FLASK_SPAN_ID_XCTC_DEC
|
|
72
|
+
expected_span_id = _FLASK_SPAN_ID_XCTC_HEX
|
|
73
|
+
flask_trace_id = f"{expected_trace_id}/{input_span_id};o=1"
|
|
69
74
|
|
|
70
75
|
app = self.create_app()
|
|
71
76
|
context = app.test_request_context(
|
|
@@ -173,9 +178,10 @@ class Test_get_request_data_from_django(unittest.TestCase):
|
|
|
173
178
|
from google.cloud.logging_v2.handlers.middleware import request
|
|
174
179
|
|
|
175
180
|
django_trace_header = "HTTP_X_CLOUD_TRACE_CONTEXT"
|
|
176
|
-
|
|
181
|
+
input_span_id = _DJANGO_SPAN_ID_XCTC_DEC
|
|
182
|
+
expected_span_id = _DJANGO_SPAN_ID_XCTC_HEX
|
|
177
183
|
expected_trace_id = _DJANGO_TRACE_ID
|
|
178
|
-
django_trace_id = f"{expected_trace_id}/{
|
|
184
|
+
django_trace_id = f"{expected_trace_id}/{input_span_id};o=1"
|
|
179
185
|
|
|
180
186
|
django_request = RequestFactory().get(
|
|
181
187
|
"/", **{django_trace_header: django_trace_id}
|
|
@@ -501,25 +507,40 @@ class Test__parse_xcloud_trace(unittest.TestCase):
|
|
|
501
507
|
self.assertEqual(sampled, False)
|
|
502
508
|
|
|
503
509
|
def test_no_trace(self):
|
|
504
|
-
|
|
510
|
+
input_span = "12345"
|
|
511
|
+
expected_span = "3039".zfill(16)
|
|
512
|
+
header = f"/{input_span}"
|
|
505
513
|
trace_id, span_id, sampled = self._call_fut(header)
|
|
506
514
|
self.assertIsNone(trace_id)
|
|
507
|
-
self.assertEqual(span_id,
|
|
515
|
+
self.assertEqual(span_id, expected_span)
|
|
508
516
|
self.assertEqual(sampled, False)
|
|
509
517
|
|
|
510
518
|
def test_with_span(self):
|
|
511
519
|
expected_trace = "12345"
|
|
512
|
-
|
|
513
|
-
|
|
520
|
+
input_span = "67890"
|
|
521
|
+
expected_span = "10932".zfill(16)
|
|
522
|
+
header = f"{expected_trace}/{input_span}"
|
|
514
523
|
trace_id, span_id, sampled = self._call_fut(header)
|
|
515
524
|
self.assertEqual(trace_id, expected_trace)
|
|
516
525
|
self.assertEqual(span_id, expected_span)
|
|
517
526
|
self.assertEqual(sampled, False)
|
|
518
527
|
|
|
528
|
+
def test_with_span_decimal_not_in_bounds(self):
|
|
529
|
+
input_spans = ["0", "9" * 100]
|
|
530
|
+
|
|
531
|
+
for input_span in input_spans:
|
|
532
|
+
expected_trace = "12345"
|
|
533
|
+
header = f"{expected_trace}/{input_span}"
|
|
534
|
+
trace_id, span_id, sampled = self._call_fut(header)
|
|
535
|
+
self.assertEqual(trace_id, expected_trace)
|
|
536
|
+
self.assertIsNone(span_id)
|
|
537
|
+
self.assertEqual(sampled, False)
|
|
538
|
+
|
|
519
539
|
def test_with_extra_characters(self):
|
|
520
540
|
expected_trace = "12345"
|
|
521
|
-
|
|
522
|
-
|
|
541
|
+
input_span = "67890"
|
|
542
|
+
expected_span = "10932".zfill(16)
|
|
543
|
+
header = f"{expected_trace}/{input_span};abc"
|
|
523
544
|
trace_id, span_id, sampled = self._call_fut(header)
|
|
524
545
|
self.assertEqual(trace_id, expected_trace)
|
|
525
546
|
self.assertEqual(span_id, expected_span)
|
|
@@ -527,8 +548,9 @@ class Test__parse_xcloud_trace(unittest.TestCase):
|
|
|
527
548
|
|
|
528
549
|
def test_with_explicit_no_sampled(self):
|
|
529
550
|
expected_trace = "12345"
|
|
530
|
-
|
|
531
|
-
|
|
551
|
+
input_span = "67890"
|
|
552
|
+
expected_span = "10932".zfill(16)
|
|
553
|
+
header = f"{expected_trace}/{input_span};o=0"
|
|
532
554
|
trace_id, span_id, sampled = self._call_fut(header)
|
|
533
555
|
self.assertEqual(trace_id, expected_trace)
|
|
534
556
|
self.assertEqual(span_id, expected_span)
|
|
@@ -536,8 +558,9 @@ class Test__parse_xcloud_trace(unittest.TestCase):
|
|
|
536
558
|
|
|
537
559
|
def test_with__sampled(self):
|
|
538
560
|
expected_trace = "12345"
|
|
539
|
-
|
|
540
|
-
|
|
561
|
+
input_span = "67890"
|
|
562
|
+
expected_span = "10932".zfill(16)
|
|
563
|
+
header = f"{expected_trace}/{input_span};o=1"
|
|
541
564
|
trace_id, span_id, sampled = self._call_fut(header)
|
|
542
565
|
self.assertEqual(trace_id, expected_trace)
|
|
543
566
|
self.assertEqual(span_id, expected_span)
|
{google_cloud_logging-3.11.2 → google_cloud_logging-3.11.4}/tests/unit/handlers/test_handlers.py
RENAMED
|
@@ -140,7 +140,7 @@ class TestCloudLoggingFilter(unittest.TestCase):
|
|
|
140
140
|
self.assertIsNone(record._labels)
|
|
141
141
|
self.assertEqual(record._labels_str, "{}")
|
|
142
142
|
|
|
143
|
-
def
|
|
143
|
+
def test_record_with_xctc_request(self):
|
|
144
144
|
"""
|
|
145
145
|
test filter adds http request data when available
|
|
146
146
|
"""
|
|
@@ -161,8 +161,9 @@ class TestCloudLoggingFilter(unittest.TestCase):
|
|
|
161
161
|
expected_path = "http://testserver/123"
|
|
162
162
|
expected_agent = "Mozilla/5.0"
|
|
163
163
|
expected_trace = "123"
|
|
164
|
-
|
|
165
|
-
|
|
164
|
+
input_span = "456"
|
|
165
|
+
expected_span = "1c8".zfill(16)
|
|
166
|
+
combined_trace = f"{expected_trace}/{input_span};o=1"
|
|
166
167
|
expected_request = {
|
|
167
168
|
"requestMethod": "GET",
|
|
168
169
|
"requestUrl": expected_path,
|
|
@@ -382,7 +382,7 @@ class TestStructuredLogHandler(unittest.TestCase):
|
|
|
382
382
|
result = handler.format(record)
|
|
383
383
|
self.assertIn(expected_result, result)
|
|
384
384
|
|
|
385
|
-
def
|
|
385
|
+
def test_format_with_xctc_request(self):
|
|
386
386
|
import logging
|
|
387
387
|
import json
|
|
388
388
|
|
|
@@ -393,8 +393,9 @@ class TestStructuredLogHandler(unittest.TestCase):
|
|
|
393
393
|
expected_path = "http://testserver/123"
|
|
394
394
|
expected_agent = "Mozilla/5.0"
|
|
395
395
|
expected_trace = "123"
|
|
396
|
-
|
|
397
|
-
|
|
396
|
+
input_span = "456"
|
|
397
|
+
expected_span = "1c8".zfill(16)
|
|
398
|
+
trace_header = f"{expected_trace}/{input_span};o=1"
|
|
398
399
|
expected_payload = {
|
|
399
400
|
"logging.googleapis.com/trace": expected_trace,
|
|
400
401
|
"logging.googleapis.com/spanId": expected_span,
|
|
@@ -17,6 +17,8 @@ import unittest
|
|
|
17
17
|
import google.auth.credentials
|
|
18
18
|
import mock
|
|
19
19
|
|
|
20
|
+
from datetime import datetime
|
|
21
|
+
|
|
20
22
|
import google.cloud.logging
|
|
21
23
|
from google.cloud import logging_v2
|
|
22
24
|
from google.cloud.logging_v2 import _gapic
|
|
@@ -173,6 +175,21 @@ class Test_LoggingAPI(unittest.TestCase):
|
|
|
173
175
|
assert request.entries[0].resource.type == entry["resource"]["type"]
|
|
174
176
|
assert request.entries[0].text_payload == "text"
|
|
175
177
|
|
|
178
|
+
def test_write_entries_parse_error(self):
|
|
179
|
+
client = self.make_logging_api()
|
|
180
|
+
with self.assertRaises(ValueError):
|
|
181
|
+
with mock.patch.object(
|
|
182
|
+
type(client._gapic_api.transport.write_log_entries), "__call__"
|
|
183
|
+
) as call:
|
|
184
|
+
entry = {
|
|
185
|
+
"logName": self.LOG_PATH,
|
|
186
|
+
"resource": {"type": "global"},
|
|
187
|
+
"jsonPayload": {"time": datetime.now()},
|
|
188
|
+
}
|
|
189
|
+
client.write_entries([entry])
|
|
190
|
+
|
|
191
|
+
call.assert_not_called()
|
|
192
|
+
|
|
176
193
|
def test_logger_delete(self):
|
|
177
194
|
client = self.make_logging_api()
|
|
178
195
|
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{google_cloud_logging-3.11.2 → google_cloud_logging-3.11.4}/google/cloud/logging/__init__.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{google_cloud_logging-3.11.2 → google_cloud_logging-3.11.4}/google/cloud/logging_v2/__init__.py
RENAMED
|
File without changes
|
{google_cloud_logging-3.11.2 → google_cloud_logging-3.11.4}/google/cloud/logging_v2/_helpers.py
RENAMED
|
File without changes
|
{google_cloud_logging-3.11.2 → google_cloud_logging-3.11.4}/google/cloud/logging_v2/_http.py
RENAMED
|
File without changes
|
|
File without changes
|
{google_cloud_logging-3.11.2 → google_cloud_logging-3.11.4}/google/cloud/logging_v2/client.py
RENAMED
|
File without changes
|
{google_cloud_logging-3.11.2 → google_cloud_logging-3.11.4}/google/cloud/logging_v2/entries.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{google_cloud_logging-3.11.2 → google_cloud_logging-3.11.4}/google/cloud/logging_v2/metric.py
RENAMED
|
File without changes
|
{google_cloud_logging-3.11.2 → google_cloud_logging-3.11.4}/google/cloud/logging_v2/py.typed
RENAMED
|
File without changes
|
{google_cloud_logging-3.11.2 → google_cloud_logging-3.11.4}/google/cloud/logging_v2/resource.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{google_cloud_logging-3.11.2 → google_cloud_logging-3.11.4}/google/cloud/logging_v2/types/logging.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{google_cloud_logging-3.11.2 → google_cloud_logging-3.11.4}/tests/performance/test_performance.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{google_cloud_logging-3.11.2 → google_cloud_logging-3.11.4}/tests/unit/gapic/logging_v2/__init__.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{google_cloud_logging-3.11.2 → google_cloud_logging-3.11.4}/tests/unit/handlers/test_app_engine.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{google_cloud_logging-3.11.2 → google_cloud_logging-3.11.4}/tests/unit/test__instrumentation.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|