Skip to content

fix(otel): use opentelemetry::nostd for opentelemetry-cpp types - #16624

Open
delphij wants to merge 1 commit into
googleapis:mainfrom
delphij:fix-otel-nostd-variant
Open

delphij wants to merge 1 commit into
googleapis:mainfrom
delphij:fix-otel-nostd-variant

Conversation

@delphij

@delphij delphij commented Nov 4, 2026

Copy link
Copy Markdown

opentelemetry-cpp's nostd::variant and nostd::string_view are aliases for std::variant and std::string_view only when opentelemetry-cpp is built with WITH_STL. With the default (non-STL) build they are opentelemetry-cpp's own types, and calling std::visit, std::get or std::holds_alternative on them, or passing a std::string_view where a nostd::string_view is expected, fails to compile.

Use opentelemetry::nostd::{visit,get,holds_alternative} and an explicit nostd::string_view conversion, as other parts of the code (e.g. bigtable and storage monitoring) already do. This works with both STL and non-STL builds of opentelemetry-cpp.

opentelemetry-cpp's nostd::variant and nostd::string_view are aliases
for std::variant and std::string_view only when opentelemetry-cpp is
built with WITH_STL. With the default (non-STL) build they are
opentelemetry-cpp's own types, and calling std::visit, std::get or
std::holds_alternative on them, or passing a std::string_view where a
nostd::string_view is expected, fails to compile.

Use opentelemetry::nostd::{visit,get,holds_alternative} and an explicit
nostd::string_view conversion, as other parts of the code (e.g.
bigtable and storage monitoring) already do. This works with both STL
and non-STL builds of opentelemetry-cpp.
@delphij
delphij requested review from a team as code owners November 4, 2026 08:17

@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 replaces standard library components such as std::visit, std::holds_alternative, std::get, and implicit string conversions with their OpenTelemetry non-standard equivalents (opentelemetry::nostd::visit, opentelemetry::nostd::holds_alternative, opentelemetry::nostd::get, and opentelemetry::nostd::string_view) across several tracing and telemetry internal source files. I have no feedback to provide as the changes are consistent and correct.

@colinmoy

colinmoy commented Nov 4, 2026

Copy link
Copy Markdown
Collaborator

/gcbrun

@colinmoy

colinmoy commented Nov 4, 2026

Copy link
Copy Markdown
Collaborator

/gharun

@codecov

codecov Bot commented Nov 4, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 92.47%. Comparing base (e4dc572) to head (a14e52f).
⚠️ Report is 4 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main   #16624   +/-   ##
=======================================
  Coverage   92.47%   92.47%           
=======================================
  Files        2269     2269           
  Lines      222037   222038    +1     
=======================================
+ Hits       205323   205336   +13     
+ Misses      16714    16702   -12     

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

This branch was successfully deployed

1 active deployment
false — a14e52f5 Deployed Nov 4, 2026 by delphij via Save PR ref #12808
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.

2 participants