class CobaltService

Defined at line 54 of file ../../third_party/cobalt/src/public/cobalt_service.h

CobaltService is the primary public interface for Cobalt on client platforms.

It is constructed using a CobaltConfig struct, which provides all available customization options

for the behavior of Cobalt.

Example:

CobaltConfig cfg;

cfg.product_name = "product";

cfg.version = "version";

... continue setting config values ...

CobaltService service(std::move(cfg));

// Get a logger:

auto logger = service.NewLogger(project_context);

logger.LogEvent(Event);

Public Methods

void CobaltService (const CobaltService & )

Defined at line 60 of file ../../third_party/cobalt/src/public/cobalt_service.h

void CobaltService (CobaltService && )

Defined at line 61 of file ../../third_party/cobalt/src/public/cobalt_service.h

lib::statusor::StatusOr<std::unique_ptr<CobaltService>> Create (CobaltConfig cfg)
lib::statusor::StatusOr<std::unique_ptr<ClocklessCobaltServiceInterface>> CreateClockless (CobaltConfig cfg)
std::unique_ptr<logger::LoggerInterface> NewLogger (std::unique_ptr<logger::ProjectContext> project_context)

NewLogger returns a new instance of a Logger object based on the provided |project_context|.

std::unique_ptr<logger::LoggerInterface> NewLogger (uint32_t customer_id, uint32_t project_id)
std::unique_ptr<logger::LoggerInterface> NewLogger (uint32_t customer_id, uint32_t project_id, std::vector<uint32_t> experiment_ids)
std::unique_ptr<logger::AtTimePointLoggerInterface> NewAtTimePointLogger (uint32_t customer_id, uint32_t project_id)
void SystemClockIsAccurate (std::unique_ptr<util::SystemClockInterface> system_clock, bool start_event_aggregator_worker)

SystemClockIsAccurate lets CobaltService know that it no longer needs to maintain an

UndatedEventManager, and can flush the data from it into the observation store.

This method should be used at most once in the lifetime of a CobaltService object.

|system_clock|: An instance of SystemClockInterface that is used to add a timestamp to all of

the events that were received before the system clock was made accurate. It is then given to

the EventAggregator if |start_event_aggregator_worker| is true.

void SetDataCollectionPolicy (DataCollectionPolicy policy)

Sets the data collection policy.

Status GenerateAggregatedObservations ()

Generates aggregated observations for aggregation periods that have ended in the time zone

associated with the metric.

Status GenerateAggregatedObservations (uint32_t final_day_index_utc)

Test-only method that generates aggregated observations for aggregation periods with day index

less than or equal to final_day_index_utc (including hourly observations).

Status GenerateAggregatedObservations (const std::chrono::system_clock::time_point & timestamp)

Generates aggregated observations for aggregation periods that have ended

before |timestamp| in the time zone associated with the metric.

CobaltService & operator= (const CobaltService & )

Defined at line 62 of file ../../third_party/cobalt/src/public/cobalt_service.h

CobaltService & operator= (CobaltService && )

Defined at line 63 of file ../../third_party/cobalt/src/public/cobalt_service.h

system_data::SystemDataInterface * system_data ()

system_data returns a pointer to the internal SystemData object. This should only be used for

updating the Expirement state or channel in SystemData.

Defined at line 107 of file ../../third_party/cobalt/src/public/cobalt_service.h

system_data::SystemDataInterface & system_data_ref ()

Defined at line 108 of file ../../third_party/cobalt/src/public/cobalt_service.h

uint64_t num_observations_added ()

Defined at line 125 of file ../../third_party/cobalt/src/public/cobalt_service.h

std::vector<uint64_t> num_observations_added_for_reports (const std::vector<lib::ReportIdentifier> & report_specs)

Defined at line 129 of file ../../third_party/cobalt/src/public/cobalt_service.h

void ShippingRequestSendSoon (const SendCallback & send_callback)

Defined at line 134 of file ../../third_party/cobalt/src/public/cobalt_service.h

void WaitUntilShippingIdle (std::chrono::seconds max_wait)

Defined at line 138 of file ../../third_party/cobalt/src/public/cobalt_service.h

void ShutDown ()

Defined at line 142 of file ../../third_party/cobalt/src/public/cobalt_service.h

size_t num_shipping_send_attempts ()

Defined at line 144 of file ../../third_party/cobalt/src/public/cobalt_service.h

size_t num_shipping_failed_attempts ()

Defined at line 147 of file ../../third_party/cobalt/src/public/cobalt_service.h

bool has_internal_logger ()

Defined at line 151 of file ../../third_party/cobalt/src/public/cobalt_service.h

Friends

class CobaltServicePeer