-
Notifications
You must be signed in to change notification settings - Fork 417
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
How could i return dynamic attributes in a sampler #2273
Comments
Valid concern. The struct SamplingResult
{
...
std::unique_ptr<const std::map<std::string, opentelemetry::sdk::common::OwnedAttributeValue>> attributes;
...
}
|
i rethink the code, found that:
the AttributeValue is string_view, is totally OK. because Span's underline is would call
span_ is protobuf, would finally hold value. so string_string is just a bridge. that is
just ok, SetAttribute finally make protobuf hold value. but in SamplingResult things are totally different. when a Sampler set attribute
after ShouldSample return, value would immediately free,so attribute hold a bad value. even if it call SetAttribute after, the value is just a bad value. |
the solution is simple. let ShouldSample can call SetAttribute .
|
Well not that easy :) The Span doesn't exist when ShouldSample is called. As Span is created based on sampling decision.
As mentioned above, this needs Span to already exist when ShouldSample is called.
We could potentially implement this, but it would result in our implementation becoming non-compliant with the specification.
Yes, this is one of the solutions, to instead use |
This issue was marked as stale due to lack of activity. |
Before opening a feature request against this repo, consider whether the feature should/could be implemented in the other OpenTelemetry client libraries. If so, please open an issue on opentelemetry-specification first.
Is your feature request related to a problem?
SampleingResult has attributes, but it's value is AttributeValue, just reference, not own memory.
so, my question is, where could i attach original value string to this session, so it could free'd after span send.
parent_context?
trace_state?
no way !!! this API just could not make it work but still keeps it exist.
i think about thread_local, object pool, delay timer, std::string allocator, but all of this just make a simple things becomes very complex。
Describe the solution you'd like
no idea, dead lock.
Describe alternatives you've considered
Additional context
The text was updated successfully, but these errors were encountered: