-
Notifications
You must be signed in to change notification settings - Fork 48
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #18 from ihippik/new_golang
Refactoring
- Loading branch information
Showing
11 changed files
with
237 additions
and
78 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
package config | ||
|
||
import ( | ||
"github.com/prometheus/client_golang/prometheus" | ||
"github.com/prometheus/client_golang/prometheus/promauto" | ||
) | ||
|
||
// Metrics Prometheus metrics. | ||
type Metrics struct { | ||
filterSkippedEvents, publishedEvents *prometheus.CounterVec | ||
} | ||
|
||
// NewMetrics create and initialize new Prometheus metrics. | ||
func NewMetrics() *Metrics { | ||
return &Metrics{ | ||
publishedEvents: promauto.NewCounterVec(prometheus.CounterOpts{ | ||
Name: "published_events", | ||
Help: "The total number of published events", | ||
}, | ||
[]string{"app", "subject", "table"}, | ||
), | ||
filterSkippedEvents: promauto.NewCounterVec(prometheus.CounterOpts{ | ||
Name: "filter_skipped_events", | ||
Help: "The total number of skipped events", | ||
}, | ||
[]string{"app", "table"}, | ||
), | ||
} | ||
} | ||
|
||
const appName = "wal-listener" | ||
|
||
// IncPublishedEvents increment published events counter. | ||
func (m Metrics) IncPublishedEvents(subject, table string) { | ||
m.publishedEvents.With(prometheus.Labels{"app": appName, "subject": subject, "table": table}).Inc() | ||
} | ||
|
||
// IncFilterSkippedEvents increment skipped by filter events counter. | ||
func (m Metrics) IncFilterSkippedEvents(table string) { | ||
m.filterSkippedEvents.With(prometheus.Labels{"app": appName, "table": table}).Inc() | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
package listener | ||
|
||
type monitorMock struct{} | ||
|
||
func (m *monitorMock) IncPublishedEvents(subject, table string) {} | ||
|
||
func (m *monitorMock) IncFilterSkippedEvents(table string) {} |
Oops, something went wrong.