Skip to content

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

Open
delphij wants to merge 2 commits into
googleapis:mainfrom
delphij:fix-otel-nostd-variant
Open

delphij wants to merge 2 commits 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.50%. Comparing base (b32a1f5) to head (393201c).
⚠️ Report is 13 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main   #16624      +/-   ##
==========================================
- Coverage   92.51%   92.50%   -0.02%     
==========================================
  Files        2269     2269              
  Lines      222804   222805       +1     
==========================================
- Hits       206126   206101      -25     
- Misses      16678    16704      +26     

☔ 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 scotthart added the do not merge Indicates a pull request not ready for merge, due to either quality or timing. label Nov 10, 2026
@colinmoy

Copy link
Copy Markdown
Collaborator

/gcbrun

This branch was successfully deployed

1 active (outdated) 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

do not merge Indicates a pull request not ready for merge, due to either quality or timing.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants