google-cloud-logging 3.9.0rc1__tar.gz → 3.11.0__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.
Files changed (111) hide show
  1. {google-cloud-logging-3.9.0rc1 → google_cloud_logging-3.11.0}/MANIFEST.in +1 -1
  2. {google-cloud-logging-3.9.0rc1/google_cloud_logging.egg-info → google_cloud_logging-3.11.0}/PKG-INFO +6 -4
  3. {google-cloud-logging-3.9.0rc1 → google_cloud_logging-3.11.0}/README.rst +2 -2
  4. {google-cloud-logging-3.9.0rc1/google/cloud/logging_v2 → google_cloud_logging-3.11.0/google/cloud/logging}/gapic_version.py +1 -1
  5. {google-cloud-logging-3.9.0rc1 → google_cloud_logging-3.11.0}/google/cloud/logging_v2/__init__.py +1 -1
  6. {google-cloud-logging-3.9.0rc1 → google_cloud_logging-3.11.0}/google/cloud/logging_v2/_gapic.py +1 -8
  7. {google-cloud-logging-3.9.0rc1 → google_cloud_logging-3.11.0}/google/cloud/logging_v2/_http.py +1 -1
  8. {google-cloud-logging-3.9.0rc1/google/cloud/logging → google_cloud_logging-3.11.0/google/cloud/logging_v2}/gapic_version.py +1 -1
  9. {google-cloud-logging-3.9.0rc1 → google_cloud_logging-3.11.0}/google/cloud/logging_v2/handlers/_helpers.py +57 -7
  10. {google-cloud-logging-3.9.0rc1 → google_cloud_logging-3.11.0}/google/cloud/logging_v2/handlers/_monitored_resources.py +75 -4
  11. {google-cloud-logging-3.9.0rc1 → google_cloud_logging-3.11.0}/google/cloud/logging_v2/handlers/handlers.py +28 -20
  12. {google-cloud-logging-3.9.0rc1 → google_cloud_logging-3.11.0}/google/cloud/logging_v2/handlers/structured_log.py +7 -1
  13. {google-cloud-logging-3.9.0rc1 → google_cloud_logging-3.11.0}/google/cloud/logging_v2/handlers/transports/sync.py +1 -1
  14. {google-cloud-logging-3.9.0rc1 → google_cloud_logging-3.11.0}/google/cloud/logging_v2/logger.py +2 -1
  15. {google-cloud-logging-3.9.0rc1 → google_cloud_logging-3.11.0}/google/cloud/logging_v2/services/__init__.py +1 -1
  16. {google-cloud-logging-3.9.0rc1 → google_cloud_logging-3.11.0}/google/cloud/logging_v2/services/config_service_v2/__init__.py +1 -1
  17. {google-cloud-logging-3.9.0rc1 → google_cloud_logging-3.11.0}/google/cloud/logging_v2/services/config_service_v2/async_client.py +158 -15
  18. {google-cloud-logging-3.9.0rc1 → google_cloud_logging-3.11.0}/google/cloud/logging_v2/services/config_service_v2/client.py +362 -35
  19. {google-cloud-logging-3.9.0rc1 → google_cloud_logging-3.11.0}/google/cloud/logging_v2/services/config_service_v2/pagers.py +1 -1
  20. {google-cloud-logging-3.9.0rc1 → google_cloud_logging-3.11.0}/google/cloud/logging_v2/services/config_service_v2/transports/__init__.py +1 -1
  21. {google-cloud-logging-3.9.0rc1 → google_cloud_logging-3.11.0}/google/cloud/logging_v2/services/config_service_v2/transports/base.py +6 -2
  22. {google-cloud-logging-3.9.0rc1 → google_cloud_logging-3.11.0}/google/cloud/logging_v2/services/config_service_v2/transports/grpc.py +2 -2
  23. {google-cloud-logging-3.9.0rc1 → google_cloud_logging-3.11.0}/google/cloud/logging_v2/services/config_service_v2/transports/grpc_asyncio.py +2 -2
  24. {google-cloud-logging-3.9.0rc1 → google_cloud_logging-3.11.0}/google/cloud/logging_v2/services/logging_service_v2/__init__.py +1 -1
  25. {google-cloud-logging-3.9.0rc1 → google_cloud_logging-3.11.0}/google/cloud/logging_v2/services/logging_service_v2/async_client.py +80 -15
  26. {google-cloud-logging-3.9.0rc1 → google_cloud_logging-3.11.0}/google/cloud/logging_v2/services/logging_service_v2/client.py +284 -35
  27. {google-cloud-logging-3.9.0rc1 → google_cloud_logging-3.11.0}/google/cloud/logging_v2/services/logging_service_v2/pagers.py +1 -1
  28. {google-cloud-logging-3.9.0rc1 → google_cloud_logging-3.11.0}/google/cloud/logging_v2/services/logging_service_v2/transports/__init__.py +1 -1
  29. {google-cloud-logging-3.9.0rc1 → google_cloud_logging-3.11.0}/google/cloud/logging_v2/services/logging_service_v2/transports/base.py +6 -2
  30. {google-cloud-logging-3.9.0rc1 → google_cloud_logging-3.11.0}/google/cloud/logging_v2/services/logging_service_v2/transports/grpc.py +2 -2
  31. {google-cloud-logging-3.9.0rc1 → google_cloud_logging-3.11.0}/google/cloud/logging_v2/services/logging_service_v2/transports/grpc_asyncio.py +2 -2
  32. {google-cloud-logging-3.9.0rc1 → google_cloud_logging-3.11.0}/google/cloud/logging_v2/services/metrics_service_v2/__init__.py +1 -1
  33. {google-cloud-logging-3.9.0rc1 → google_cloud_logging-3.11.0}/google/cloud/logging_v2/services/metrics_service_v2/async_client.py +77 -15
  34. {google-cloud-logging-3.9.0rc1 → google_cloud_logging-3.11.0}/google/cloud/logging_v2/services/metrics_service_v2/client.py +281 -35
  35. {google-cloud-logging-3.9.0rc1 → google_cloud_logging-3.11.0}/google/cloud/logging_v2/services/metrics_service_v2/pagers.py +1 -1
  36. {google-cloud-logging-3.9.0rc1 → google_cloud_logging-3.11.0}/google/cloud/logging_v2/services/metrics_service_v2/transports/__init__.py +1 -1
  37. {google-cloud-logging-3.9.0rc1 → google_cloud_logging-3.11.0}/google/cloud/logging_v2/services/metrics_service_v2/transports/base.py +6 -2
  38. {google-cloud-logging-3.9.0rc1 → google_cloud_logging-3.11.0}/google/cloud/logging_v2/services/metrics_service_v2/transports/grpc.py +2 -2
  39. {google-cloud-logging-3.9.0rc1 → google_cloud_logging-3.11.0}/google/cloud/logging_v2/services/metrics_service_v2/transports/grpc_asyncio.py +2 -2
  40. {google-cloud-logging-3.9.0rc1 → google_cloud_logging-3.11.0}/google/cloud/logging_v2/types/__init__.py +1 -1
  41. {google-cloud-logging-3.9.0rc1 → google_cloud_logging-3.11.0}/google/cloud/logging_v2/types/log_entry.py +1 -1
  42. {google-cloud-logging-3.9.0rc1 → google_cloud_logging-3.11.0}/google/cloud/logging_v2/types/logging.py +1 -1
  43. {google-cloud-logging-3.9.0rc1 → google_cloud_logging-3.11.0}/google/cloud/logging_v2/types/logging_config.py +1 -1
  44. {google-cloud-logging-3.9.0rc1 → google_cloud_logging-3.11.0}/google/cloud/logging_v2/types/logging_metrics.py +1 -1
  45. {google-cloud-logging-3.9.0rc1 → google_cloud_logging-3.11.0/google_cloud_logging.egg-info}/PKG-INFO +6 -4
  46. {google-cloud-logging-3.9.0rc1 → google_cloud_logging-3.11.0}/google_cloud_logging.egg-info/requires.txt +3 -1
  47. {google-cloud-logging-3.9.0rc1 → google_cloud_logging-3.11.0}/setup.py +5 -1
  48. {google-cloud-logging-3.9.0rc1 → google_cloud_logging-3.11.0}/tests/__init__.py +1 -1
  49. {google-cloud-logging-3.9.0rc1 → google_cloud_logging-3.11.0}/tests/system/test_system.py +58 -1
  50. {google-cloud-logging-3.9.0rc1 → google_cloud_logging-3.11.0}/tests/unit/__init__.py +1 -1
  51. {google-cloud-logging-3.9.0rc1 → google_cloud_logging-3.11.0}/tests/unit/gapic/__init__.py +1 -1
  52. google_cloud_logging-3.11.0/tests/unit/gapic/logging_v2/__init__.py +15 -0
  53. {google-cloud-logging-3.9.0rc1 → google_cloud_logging-3.11.0}/tests/unit/gapic/logging_v2/test_config_service_v2.py +2226 -132
  54. {google-cloud-logging-3.9.0rc1 → google_cloud_logging-3.11.0}/tests/unit/gapic/logging_v2/test_logging_service_v2.py +719 -44
  55. {google-cloud-logging-3.9.0rc1 → google_cloud_logging-3.11.0}/tests/unit/gapic/logging_v2/test_metrics_service_v2.py +730 -36
  56. google_cloud_logging-3.11.0/tests/unit/handlers/__init__.py +54 -0
  57. {google-cloud-logging-3.9.0rc1 → google_cloud_logging-3.11.0}/tests/unit/handlers/test__helpers.py +143 -0
  58. {google-cloud-logging-3.9.0rc1 → google_cloud_logging-3.11.0}/tests/unit/handlers/test__monitored_resources.py +48 -14
  59. {google-cloud-logging-3.9.0rc1 → google_cloud_logging-3.11.0}/tests/unit/handlers/test_app_engine.py +1 -1
  60. {google-cloud-logging-3.9.0rc1 → google_cloud_logging-3.11.0}/tests/unit/handlers/test_handlers.py +170 -2
  61. {google-cloud-logging-3.9.0rc1 → google_cloud_logging-3.11.0}/tests/unit/handlers/test_structured_log.py +102 -1
  62. {google-cloud-logging-3.9.0rc1 → google_cloud_logging-3.11.0}/tests/unit/test__gapic.py +0 -1
  63. {google-cloud-logging-3.9.0rc1 → google_cloud_logging-3.11.0}/tests/unit/test__instrumentation.py +7 -7
  64. {google-cloud-logging-3.9.0rc1 → google_cloud_logging-3.11.0}/tests/unit/test_client.py +36 -6
  65. google-cloud-logging-3.9.0rc1/tests/unit/gapic/logging_v2/__init__.py +0 -15
  66. google-cloud-logging-3.9.0rc1/tests/unit/handlers/transports/__init__.py +0 -13
  67. {google-cloud-logging-3.9.0rc1 → google_cloud_logging-3.11.0}/LICENSE +0 -0
  68. {google-cloud-logging-3.9.0rc1 → google_cloud_logging-3.11.0}/google/cloud/logging/__init__.py +0 -0
  69. {google-cloud-logging-3.9.0rc1 → google_cloud_logging-3.11.0}/google/cloud/logging/handlers/__init__.py +0 -0
  70. {google-cloud-logging-3.9.0rc1 → google_cloud_logging-3.11.0}/google/cloud/logging/handlers/middleware/__init__.py +0 -0
  71. {google-cloud-logging-3.9.0rc1 → google_cloud_logging-3.11.0}/google/cloud/logging/handlers/transports/__init__.py +0 -0
  72. {google-cloud-logging-3.9.0rc1 → google_cloud_logging-3.11.0}/google/cloud/logging/py.typed +0 -0
  73. {google-cloud-logging-3.9.0rc1 → google_cloud_logging-3.11.0}/google/cloud/logging_v2/_helpers.py +0 -0
  74. {google-cloud-logging-3.9.0rc1 → google_cloud_logging-3.11.0}/google/cloud/logging_v2/_instrumentation.py +0 -0
  75. {google-cloud-logging-3.9.0rc1 → google_cloud_logging-3.11.0}/google/cloud/logging_v2/client.py +0 -0
  76. {google-cloud-logging-3.9.0rc1 → google_cloud_logging-3.11.0}/google/cloud/logging_v2/entries.py +0 -0
  77. {google-cloud-logging-3.9.0rc1 → google_cloud_logging-3.11.0}/google/cloud/logging_v2/gapic_metadata.json +0 -0
  78. {google-cloud-logging-3.9.0rc1 → google_cloud_logging-3.11.0}/google/cloud/logging_v2/handlers/__init__.py +0 -0
  79. {google-cloud-logging-3.9.0rc1 → google_cloud_logging-3.11.0}/google/cloud/logging_v2/handlers/app_engine.py +0 -0
  80. {google-cloud-logging-3.9.0rc1 → google_cloud_logging-3.11.0}/google/cloud/logging_v2/handlers/container_engine.py +0 -0
  81. {google-cloud-logging-3.9.0rc1 → google_cloud_logging-3.11.0}/google/cloud/logging_v2/handlers/middleware/__init__.py +0 -0
  82. {google-cloud-logging-3.9.0rc1 → google_cloud_logging-3.11.0}/google/cloud/logging_v2/handlers/middleware/request.py +0 -0
  83. {google-cloud-logging-3.9.0rc1 → google_cloud_logging-3.11.0}/google/cloud/logging_v2/handlers/transports/__init__.py +0 -0
  84. {google-cloud-logging-3.9.0rc1 → google_cloud_logging-3.11.0}/google/cloud/logging_v2/handlers/transports/background_thread.py +0 -0
  85. {google-cloud-logging-3.9.0rc1 → google_cloud_logging-3.11.0}/google/cloud/logging_v2/handlers/transports/base.py +0 -0
  86. {google-cloud-logging-3.9.0rc1 → google_cloud_logging-3.11.0}/google/cloud/logging_v2/metric.py +0 -0
  87. {google-cloud-logging-3.9.0rc1 → google_cloud_logging-3.11.0}/google/cloud/logging_v2/py.typed +0 -0
  88. {google-cloud-logging-3.9.0rc1 → google_cloud_logging-3.11.0}/google/cloud/logging_v2/resource.py +0 -0
  89. {google-cloud-logging-3.9.0rc1 → google_cloud_logging-3.11.0}/google/cloud/logging_v2/sink.py +0 -0
  90. {google-cloud-logging-3.9.0rc1 → google_cloud_logging-3.11.0}/google_cloud_logging.egg-info/SOURCES.txt +0 -0
  91. {google-cloud-logging-3.9.0rc1 → google_cloud_logging-3.11.0}/google_cloud_logging.egg-info/dependency_links.txt +0 -0
  92. {google-cloud-logging-3.9.0rc1 → google_cloud_logging-3.11.0}/google_cloud_logging.egg-info/not-zip-safe +0 -0
  93. {google-cloud-logging-3.9.0rc1 → google_cloud_logging-3.11.0}/google_cloud_logging.egg-info/top_level.txt +0 -0
  94. {google-cloud-logging-3.9.0rc1 → google_cloud_logging-3.11.0}/setup.cfg +0 -0
  95. {google-cloud-logging-3.9.0rc1 → google_cloud_logging-3.11.0}/tests/performance/noxfile.py +0 -0
  96. {google-cloud-logging-3.9.0rc1 → google_cloud_logging-3.11.0}/tests/performance/test_performance.py +0 -0
  97. {google-cloud-logging-3.9.0rc1 → google_cloud_logging-3.11.0}/tests/system/gapic/v2/test_system_logging_service_v2_v2.py +0 -0
  98. {google-cloud-logging-3.9.0rc1 → google_cloud_logging-3.11.0}/tests/unit/handlers/middleware/test_request.py +0 -0
  99. {google-cloud-logging-3.9.0rc1 → google_cloud_logging-3.11.0}/tests/unit/handlers/test_container_engine.py +0 -0
  100. {google-cloud-logging-3.9.0rc1/tests/unit/handlers → google_cloud_logging-3.11.0/tests/unit/handlers/transports}/__init__.py +0 -0
  101. {google-cloud-logging-3.9.0rc1 → google_cloud_logging-3.11.0}/tests/unit/handlers/transports/test_background_thread.py +0 -0
  102. {google-cloud-logging-3.9.0rc1 → google_cloud_logging-3.11.0}/tests/unit/handlers/transports/test_base.py +0 -0
  103. {google-cloud-logging-3.9.0rc1 → google_cloud_logging-3.11.0}/tests/unit/handlers/transports/test_sync.py +0 -0
  104. {google-cloud-logging-3.9.0rc1 → google_cloud_logging-3.11.0}/tests/unit/test__helpers.py +0 -0
  105. {google-cloud-logging-3.9.0rc1 → google_cloud_logging-3.11.0}/tests/unit/test__http.py +0 -0
  106. {google-cloud-logging-3.9.0rc1 → google_cloud_logging-3.11.0}/tests/unit/test_entries.py +0 -0
  107. {google-cloud-logging-3.9.0rc1 → google_cloud_logging-3.11.0}/tests/unit/test_logger.py +0 -0
  108. {google-cloud-logging-3.9.0rc1 → google_cloud_logging-3.11.0}/tests/unit/test_logging_shim.py +0 -0
  109. {google-cloud-logging-3.9.0rc1 → google_cloud_logging-3.11.0}/tests/unit/test_metric.py +0 -0
  110. {google-cloud-logging-3.9.0rc1 → google_cloud_logging-3.11.0}/tests/unit/test_packaging.py +0 -0
  111. {google-cloud-logging-3.9.0rc1 → google_cloud_logging-3.11.0}/tests/unit/test_sink.py +0 -0
@@ -1,6 +1,6 @@
1
1
  # -*- coding: utf-8 -*-
2
2
  #
3
- # Copyright 2023 Google LLC
3
+ # Copyright 2024 Google LLC
4
4
  #
5
5
  # Licensed under the Apache License, Version 2.0 (the "License");
6
6
  # you may not use this file except in compliance with the License.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: google-cloud-logging
3
- Version: 3.9.0rc1
3
+ Version: 3.11.0
4
4
  Summary: Stackdriver Logging API client library
5
5
  Home-page: https://github.com/googleapis/python-logging
6
6
  Author: Google LLC
@@ -22,11 +22,13 @@ Classifier: Operating System :: OS Independent
22
22
  Classifier: Topic :: Internet
23
23
  Requires-Python: >=3.7
24
24
  License-File: LICENSE
25
- Requires-Dist: google-api-core[grpc]!=2.0.*,!=2.1.*,!=2.2.*,!=2.3.*,!=2.4.*,!=2.5.*,!=2.6.*,!=2.7.*,<3.0.0dev,>=1.33.2
25
+ Requires-Dist: google-api-core[grpc]!=2.0.*,!=2.1.*,!=2.10.*,!=2.2.*,!=2.3.*,!=2.4.*,!=2.5.*,!=2.6.*,!=2.7.*,!=2.8.*,!=2.9.*,<3.0.0dev,>=1.34.1
26
+ Requires-Dist: google-auth!=2.24.0,!=2.25.0,<3.0.0dev,>=2.14.1
26
27
  Requires-Dist: google-cloud-appengine-logging<2.0.0dev,>=0.1.0
27
28
  Requires-Dist: google-cloud-audit-log<1.0.0dev,>=0.1.0
28
29
  Requires-Dist: google-cloud-core<3.0.0dev,>=2.0.0
29
30
  Requires-Dist: grpc-google-iam-v1<1.0.0dev,>=0.12.4
31
+ Requires-Dist: opentelemetry-api>=1.0.0
30
32
  Requires-Dist: proto-plus<2.0.0dev,>=1.22.0
31
33
  Requires-Dist: proto-plus<2.0.0dev,>=1.22.2; python_version >= "3.11"
32
34
  Requires-Dist: protobuf!=3.20.0,!=3.20.1,!=4.21.0,!=4.21.1,!=4.21.2,!=4.21.3,!=4.21.4,!=4.21.5,<5.0.0dev,>=3.19.5
@@ -94,8 +96,8 @@ Python >= 3.7
94
96
 
95
97
  Unsupported Python Versions
96
98
  ^^^^^^^^^^^^^^^^^^^^^^^^^^^
97
- Python == 2.7. The last version of the library compatible with Python 2.7 is `google-cloud-logging==1.15.1`.
98
- Python == 3.6. The last version of the library compatible with Python 3.6 is `google-cloud-logging==3.1.2`.
99
+ | Python == 2.7. The last version of the library compatible with Python 2.7 is ``google-cloud-logging==1.15.1``.
100
+ | Python == 3.6. The last version of the library compatible with Python 3.6 is ``google-cloud-logging==3.1.2``.
99
101
 
100
102
 
101
103
  Mac/Linux
@@ -61,8 +61,8 @@ Python >= 3.7
61
61
 
62
62
  Unsupported Python Versions
63
63
  ^^^^^^^^^^^^^^^^^^^^^^^^^^^
64
- Python == 2.7. The last version of the library compatible with Python 2.7 is `google-cloud-logging==1.15.1`.
65
- Python == 3.6. The last version of the library compatible with Python 3.6 is `google-cloud-logging==3.1.2`.
64
+ | Python == 2.7. The last version of the library compatible with Python 2.7 is ``google-cloud-logging==1.15.1``.
65
+ | Python == 3.6. The last version of the library compatible with Python 3.6 is ``google-cloud-logging==3.1.2``.
66
66
 
67
67
 
68
68
  Mac/Linux
@@ -13,4 +13,4 @@
13
13
  # See the License for the specific language governing permissions and
14
14
  # limitations under the License.
15
15
  #
16
- __version__ = "3.9.0" # {x-release-please-version}
16
+ __version__ = "3.11.0" # {x-release-please-version}
@@ -36,7 +36,7 @@ from google.cloud.logging_v2 import types
36
36
  ASCENDING = "timestamp asc"
37
37
  """Query string to order by ascending timestamps."""
38
38
  DESCENDING = "timestamp desc"
39
- """Query string to order by decending timestamps."""
39
+ """Query string to order by descending timestamps."""
40
40
  _instrumentation_emitted = False
41
41
  """Flag for whether instrumentation info has been emitted"""
42
42
 
@@ -271,7 +271,6 @@ class _SinksAPI(object):
271
271
  return MessageToDict(
272
272
  LogSink.pb(created_pb),
273
273
  preserving_proto_field_name=False,
274
- including_default_value_fields=False,
275
274
  )
276
275
 
277
276
  def sink_get(self, sink_name):
@@ -298,7 +297,6 @@ class _SinksAPI(object):
298
297
  return MessageToDict(
299
298
  LogSink.pb(sink_pb),
300
299
  preserving_proto_field_name=False,
301
- including_default_value_fields=False,
302
300
  )
303
301
 
304
302
  def sink_update(
@@ -333,7 +331,7 @@ class _SinksAPI(object):
333
331
  dict: The sink resource returned from the API (converted from a
334
332
  protobuf to a dictionary).
335
333
  """
336
- name = sink_name.split("/")[-1] # parse name out of full resoure name
334
+ name = sink_name.split("/")[-1] # parse name out of full resource name
337
335
  sink_pb = LogSink(
338
336
  name=name,
339
337
  filter=filter_,
@@ -351,7 +349,6 @@ class _SinksAPI(object):
351
349
  return MessageToDict(
352
350
  LogSink.pb(sink_pb),
353
351
  preserving_proto_field_name=False,
354
- including_default_value_fields=False,
355
352
  )
356
353
 
357
354
  def sink_delete(self, sink_name):
@@ -459,7 +456,6 @@ class _MetricsAPI(object):
459
456
  return MessageToDict(
460
457
  LogMetric.pb(metric_pb),
461
458
  preserving_proto_field_name=False,
462
- including_default_value_fields=False,
463
459
  )
464
460
 
465
461
  def metric_update(
@@ -496,7 +492,6 @@ class _MetricsAPI(object):
496
492
  return MessageToDict(
497
493
  LogMetric.pb(metric_pb),
498
494
  preserving_proto_field_name=False,
499
- including_default_value_fields=False,
500
495
  )
501
496
 
502
497
  def metric_delete(self, project, metric_name):
@@ -530,7 +525,6 @@ def _parse_log_entry(entry_pb):
530
525
  return MessageToDict(
531
526
  entry_pb,
532
527
  preserving_proto_field_name=False,
533
- including_default_value_fields=False,
534
528
  )
535
529
  except TypeError:
536
530
  if entry_pb.HasField("proto_payload"):
@@ -539,7 +533,6 @@ def _parse_log_entry(entry_pb):
539
533
  entry_mapping = MessageToDict(
540
534
  entry_pb,
541
535
  preserving_proto_field_name=False,
542
- including_default_value_fields=False,
543
536
  )
544
537
  entry_mapping["protoPayload"] = proto_payload
545
538
  return entry_mapping
@@ -347,7 +347,7 @@ class _SinksAPI(object):
347
347
  dict: The returned (updated) resource.
348
348
  """
349
349
  target = f"/{sink_name}"
350
- name = sink_name.split("/")[-1] # parse name out of full resoure name
350
+ name = sink_name.split("/")[-1] # parse name out of full resource name
351
351
  data = {"name": name, "filter": filter_, "destination": destination}
352
352
  query_params = {"uniqueWriterIdentity": unique_writer_identity}
353
353
  return self.api_request(
@@ -13,4 +13,4 @@
13
13
  # See the License for the specific language governing permissions and
14
14
  # limitations under the License.
15
15
  #
16
- __version__ = "3.9.0rc1" # {x-release-please-version}
16
+ __version__ = "3.11.0" # {x-release-please-version}
@@ -24,6 +24,8 @@ try:
24
24
  except ImportError: # pragma: NO COVER
25
25
  flask = None
26
26
 
27
+ import opentelemetry.trace
28
+
27
29
  from google.cloud.logging_v2.handlers.middleware.request import _get_django_request
28
30
 
29
31
  _DJANGO_CONTENT_LENGTH = "CONTENT_LENGTH"
@@ -66,7 +68,7 @@ def get_request_data_from_flask():
66
68
  Returns:
67
69
  Tuple[Optional[dict], Optional[str], Optional[str], bool]:
68
70
  Data related to the current http request, trace_id, span_id and trace_sampled
69
- for the request. All fields will be None if a django request isn't found.
71
+ for the request. All fields will be None if a Flask request isn't found.
70
72
  """
71
73
  if flask is None or not flask.request:
72
74
  return None, None, None, False
@@ -191,23 +193,71 @@ def _parse_xcloud_trace(header):
191
193
  return trace_id, span_id, trace_sampled
192
194
 
193
195
 
196
+ def _retrieve_current_open_telemetry_span():
197
+ """Helper to retrieve trace, span ID, and trace sampled information from the current
198
+ OpenTelemetry span.
199
+
200
+ Returns:
201
+ Tuple[Optional[str], Optional[str], bool]:
202
+ Data related to the current trace_id, span_id, and trace_sampled for the
203
+ current OpenTelemetry span. If a span is not found, return None/False for all
204
+ fields.
205
+ """
206
+ span = opentelemetry.trace.get_current_span()
207
+ if span != opentelemetry.trace.span.INVALID_SPAN:
208
+ context = span.get_span_context()
209
+ trace_id = opentelemetry.trace.format_trace_id(context.trace_id)
210
+ span_id = opentelemetry.trace.format_span_id(context.span_id)
211
+ trace_sampled = context.trace_flags.sampled
212
+
213
+ return trace_id, span_id, trace_sampled
214
+
215
+ return None, None, False
216
+
217
+
194
218
  def get_request_data():
195
219
  """Helper to get http_request and trace data from supported web
196
- frameworks (currently supported: Flask and Django).
220
+ frameworks (currently supported: Flask and Django), as well as OpenTelemetry. Attempts
221
+ to retrieve trace/spanID from OpenTelemetry first, before going to Traceparent then XCTC.
222
+ HTTP request data is taken from a supporting web framework (currently Flask or Django).
223
+ Because HTTP request data is decoupled from OpenTelemetry, it is possible to get as a
224
+ return value the HTTP request from the web framework of choice, and trace/span data from
225
+ OpenTelemetry, even if trace data is present in the HTTP request headers.
197
226
 
198
227
  Returns:
199
228
  Tuple[Optional[dict], Optional[str], Optional[str], bool]:
200
229
  Data related to the current http request, trace_id, span_id, and trace_sampled
201
230
  for the request. All fields will be None if a http request isn't found.
202
231
  """
232
+
233
+ (
234
+ otel_trace_id,
235
+ otel_span_id,
236
+ otel_trace_sampled,
237
+ ) = _retrieve_current_open_telemetry_span()
238
+
239
+ # Get HTTP request data
203
240
  checkers = (
204
241
  get_request_data_from_django,
205
242
  get_request_data_from_flask,
206
243
  )
207
244
 
208
- for checker in checkers:
209
- http_request, trace_id, span_id, trace_sampled = checker()
210
- if http_request is not None:
211
- return http_request, trace_id, span_id, trace_sampled
245
+ http_request, http_trace_id, http_span_id, http_trace_sampled = (
246
+ None,
247
+ None,
248
+ None,
249
+ False,
250
+ )
212
251
 
213
- return None, None, None, False
252
+ for checker in checkers:
253
+ http_request, http_trace_id, http_span_id, http_trace_sampled = checker()
254
+ if http_request is None:
255
+ http_trace_id, http_span_id, http_trace_sampled = None, None, False
256
+ else:
257
+ break
258
+
259
+ # otel_trace_id existing means the other return values are non-null
260
+ if otel_trace_id:
261
+ return http_request, otel_trace_id, otel_span_id, otel_trace_sampled
262
+ else:
263
+ return http_request, http_trace_id, http_span_id, http_trace_sampled
@@ -12,6 +12,8 @@
12
12
  # See the License for the specific language governing permissions and
13
13
  # limitations under the License.
14
14
 
15
+ import functools
16
+ import logging
15
17
  import os
16
18
 
17
19
  from google.cloud.logging_v2.resource import Resource
@@ -61,9 +63,26 @@ _GCE_INSTANCE_ID = "instance/id"
61
63
  _GKE_CLUSTER_NAME = "instance/attributes/cluster-name"
62
64
  """Attribute in metadata server when in GKE environment."""
63
65
 
66
+ _GKE_CLUSTER_LOCATION = "instance/attributes/cluster-location"
67
+ """Attribute in metadata server when in GKE environment."""
68
+
64
69
  _PROJECT_NAME = "project/project-id"
65
70
  """Attribute in metadata server when in GKE environment."""
66
71
 
72
+ _GAE_RESOURCE_TYPE = "gae_app"
73
+ """Resource type for App Engine environment."""
74
+
75
+ _CLOUD_RUN_JOB_RESOURCE_TYPE = "cloud_run_job"
76
+ """Resource type for Cloud Run Jobs."""
77
+
78
+ _GAE_TRACE_ID_LABEL = "appengine.googleapis.com/trace_id"
79
+ """Extra trace label to be added on App Engine environments"""
80
+
81
+ _CLOUD_RUN_JOBS_EXECUTION_NAME_LABEL = "run.googleapis.com/execution_name"
82
+ _CLOUD_RUN_JOBS_TASK_INDEX_LABEL = "run.googleapis.com/task_index"
83
+ _CLOUD_RUN_JOBS_TASK_ATTEMPT_LABEL = "run.googleapis.com/task_attempt"
84
+ """Extra labels for Cloud Run environments to be recognized by Cloud Run Jobs web UI."""
85
+
67
86
 
68
87
  def _create_functions_resource():
69
88
  """Create a standardized Cloud Functions resource.
@@ -94,7 +113,7 @@ def _create_kubernetes_resource():
94
113
  Returns:
95
114
  google.cloud.logging.Resource
96
115
  """
97
- zone = retrieve_metadata_server(_ZONE_ID)
116
+ location = retrieve_metadata_server(_GKE_CLUSTER_LOCATION)
98
117
  cluster_name = retrieve_metadata_server(_GKE_CLUSTER_NAME)
99
118
  project = retrieve_metadata_server(_PROJECT_NAME)
100
119
 
@@ -102,7 +121,7 @@ def _create_kubernetes_resource():
102
121
  type="k8s_container",
103
122
  labels={
104
123
  "project_id": project if project else "",
105
- "location": zone if zone else "",
124
+ "location": location if location else "",
106
125
  "cluster_name": cluster_name if cluster_name else "",
107
126
  },
108
127
  )
@@ -156,7 +175,7 @@ def _create_cloud_run_job_resource():
156
175
  region = retrieve_metadata_server(_REGION_ID)
157
176
  project = retrieve_metadata_server(_PROJECT_NAME)
158
177
  resource = Resource(
159
- type="cloud_run_job",
178
+ type=_CLOUD_RUN_JOB_RESOURCE_TYPE,
160
179
  labels={
161
180
  "project_id": project if project else "",
162
181
  "job_name": os.environ.get(_CLOUD_RUN_JOB_ID, ""),
@@ -174,7 +193,7 @@ def _create_app_engine_resource():
174
193
  zone = retrieve_metadata_server(_ZONE_ID)
175
194
  project = retrieve_metadata_server(_PROJECT_NAME)
176
195
  resource = Resource(
177
- type="gae_app",
196
+ type=_GAE_RESOURCE_TYPE,
178
197
  labels={
179
198
  "project_id": project if project else "",
180
199
  "module_id": os.environ.get(_GAE_SERVICE_ENV, ""),
@@ -230,3 +249,55 @@ def detect_resource(project=""):
230
249
  else:
231
250
  # use generic global resource
232
251
  return _create_global_resource(project)
252
+
253
+
254
+ @functools.lru_cache(maxsize=None)
255
+ def _get_environmental_labels(resource_type):
256
+ """Builds a dictionary of labels to be inserted into a LogRecord of the given resource type.
257
+ This function should only build a dict of items that are consistent across multiple logging statements
258
+ of the same resource type, such as environment variables. Th
259
+
260
+ Returns:
261
+ dict:
262
+ A dict representation of labels and the values of those labels
263
+ """
264
+ labels = {}
265
+ environ_vars = {
266
+ _CLOUD_RUN_JOB_RESOURCE_TYPE: {
267
+ _CLOUD_RUN_JOBS_EXECUTION_NAME_LABEL: _CLOUD_RUN_EXECUTION_ID,
268
+ _CLOUD_RUN_JOBS_TASK_INDEX_LABEL: _CLOUD_RUN_TASK_INDEX,
269
+ _CLOUD_RUN_JOBS_TASK_ATTEMPT_LABEL: _CLOUD_RUN_TASK_ATTEMPT,
270
+ }
271
+ }
272
+
273
+ if resource_type in environ_vars:
274
+ for key, env_var in environ_vars[resource_type].items():
275
+ val = os.environ.get(env_var, "")
276
+ if val:
277
+ labels[key] = val
278
+
279
+ return labels
280
+
281
+
282
+ def add_resource_labels(resource: Resource, record: logging.LogRecord):
283
+ """Returns additional labels to be appended on to a LogRecord object based on the
284
+ local environment. Defaults to an empty dictionary if none apply. This is only to be
285
+ used for CloudLoggingHandler, as the structured logging daemon already does this.
286
+
287
+ Args:
288
+ resource (google.cloud.logging.Resource): Resource based on the environment
289
+ record (logging.LogRecord): A LogRecord object representing a log record
290
+ Returns:
291
+ Dict[str, str]: New labels to append to the labels of the LogRecord
292
+ """
293
+ if not resource:
294
+ return None
295
+
296
+ # Get environmental labels from the resource type
297
+ labels = _get_environmental_labels(resource.type)
298
+
299
+ # Add labels from log record
300
+ if resource.type == _GAE_RESOURCE_TYPE and record._trace is not None:
301
+ labels[_GAE_TRACE_ID_LABEL] = record._trace
302
+
303
+ return labels
@@ -18,30 +18,38 @@ import collections
18
18
  import json
19
19
  import logging
20
20
 
21
- from google.cloud.logging_v2.handlers.transports import BackgroundThreadTransport
22
- from google.cloud.logging_v2.handlers._monitored_resources import detect_resource
21
+ from typing import Optional, IO
22
+
23
+ from google.cloud.logging_v2.handlers.transports import (
24
+ BackgroundThreadTransport,
25
+ Transport,
26
+ )
27
+ from google.cloud.logging_v2.handlers._monitored_resources import (
28
+ detect_resource,
29
+ add_resource_labels,
30
+ )
23
31
  from google.cloud.logging_v2.handlers._helpers import get_request_data
32
+ from google.cloud.logging_v2.resource import Resource
33
+
24
34
 
25
35
  DEFAULT_LOGGER_NAME = "python"
26
36
 
27
- """Exclude internal logs from propagating through handlers"""
37
+ """Defaults for filtering out noisy loggers"""
28
38
  EXCLUDED_LOGGER_DEFAULTS = (
39
+ "google.api_core.bidi",
40
+ "werkzeug",
41
+ )
42
+
43
+ """Exclude internal logs from propagating through handlers"""
44
+ _INTERNAL_LOGGERS = (
29
45
  "google.cloud",
30
46
  "google.auth",
31
47
  "google_auth_httplib2",
32
- "google.api_core.bidi",
33
- "werkzeug",
34
48
  )
35
49
 
36
50
  """These environments require us to remove extra handlers on setup"""
37
51
  _CLEAR_HANDLER_RESOURCE_TYPES = ("gae_app", "cloud_function")
38
52
 
39
- """Extra trace label to be added on App Engine environments"""
40
- _GAE_TRACE_ID_LABEL = "appengine.googleapis.com/trace_id"
41
-
42
- """Resource name for App Engine environments"""
43
- _GAE_RESOURCE_TYPE = "gae_app"
44
-
45
53
 
46
54
  class CloudLoggingFilter(logging.Filter):
47
55
  """Python standard ``logging`` Filter class to add Cloud Logging
@@ -148,11 +156,12 @@ class CloudLoggingHandler(logging.StreamHandler):
148
156
  self,
149
157
  client,
150
158
  *,
151
- name=DEFAULT_LOGGER_NAME,
152
- transport=BackgroundThreadTransport,
153
- resource=None,
154
- labels=None,
155
- stream=None,
159
+ name: str = DEFAULT_LOGGER_NAME,
160
+ transport: Transport = BackgroundThreadTransport,
161
+ resource: Resource = None,
162
+ labels: Optional[dict] = None,
163
+ stream: Optional[IO] = None,
164
+ **kwargs,
156
165
  ):
157
166
  """
158
167
  Args:
@@ -201,9 +210,8 @@ class CloudLoggingHandler(logging.StreamHandler):
201
210
  labels = record._labels
202
211
  message = _format_and_parse_message(record, self)
203
212
 
204
- if resource.type == _GAE_RESOURCE_TYPE and record._trace is not None:
205
- # add GAE-specific label
206
- labels = {_GAE_TRACE_ID_LABEL: record._trace, **(labels or {})}
213
+ labels = {**add_resource_labels(resource, record), **(labels or {})} or None
214
+
207
215
  # send off request
208
216
  self.transport.send(
209
217
  record,
@@ -291,7 +299,7 @@ def setup_logging(
291
299
  log_level (Optional[int]): Python logging log level. Defaults to
292
300
  :const:`logging.INFO`.
293
301
  """
294
- all_excluded_loggers = set(excluded_loggers + EXCLUDED_LOGGER_DEFAULTS)
302
+ all_excluded_loggers = set(excluded_loggers + _INTERNAL_LOGGERS)
295
303
  logger = logging.getLogger()
296
304
 
297
305
  # remove built-in handlers on App Engine or Cloud Functions environments
@@ -63,7 +63,13 @@ class StructuredLogHandler(logging.StreamHandler):
63
63
  """
64
64
 
65
65
  def __init__(
66
- self, *, labels=None, stream=None, project_id=None, json_encoder_cls=None
66
+ self,
67
+ *,
68
+ labels=None,
69
+ stream=None,
70
+ project_id=None,
71
+ json_encoder_cls=None,
72
+ **kwargs
67
73
  ):
68
74
  """
69
75
  Args:
@@ -14,7 +14,7 @@
14
14
 
15
15
  """Transport for Python logging handler.
16
16
 
17
- Logs directly to the the Cloud Logging API with a synchronous call.
17
+ Logs directly to the Cloud Logging API with a synchronous call.
18
18
  """
19
19
  from google.cloud.logging_v2 import _helpers
20
20
  from google.cloud.logging_v2.handlers.transports.base import Transport
@@ -29,6 +29,7 @@ from google.cloud.logging_v2._instrumentation import _add_instrumentation
29
29
  from google.api_core.exceptions import InvalidArgument
30
30
  from google.rpc.error_details_pb2 import DebugInfo
31
31
 
32
+ import google.cloud.logging_v2
32
33
  import google.protobuf.message
33
34
 
34
35
  _GLOBAL_RESOURCE = Resource(type="global", labels={})
@@ -359,7 +360,7 @@ class Batch(object):
359
360
  Args:
360
361
  logger (logging_v2.logger.Logger):
361
362
  the logger to which entries will be logged.
362
- client (~logging_V2.client.Cilent):
363
+ client (~logging_V2.client.Client):
363
364
  The client to use.
364
365
  resource (Optional[~logging_v2.resource.Resource]):
365
366
  Monitored resource of the batch, defaults
@@ -1,5 +1,5 @@
1
1
  # -*- coding: utf-8 -*-
2
- # Copyright 2023 Google LLC
2
+ # Copyright 2024 Google LLC
3
3
  #
4
4
  # Licensed under the Apache License, Version 2.0 (the "License");
5
5
  # you may not use this file except in compliance with the License.
@@ -1,5 +1,5 @@
1
1
  # -*- coding: utf-8 -*-
2
- # Copyright 2023 Google LLC
2
+ # Copyright 2024 Google LLC
3
3
  #
4
4
  # Licensed under the Apache License, Version 2.0 (the "License");
5
5
  # you may not use this file except in compliance with the License.