class Logger

Defined at line 31 of file ../../third_party/cobalt/src/logger/logger.h

Concrete implementation of both LoggerInterface and AtTimePointLoggerInterface.

After constructing a Logger use the Log*() methods to Log Events to Cobalt.

There should be an instance of Logger for each client-side Project.

On a Fuchsia system instances of Logger are created by the Cobalt FIDL

service for each FIDL connection from a client project.

Public Methods

void Logger (util::NotNullUniquePtr<ProjectContext> project_context, local_aggregation::LocalAggregation & local_aggregation, ObservationWriter & observation_writer, system_data::SystemDataInterface & system_data, util::CivilTimeConverterInterface & civil_time_converter, std::vector<uint32_t> experiment_ids, InternalMetrics * internal_metrics)

Constructor for a Logger when the system clock is, and will remain, accurate.

|project_context| The ProjectContext of the client-side project for which

the Logger will log events.

|local_aggregation| The system's singleton instance of LocalAggregation.

This must remain valid as long as the Logger is being used. The Logger

uses this to aggregate values derived from Cobalt Events and to produce

locally aggregated Observations.

|observation_writer| An instance of ObservationWriter, used by the Logger

to write immediate Observations to an ObservationStore. Must remain valid

as long as the Logger is in use.

|system_data| A pointer to a SystemDataInterface.

|civil_time_converter| The system's singleton instance of CivilTimeConverterInterface.

Must remain valid as long as the logger is used. The Logger uses this to convert

absolute times to civil times for metrics with the OTHER_TIME_ZONE TimeZonePolicy.

|experiment_ids| The set of all active experiments to be associated with

this logger.

|internal_metrics| An instance of InternalMetrics, used internally by the

Logger to send metrics about Cobalt to Cobalt. If nullptr, no such internal

logging will be performed by this Logger.

void Logger (util::NotNullUniquePtr<ProjectContext> project_context, local_aggregation::LocalAggregation & local_aggregation, ObservationWriter & observation_writer, system_data::SystemDataInterface & system_data, util::ValidatedClockInterface * validated_clock, util::CivilTimeConverterInterface & civil_time_converter, std::weak_ptr<UndatedEventManager> undated_event_manager, std::vector<uint32_t> experiment_ids, InternalMetrics * internal_metrics)

Constructor for a Logger when the clock is not yet accurate.

|project_context| The ProjectContext of the client-side project for which

the Logger will log events.

|local_aggregation| The system's singleton instance of LocalAggregation.

This must remain valid as long as the Logger is being used. The Logger

uses this to aggregate values derived from Cobalt Events and to produce

locally aggregated Observations.

|observation_writer| An instance of ObservationWriter, used by the Logger

to write immediate Observations to an ObservationStore. Must remain valid

as long as the Logger is in use.

|system_data| A pointer to a SystemDataInterface.

|validated_clock| An instance of a clock that refuses to provide the time if a quality

condition is not satisfied.

|civil_time_converter| The system's singleton instance of CivilTimeConverterInterface.

Must remain valid as long as the logger is used. The Logger uses this to convert

absolute times to civil times for metrics with the OTHER_TIME_ZONE TimeZonePolicy.

|experiment_ids| The set of all active experiments to be associated with

this logger.

|undated_event_manager| An instance of UndatedEventManager to use to save events until the

clock becomes accurate.

|internal_metrics| An instance of InternalMetrics, used internally by the

Logger to send metrics about Cobalt to Cobalt. If nullptr, no such internal

logging will be performed by this Logger.

Status LogOccurrence (uint32_t metric_id, uint64_t count, const std::vector<uint32_t> & event_codes)

Logging Methods

Status LogInteger (uint32_t metric_id, int64_t value, const std::vector<uint32_t> & event_codes)
Status LogIntegerHistogram (uint32_t metric_id, HistogramPtr histogram, const std::vector<uint32_t> & event_codes)
Status LogString (uint32_t metric_id, const std::string & string_value, const std::vector<uint32_t> & event_codes)
Status LogOccurrence (uint32_t metric_id, uint64_t count, const std::vector<uint32_t> & event_codes, const std::chrono::system_clock::time_point & event_timestamp)

Logs that an occurrence event happened at a particular point in time given

by |event_timestamp|. In contrast, the corresponding method without the |event_timestamp|

parameter assumes that the event happened at the time the method is called.

This method implements the one in the AtTimePointLoggerInterface and is intended to be used

on platforms where Cobalt does not run as a service.

Status LogInteger (uint32_t metric_id, int64_t value, const std::vector<uint32_t> & event_codes, const std::chrono::system_clock::time_point & event_timestamp)

Logs that an integer log event happened at a particular point in time given

by |event_timestamp|. In contrast, the corresponding method without the |event_timestamp|

parameter assumes that the event happened at the time the method is called.

This method implements the one in the AtTimePointLoggerInterface and is intended to be used

on platforms where Cobalt does not run as a service.

Status LogIntegerHistogram (uint32_t metric_id, HistogramPtr histogram, const std::vector<uint32_t> & event_codes, const std::chrono::system_clock::time_point & event_timestamp)

Logs that an integer histogram log event happened at a particular point in

time given by |event_timestamp|. In contrast, the corresponding method without the

|event_timestamp|

parameter assumes that the event happened at the time the method is called.

This method implements the one in the AtTimePointLoggerInterface and is intended to be used

on platforms where Cobalt does not run as a service.

Status LogString (uint32_t metric_id, const std::string & string_value, const std::vector<uint32_t> & event_codes, const std::chrono::system_clock::time_point & event_timestamp)

Logs that an string log event happened at a particular point in time given

by |event_timestamp|. In contrast, the corresponding method without the |event_timestamp|

parameter assumes that the event happened at the time the method is called.

This method implements the one in the AtTimePointLoggerInterface and is intended to be used

on platforms where Cobalt does not run as a service.

void PauseInternalLogging ()

Pauses Cobalt's internal metrics collection.

void ~Logger ()

Defined at line 105 of file ../../third_party/cobalt/src/logger/logger.h

void RecordLoggerCall (LoggerCallsMadeMigratedMetricDimensionLoggerMethod method)

LoggerCalled (cobalt_internal::metrics::logger_calls_made_migrated) is logged

for every call to Logger along with which method was called.

Defined at line 158 of file ../../third_party/cobalt/src/logger/logger.h

void ResumeInternalLogging ()

Resumes Cobalt's internal metrics collection.

Friends

class LoggerTest