Skip to content

build: OpenTelemetry ABI now defaults to version 2 - #16387

Draft
scotthart wants to merge 7 commits into
googleapis:mainfrom
scotthart:otel_default_abi_2
Draft

build: OpenTelemetry ABI now defaults to version 2#16387
scotthart wants to merge 7 commits into
googleapis:mainfrom
scotthart:otel_default_abi_2

Conversation

@scotthart

Copy link
Copy Markdown
Member

OTel ABI version 1 is still available for now, via:

  • In Bazel builds, downstream consumers requiring ABI version 1 can configure
    --//:otel_abi_version_no=1 (or use --config=otel1 when building in this
    repository).
  • In CMake builds, downstream consumers requiring ABI version 1 can configure
    -DGOOGLE_CLOUD_CPP_OPENTELEMETRY_ABI_VERSION=1.

@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 the default OpenTelemetry C++ ABI version to 2 for both Bazel and CMake builds, adjusting CI configurations and documentation to match. The review feedback recommends simplifying the Bazel configuration by removing the redundant custom otel_abi_version_no flag and directly referencing the upstream @opentelemetry-cpp//api:abi_version_no flag to prevent potential ABI mismatches. This change simplifies BUILD.bazel, .bazelrc, and the changelog instructions. Additionally, it is suggested to rename the ABI test script and its triggers to explicitly reflect that they test ABI version 1, since version 2 is now the default.

Comment thread BUILD.bazel
Comment on lines +155 to +172
string_flag(
name = "otel_abi_version_no",
build_setting_default = "2",
values = [
"1",
"2",
],
)

config_setting(
name = "otel_abi_v1",
flag_values = {":otel_abi_version_no": "1"},
)

config_setting(
name = "otel_abi_v2",
flag_values = {":otel_abi_version_no": "2"},
)

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

high

Defining a custom otel_abi_version_no flag in this repository introduces a risk of ABI mismatch if a downstream consumer configures the upstream --@opentelemetry-cpp//api:abi_version_no flag but forgets to also set --//:otel_abi_version_no.

To ensure a single source of truth and prevent silent ABI mismatches, we can define the config_settings to directly check the upstream @opentelemetry-cpp//api:abi_version_no flag. This allows us to completely remove the redundant otel_abi_version_no string flag.

Suggested change
string_flag(
name = "otel_abi_version_no",
build_setting_default = "2",
values = [
"1",
"2",
],
)
config_setting(
name = "otel_abi_v1",
flag_values = {":otel_abi_version_no": "1"},
)
config_setting(
name = "otel_abi_v2",
flag_values = {":otel_abi_version_no": "2"},
)
config_setting(
name = "otel_abi_v1",
flag_values = {"@opentelemetry-cpp//api:abi_version_no": "1"},
)
config_setting(
name = "otel_abi_v2",
flag_values = {"@opentelemetry-cpp//api:abi_version_no": "2"},
)

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

We want to default to ABI 2 without having to upstream changes to opentelemetry-cpp. We will emit a warning when there is a mismatch between the flags.

Comment thread BUILD.bazel
# limitations under the License.

load("@bazel_skylib//rules:common_settings.bzl", "bool_flag")
load("@bazel_skylib//rules:common_settings.bzl", "bool_flag", "string_flag")

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

medium

Since we are removing the custom string_flag in favor of directly referencing the upstream OpenTelemetry flag, we no longer need to load string_flag from @bazel_skylib.

Suggested change
load("@bazel_skylib//rules:common_settings.bzl", "bool_flag", "string_flag")
load("@bazel_skylib//rules:common_settings.bzl", "bool_flag")

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

We're keeping the flag.

Comment thread .bazelrc
Comment on lines +135 to +137
# --config otel1: Open Telemetry ABI version 1
build:otel1 --//:otel_abi_version_no=1
build:otel1 --@opentelemetry-cpp//api:abi_version_no=1

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

medium

With the removal of the custom otel_abi_version_no flag, we can simplify the otel1 config to only set the upstream OpenTelemetry flag.

# --config otel1: Open Telemetry ABI version 1
build:otel1 --@opentelemetry-cpp//api:abi_version_no=1

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

But we're not removing the custom flag.

Comment thread CHANGELOG.md Outdated
Comment on lines +19 to +21
* In Bazel builds, downstream consumers requiring ABI version 1 can configure
`--//:otel_abi_version_no=1` (or use `--config=otel1` when building in this
repository).

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

medium

Update the instructions for downstream Bazel consumers to use the standard --@opentelemetry-cpp//api:abi_version_no=1 flag instead of the removed custom flag.

Suggested change
* In Bazel builds, downstream consumers requiring ABI version 1 can configure
`--//:otel_abi_version_no=1` (or use `--config=otel1` when building in this
repository).
* In Bazel builds, downstream consumers requiring ABI version 1 can configure
`--@opentelemetry-cpp//api:abi_version_no=1` (or use `--config=otel1` when building in this
repository).

Comment thread ci/cloudbuild/builds/bazel-otel-abi.sh Outdated

mapfile -t args < <(bazel::common_args)
args+=("--config=otel2")
args+=("--config=otel1")

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

medium

Since OpenTelemetry ABI version 2 is now the default, a generic name like bazel-otel-abi for this script and its triggers is misleading because it actually tests the non-default ABI version 1 (--config=otel1).

To improve maintainability and avoid confusion, please consider renaming the script to bazel-otel-abi-1.sh (or bazel-otel-abi-v1.sh) and updating the corresponding Cloud Build trigger YAML files accordingly.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Future versions of this test may include multiple ABI versions, so we're keeping the more generic name.

@codecov

codecov Bot commented Aug 26, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 92.29%. Comparing base (82fcb08) to head (9bd6fc4).

Additional details and impacted files
@@            Coverage Diff             @@
##             main   #16387      +/-   ##
==========================================
- Coverage   92.30%   92.29%   -0.01%     
==========================================
  Files        2245     2245              
  Lines      211870   211824      -46     
==========================================
- Hits       195568   195511      -57     
- Misses      16302    16313      +11     

☔ 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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant