Skip to content

How could i return dynamic attributes in a sampler #2273

Open
@xiehuc

Description

@xiehuc

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?

::opentelemetry::sdk::trace::SamplingResult MySampler::ShouldSample(
    const ::opentelemetry::trace::SpanContext& parent_context,
    ::opentelemetry::trace::TraceId trace_id, ::opentelemetry::nostd::string_view name,
    ::opentelemetry::trace::SpanKind span_kind,
    const ::opentelemetry::common::KeyValueIterable& attributes,
    const ::opentelemetry::trace::SpanContextKeyValueIterable& links) noexcept 

    result.attributes =
        std::make_unique<const std::map<std::string, opentelemetry::common::AttributeValue>>(
            std::move(kv));

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

Metadata

Metadata

Assignees

Labels

Staletriage/acceptedIndicates an issue or PR is ready to be actively worked on.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions