userver: tracing::TagScope Class Reference
Loading...
Searching...
No Matches
tracing::TagScope Class Reference

#include <userver/tracing/tag_scope.hpp>

Detailed Description

RAII object that calls Span::AddTag/Span::AddTagFrozen function in constructor and reverts these actions in destructor.

Example usage:

tracing::Span myspan{"myspan"};
myspan.AddTag("key", "value");
{
const tracing::TagScope tag{myspan, "key", "2value2"};
LOG_INFO() << "1";
const auto logs = GetStreamString();
ASSERT_THAT(logs, testing::Not(testing::HasSubstr("key=value")));
ASSERT_THAT(logs, testing::HasSubstr("key=2value2"));
}
ClearLog();
LOG_INFO() << "1";
const auto logs = GetStreamString();
ASSERT_THAT(logs, testing::HasSubstr("key=value"));
ASSERT_THAT(logs, testing::Not(testing::HasSubstr("key=2value2")));

Definition at line 20 of file tag_scope.hpp.

Public Member Functions

 TagScope (std::string key, logging::LogExtra::Value value, logging::LogExtra::ExtendType extend_type=logging::LogExtra::ExtendType::kNormal)
 
 TagScope (Span &parent, std::string key, logging::LogExtra::Value value, logging::LogExtra::ExtendType extend_type=logging::LogExtra::ExtendType::kNormal)
 
 TagScope (logging::LogExtra &&extra)
 
 TagScope (Span &parent, logging::LogExtra &&extra)
 
 TagScope (const TagScope &other)=delete
 
TagScopeoperator= (const TagScope &other)=delete
 
 TagScope (TagScope &&other)=delete
 
TagScopeoperator= (TagScope &&other)=delete
 

The documentation for this class was generated from the following file: