open-telemetry / open-telemetry/opentelemetry-cpp
opentelemetry::v1::nostd::string_view is not compatible with std::string_view
@marcalff is already working on this.
Since Jun 12, 2024.
- Dominant language
- C++
- Stars
- 1.4k
- Forks
- 632
- Avg merge
- 1d 13h
- Merged PRs (30d)
- 75
Description
The problem with the internal opentelemetry::v1::nostd::string_view only being compatible with std::string and not std::string_view is really obvious when using opentelemetry::context::propagation::TextMapCarrier
By using TextMapCarrier as a base class you need to implement "virtual nostd::string_view Get(nostd::string_view key) const noexcept = 0;" for instance. My experience is that C++ HTTP libraries are commonly based on std::string_view in order to avoid unnecessary copying of strings. Boost Beast for instance uses std::string_view for header parameters.
I know that it is possible to copy data/strings from a std::map<std::string_view, std::string_view> into a std::map<std::string, std::string>. But doing that for every request is a bad design. Am I missing something here? Is there a way of using the internal string_view implementation together with the std version? Why not use std::string_view in opentelemetry?
Maybe the TextMapCarrier base class should be a template instead. But I guess it will affect the TextMapPropagator as well then.
What's your take on this issue? I doubt other third party libraries will implement support for opentelemetry::v1::nostd::string_view.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Assessment
This issue has not been assessed yet.