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}
                                } 
    } 
}
  • Introduction
  • How Antithesis Works
  • Getting started
  • Package your software
  • Make it go
  • Deploy to Antithesis
  • Launch a test run
  • User manual
  • Properties and Assertions
  • Properties in Antithesis
  • Assertions in Antithesis
  • Properties to Test For
  • Sometimes Assertions
  • Test Composer
  • Test Composer Basics
  • Test Composer Reference
  • Principles of Test Composition
  • Checking Test Templates Locally
  • Webhooks
  • Launching a test
  • Retrieving logs
  • Launching a debugging session
  • Webhook API
  • Reports
  • Triage report
  • Bug report
  • Multiverse debugging
  • Overview
  • Exploring the multiverse
  • Querying with event sets
  • The Environment and its utilities
  • Using the Antithesis Notebook
  • Cookbook
  • The Environment and Multiverse
  • The Antithesis Environment
  • Fault Injection
  • CPUID
  • Reference
  • Handling External Dependencies
  • SDK reference
  • Go
  • Tutorial
  • Instrumentor
  • Assert (reference)
  • Lifecycle (reference)
  • Random (reference)
  • Java
  • Tutorial
  • Instrumentation
  • Assert (reference)
  • Lifecycle (reference)
  • Random (reference)
  • C
  • C++
  • Tutorial
  • C/C++ Instrumentation
  • Assert (reference)
  • Lifecycle (reference)
  • Random (reference)
  • JavaScript
  • Python
  • Tutorial
  • Assert (reference)
  • Lifecycle (reference)
  • Random (reference)
  • Rust
  • Tutorial
  • Instrumentation
  • Assert (reference)
  • Lifecycle (reference)
  • Random (reference)
  • .NET
  • Languages not listed above
  • Assert (reference)
  • Lifecycle (reference)
  • Tooling integrations
  • CI integration
  • Discord and Slack integrations
  • Configuring Antithesis
  • Instrumentation
  • User management
  • Sizing your deployment
  • Best practices
  • Is Antithesis working?
  • Optimizing for Antithesis
  • Finding more bugs
  • Release notes
  • Release notes