CVB++ 15.0
Loading...
Searching...
No Matches

A span object to report traces. More...

#include <cvb/telemetry/span.hpp>

Inherits AttributeMap.

Public Member Functions

 operator bool () const noexcept
 Operator to evaluate as bool.
 
void Succeed () noexcept
 Set the span status to success.
 
template<class T>
Succeed (T &&result)
 Return a result and the span status to success.
 
void Fail () noexcept
 Set the span status to fail.
 
void Fail (const std::string &message) noexcept
 Set the span status to fail with a message.
 
template<class T>
void Raise (const T &error)
 Set the span status to fail and raises an exception.
 
template<class T>
Return (T code) noexcept
 Set the span status based on return code evaluation.
 
template<class T>
ReturnBool (T res) noexcept
 Set the span status based on boolean interpretation of a result.
 
void SetStatusMessage (const std::string &statusMessage) noexcept
 Set the status message.
 
- Public Member Functions inherited from AttributeMap
AttributeMapoperator() (const std::string &key, const Char *value)
 Specialization for Cvb::Char*.
 
AttributeMapoperator() (const std::string &key, void *value)
 Specialization for void*.
 
template<>
AttributeMapoperator() (const std::string &key, const double &value)
 Specialization for double.
 
template<>
AttributeMapoperator() (const std::string &key, const float &value)
 Specialization for float.
 
template<>
AttributeMapoperator() (const std::string &key, const String &value)
 Specialization for Cvb::String.
 
template<>
AttributeMapoperator() (const std::string &key, const bool &value)
 Specialization for bool.
 
template<>
AttributeMapoperator() (const std::string &key, const int8_t &value)
 Specialization for int8_t.
 
template<>
AttributeMapoperator() (const std::string &key, const uint8_t &value)
 Specialization for uint8_t.
 
template<>
AttributeMapoperator() (const std::string &key, const int16_t &value)
 Specialization for int16_t.
 
template<>
AttributeMapoperator() (const std::string &key, const uint16_t &value)
 Specialization for uint16_t.
 
template<>
AttributeMapoperator() (const std::string &key, const int32_t &value)
 Specialization for int32_t.
 
template<>
AttributeMapoperator() (const std::string &key, const uint32_t &value)
 Specialization for uint32_t.
 
template<>
AttributeMapoperator() (const std::string &key, const int64_t &value)
 Specialization for int64_t.
 
template<>
AttributeMapoperator() (const std::string &key, const uint64_t &value)
 Specialization for uint64_t.
 

Static Public Member Functions

static Span Create (const std::string &name)
 Creates a span with the given name.
 
static Span Create ()
 Creates a dummy span.
 

Detailed Description

A span object to report traces.

Log objects are created to stream messages. They support all std::ostream compatible types.

Member Function Documentation

◆ Create() [1/2]

static Span Create ( )
inlinestatic

Creates a dummy span.

Exceptions
Doesnot throw any exception.

A dummy span will evaluate to false. and perform only NOPs. Dummy spans are used when tracing is deactivated.

◆ Create() [2/2]

static Span Create ( const std::string & name)
inlinestatic

Creates a span with the given name.

Parameters
[in]nameThe span name.
Exceptions
Doesnot throw any exception.

◆ Fail() [1/2]

void Fail ( )
inlinenoexcept

Set the span status to fail.

Exceptions
Doesnot throw any exception.

◆ Fail() [2/2]

void Fail ( const std::string & message)
inlinenoexcept

Set the span status to fail with a message.

Parameters
[in]messageThe message.
Exceptions
Doesnot throw any exception.

◆ operator bool()

operator bool ( ) const
inlineexplicitnoexcept

Operator to evaluate as bool.

Exceptions
Doesnot throw any exception.

Dummy spans always evaluate to false. Otherwise spans evaluate to true.

◆ Raise()

template<class T>
void Raise ( const T & error)
inline

Set the span status to fail and raises an exception.

Parameters
[in]errorThe error.
Exceptions
error.

◆ Return()

template<class T>
T Return ( T code)
inlinenoexcept

Set the span status based on return code evaluation.

Parameters
[in]codeThe code.
Returns
The code.
Exceptions
Doesnot throw any exception.

◆ ReturnBool()

template<class T>
T ReturnBool ( T res)
inlinenoexcept

Set the span status based on boolean interpretation of a result.

Parameters
[in]resThe result.
Returns
The result.
Exceptions
Doesnot throw any exception.

◆ SetStatusMessage()

void SetStatusMessage ( const std::string & statusMessage)
inlinenoexcept

Set the status message.

Parameters
[in]messageThe message.
Exceptions
Doesnot throw any exception.

◆ Succeed() [1/2]

void Succeed ( )
inlinenoexcept

Set the span status to success.

Exceptions
Doesnot throw any exception.

◆ Succeed() [2/2]

template<class T>
T Succeed ( T && result)
inline

Return a result and the span status to success.

Parameters
[in]resultThe result to return.
Returns
The result.
Exceptions
Doesnot throw any exception.