Replies: 1 comment 1 reply
-
(there is a glitch in Discussion, it crashed with 404, and the same idea got submitted twice 😁 ) |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Our Tracing API surface assumes that the
common::AttributeValue
here does not own the originating event attribute memory.When I use the SDK to append some event on Span, e.g.
Then use some utility function that returns a temporary
std::string
, e.g.std::string getSomeValue()
I cannot code my events this way:
Because
nostd::string_view
would refer to temporary that does not have any lifecycle guarantees.Now to overcome this limitation, I could do the following:
Then emit my span attributes, which would be handled more coherently.
I wonder if we could create another class similar to
OwnedAttributeValue
in API, maybe naming itEventProperties
orProperties
orAttributes
, being owning collection in order to simplify the usage of OpenTelemetry SDK. Without this concept it is very easy to fall into trap of a memory corruption on a temporary assigned to non-owningnostd::string_view
.As alternative, I'd like to show what could have been done to address this:
https://github.com/maxgolov/opentelemetry-cpp/blob/master/api/include/opentelemetry/event/Properties.hpp
This code is inspired by the following original implementation:
https://github.com/microsoft/cpp_client_telemetry/blob/master/lib/include/public/EventProperties.hpp
Beta Was this translation helpful? Give feedback.
All reactions