Lifecycle functions (C++ SDK)

Lifecycle functions inform the Antithesis environment that particular test phases or milestones have been reached. They are part of the Antithesis C++ SDK.

Every macro takes a parameter details, which allows you to record additional contextual information.

Functions

Setup

void setup_complete(JSON details)

Indicates to Antithesis that setup has completed. Call this function when your system and workload are fully initialized. After this function is called, Antithesis will take a snapshot of your system and begin injecting faults.

Calling this function multiple times or from multiple processes will have no effect. Antithesis will treat the first time any process called this function as the moment that the setup was completed.

The function is called using the Antithesis namespace:

antithesis::setup_complete(details)

Parameters

details
JSON. Optional additional information provided by the user to add context for assertion failures. The information that is logged will appear in a triage report, under the details section of the generated property.

Normally the values passed to details are evaluated at runtime. If you do not wish to provide details, then pass {} as the parameter.

The type of details is std::map<std::string, antithesis::ValueType> where antithesis::ValueType is a std::variant consisting of many common types, including a nested JSON type.

You can specify details using initialization syntax:

{ 
    {"name", "Bob"}, 
    {"number", 123.4} 
}

You can also include nested JSON in details, which requires the identifier antithesis::JSON:

{ 
    {"nested", antithesis::JSON{
                                    {"a", "b"},
                                    {"c", 1234}
                                } 
    } 
}

Send event

void send_event(const char* name, JSON details)

This causes an event with the name and details provided to be sent to the Antithesis platform. This is analogous to logging an event, and may be slightly preferable because (1) the event is structured JSON, and (2) the timing of the event is much more precise with respect to your assertions, so debugging may be slightly easier for issues where exact timing matters for diagnosing a problem.

The function is called using the Antithesis namespace:

antithesis::send_event(name, details)

Parameters

name
const char*. The name of the event that you are logging. This name will appear in the logs section of a triage report.

details
JSON. Optional additional information provided by the user to add context for assertion failures. The information that is logged will appear in a triage report, under the details section of the generated property.

Normally the values passed to details are evaluated at runtime. If you do not wish to provide details, then pass {} as the parameter.

The type of details is std::map<std::string, antithesis::ValueType> where antithesis::ValueType is a std::variant consisting of many common types, including a nested JSON type.

You can specify details using initialization syntax:

{ 
    {"name", "Bob"}, 
    {"number", 123.4} 
}

You can also include nested JSON in details, which requires the identifier antithesis::JSON:

{ 
    {"nested", antithesis::JSON{
                                    {"a", "b"},
                                    {"c", 1234}
                                } 
    } 
}

Common parameters

details
JSON. Optional additional information provided by the user to add context for assertion failures. The information that is logged will appear in a triage report, under the details section of the generated property.

Normally the values passed to details are evaluated at runtime. If you do not wish to provide details, then pass {} as the parameter.

The type of details is std::map<std::string, antithesis::ValueType> where antithesis::ValueType is a std::variant consisting of many common types, including a nested JSON type.

You can specify details using initialization syntax:

{ 
    {"name", "Bob"}, 
    {"number", 123.4} 
}

You can also include nested JSON in details, which requires the identifier antithesis::JSON:

{ 
    {"nested", antithesis::JSON{
                                    {"a", "b"},
                                    {"c", 1234}
                                } 
    } 
}