google-cloud-logging 3.11.1__tar.gz → 3.11.3__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 (109) hide show
  1. {google_cloud_logging-3.11.1/google_cloud_logging.egg-info → google_cloud_logging-3.11.3}/PKG-INFO +4 -4
  2. {google_cloud_logging-3.11.1 → google_cloud_logging-3.11.3}/google/cloud/logging/gapic_version.py +1 -1
  3. {google_cloud_logging-3.11.1 → google_cloud_logging-3.11.3}/google/cloud/logging_v2/gapic_version.py +1 -1
  4. {google_cloud_logging-3.11.1 → google_cloud_logging-3.11.3}/google/cloud/logging_v2/handlers/_helpers.py +22 -2
  5. {google_cloud_logging-3.11.1 → google_cloud_logging-3.11.3}/google/cloud/logging_v2/handlers/handlers.py +2 -2
  6. {google_cloud_logging-3.11.1 → google_cloud_logging-3.11.3/google_cloud_logging.egg-info}/PKG-INFO +4 -4
  7. {google_cloud_logging-3.11.1 → google_cloud_logging-3.11.3}/google_cloud_logging.egg-info/requires.txt +3 -3
  8. {google_cloud_logging-3.11.1 → google_cloud_logging-3.11.3}/setup.py +3 -3
  9. {google_cloud_logging-3.11.1 → google_cloud_logging-3.11.3}/tests/unit/handlers/test__helpers.py +37 -14
  10. {google_cloud_logging-3.11.1 → google_cloud_logging-3.11.3}/tests/unit/handlers/test_handlers.py +4 -3
  11. {google_cloud_logging-3.11.1 → google_cloud_logging-3.11.3}/tests/unit/handlers/test_structured_log.py +4 -3
  12. {google_cloud_logging-3.11.1 → google_cloud_logging-3.11.3}/LICENSE +0 -0
  13. {google_cloud_logging-3.11.1 → google_cloud_logging-3.11.3}/MANIFEST.in +0 -0
  14. {google_cloud_logging-3.11.1 → google_cloud_logging-3.11.3}/README.rst +0 -0
  15. {google_cloud_logging-3.11.1 → google_cloud_logging-3.11.3}/google/cloud/logging/__init__.py +0 -0
  16. {google_cloud_logging-3.11.1 → google_cloud_logging-3.11.3}/google/cloud/logging/handlers/__init__.py +0 -0
  17. {google_cloud_logging-3.11.1 → google_cloud_logging-3.11.3}/google/cloud/logging/handlers/middleware/__init__.py +0 -0
  18. {google_cloud_logging-3.11.1 → google_cloud_logging-3.11.3}/google/cloud/logging/handlers/transports/__init__.py +0 -0
  19. {google_cloud_logging-3.11.1 → google_cloud_logging-3.11.3}/google/cloud/logging/py.typed +0 -0
  20. {google_cloud_logging-3.11.1 → google_cloud_logging-3.11.3}/google/cloud/logging_v2/__init__.py +0 -0
  21. {google_cloud_logging-3.11.1 → google_cloud_logging-3.11.3}/google/cloud/logging_v2/_gapic.py +0 -0
  22. {google_cloud_logging-3.11.1 → google_cloud_logging-3.11.3}/google/cloud/logging_v2/_helpers.py +0 -0
  23. {google_cloud_logging-3.11.1 → google_cloud_logging-3.11.3}/google/cloud/logging_v2/_http.py +0 -0
  24. {google_cloud_logging-3.11.1 → google_cloud_logging-3.11.3}/google/cloud/logging_v2/_instrumentation.py +0 -0
  25. {google_cloud_logging-3.11.1 → google_cloud_logging-3.11.3}/google/cloud/logging_v2/client.py +0 -0
  26. {google_cloud_logging-3.11.1 → google_cloud_logging-3.11.3}/google/cloud/logging_v2/entries.py +0 -0
  27. {google_cloud_logging-3.11.1 → google_cloud_logging-3.11.3}/google/cloud/logging_v2/gapic_metadata.json +0 -0
  28. {google_cloud_logging-3.11.1 → google_cloud_logging-3.11.3}/google/cloud/logging_v2/handlers/__init__.py +0 -0
  29. {google_cloud_logging-3.11.1 → google_cloud_logging-3.11.3}/google/cloud/logging_v2/handlers/_monitored_resources.py +0 -0
  30. {google_cloud_logging-3.11.1 → google_cloud_logging-3.11.3}/google/cloud/logging_v2/handlers/app_engine.py +0 -0
  31. {google_cloud_logging-3.11.1 → google_cloud_logging-3.11.3}/google/cloud/logging_v2/handlers/container_engine.py +0 -0
  32. {google_cloud_logging-3.11.1 → google_cloud_logging-3.11.3}/google/cloud/logging_v2/handlers/middleware/__init__.py +0 -0
  33. {google_cloud_logging-3.11.1 → google_cloud_logging-3.11.3}/google/cloud/logging_v2/handlers/middleware/request.py +0 -0
  34. {google_cloud_logging-3.11.1 → google_cloud_logging-3.11.3}/google/cloud/logging_v2/handlers/structured_log.py +0 -0
  35. {google_cloud_logging-3.11.1 → google_cloud_logging-3.11.3}/google/cloud/logging_v2/handlers/transports/__init__.py +0 -0
  36. {google_cloud_logging-3.11.1 → google_cloud_logging-3.11.3}/google/cloud/logging_v2/handlers/transports/background_thread.py +0 -0
  37. {google_cloud_logging-3.11.1 → google_cloud_logging-3.11.3}/google/cloud/logging_v2/handlers/transports/base.py +0 -0
  38. {google_cloud_logging-3.11.1 → google_cloud_logging-3.11.3}/google/cloud/logging_v2/handlers/transports/sync.py +0 -0
  39. {google_cloud_logging-3.11.1 → google_cloud_logging-3.11.3}/google/cloud/logging_v2/logger.py +0 -0
  40. {google_cloud_logging-3.11.1 → google_cloud_logging-3.11.3}/google/cloud/logging_v2/metric.py +0 -0
  41. {google_cloud_logging-3.11.1 → google_cloud_logging-3.11.3}/google/cloud/logging_v2/py.typed +0 -0
  42. {google_cloud_logging-3.11.1 → google_cloud_logging-3.11.3}/google/cloud/logging_v2/resource.py +0 -0
  43. {google_cloud_logging-3.11.1 → google_cloud_logging-3.11.3}/google/cloud/logging_v2/services/__init__.py +0 -0
  44. {google_cloud_logging-3.11.1 → google_cloud_logging-3.11.3}/google/cloud/logging_v2/services/config_service_v2/__init__.py +0 -0
  45. {google_cloud_logging-3.11.1 → google_cloud_logging-3.11.3}/google/cloud/logging_v2/services/config_service_v2/async_client.py +0 -0
  46. {google_cloud_logging-3.11.1 → google_cloud_logging-3.11.3}/google/cloud/logging_v2/services/config_service_v2/client.py +0 -0
  47. {google_cloud_logging-3.11.1 → google_cloud_logging-3.11.3}/google/cloud/logging_v2/services/config_service_v2/pagers.py +0 -0
  48. {google_cloud_logging-3.11.1 → google_cloud_logging-3.11.3}/google/cloud/logging_v2/services/config_service_v2/transports/__init__.py +0 -0
  49. {google_cloud_logging-3.11.1 → google_cloud_logging-3.11.3}/google/cloud/logging_v2/services/config_service_v2/transports/base.py +0 -0
  50. {google_cloud_logging-3.11.1 → google_cloud_logging-3.11.3}/google/cloud/logging_v2/services/config_service_v2/transports/grpc.py +0 -0
  51. {google_cloud_logging-3.11.1 → google_cloud_logging-3.11.3}/google/cloud/logging_v2/services/config_service_v2/transports/grpc_asyncio.py +0 -0
  52. {google_cloud_logging-3.11.1 → google_cloud_logging-3.11.3}/google/cloud/logging_v2/services/logging_service_v2/__init__.py +0 -0
  53. {google_cloud_logging-3.11.1 → google_cloud_logging-3.11.3}/google/cloud/logging_v2/services/logging_service_v2/async_client.py +0 -0
  54. {google_cloud_logging-3.11.1 → google_cloud_logging-3.11.3}/google/cloud/logging_v2/services/logging_service_v2/client.py +0 -0
  55. {google_cloud_logging-3.11.1 → google_cloud_logging-3.11.3}/google/cloud/logging_v2/services/logging_service_v2/pagers.py +0 -0
  56. {google_cloud_logging-3.11.1 → google_cloud_logging-3.11.3}/google/cloud/logging_v2/services/logging_service_v2/transports/__init__.py +0 -0
  57. {google_cloud_logging-3.11.1 → google_cloud_logging-3.11.3}/google/cloud/logging_v2/services/logging_service_v2/transports/base.py +0 -0
  58. {google_cloud_logging-3.11.1 → google_cloud_logging-3.11.3}/google/cloud/logging_v2/services/logging_service_v2/transports/grpc.py +0 -0
  59. {google_cloud_logging-3.11.1 → google_cloud_logging-3.11.3}/google/cloud/logging_v2/services/logging_service_v2/transports/grpc_asyncio.py +0 -0
  60. {google_cloud_logging-3.11.1 → google_cloud_logging-3.11.3}/google/cloud/logging_v2/services/metrics_service_v2/__init__.py +0 -0
  61. {google_cloud_logging-3.11.1 → google_cloud_logging-3.11.3}/google/cloud/logging_v2/services/metrics_service_v2/async_client.py +0 -0
  62. {google_cloud_logging-3.11.1 → google_cloud_logging-3.11.3}/google/cloud/logging_v2/services/metrics_service_v2/client.py +0 -0
  63. {google_cloud_logging-3.11.1 → google_cloud_logging-3.11.3}/google/cloud/logging_v2/services/metrics_service_v2/pagers.py +0 -0
  64. {google_cloud_logging-3.11.1 → google_cloud_logging-3.11.3}/google/cloud/logging_v2/services/metrics_service_v2/transports/__init__.py +0 -0
  65. {google_cloud_logging-3.11.1 → google_cloud_logging-3.11.3}/google/cloud/logging_v2/services/metrics_service_v2/transports/base.py +0 -0
  66. {google_cloud_logging-3.11.1 → google_cloud_logging-3.11.3}/google/cloud/logging_v2/services/metrics_service_v2/transports/grpc.py +0 -0
  67. {google_cloud_logging-3.11.1 → google_cloud_logging-3.11.3}/google/cloud/logging_v2/services/metrics_service_v2/transports/grpc_asyncio.py +0 -0
  68. {google_cloud_logging-3.11.1 → google_cloud_logging-3.11.3}/google/cloud/logging_v2/sink.py +0 -0
  69. {google_cloud_logging-3.11.1 → google_cloud_logging-3.11.3}/google/cloud/logging_v2/types/__init__.py +0 -0
  70. {google_cloud_logging-3.11.1 → google_cloud_logging-3.11.3}/google/cloud/logging_v2/types/log_entry.py +0 -0
  71. {google_cloud_logging-3.11.1 → google_cloud_logging-3.11.3}/google/cloud/logging_v2/types/logging.py +0 -0
  72. {google_cloud_logging-3.11.1 → google_cloud_logging-3.11.3}/google/cloud/logging_v2/types/logging_config.py +0 -0
  73. {google_cloud_logging-3.11.1 → google_cloud_logging-3.11.3}/google/cloud/logging_v2/types/logging_metrics.py +0 -0
  74. {google_cloud_logging-3.11.1 → google_cloud_logging-3.11.3}/google_cloud_logging.egg-info/SOURCES.txt +0 -0
  75. {google_cloud_logging-3.11.1 → google_cloud_logging-3.11.3}/google_cloud_logging.egg-info/dependency_links.txt +0 -0
  76. {google_cloud_logging-3.11.1 → google_cloud_logging-3.11.3}/google_cloud_logging.egg-info/not-zip-safe +0 -0
  77. {google_cloud_logging-3.11.1 → google_cloud_logging-3.11.3}/google_cloud_logging.egg-info/top_level.txt +0 -0
  78. {google_cloud_logging-3.11.1 → google_cloud_logging-3.11.3}/setup.cfg +0 -0
  79. {google_cloud_logging-3.11.1 → google_cloud_logging-3.11.3}/tests/__init__.py +0 -0
  80. {google_cloud_logging-3.11.1 → google_cloud_logging-3.11.3}/tests/performance/noxfile.py +0 -0
  81. {google_cloud_logging-3.11.1 → google_cloud_logging-3.11.3}/tests/performance/test_performance.py +0 -0
  82. {google_cloud_logging-3.11.1 → google_cloud_logging-3.11.3}/tests/system/gapic/v2/test_system_logging_service_v2_v2.py +0 -0
  83. {google_cloud_logging-3.11.1 → google_cloud_logging-3.11.3}/tests/system/test_system.py +0 -0
  84. {google_cloud_logging-3.11.1 → google_cloud_logging-3.11.3}/tests/unit/__init__.py +0 -0
  85. {google_cloud_logging-3.11.1 → google_cloud_logging-3.11.3}/tests/unit/gapic/__init__.py +0 -0
  86. {google_cloud_logging-3.11.1 → google_cloud_logging-3.11.3}/tests/unit/gapic/logging_v2/__init__.py +0 -0
  87. {google_cloud_logging-3.11.1 → google_cloud_logging-3.11.3}/tests/unit/gapic/logging_v2/test_config_service_v2.py +0 -0
  88. {google_cloud_logging-3.11.1 → google_cloud_logging-3.11.3}/tests/unit/gapic/logging_v2/test_logging_service_v2.py +0 -0
  89. {google_cloud_logging-3.11.1 → google_cloud_logging-3.11.3}/tests/unit/gapic/logging_v2/test_metrics_service_v2.py +0 -0
  90. {google_cloud_logging-3.11.1 → google_cloud_logging-3.11.3}/tests/unit/handlers/__init__.py +0 -0
  91. {google_cloud_logging-3.11.1 → google_cloud_logging-3.11.3}/tests/unit/handlers/middleware/test_request.py +0 -0
  92. {google_cloud_logging-3.11.1 → google_cloud_logging-3.11.3}/tests/unit/handlers/test__monitored_resources.py +0 -0
  93. {google_cloud_logging-3.11.1 → google_cloud_logging-3.11.3}/tests/unit/handlers/test_app_engine.py +0 -0
  94. {google_cloud_logging-3.11.1 → google_cloud_logging-3.11.3}/tests/unit/handlers/test_container_engine.py +0 -0
  95. {google_cloud_logging-3.11.1 → google_cloud_logging-3.11.3}/tests/unit/handlers/transports/__init__.py +0 -0
  96. {google_cloud_logging-3.11.1 → google_cloud_logging-3.11.3}/tests/unit/handlers/transports/test_background_thread.py +0 -0
  97. {google_cloud_logging-3.11.1 → google_cloud_logging-3.11.3}/tests/unit/handlers/transports/test_base.py +0 -0
  98. {google_cloud_logging-3.11.1 → google_cloud_logging-3.11.3}/tests/unit/handlers/transports/test_sync.py +0 -0
  99. {google_cloud_logging-3.11.1 → google_cloud_logging-3.11.3}/tests/unit/test__gapic.py +0 -0
  100. {google_cloud_logging-3.11.1 → google_cloud_logging-3.11.3}/tests/unit/test__helpers.py +0 -0
  101. {google_cloud_logging-3.11.1 → google_cloud_logging-3.11.3}/tests/unit/test__http.py +0 -0
  102. {google_cloud_logging-3.11.1 → google_cloud_logging-3.11.3}/tests/unit/test__instrumentation.py +0 -0
  103. {google_cloud_logging-3.11.1 → google_cloud_logging-3.11.3}/tests/unit/test_client.py +0 -0
  104. {google_cloud_logging-3.11.1 → google_cloud_logging-3.11.3}/tests/unit/test_entries.py +0 -0
  105. {google_cloud_logging-3.11.1 → google_cloud_logging-3.11.3}/tests/unit/test_logger.py +0 -0
  106. {google_cloud_logging-3.11.1 → google_cloud_logging-3.11.3}/tests/unit/test_logging_shim.py +0 -0
  107. {google_cloud_logging-3.11.1 → google_cloud_logging-3.11.3}/tests/unit/test_metric.py +0 -0
  108. {google_cloud_logging-3.11.1 → google_cloud_logging-3.11.3}/tests/unit/test_packaging.py +0 -0
  109. {google_cloud_logging-3.11.1 → google_cloud_logging-3.11.3}/tests/unit/test_sink.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: google-cloud-logging
3
- Version: 3.11.1
3
+ Version: 3.11.3
4
4
  Summary: Stackdriver Logging API client library
5
5
  Home-page: https://github.com/googleapis/python-logging
6
6
  Author: Google LLC
@@ -24,11 +24,11 @@ Requires-Python: >=3.7
24
24
  License-File: LICENSE
25
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
26
  Requires-Dist: google-auth!=2.24.0,!=2.25.0,<3.0.0dev,>=2.14.1
27
- Requires-Dist: google-cloud-appengine-logging<2.0.0dev,>=0.1.0
28
- Requires-Dist: google-cloud-audit-log<1.0.0dev,>=0.1.0
27
+ Requires-Dist: google-cloud-appengine-logging<2.0.0dev,>=0.1.3
28
+ Requires-Dist: google-cloud-audit-log<1.0.0dev,>=0.2.4
29
29
  Requires-Dist: google-cloud-core<3.0.0dev,>=2.0.0
30
30
  Requires-Dist: grpc-google-iam-v1<1.0.0dev,>=0.12.4
31
- Requires-Dist: opentelemetry-api>=1.0.0
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
34
  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
@@ -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.11.1" # {x-release-please-version}
16
+ __version__ = "3.11.3" # {x-release-please-version}
@@ -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.11.1" # {x-release-please-version}
16
+ __version__ = "3.11.3" # {x-release-please-version}
@@ -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[dict], Optional[str], bool]:
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
- # see https://cloud.google.com/trace/docs/setup for X-Cloud-Trace_Context format
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
@@ -18,7 +18,7 @@ import collections
18
18
  import json
19
19
  import logging
20
20
 
21
- from typing import Optional, IO
21
+ from typing import Optional, IO, Type
22
22
 
23
23
  from google.cloud.logging_v2.handlers.transports import (
24
24
  BackgroundThreadTransport,
@@ -157,7 +157,7 @@ class CloudLoggingHandler(logging.StreamHandler):
157
157
  client,
158
158
  *,
159
159
  name: str = DEFAULT_LOGGER_NAME,
160
- transport: Transport = BackgroundThreadTransport,
160
+ transport: Type[Transport] = BackgroundThreadTransport,
161
161
  resource: Resource = None,
162
162
  labels: Optional[dict] = None,
163
163
  stream: Optional[IO] = None,
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: google-cloud-logging
3
- Version: 3.11.1
3
+ Version: 3.11.3
4
4
  Summary: Stackdriver Logging API client library
5
5
  Home-page: https://github.com/googleapis/python-logging
6
6
  Author: Google LLC
@@ -24,11 +24,11 @@ Requires-Python: >=3.7
24
24
  License-File: LICENSE
25
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
26
  Requires-Dist: google-auth!=2.24.0,!=2.25.0,<3.0.0dev,>=2.14.1
27
- Requires-Dist: google-cloud-appengine-logging<2.0.0dev,>=0.1.0
28
- Requires-Dist: google-cloud-audit-log<1.0.0dev,>=0.1.0
27
+ Requires-Dist: google-cloud-appengine-logging<2.0.0dev,>=0.1.3
28
+ Requires-Dist: google-cloud-audit-log<1.0.0dev,>=0.2.4
29
29
  Requires-Dist: google-cloud-core<3.0.0dev,>=2.0.0
30
30
  Requires-Dist: grpc-google-iam-v1<1.0.0dev,>=0.12.4
31
- Requires-Dist: opentelemetry-api>=1.0.0
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
34
  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
@@ -1,10 +1,10 @@
1
1
  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
2
2
  google-auth!=2.24.0,!=2.25.0,<3.0.0dev,>=2.14.1
3
- google-cloud-appengine-logging<2.0.0dev,>=0.1.0
4
- google-cloud-audit-log<1.0.0dev,>=0.1.0
3
+ google-cloud-appengine-logging<2.0.0dev,>=0.1.3
4
+ google-cloud-audit-log<1.0.0dev,>=0.2.4
5
5
  google-cloud-core<3.0.0dev,>=2.0.0
6
6
  grpc-google-iam-v1<1.0.0dev,>=0.12.4
7
- opentelemetry-api>=1.0.0
7
+ opentelemetry-api>=1.9.0
8
8
  proto-plus<2.0.0dev,>=1.22.0
9
9
  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
10
10
 
@@ -40,11 +40,11 @@ dependencies = [
40
40
  # Exclude incompatible versions of `google-auth`
41
41
  # See https://github.com/googleapis/google-cloud-python/issues/12364
42
42
  "google-auth >= 2.14.1, <3.0.0dev,!=2.24.0,!=2.25.0",
43
- "google-cloud-appengine-logging>=0.1.0, <2.0.0dev",
44
- "google-cloud-audit-log >= 0.1.0, < 1.0.0dev",
43
+ "google-cloud-appengine-logging>=0.1.3, <2.0.0dev",
44
+ "google-cloud-audit-log >= 0.2.4, < 1.0.0dev",
45
45
  "google-cloud-core >= 2.0.0, <3.0.0dev",
46
46
  "grpc-google-iam-v1 >=0.12.4, <1.0.0dev",
47
- "opentelemetry-api >= 1.0.0",
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
50
  "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",
@@ -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
- expected_span_id = _FLASK_SPAN_ID
68
- flask_trace_id = f"{expected_trace_id}/{expected_span_id};o=1"
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
- expected_span_id = _DJANGO_SPAN_ID
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}/{expected_span_id};o=1"
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
- header = "/12345"
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, "12345")
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
- expected_span = "67890"
513
- header = f"{expected_trace}/{expected_span}"
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
- expected_span = "67890"
522
- header = f"{expected_trace}/{expected_span};abc"
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
- expected_span = "67890"
531
- header = f"{expected_trace}/{expected_span};o=0"
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
- expected_span = "67890"
540
- header = f"{expected_trace}/{expected_span};o=1"
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)
@@ -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 test_record_with_request(self):
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
- expected_span = "456"
165
- combined_trace = f"{expected_trace}/{expected_span};o=1"
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 test_format_with_request(self):
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
- expected_span = "456"
397
- trace_header = f"{expected_trace}/{expected_span};o=1"
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,