userver icon indicating copy to clipboard operation
userver copied to clipboard

Scoped tags for tracing::Span

Open apolukhin opened this issue 2 years ago • 2 comments

Implement a tracing::ScopeTag for tracing::Span. The tracing::ScopeTag should add a tag to the current span for the lifetime of the tracing::ScopeTag.

Add tests for the feature.

Internal ticket: 5164

apolukhin avatar Oct 25 '23 15:10 apolukhin

tracing::TagScope

Anton3 avatar Dec 04 '23 10:12 Anton3

Hello @apolukhin . I would like to work on this issue.

Also I have a question about dealing with key collision. Consider following code:

Span s{"myspan"};
{
  ScopeTag low = s.AddScopeTag("key", "value");
  {
    ScopeTag high = s.AddScopeTag("key", "value2");
    LOG(DEBUG) << "something";
  }
  LOG(DEBUG) << "something";
}

I see 3 ways of designing this:

  1. The code snippet is valid, output is: first log: "key=value2" second log: "key=value"
  2. Get an error trying to add second ScopeTag. Colliding keys are not allowed.
  3. Ignore an attempt to add colliding key, output is: first log: "key=value" second log: "key=value"

nfrmtk avatar Dec 18 '23 17:12 nfrmtk