open-telemetry / open-telemetry/opentelemetry-cpp

How could i return dynamic attributes in a sampler

Open
#2,273 5 comments 0 reactions 1 assignee View on GitHub

@lalitb is already working on this.

Since Sep 6, 2023.

Stale triage/accepted
Dominant language
C++
Stars
1.4k
Forks
632
Avg merge
1d 13h
Merged PRs (30d)
75

Description

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

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.