Skip to content

cleanup(storage): fix GCS tracing test on macOS - #16392

Merged
dbolduc merged 1 commit into
mainfrom
ci-gha-fix-macos-gcs-otel-test
Aug 27, 2026
Merged

cleanup(storage): fix GCS tracing test on macOS#16392
dbolduc merged 1 commit into
mainfrom
ci-gha-fix-macos-gcs-otel-test

Conversation

@dbolduc

@dbolduc dbolduc commented Aug 27, 2026

Copy link
Copy Markdown
Member
  The Root Cause: LP64 Type Aliasing Mismatch

  The compilation error occurs during the template instantiation of google::cloud::testing_util::OTelAttribute<std::size_t> at line 678 in
  google/cloud/storage/internal/async/connection_tracing_test.cc.

  Under the standard LP64 data model used by both 64-bit Linux and 64-bit macOS:
   - std::size_t is defined as unsigned long on both systems.
   - However, how std::uint64_t (from <cstdint>) is defined differs:
     - On 64-bit Linux (GCC/Clang): std::uint64_t is defined as unsigned long. Thus, std::size_t and std::uint64_t are the exact same type.
     - On 64-bit macOS (Clang): std::uint64_t is defined as unsigned long long. Thus, std::size_t (unsigned long) and std::uint64_t
       (unsigned long long) are distinct and different types, even though both are 64-bit.

  Why this breaks OpenTelemetry's Matcher
  The OpenTelemetry SDK's OwnedAttributeValue is a std::variant that holds supported attribute types, including std::uint64_t and
  std::int64_t. 

  In the test helper opentelemetry_matchers.h, OTelAttribute<T> utilizes GoogleTest's ::testing::VariantWith<T>(matcher), which internally
  checks:

   1 std::holds_alternative<T>(value)
   - On Linux: Since T = std::size_t resolves to unsigned long (which matches the variant's std::uint64_t type), the variant contains this
     type, and it compiles.
   - On macOS: Since T = std::size_t resolves to unsigned long, but the variant only contains std::uint64_t (which is unsigned long long),
     unsigned long is not in the variant. This triggers the static_assert failure in std::variant: type not found in type list.

  ---

  The Solution

  The solution is to use std::uint64_t instead of std::size_t in connection_tracing_test.cc. 

  Because std::uint64_t is guaranteed to be one of the types in the OpenTelemetry variant on both platforms (mapping to unsigned long on
  Linux and unsigned long long on macOS), using it resolves the compilation failure.

  Proposed Change

  In google/cloud/storage/internal/async/connection_tracing_test.cc:

   1 // Change this:
   2                        SpanHasAttributes(OTelAttribute<std::size_t>(
   3                            "gl-cpp.initial-read-ranges.ranges-count", 2)),
   4
   5 // To this:
   6                        SpanHasAttributes(OTelAttribute<std::uint64_t>(
   7                            "gl-cpp.initial-read-ranges.ranges-count", 2)),

@product-auto-label product-auto-label Bot added the api: storage Issues related to the Cloud Storage API. label Aug 27, 2026

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request updates a unit test in connection_tracing_test.cc to use std::uint64_t instead of std::size_t for the OTelAttribute type when checking the gl-cpp.initial-read-ranges.ranges-count attribute. There are no review comments, and I have no additional feedback to provide.

@dbolduc
dbolduc marked this pull request as ready for review August 27, 2026 16:53
@dbolduc
dbolduc requested review from a team as code owners August 27, 2026 16:53
@dbolduc
dbolduc enabled auto-merge (squash) August 27, 2026 16:53
@codecov

codecov Bot commented Aug 27, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 92.24%. Comparing base (17ad4f5) to head (b7f28aa).

Additional details and impacted files
@@           Coverage Diff           @@
##             main   #16392   +/-   ##
=======================================
  Coverage   92.24%   92.24%           
=======================================
  Files        2246     2246           
  Lines      212035   212035           
=======================================
  Hits       195598   195598           
  Misses      16437    16437           

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@scotthart

Copy link
Copy Markdown
Member

Thanks for the PR!

@dbolduc
dbolduc merged commit 759a59c into main Aug 27, 2026
78 checks passed
@dbolduc
dbolduc deleted the ci-gha-fix-macos-gcs-otel-test branch August 27, 2026 17:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

api: storage Issues related to the Cloud Storage API.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants