Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Export NoopMetricsProvider #11

Merged
merged 1 commit into from
Jul 12, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion config.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ func (config *Config) setDefaults() {
config.Logger = NewBasicLogger(false)
}
if config.MetricsProvider == nil {
config.MetricsProvider = &noopMetricsProvider{}
config.MetricsProvider = &NoopMetricsProvider{}
}
if config.MetricsUpdateInterval == 0 {
config.MetricsUpdateInterval = 15 * time.Second
Expand Down
2 changes: 1 addition & 1 deletion elasticsearch_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ func init() {
config := &Config{
TopicProcessorName: "test",
Logger: &noopLogger{},
MetricsProvider: &noopMetricsProvider{},
MetricsProvider: &NoopMetricsProvider{},
}
url := fmt.Sprintf("http://%s:9200", getCIHost())
client, err := elastic.NewClient(
Expand Down
4 changes: 2 additions & 2 deletions multi_elasticsearch_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ func TestMultiElasticsearch(t *testing.T) {
config := &Config{
TopicProcessorName: "test",
Logger: &noopLogger{},
MetricsProvider: &noopMetricsProvider{},
MetricsProvider: &NoopMetricsProvider{},
}
url := fmt.Sprintf("http://%s:9200", getCIHost())
client, err := elastic.NewClient(
Expand All @@ -38,7 +38,7 @@ func TestMultiElasticsearch_PutAll_GetAll(t *testing.T) {
config := &Config{
TopicProcessorName: "test",
Logger: &noopLogger{},
MetricsProvider: &noopMetricsProvider{},
MetricsProvider: &NoopMetricsProvider{},
}
url := fmt.Sprintf("http://%s:9200", getCIHost())
client, err := elastic.NewClient(
Expand Down
4 changes: 2 additions & 2 deletions multi_redis_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ func TestMultiRedis(t *testing.T) {
config := &Config{
TopicProcessorName: "test",
Logger: &noopLogger{},
MetricsProvider: &noopMetricsProvider{},
MetricsProvider: &NoopMetricsProvider{},
}
url := fmt.Sprintf("redis://%s:6379", getCIHost())
conn, err := redis.DialURL(url)
Expand All @@ -27,7 +27,7 @@ func TestMultiRedis_PutAll_GetAll(t *testing.T) {
config := &Config{
TopicProcessorName: "test",
Logger: &noopLogger{},
MetricsProvider: &noopMetricsProvider{},
MetricsProvider: &NoopMetricsProvider{},
}
url := fmt.Sprintf("redis://%s:6379", getCIHost())
conn, err := redis.DialURL(url)
Expand Down
13 changes: 9 additions & 4 deletions noop_metrics.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,16 +12,21 @@ func (m *noopMetric) Add(value float64, labelValues ...string) {}

func (m *noopMetric) Observe(value float64, labelValues ...string) {}

type noopMetricsProvider struct{}
// NoopMetricsProvider is a dummy implementation of MetricsProvider that does nothing.
// Useful for testing, not recommended in production.
type NoopMetricsProvider struct{}

func (m *noopMetricsProvider) NewCounter(name string, help string, labelNames ...string) Counter {
// NewCounter creates a new no-op Counter
func (m *NoopMetricsProvider) NewCounter(name string, help string, labelNames ...string) Counter {
return &noopMetric{len(labelNames)}
}

func (m *noopMetricsProvider) NewGauge(name string, help string, labelNames ...string) Gauge {
// NewGauge creates a new no-op Gauge
func (m *NoopMetricsProvider) NewGauge(name string, help string, labelNames ...string) Gauge {
return &noopMetric{len(labelNames)}
}

func (m *noopMetricsProvider) NewSummary(name string, help string, labelNames ...string) Summary {
// NewSummary creates a new no-op Summary
func (m *NoopMetricsProvider) NewSummary(name string, help string, labelNames ...string) Summary {
return &noopMetric{len(labelNames)}
}
2 changes: 1 addition & 1 deletion redis_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ func init() {
config := &Config{
TopicProcessorName: "test",
Logger: &noopLogger{},
MetricsProvider: &noopMetricsProvider{},
MetricsProvider: &NoopMetricsProvider{},
}
url := fmt.Sprintf("redis://%s:6379", getCIHost())
conn, err := redis.DialURL(url)
Expand Down