open-telemetry / open-telemetry/opentelemetry-cpp

Why do I need to keep track of the lifetime of the scope/span objects myself?

Open
#2,249 6 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

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

Description

I'm trying to instrument some code that's used in a library that has very specific code flow. Keeping track of the spans and scopes myself is very tricky because I can't pass the spans/scopes. I have to store them in some locally managed storage.

In other tracing libraries (not c++), I've always just been able to do the equivalent of tracer->StartSpan(), and then some time later tracer->CurrentSpan()->End() or whatever. Is there advice on managing scopes if their lifetime is complicated? The only ways I see it working are global state, or polluting the types of all my functions to pass the scope around.

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.

Research direction

The issue names tracer->StartSpan(), tracer->CurrentSpan(), and End() as the relevant entry points, but identifies no file or test. Start by examining the C++ tracing API's scope and span lifetime behavior around these calls; done would require an agreed approach or documented guidance for managing scopes with complex lifetimes.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp
Domain
observability
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.