// generate is the main generator logic that all the spec types and storers share. Mainly
// has the logic of the generate app service.
generate is the main generator logic that all the spec types and storers share. Mainly
has the logic of the generate app service.
// generate is the main generator logic that all the spec types and storers share . Mainly // has the logic of the generate app service .
func generateRules(ctx context.Context, logger log.Logger, info info.Info, disableRecs, disableAlerts bool, extraLabels map[string]string, slos prometheus.SLOGroup) (*generate.Response, error) {
	var sliRuleGen generate.SLIRecordingRulesGenerator = generate.NoopSLIRecordingRulesGenerator
	var metaRuleGen generate.MetadataRecordingRulesGenerator = generate.NoopMetadataRecordingRulesGenerator
	if !disableRecs {
		sliRuleGen = prometheus.SLIRecordingRulesGenerator
		metaRuleGen = prometheus.MetadataRecordingRulesGenerator
	}
	var alertRuleGen generate.SLOAlertRulesGenerator = generate.NoopSLOAlertRulesGenerator
	if !disableAlerts {
		alertRuleGen = prometheus.SLOAlertRulesGenerator
	}
	controller, err := generate.NewService(generate.ServiceConfig{
		AlertGenerator:              alert.AlertGenerator,
		SLIRecordingRulesGenerator:  sliRuleGen,
		MetaRecordingRulesGenerator: metaRuleGen,
		SLOAlertRulesGenerator:      alertRuleGen,
		Logger:                      logger,
	})
	if err != nil {
		return nil, fmt.Errorf("could not create application service: %w", err)
	}
	result, err := controller.Generate(ctx, generate.Request{
		ExtraLabels: extraLabels,
		Info:        info,
		SLOGroup:    slos,
	})
	if err != nil {
		return nil, fmt.Errorf("could not generate prometheus rules: %w", err)
	}
	return result, nil
}
func generateRules ( ctx context . Context , logger log . Logger , info info . Info , disableRecs , disableAlerts bool , extraLabels map [ string ] string , slos prometheus . SLOGroup ) ( * generate . Response , error ) { var sliRuleGen generate . SLIRecordingRulesGenerator = generate . NoopSLIRecordingRulesGenerator var metaRuleGen generate . MetadataRecordingRulesGenerator = generate . NoopMetadataRecordingRulesGenerator if ! disableRecs { sliRuleGen = prometheus . SLIRecordingRulesGenerator metaRuleGen = prometheus . MetadataRecordingRulesGenerator } var alertRuleGen generate . SLOAlertRulesGenerator = generate . NoopSLOAlertRulesGenerator if ! disableAlerts { alertRuleGen = prometheus . SLOAlertRulesGenerator } controller , err := generate . NewService ( generate . ServiceConfig { AlertGenerator : alert . AlertGenerator , SLIRecordingRulesGenerator : sliRuleGen , MetaRecordingRulesGenerator : metaRuleGen , SLOAlertRulesGenerator : alertRuleGen , Logger : logger , } ) if err != nil { return nil , fmt . Errorf ( " " , err ) } result , err := controller . Generate ( ctx , generate . Request { ExtraLabels : extraLabels , Info : info , SLOGroup : slos , } ) if err != nil { return nil , fmt . Errorf ( " " , err ) } return result , nil }
generate is the main generator logic that all the spec types and storers share.
generate is the main generator logic that all the spec types and storers share .
// Disable recording rules if required. // Disable alert rules if required. // Generate.