class ObservationGenerator
Defined at line 35 of file ../../third_party/cobalt/src/local_aggregation/observation_generator.h
ObservationGenerator manages the background task that is responsible for generating observations
and writing them to |observation_writer| on a regular schedule (~once per hour).
There should be only one ObservationGenerator per system.
Once the system clock has become accurate, the Start() method should be called with the
SystemClockInterface exactly once. After that point, the ObservationGenerator will generate
observations on a regular schedule until ShutDown() is called.
Public Methods
void ObservationGenerator (LocalAggregateStorage & aggregate_storage, const logger::ProjectContextFactory & global_project_context_factory, system_data::SystemDataInterface & system_data, const logger::ObservationWriter & observation_writer, std::unique_ptr<logger::PrivacyEncoder> privacy_encoder, util::CivilTimeConverterInterface & civil_time_converter, bool generate_observations_with_current_system_profile, bool test_dont_backfill_empty_reports, uint32_t backfill_manager_days)
Constructor for ObservationGenerator
|aggregate_storage|: The file-backed storage for MetricAggregate objects.
|global_project_context_factory|: The current global registry.
|system_data|: Used to retrieve global SystemProfile data.
|observation_writer|: Used for writing generated observations to observation storage.
|privacy_encoder|: Used for encoding generated observations using privacy algorithms.
|civil_time_converter|: Converts a `time_point` to a civil time for a given time zone.
|generate_observations_with_current_system_profile|: If set, any missing system profile fields
should be taken from the current system profile.
|dont_backfill_empty_reports|: If set, reports that have never had any events will be skipped.
Only enable this in tests.
void Start (util::SystemClockInterface * clock)
Start begins the background thread to generate observations on a fixed schedule. This method
should only be called once when the system clock has become accurate.
void ShutDown ()
ShutDown halts the background thread, allowing the ObservationGenerator to be destroyed.
Status GenerateObservationsOnce (std::chrono::system_clock::time_point system_time)
GenerateObservationsOnce iterates through all of the metrics/reports in the global registry and
attempts to generate observations for them. Any generated observations will be written to the
|observation_writer_|.
|system_time|: The most recent time that should be considered for any report. In general,
GenerateObservationsOnce generates observations for time periods that have
ended before `system_time`. For expedited reports, observations are also
generated for the time period containing `system_time`.
This method is called automatically in the background thread by 'GenerateObservations()', but
can be called manually while testing to avoid having to wait.
void ResetInternalMetrics (logger::InternalMetrics * internal_metrics)
Defined at line 79 of file ../../third_party/cobalt/src/local_aggregation/observation_generator.h