Add license header to fix CI

Signed-off-by: Mustafain Ali Khan <mustalik@amazon.com>
This commit is contained in:
Mustafain Ali Khan 2024-12-12 13:50:47 -08:00
parent 0736877480
commit c432672c14
4 changed files with 32 additions and 3 deletions

View file

@ -42,6 +42,7 @@ const (
alertMetricName = "ALERTS" alertMetricName = "ALERTS"
// AlertForStateMetricName is the metric name for 'for' state of alert. // AlertForStateMetricName is the metric name for 'for' state of alert.
alertForStateMetricName = "ALERTS_FOR_STATE" alertForStateMetricName = "ALERTS_FOR_STATE"
// AlertStateLabel is the label name indicating the state of an alert. // AlertStateLabel is the label name indicating the state of an alert.
alertStateLabel = "alertstate" alertStateLabel = "alertstate"
) )
@ -577,6 +578,8 @@ func (r *AlertingRule) sendAlerts(ctx context.Context, ts time.Time, resendDelay
notifyFunc(ctx, r.vector.String(), alerts...) notifyFunc(ctx, r.vector.String(), alerts...)
} }
// Note that changing format of String() changes value of GetFingerprint() leading to loss of persisted state
// when the `alert-state-persistence` feature is enabled.
func (r *AlertingRule) String() string { func (r *AlertingRule) String() string {
ar := rulefmt.Rule{ ar := rulefmt.Rule{
Alert: r.name, Alert: r.name,

View file

@ -129,7 +129,7 @@ type ManagerOptions struct {
RuleDependencyController RuleDependencyController RuleDependencyController RuleDependencyController
AlertStore AlertStore AlertStore AlertStore
Metrics *Metrics Metrics *Metrics
} }
// NewManager returns an implementation of Manager, ready to be started // NewManager returns an implementation of Manager, ready to be started

View file

@ -1,3 +1,16 @@
// Copyright 2024 The Prometheus Authors
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package rules package rules
import ( import (
@ -65,9 +78,9 @@ func (s *FileStore) initState(registerer prometheus.Registerer) {
var data *FileData var data *FileData
err = json.NewDecoder(file).Decode(&data) err = json.NewDecoder(file).Decode(&data)
if err != nil { if err != nil {
data = nil
s.logger.Error("Failed reading alerts state from file", "err", err) s.logger.Error("Failed reading alerts state from file", "err", err)
s.storeInitErrors.Inc() s.storeInitErrors.Inc()
return
} }
alertsByRule := make(map[uint64][]*Alert) alertsByRule := make(map[uint64][]*Alert)
if data != nil && data.Alerts != nil { if data != nil && data.Alerts != nil {

View file

@ -1,3 +1,16 @@
// Copyright 2024 The Prometheus Authors
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package rules package rules
import ( import (
@ -6,9 +19,9 @@ import (
"time" "time"
"github.com/prometheus/client_golang/prometheus" "github.com/prometheus/client_golang/prometheus"
"github.com/prometheus/common/promslog"
"github.com/stretchr/testify/require" "github.com/stretchr/testify/require"
"github.com/prometheus/common/promslog"
"github.com/prometheus/prometheus/model/labels" "github.com/prometheus/prometheus/model/labels"
) )