X-TraceC++Library
|
Represents an X-Trace Event, with enough information to generate an X-Trace report. More...
#include <XtrEvent.h>
Public Member Functions | |
Event () | |
Creates a new Event. | |
Event (const Metadata &xtr) | |
Creates a new Event from a given Metadata, with no incoming edges. | |
Event (const Event &model) | |
Creates a new Event with a default event as a model, i.e., with pre-filled fields. | |
xtr_result | setTaskId (const TaskId &taskId) |
Sets the taskId of the event. | |
xtr_result | setRandomOpId (size_t opIdLen=4) |
Sets the opId of the Event to a random one. | |
xtr_result | setSeverity (u_int8_t severity) |
Sets the severity of the Event. | |
u_int8_t | getSeverity () |
Gets the severity of the event. | |
xtr_result | addEdge (const Metadata &xtr, EventEdge::EdgeDir dir=EventEdge::NEXT) |
Adds an edge to the event. | |
xtr_result | addInfo (const char *key, const char *value) |
Adds information to this event. | |
void | addTimestamp (const char *label) |
size_t | fork () |
Indicates that the task is forking at this event, i.e., two or more concurrent events will follow this task. | |
const Metadata & | getMetadata () |
Returns an Metadata object to be propagated to the subsequent events in this task. | |
const Metadata & | getMetadata (size_t index) |
Returns an Metadata object to be propagated to the subsequent events in this task, indexed by the parameter index. | |
string | getReport () |
Returns a string representation of the report for this event. | |
xtr_result | sendReport () |
Directly call the Reporter report method. |
Represents an X-Trace Event, with enough information to generate an X-Trace report.
xtr::Event::Event | ( | ) |
Creates a new Event.
It has a new, random opId, but invalid taskId.
xtr::Event::Event | ( | const Metadata & | xtr | ) |
xtr::Event::Event | ( | const Event & | model | ) |
Creates a new Event with a default event as a model, i.e., with pre-filled fields.
The event is initialized as in the default constructor, except that the extra information (info) is copied. This constructor is useful to set things like Agent, Machine, or some other key/value pairs that would be repeated.
xtr_result xtr::Event::addEdge | ( | const Metadata & | xtr, |
EventEdge::EdgeDir | dir = EventEdge::NEXT |
||
) |
Adds an edge to the event.
This has several effects on the event. The default type of edge added is 'NEXT'. The first edge added does: 1. sets the taskId of the event if not already set 2. logically adds an edge to the report 3. sets the size of the event opId A subsequent edge added with a different TaskId has no effect. It is an error. This is added to the report as an error report. TODO: this is not an error, and can help identify cross-task interactions A subsequent edge added with the same ChainId: 1. logically adds an edge to the report A subsequent edge added with a different ChainId: 1. logically adds an edge to the report 2. signifies that the event is a barrier. This will cause the termination of the incoming ChainId
xtr | |
dir |
xtr_result xtr::Event::addInfo | ( | const char * | key, |
const char * | value | ||
) |
Adds information to this event.
This is a key-value pair of strings. This information is added to the report for this event. Multiple additions to the same key are allowed, and are listed in the report in an arbitrary order.
key | key for the info |
value | value for the info |
void xtr::Event::addTimestamp | ( | const char * | label | ) |
The timestamp is added automatically when the event is reported.
size_t xtr::Event::fork | ( | ) |
Indicates that the task is forking at this event, i.e., two or more concurrent events will follow this task.
fork() creates a new chainId, and returns its index. The index starts with 0, and by default the chainId of index 0 is the same as the first edge added to the task.
fork() will set up state such that the next metadata retrieved from this EventCtx will be in a different chainId than the original one.
const Metadata& xtr::Event::getMetadata | ( | ) |
Returns an Metadata object to be propagated to the subsequent events in this task.
The metadata returned will have the current chainId, as set by calls to fork(). The default chainId is the chainId of the first edge added to the context, or the canonical chainId 0 otherwise.
const Metadata& xtr::Event::getMetadata | ( | size_t | index | ) |
string xtr::Event::getReport | ( | ) |
Returns a string representation of the report for this event.
This is a fully formated report that can be sent to the reporting daemon, and conforms to the X-Trace report specification version 1.0.
u_int8_t xtr::Event::getSeverity | ( | ) |
Gets the severity of the event.
xtr_result xtr::Event::sendReport | ( | ) |
Directly call the Reporter report method.
xtr_result xtr::Event::setRandomOpId | ( | size_t | opIdLen = 4 | ) |
Sets the opId of the Event to a random one.
xtr_result xtr::Event::setSeverity | ( | u_int8_t | severity | ) |
Sets the severity of the Event.
The severity will be used when reporting.
severity | severity of this event |
xtr_result xtr::Event::setTaskId | ( | const TaskId & | taskId | ) |
Sets the taskId of the event.
If the taskId is already set and is different from the one being set, an error is returned.
taskId | taskId to set |