Lifecycle functions (C++ SDK)#

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

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:

See common parameters below. The precise data type of details is described there.

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:

See common parameters below. The precise data type of details is described there.

Common parameters#

details

Optional JSON. Optional additional information provided by the user to add context for assertion failures. The information that is logged will appear in the logs section of a triage report. Normally the values passed to details are evaluated at runtime.

The description of this parameter is identical for both lifecycle and assert.

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 specify details using nested JSON, which requires the identifier antithesis::JSON:

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