Export newMetrics function and metrics struct (#2523)

Signed-off-by: Ganesh Vernekar <ganeshvern@gmail.com>
This commit is contained in:
Ganesh Vernekar 2021-03-24 12:37:58 +05:30 committed by GitHub
parent 72deec44a8
commit 10757eb5fb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 11 additions and 11 deletions

View File

@ -231,7 +231,7 @@ type NotificationLog interface {
Query(params ...nflog.QueryParam) ([]*nflogpb.Entry, error) Query(params ...nflog.QueryParam) ([]*nflogpb.Entry, error)
} }
type metrics struct { type Metrics struct {
numNotifications *prometheus.CounterVec numNotifications *prometheus.CounterVec
numTotalFailedNotifications *prometheus.CounterVec numTotalFailedNotifications *prometheus.CounterVec
numNotificationRequestsTotal *prometheus.CounterVec numNotificationRequestsTotal *prometheus.CounterVec
@ -239,8 +239,8 @@ type metrics struct {
notificationLatencySeconds *prometheus.HistogramVec notificationLatencySeconds *prometheus.HistogramVec
} }
func newMetrics(r prometheus.Registerer) *metrics { func NewMetrics(r prometheus.Registerer) *Metrics {
m := &metrics{ m := &Metrics{
numNotifications: prometheus.NewCounterVec(prometheus.CounterOpts{ numNotifications: prometheus.NewCounterVec(prometheus.CounterOpts{
Namespace: "alertmanager", Namespace: "alertmanager",
Name: "notifications_total", Name: "notifications_total",
@ -293,12 +293,12 @@ func newMetrics(r prometheus.Registerer) *metrics {
} }
type PipelineBuilder struct { type PipelineBuilder struct {
metrics *metrics metrics *Metrics
} }
func NewPipelineBuilder(r prometheus.Registerer) *PipelineBuilder { func NewPipelineBuilder(r prometheus.Registerer) *PipelineBuilder {
return &PipelineBuilder{ return &PipelineBuilder{
metrics: newMetrics(r), metrics: NewMetrics(r),
} }
} }
@ -332,7 +332,7 @@ func createReceiverStage(
integrations []Integration, integrations []Integration,
wait func() time.Duration, wait func() time.Duration,
notificationLog NotificationLog, notificationLog NotificationLog,
metrics *metrics, metrics *Metrics,
) Stage { ) Stage {
var fs FanoutStage var fs FanoutStage
for i := range integrations { for i := range integrations {
@ -638,11 +638,11 @@ func (n *DedupStage) Exec(ctx context.Context, _ log.Logger, alerts ...*types.Al
type RetryStage struct { type RetryStage struct {
integration Integration integration Integration
groupName string groupName string
metrics *metrics metrics *Metrics
} }
// NewRetryStage returns a new instance of a RetryStage. // NewRetryStage returns a new instance of a RetryStage.
func NewRetryStage(i Integration, groupName string, metrics *metrics) *RetryStage { func NewRetryStage(i Integration, groupName string, metrics *Metrics) *RetryStage {
return &RetryStage{ return &RetryStage{
integration: i, integration: i,
groupName: groupName, groupName: groupName,

View File

@ -392,7 +392,7 @@ func TestRetryStageWithError(t *testing.T) {
} }
r := RetryStage{ r := RetryStage{
integration: i, integration: i,
metrics: newMetrics(prometheus.NewRegistry()), metrics: NewMetrics(prometheus.NewRegistry()),
} }
alerts := []*types.Alert{ alerts := []*types.Alert{
@ -433,7 +433,7 @@ func TestRetryStageNoResolved(t *testing.T) {
} }
r := RetryStage{ r := RetryStage{
integration: i, integration: i,
metrics: newMetrics(prometheus.NewRegistry()), metrics: NewMetrics(prometheus.NewRegistry()),
} }
alerts := []*types.Alert{ alerts := []*types.Alert{
@ -487,7 +487,7 @@ func TestRetryStageSendResolved(t *testing.T) {
} }
r := RetryStage{ r := RetryStage{
integration: i, integration: i,
metrics: newMetrics(prometheus.NewRegistry()), metrics: NewMetrics(prometheus.NewRegistry()),
} }
alerts := []*types.Alert{ alerts := []*types.Alert{