class CobaltServiceInterface

Defined at line 20 of file ../../third_party/cobalt/src/public/cobalt_service_interface.h

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

Public Methods

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)

NewLogger returns a new instance of a Logger object using the customer_id and project_id based

on the registry provided in the config. If the project is not found, this will return nullptr.

If no registry was provided, this will crash.

std::unique_ptr<logger::LoggerInterface> NewLogger (uint32_t customer_id, uint32_t project_id, std::vector<uint32_t> experiment_ids)

NewLogger returns a new instance of a Logger object using the customer_id and project_id based

on the registry provided in the config. If the project is not found, this will return nullptr.

If no registry was provided, this will crash. This method also allows for

setting experiment_id information.

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 CobaltServiceInterface 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.

system_data::SystemDataInterface * system_data ()

system_data returns a pointer to the internal SystemDataInterface object. This should only be

used for updating the Experiment state or channel in the system data.

system_data::SystemDataInterface & system_data_ref ()

system_data_ref returns a reference to the internal SystemDataInterface object. This should be

used instead of system_data().

void SetDataCollectionPolicy (DataCollectionPolicy policy)

Sets the data collection policy.

Status GenerateAggregatedObservations ()

Triggers an out of schedule generation of aggregate observations for rolling windows ending

now.

Returns the result of the generation.

This method is intended for use in cobalt embeddings where running the local aggregation

background threads is undesirable. This should only be called if

CobaltConfig::start_worker_threads is false.

This method should be called before attempting to read observations from the ObservationStore

for uploading, to make sure that the most up-to-date aggregated observations have been created.

Status GenerateAggregatedObservations (uint32_t final_day_index_utc)

Triggers an out of schedule generation of aggregate observations for rolling windows ending on

|final_day_index_utc|.

Returns the result of the generation.

This method is intended for use in the Cobalt testapps which require a single thread to

both log events to and generate Observations from an EventAggregator.

uint64_t num_observations_added ()

Returns the number of Observations that have been added to the ObservationStore.

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

Returns a vector containing the number of Observations that have been added

to the ObservationStore for each specified report.

void ShippingRequestSendSoon (const SendCallback & send_callback)

Register a request for an expedited send of observations to the server. The

accumulated unsent Observations will be sent as soon as possible (with some rate limiting).

|send_callback| will be invoked with the result of the requested send

attempt. More precisely, send_callback will be invoked after the

attempt to send all of the outstanding Observations. It will be invoked with true if all such

Observations were successfully sent. It will be invoked with false if some

Observations were not able to be sent, but the status of any particular

Observation may not be determined. This is useful mainly in tests.

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

Blocks for |max_wait| seconds or until the sending of all previously added Observations is

complete.

void ShutDown ()

Courtesy signal for Cobalt to begin a graceful shutdown.

Cobalt may be terminated before the shut down process is complete. The

amount of time before this occurs depends on caller. No metrics should be

logged after the shutdown signal is sent.

void ~CobaltServiceInterface ()

Defined at line 22 of file ../../third_party/cobalt/src/public/cobalt_service_interface.h

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

Defined at line 109 of file ../../third_party/cobalt/src/public/cobalt_service_interface.h

size_t num_shipping_send_attempts ()

These diagnostic stats are mostly useful in a testing environment but

may possibly prove useful in production also.

size_t num_shipping_failed_attempts ()

Enumerations

enum DataCollectionPolicy
Name Value
COLLECT_AND_UPLOAD 1
DO_NOT_UPLOAD 2
DO_NOT_COLLECT 3

Defined at line 59 of file ../../third_party/cobalt/src/public/cobalt_service_interface.h