blob: c303ee6fdb2633e3e62bb91fe71a82f77407f579 [file] [log] [blame]
package config_parser
import (
"config"
)
func ExpandDefaults(configs []ProjectConfigData) {
for _, c := range configs {
expandDefaultsForConfig(&c)
}
}
func expandDefaultsForConfig(c *ProjectConfigData) {
for _, metric := range c.ProjectConfigFile.MetricDefinitions {
if !Cobalt11MetricTypesSet[metric.MetricType] {
continue
}
for _, report := range metric.Reports {
if !Cobalt11ReportTypesSet[report.ReportType] {
continue
}
expandDefaultsForCobalt11Report(report)
}
}
}
var DefaultSystemProfileSelectionPolicy = map[config.ReportDefinition_ReportType]config.SystemProfileSelectionPolicy{
config.ReportDefinition_FLEETWIDE_OCCURRENCE_COUNTS: config.SystemProfileSelectionPolicy_REPORT_ALL,
config.ReportDefinition_FLEETWIDE_HISTOGRAMS: config.SystemProfileSelectionPolicy_REPORT_ALL,
config.ReportDefinition_FLEETWIDE_MEANS: config.SystemProfileSelectionPolicy_REPORT_ALL,
config.ReportDefinition_UNIQUE_DEVICE_NUMERIC_STATS: config.SystemProfileSelectionPolicy_REPORT_ALL,
config.ReportDefinition_HOURLY_VALUE_NUMERIC_STATS: config.SystemProfileSelectionPolicy_REPORT_ALL,
config.ReportDefinition_STRING_COUNTS: config.SystemProfileSelectionPolicy_REPORT_ALL,
}
func expandDefaultsForCobalt11Report(report *config.ReportDefinition) {
if report.LocalAggregationProcedure == config.ReportDefinition_SELECT_FIRST && report.EventVectorBufferMax == 0 {
report.EventVectorBufferMax = 1
}
if report.SystemProfileSelection == config.SystemProfileSelectionPolicy_SELECT_DEFAULT {
if def, ok := DefaultSystemProfileSelectionPolicy[report.ReportType]; ok {
report.SystemProfileSelection = def
}
}
}