google-cloud-logging 3.6.0__tar.gz → 3.8.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 (112) hide show
  1. {google-cloud-logging-3.6.0 → google-cloud-logging-3.8.0}/MANIFEST.in +1 -1
  2. {google-cloud-logging-3.6.0/google_cloud_logging.egg-info → google-cloud-logging-3.8.0}/PKG-INFO +1 -1
  3. {google-cloud-logging-3.6.0/google/cloud/logging_v2 → google-cloud-logging-3.8.0/google/cloud/logging}/gapic_version.py +1 -1
  4. {google-cloud-logging-3.6.0 → google-cloud-logging-3.8.0}/google/cloud/logging_v2/_gapic.py +3 -3
  5. {google-cloud-logging-3.6.0 → google-cloud-logging-3.8.0}/google/cloud/logging_v2/client.py +1 -1
  6. {google-cloud-logging-3.6.0 → google-cloud-logging-3.8.0}/google/cloud/logging_v2/gapic_metadata.json +60 -0
  7. {google-cloud-logging-3.6.0/google/cloud/logging → google-cloud-logging-3.8.0/google/cloud/logging_v2}/gapic_version.py +1 -1
  8. {google-cloud-logging-3.6.0 → google-cloud-logging-3.8.0}/google/cloud/logging_v2/handlers/_helpers.py +8 -1
  9. {google-cloud-logging-3.6.0 → google-cloud-logging-3.8.0}/google/cloud/logging_v2/handlers/_monitored_resources.py +36 -5
  10. {google-cloud-logging-3.6.0 → google-cloud-logging-3.8.0}/google/cloud/logging_v2/handlers/structured_log.py +12 -6
  11. {google-cloud-logging-3.6.0/tests/unit → google-cloud-logging-3.8.0/google/cloud/logging_v2/services}/__init__.py +1 -1
  12. {google-cloud-logging-3.6.0 → google-cloud-logging-3.8.0}/google/cloud/logging_v2/services/config_service_v2/__init__.py +1 -1
  13. {google-cloud-logging-3.6.0 → google-cloud-logging-3.8.0}/google/cloud/logging_v2/services/config_service_v2/async_client.py +918 -59
  14. {google-cloud-logging-3.6.0 → google-cloud-logging-3.8.0}/google/cloud/logging_v2/services/config_service_v2/client.py +928 -45
  15. {google-cloud-logging-3.6.0 → google-cloud-logging-3.8.0}/google/cloud/logging_v2/services/config_service_v2/pagers.py +129 -1
  16. {google-cloud-logging-3.6.0 → google-cloud-logging-3.8.0}/google/cloud/logging_v2/services/config_service_v2/transports/__init__.py +1 -1
  17. {google-cloud-logging-3.6.0 → google-cloud-logging-3.8.0}/google/cloud/logging_v2/services/config_service_v2/transports/base.py +115 -1
  18. {google-cloud-logging-3.6.0 → google-cloud-logging-3.8.0}/google/cloud/logging_v2/services/config_service_v2/transports/grpc.py +224 -7
  19. {google-cloud-logging-3.6.0 → google-cloud-logging-3.8.0}/google/cloud/logging_v2/services/config_service_v2/transports/grpc_asyncio.py +234 -7
  20. {google-cloud-logging-3.6.0 → google-cloud-logging-3.8.0}/google/cloud/logging_v2/services/logging_service_v2/__init__.py +1 -1
  21. {google-cloud-logging-3.6.0 → google-cloud-logging-3.8.0}/google/cloud/logging_v2/services/logging_service_v2/async_client.py +175 -13
  22. {google-cloud-logging-3.6.0 → google-cloud-logging-3.8.0}/google/cloud/logging_v2/services/logging_service_v2/client.py +174 -12
  23. {google-cloud-logging-3.6.0 → google-cloud-logging-3.8.0}/google/cloud/logging_v2/services/logging_service_v2/pagers.py +1 -1
  24. {google-cloud-logging-3.6.0 → google-cloud-logging-3.8.0}/google/cloud/logging_v2/services/logging_service_v2/transports/__init__.py +1 -1
  25. {google-cloud-logging-3.6.0 → google-cloud-logging-3.8.0}/google/cloud/logging_v2/services/logging_service_v2/transports/base.py +29 -1
  26. {google-cloud-logging-3.6.0 → google-cloud-logging-3.8.0}/google/cloud/logging_v2/services/logging_service_v2/transports/grpc.py +55 -1
  27. {google-cloud-logging-3.6.0 → google-cloud-logging-3.8.0}/google/cloud/logging_v2/services/logging_service_v2/transports/grpc_asyncio.py +55 -1
  28. {google-cloud-logging-3.6.0 → google-cloud-logging-3.8.0}/google/cloud/logging_v2/services/metrics_service_v2/__init__.py +1 -1
  29. {google-cloud-logging-3.6.0 → google-cloud-logging-3.8.0}/google/cloud/logging_v2/services/metrics_service_v2/async_client.py +169 -2
  30. {google-cloud-logging-3.6.0 → google-cloud-logging-3.8.0}/google/cloud/logging_v2/services/metrics_service_v2/client.py +168 -1
  31. {google-cloud-logging-3.6.0 → google-cloud-logging-3.8.0}/google/cloud/logging_v2/services/metrics_service_v2/pagers.py +1 -1
  32. {google-cloud-logging-3.6.0 → google-cloud-logging-3.8.0}/google/cloud/logging_v2/services/metrics_service_v2/transports/__init__.py +1 -1
  33. {google-cloud-logging-3.6.0 → google-cloud-logging-3.8.0}/google/cloud/logging_v2/services/metrics_service_v2/transports/base.py +29 -1
  34. {google-cloud-logging-3.6.0 → google-cloud-logging-3.8.0}/google/cloud/logging_v2/services/metrics_service_v2/transports/grpc.py +55 -1
  35. {google-cloud-logging-3.6.0 → google-cloud-logging-3.8.0}/google/cloud/logging_v2/services/metrics_service_v2/transports/grpc_asyncio.py +55 -1
  36. {google-cloud-logging-3.6.0 → google-cloud-logging-3.8.0}/google/cloud/logging_v2/types/__init__.py +25 -1
  37. {google-cloud-logging-3.6.0 → google-cloud-logging-3.8.0}/google/cloud/logging_v2/types/log_entry.py +49 -12
  38. {google-cloud-logging-3.6.0 → google-cloud-logging-3.8.0}/google/cloud/logging_v2/types/logging.py +44 -44
  39. {google-cloud-logging-3.6.0 → google-cloud-logging-3.8.0}/google/cloud/logging_v2/types/logging_config.py +502 -24
  40. {google-cloud-logging-3.6.0 → google-cloud-logging-3.8.0}/google/cloud/logging_v2/types/logging_metrics.py +19 -3
  41. {google-cloud-logging-3.6.0 → google-cloud-logging-3.8.0/google_cloud_logging.egg-info}/PKG-INFO +1 -1
  42. {google-cloud-logging-3.6.0/google/cloud/logging_v2/services → google-cloud-logging-3.8.0/tests}/__init__.py +1 -1
  43. {google-cloud-logging-3.6.0/tests → google-cloud-logging-3.8.0/tests/unit}/__init__.py +1 -1
  44. {google-cloud-logging-3.6.0 → google-cloud-logging-3.8.0}/tests/unit/gapic/__init__.py +1 -1
  45. google-cloud-logging-3.8.0/tests/unit/gapic/logging_v2/__init__.py +15 -0
  46. {google-cloud-logging-3.6.0 → google-cloud-logging-3.8.0}/tests/unit/gapic/logging_v2/test_config_service_v2.py +4378 -2451
  47. {google-cloud-logging-3.6.0 → google-cloud-logging-3.8.0}/tests/unit/gapic/logging_v2/test_logging_service_v2.py +446 -7
  48. {google-cloud-logging-3.6.0 → google-cloud-logging-3.8.0}/tests/unit/gapic/logging_v2/test_metrics_service_v2.py +450 -3
  49. {google-cloud-logging-3.6.0 → google-cloud-logging-3.8.0}/tests/unit/handlers/test__helpers.py +13 -0
  50. {google-cloud-logging-3.6.0 → google-cloud-logging-3.8.0}/tests/unit/handlers/test__monitored_resources.py +34 -6
  51. google-cloud-logging-3.6.0/tests/unit/gapic/logging_v2/__init__.py +0 -15
  52. {google-cloud-logging-3.6.0 → google-cloud-logging-3.8.0}/LICENSE +0 -0
  53. {google-cloud-logging-3.6.0 → google-cloud-logging-3.8.0}/README.rst +0 -0
  54. {google-cloud-logging-3.6.0 → google-cloud-logging-3.8.0}/google/__init__.py +0 -0
  55. {google-cloud-logging-3.6.0 → google-cloud-logging-3.8.0}/google/cloud/__init__.py +0 -0
  56. {google-cloud-logging-3.6.0 → google-cloud-logging-3.8.0}/google/cloud/logging/__init__.py +0 -0
  57. {google-cloud-logging-3.6.0 → google-cloud-logging-3.8.0}/google/cloud/logging/handlers/__init__.py +0 -0
  58. {google-cloud-logging-3.6.0 → google-cloud-logging-3.8.0}/google/cloud/logging/handlers/middleware/__init__.py +0 -0
  59. {google-cloud-logging-3.6.0 → google-cloud-logging-3.8.0}/google/cloud/logging/handlers/transports/__init__.py +0 -0
  60. {google-cloud-logging-3.6.0 → google-cloud-logging-3.8.0}/google/cloud/logging/py.typed +0 -0
  61. {google-cloud-logging-3.6.0 → google-cloud-logging-3.8.0}/google/cloud/logging_v2/__init__.py +0 -0
  62. {google-cloud-logging-3.6.0 → google-cloud-logging-3.8.0}/google/cloud/logging_v2/_helpers.py +0 -0
  63. {google-cloud-logging-3.6.0 → google-cloud-logging-3.8.0}/google/cloud/logging_v2/_http.py +0 -0
  64. {google-cloud-logging-3.6.0 → google-cloud-logging-3.8.0}/google/cloud/logging_v2/_instrumentation.py +0 -0
  65. {google-cloud-logging-3.6.0 → google-cloud-logging-3.8.0}/google/cloud/logging_v2/entries.py +0 -0
  66. {google-cloud-logging-3.6.0 → google-cloud-logging-3.8.0}/google/cloud/logging_v2/handlers/__init__.py +0 -0
  67. {google-cloud-logging-3.6.0 → google-cloud-logging-3.8.0}/google/cloud/logging_v2/handlers/app_engine.py +0 -0
  68. {google-cloud-logging-3.6.0 → google-cloud-logging-3.8.0}/google/cloud/logging_v2/handlers/container_engine.py +0 -0
  69. {google-cloud-logging-3.6.0 → google-cloud-logging-3.8.0}/google/cloud/logging_v2/handlers/handlers.py +0 -0
  70. {google-cloud-logging-3.6.0 → google-cloud-logging-3.8.0}/google/cloud/logging_v2/handlers/middleware/__init__.py +0 -0
  71. {google-cloud-logging-3.6.0 → google-cloud-logging-3.8.0}/google/cloud/logging_v2/handlers/middleware/request.py +0 -0
  72. {google-cloud-logging-3.6.0 → google-cloud-logging-3.8.0}/google/cloud/logging_v2/handlers/transports/__init__.py +0 -0
  73. {google-cloud-logging-3.6.0 → google-cloud-logging-3.8.0}/google/cloud/logging_v2/handlers/transports/background_thread.py +0 -0
  74. {google-cloud-logging-3.6.0 → google-cloud-logging-3.8.0}/google/cloud/logging_v2/handlers/transports/base.py +0 -0
  75. {google-cloud-logging-3.6.0 → google-cloud-logging-3.8.0}/google/cloud/logging_v2/handlers/transports/sync.py +0 -0
  76. {google-cloud-logging-3.6.0 → google-cloud-logging-3.8.0}/google/cloud/logging_v2/logger.py +0 -0
  77. {google-cloud-logging-3.6.0 → google-cloud-logging-3.8.0}/google/cloud/logging_v2/metric.py +0 -0
  78. {google-cloud-logging-3.6.0 → google-cloud-logging-3.8.0}/google/cloud/logging_v2/py.typed +0 -0
  79. {google-cloud-logging-3.6.0 → google-cloud-logging-3.8.0}/google/cloud/logging_v2/resource.py +0 -0
  80. {google-cloud-logging-3.6.0 → google-cloud-logging-3.8.0}/google/cloud/logging_v2/sink.py +0 -0
  81. {google-cloud-logging-3.6.0 → google-cloud-logging-3.8.0}/google_cloud_logging.egg-info/SOURCES.txt +0 -0
  82. {google-cloud-logging-3.6.0 → google-cloud-logging-3.8.0}/google_cloud_logging.egg-info/dependency_links.txt +0 -0
  83. {google-cloud-logging-3.6.0 → google-cloud-logging-3.8.0}/google_cloud_logging.egg-info/namespace_packages.txt +0 -0
  84. {google-cloud-logging-3.6.0 → google-cloud-logging-3.8.0}/google_cloud_logging.egg-info/not-zip-safe +0 -0
  85. {google-cloud-logging-3.6.0 → google-cloud-logging-3.8.0}/google_cloud_logging.egg-info/requires.txt +0 -0
  86. {google-cloud-logging-3.6.0 → google-cloud-logging-3.8.0}/google_cloud_logging.egg-info/top_level.txt +0 -0
  87. {google-cloud-logging-3.6.0 → google-cloud-logging-3.8.0}/setup.cfg +0 -0
  88. {google-cloud-logging-3.6.0 → google-cloud-logging-3.8.0}/setup.py +0 -0
  89. {google-cloud-logging-3.6.0 → google-cloud-logging-3.8.0}/tests/performance/noxfile.py +0 -0
  90. {google-cloud-logging-3.6.0 → google-cloud-logging-3.8.0}/tests/performance/test_performance.py +0 -0
  91. {google-cloud-logging-3.6.0 → google-cloud-logging-3.8.0}/tests/system/gapic/v2/test_system_logging_service_v2_v2.py +0 -0
  92. {google-cloud-logging-3.6.0 → google-cloud-logging-3.8.0}/tests/system/test_system.py +0 -0
  93. {google-cloud-logging-3.6.0 → google-cloud-logging-3.8.0}/tests/unit/handlers/__init__.py +0 -0
  94. {google-cloud-logging-3.6.0 → google-cloud-logging-3.8.0}/tests/unit/handlers/middleware/test_request.py +0 -0
  95. {google-cloud-logging-3.6.0 → google-cloud-logging-3.8.0}/tests/unit/handlers/test_app_engine.py +0 -0
  96. {google-cloud-logging-3.6.0 → google-cloud-logging-3.8.0}/tests/unit/handlers/test_container_engine.py +0 -0
  97. {google-cloud-logging-3.6.0 → google-cloud-logging-3.8.0}/tests/unit/handlers/test_handlers.py +0 -0
  98. {google-cloud-logging-3.6.0 → google-cloud-logging-3.8.0}/tests/unit/handlers/test_structured_log.py +0 -0
  99. {google-cloud-logging-3.6.0 → google-cloud-logging-3.8.0}/tests/unit/handlers/transports/__init__.py +0 -0
  100. {google-cloud-logging-3.6.0 → google-cloud-logging-3.8.0}/tests/unit/handlers/transports/test_background_thread.py +0 -0
  101. {google-cloud-logging-3.6.0 → google-cloud-logging-3.8.0}/tests/unit/handlers/transports/test_base.py +0 -0
  102. {google-cloud-logging-3.6.0 → google-cloud-logging-3.8.0}/tests/unit/handlers/transports/test_sync.py +0 -0
  103. {google-cloud-logging-3.6.0 → google-cloud-logging-3.8.0}/tests/unit/test__gapic.py +0 -0
  104. {google-cloud-logging-3.6.0 → google-cloud-logging-3.8.0}/tests/unit/test__helpers.py +0 -0
  105. {google-cloud-logging-3.6.0 → google-cloud-logging-3.8.0}/tests/unit/test__http.py +0 -0
  106. {google-cloud-logging-3.6.0 → google-cloud-logging-3.8.0}/tests/unit/test__instrumentation.py +0 -0
  107. {google-cloud-logging-3.6.0 → google-cloud-logging-3.8.0}/tests/unit/test_client.py +0 -0
  108. {google-cloud-logging-3.6.0 → google-cloud-logging-3.8.0}/tests/unit/test_entries.py +0 -0
  109. {google-cloud-logging-3.6.0 → google-cloud-logging-3.8.0}/tests/unit/test_logger.py +0 -0
  110. {google-cloud-logging-3.6.0 → google-cloud-logging-3.8.0}/tests/unit/test_logging_shim.py +0 -0
  111. {google-cloud-logging-3.6.0 → google-cloud-logging-3.8.0}/tests/unit/test_metric.py +0 -0
  112. {google-cloud-logging-3.6.0 → google-cloud-logging-3.8.0}/tests/unit/test_sink.py +0 -0
@@ -1,6 +1,6 @@
1
1
  # -*- coding: utf-8 -*-
2
2
  #
3
- # Copyright 2020 Google LLC
3
+ # Copyright 2023 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.6.0
3
+ Version: 3.8.0
4
4
  Summary: Stackdriver Logging API client library
5
5
  Home-page: https://github.com/googleapis/python-logging
6
6
  Author: Google LLC
@@ -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.6.0" # {x-release-please-version}
16
+ __version__ = "3.8.0" # {x-release-please-version}
@@ -592,7 +592,7 @@ def make_logging_api(client):
592
592
  _LoggingAPI: A metrics API instance with the proper credentials.
593
593
  """
594
594
  info = client._client_info
595
- if type(info) == client_info.ClientInfo:
595
+ if isinstance(info, client_info.ClientInfo):
596
596
  # convert into gapic-compatible subclass
597
597
  info = _client_info_to_gapic(info)
598
598
 
@@ -615,7 +615,7 @@ def make_metrics_api(client):
615
615
  _MetricsAPI: A metrics API instance with the proper credentials.
616
616
  """
617
617
  info = client._client_info
618
- if type(info) == client_info.ClientInfo:
618
+ if isinstance(info, client_info.ClientInfo):
619
619
  # convert into gapic-compatible subclass
620
620
  info = _client_info_to_gapic(info)
621
621
 
@@ -638,7 +638,7 @@ def make_sinks_api(client):
638
638
  _SinksAPI: A metrics API instance with the proper credentials.
639
639
  """
640
640
  info = client._client_info
641
- if type(info) == client_info.ClientInfo:
641
+ if isinstance(info, client_info.ClientInfo):
642
642
  # convert into gapic-compatible subclass
643
643
  info = _client_info_to_gapic(info)
644
644
 
@@ -128,7 +128,7 @@ class Client(ClientWithProject):
128
128
 
129
129
  kw_args = {"client_info": client_info}
130
130
  if client_options:
131
- if type(client_options) == dict:
131
+ if isinstance(client_options, dict):
132
132
  client_options = google.api_core.client_options.from_dict(
133
133
  client_options
134
134
  )
@@ -20,11 +20,21 @@
20
20
  "create_bucket"
21
21
  ]
22
22
  },
23
+ "CreateBucketAsync": {
24
+ "methods": [
25
+ "create_bucket_async"
26
+ ]
27
+ },
23
28
  "CreateExclusion": {
24
29
  "methods": [
25
30
  "create_exclusion"
26
31
  ]
27
32
  },
33
+ "CreateLink": {
34
+ "methods": [
35
+ "create_link"
36
+ ]
37
+ },
28
38
  "CreateSink": {
29
39
  "methods": [
30
40
  "create_sink"
@@ -45,6 +55,11 @@
45
55
  "delete_exclusion"
46
56
  ]
47
57
  },
58
+ "DeleteLink": {
59
+ "methods": [
60
+ "delete_link"
61
+ ]
62
+ },
48
63
  "DeleteSink": {
49
64
  "methods": [
50
65
  "delete_sink"
@@ -70,6 +85,11 @@
70
85
  "get_exclusion"
71
86
  ]
72
87
  },
88
+ "GetLink": {
89
+ "methods": [
90
+ "get_link"
91
+ ]
92
+ },
73
93
  "GetSettings": {
74
94
  "methods": [
75
95
  "get_settings"
@@ -95,6 +115,11 @@
95
115
  "list_exclusions"
96
116
  ]
97
117
  },
118
+ "ListLinks": {
119
+ "methods": [
120
+ "list_links"
121
+ ]
122
+ },
98
123
  "ListSinks": {
99
124
  "methods": [
100
125
  "list_sinks"
@@ -115,6 +140,11 @@
115
140
  "update_bucket"
116
141
  ]
117
142
  },
143
+ "UpdateBucketAsync": {
144
+ "methods": [
145
+ "update_bucket_async"
146
+ ]
147
+ },
118
148
  "UpdateCmekSettings": {
119
149
  "methods": [
120
150
  "update_cmek_settings"
@@ -155,11 +185,21 @@
155
185
  "create_bucket"
156
186
  ]
157
187
  },
188
+ "CreateBucketAsync": {
189
+ "methods": [
190
+ "create_bucket_async"
191
+ ]
192
+ },
158
193
  "CreateExclusion": {
159
194
  "methods": [
160
195
  "create_exclusion"
161
196
  ]
162
197
  },
198
+ "CreateLink": {
199
+ "methods": [
200
+ "create_link"
201
+ ]
202
+ },
163
203
  "CreateSink": {
164
204
  "methods": [
165
205
  "create_sink"
@@ -180,6 +220,11 @@
180
220
  "delete_exclusion"
181
221
  ]
182
222
  },
223
+ "DeleteLink": {
224
+ "methods": [
225
+ "delete_link"
226
+ ]
227
+ },
183
228
  "DeleteSink": {
184
229
  "methods": [
185
230
  "delete_sink"
@@ -205,6 +250,11 @@
205
250
  "get_exclusion"
206
251
  ]
207
252
  },
253
+ "GetLink": {
254
+ "methods": [
255
+ "get_link"
256
+ ]
257
+ },
208
258
  "GetSettings": {
209
259
  "methods": [
210
260
  "get_settings"
@@ -230,6 +280,11 @@
230
280
  "list_exclusions"
231
281
  ]
232
282
  },
283
+ "ListLinks": {
284
+ "methods": [
285
+ "list_links"
286
+ ]
287
+ },
233
288
  "ListSinks": {
234
289
  "methods": [
235
290
  "list_sinks"
@@ -250,6 +305,11 @@
250
305
  "update_bucket"
251
306
  ]
252
307
  },
308
+ "UpdateBucketAsync": {
309
+ "methods": [
310
+ "update_bucket_async"
311
+ ]
312
+ },
253
313
  "UpdateCmekSettings": {
254
314
  "methods": [
255
315
  "update_cmek_settings"
@@ -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.6.0" # {x-release-please-version}
16
+ __version__ = "3.8.0" # {x-release-please-version}
@@ -104,10 +104,17 @@ def get_request_data_from_django():
104
104
  if request is None:
105
105
  return None, None, None, False
106
106
 
107
+ # Django can raise django.core.exceptions.DisallowedHost here for a
108
+ # malformed HTTP_HOST header. But we don't want to import Django modules.
109
+ try:
110
+ request_url = request.build_absolute_uri()
111
+ except Exception:
112
+ request_url = None
113
+
107
114
  # build http_request
108
115
  http_request = {
109
116
  "requestMethod": request.method,
110
- "requestUrl": request.build_absolute_uri(),
117
+ "requestUrl": request_url,
111
118
  "userAgent": request.META.get(_DJANGO_USERAGENT_HEADER),
112
119
  "protocol": request.META.get(_PROTOCOL_HEADER),
113
120
  }
@@ -26,11 +26,21 @@ _GAE_ENV_VARS = [_GAE_SERVICE_ENV, _GAE_VERSION_ENV, _GAE_INSTANCE_ENV]
26
26
  _CLOUD_RUN_SERVICE_ID = "K_SERVICE"
27
27
  _CLOUD_RUN_REVISION_ID = "K_REVISION"
28
28
  _CLOUD_RUN_CONFIGURATION_ID = "K_CONFIGURATION"
29
- _CLOUD_RUN_ENV_VARS = [
29
+ _CLOUD_RUN_SERVICE_ENV_VARS = [
30
30
  _CLOUD_RUN_SERVICE_ID,
31
31
  _CLOUD_RUN_REVISION_ID,
32
32
  _CLOUD_RUN_CONFIGURATION_ID,
33
33
  ]
34
+ _CLOUD_RUN_JOB_ID = "CLOUD_RUN_JOB"
35
+ _CLOUD_RUN_EXECUTION_ID = "CLOUD_RUN_EXECUTION"
36
+ _CLOUD_RUN_TASK_INDEX = "CLOUD_RUN_TASK_INDEX"
37
+ _CLOUD_RUN_TASK_ATTEMPT = "CLOUD_RUN_TASK_ATTEMPT"
38
+ _CLOUD_RUN_JOB_ENV_VARS = [
39
+ _CLOUD_RUN_JOB_ID,
40
+ _CLOUD_RUN_EXECUTION_ID,
41
+ _CLOUD_RUN_TASK_INDEX,
42
+ _CLOUD_RUN_TASK_ATTEMPT,
43
+ ]
34
44
  """Environment variables set in Cloud Run environment."""
35
45
 
36
46
  _FUNCTION_TARGET = "FUNCTION_TARGET"
@@ -118,8 +128,8 @@ def _create_compute_resource():
118
128
  return resource
119
129
 
120
130
 
121
- def _create_cloud_run_resource():
122
- """Create a standardized Cloud Run resource.
131
+ def _create_cloud_run_service_resource():
132
+ """Create a standardized Cloud Run service resource.
123
133
  Returns:
124
134
  google.cloud.logging.Resource
125
135
  """
@@ -138,6 +148,24 @@ def _create_cloud_run_resource():
138
148
  return resource
139
149
 
140
150
 
151
+ def _create_cloud_run_job_resource():
152
+ """Create a standardized Cloud Run job resource.
153
+ Returns:
154
+ google.cloud.logging.Resource
155
+ """
156
+ region = retrieve_metadata_server(_REGION_ID)
157
+ project = retrieve_metadata_server(_PROJECT_NAME)
158
+ resource = Resource(
159
+ type="cloud_run_job",
160
+ labels={
161
+ "project_id": project if project else "",
162
+ "job_name": os.environ.get(_CLOUD_RUN_JOB_ID, ""),
163
+ "location": region.split("/")[-1] if region else "",
164
+ },
165
+ )
166
+ return resource
167
+
168
+
141
169
  def _create_app_engine_resource():
142
170
  """Create a standardized App Engine resource.
143
171
  Returns:
@@ -190,9 +218,12 @@ def detect_resource(project=""):
190
218
  ):
191
219
  # Cloud Functions
192
220
  return _create_functions_resource()
193
- elif all([env in os.environ for env in _CLOUD_RUN_ENV_VARS]):
221
+ elif all([env in os.environ for env in _CLOUD_RUN_SERVICE_ENV_VARS]):
222
+ # Cloud Run
223
+ return _create_cloud_run_service_resource()
224
+ elif all([env in os.environ for env in _CLOUD_RUN_JOB_ENV_VARS]):
194
225
  # Cloud Run
195
- return _create_cloud_run_resource()
226
+ return _create_cloud_run_job_resource()
196
227
  elif gce_instance_name is not None:
197
228
  # Compute Engine
198
229
  return _create_compute_resource()
@@ -79,8 +79,18 @@ class StructuredLogHandler(logging.StreamHandler):
79
79
  log_filter = CloudLoggingFilter(project=project_id, default_labels=labels)
80
80
  self.addFilter(log_filter)
81
81
 
82
+ class _Formatter(logging.Formatter):
83
+ """Formatter to format log message without traceback"""
84
+
85
+ def format(self, record):
86
+ """Ignore exception info to avoid duplicating it
87
+ https://github.com/googleapis/python-logging/issues/382
88
+ """
89
+ record.message = record.getMessage()
90
+ return self.formatMessage(record)
91
+
82
92
  # make logs appear in GCP structured logging format
83
- self._gcp_formatter = logging.Formatter(GCP_FORMAT)
93
+ self._gcp_formatter = _Formatter(GCP_FORMAT)
84
94
 
85
95
  self._json_encoder_cls = json_encoder_cls or json.JSONEncoder
86
96
 
@@ -115,11 +125,7 @@ class StructuredLogHandler(logging.StreamHandler):
115
125
  payload = '"message": {},'.format(encoded_message)
116
126
 
117
127
  record._payload_str = payload or ""
118
- # remove exception info to avoid duplicating it
119
- # https://github.com/googleapis/python-logging/issues/382
120
- record.exc_info = None
121
- record.exc_text = None
122
- # convert to GCP structred logging format
128
+ # convert to GCP structured logging format
123
129
  gcp_payload = self._gcp_formatter.format(record)
124
130
  return gcp_payload
125
131
 
@@ -1,5 +1,5 @@
1
1
  # -*- coding: utf-8 -*-
2
- # Copyright 2022 Google LLC
2
+ # Copyright 2023 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 2022 Google LLC
2
+ # Copyright 2023 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.