blob: bfc5a543f046ee77f2aa18a8a6d90b60171030b5 [file] [log] [blame]
// Copyright 2018 The Fuchsia Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
syntax = "proto3";
package cobalt;
import "src/registry/aggregation_window.proto";
import "src/registry/metric_definition.proto";
import "src/registry/report_definition.proto";
import "src/registry/project.proto";
// An identifier of a locally aggregated report.
message ReportAggregationKey {
uint32 customer_id = 1;
uint32 project_id = 2;
uint32 metric_id = 3;
uint32 report_id = 4;
}
// A container used by the EventAggregator to store local aggregates of
// logged events.
message LocalAggregateStore {
// The version number of the LocalAggregateStore.
uint32 version = 2;
// Keyed by base64-encoded serializations of ReportAggregationKey messages.
map<string, ReportAggregates> by_report_key = 1;
}
message ReportAggregates {
// A collection of aggregates whose form depends on the report type.
oneof type {
UniqueActivesReportAggregates unique_actives_aggregates = 1;
PerDeviceNumericAggregates numeric_aggregates = 2;
}
// The configuration for the report represented by the ReportAggregationKey
// of this ReportAggregates.
AggregationConfig aggregation_config = 100;
}
message UniqueActivesReportAggregates {
// Keyed by single event code.
map<uint32, DailyAggregates> by_event_code = 1;
}
message PerDeviceNumericAggregates {
// Keyed by component string.
map<string, EventCodeAggregates> by_component = 1;
}
message EventCodeAggregates {
// Keyed by packed multi-event code.
map<uint64, DailyAggregates> by_event_code = 1;
}
message DailyAggregates {
// Keyed by day index.
map<uint32, DailyAggregate> by_day_index = 1;
}
// A value formed by aggregating the events logged for a single report, event
// code, and day index.
message DailyAggregate {
oneof type {
ActivityDailyAggregate activity_daily_aggregate = 1;
NumericDailyAggregate numeric_daily_aggregate = 2;
}
}
// A representation of the occurrence or non-occurrence of an event code on
// a given day.
message ActivityDailyAggregate {
bool activity_indicator = 1;
}
// An aggregate of the numeric values with a particular event code and
// component label, for a given day. The way in which numeric values are
// aggregated (e.g. summing, taking the max or min) is determined by the
// aggregation_type field of the ReportDefinition.
message NumericDailyAggregate {
int64 value = 1;
}
// A representation of the configuration of a locally aggregated report and
// of its parent metric.
message AggregationConfig {
// A Project message.
Project project = 1;
// A MetricDefinition.
//
// TODO(pesk): When implementing handling of config changes, replace this
// field with a MetricDefinition with all ReportDefinitions removed, as well
// as all fields which should not affect the EventAggregator's handling
// of the MetricDefinition.
MetricDefinition metric = 2;
// A ReportDefinition message.
//
// TODO(pesk): When implementing handling of config changes, replace this
// field with a ReportDefinition with all WindowSizes removed, as well as
// all fields which should not affect the EventAggregator's handling of the
// ReportDefinition.
ReportDefinition report = 3;
// A list of window sizes for this report, sorted in increasing order.
repeated uint32 window_size = 4;
// A list of aggregation windows for this report, sorted in increasing order.
repeated OnDeviceAggregationWindow aggregation_window = 5;
}
// A container used by the EventAggregator to store the history of generated
// Observations, indexed by report.
message AggregatedObservationHistoryStore {
// The version number of the AggregatedObservationHistoryStore.
uint32 version = 2;
// Keyed by base64-encoded serializations of ReportAggregationKey messages.
map<string, AggregatedObservationHistory> by_report_key = 1;
}
// A container for the history of Observations that have been generated for a
// single report.
message AggregatedObservationHistory {
// If this is a locally aggregated report, then AggregatedObservationHistory
// has one of the following types.
oneof type {
// A container for the history of UniqueActivesObservations generated
// for a UNIQUE_N_DAY_ACTIVES report.
UniqueActivesObservationHistory unique_actives_history = 1;
// A container for the history of PerDeviceNumericObservations generated
// for a PER_DEVICE_NUMERIC_STATS report.
PerDeviceNumericObservationHistory per_device_numeric_history = 2;
}
// A container for the history of ReportParticipationObservations generated
// for this report. Unset if ReportParticipationObservations should not be
// generated for this report.
ReportParticipationObservationHistory report_participation_history = 100;
}
message UniqueActivesObservationHistory {
// Keyed by single event code.
map<uint32, HistoryByWindowSize> by_event_code = 1;
}
message PerDeviceNumericObservationHistory {
// The history of PerDeviceNumericObservations. Keyed by component string.
map<string, HistoryByEventCode> by_component = 1;
}
message ReportParticipationObservationHistory {
// The last day index for which a ReportParticipationObservation was
// generated for this report.
//
// TODO(pesk): if ReportParticipationObservation has a window_size
// field in the future, consider changing this to a repeated field
// where the k-th last_generated field holds the value for window
// size k.
uint32 last_generated = 1;
}
message HistoryByEventCode {
// Keyed by packed multi-event code.
map<uint64, HistoryByWindowSize> by_event_code = 1;
}
message HistoryByWindowSize {
// Keyed by window size. The value at a window size is the latest day index
// for which an Observation has been generated for this report, event code,
// and window size.
map<uint32, uint32> by_window_size = 1;
}