-
Notifications
You must be signed in to change notification settings - Fork 38
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Ajat|Baskara] add InitializeStatsdCollector function
- Loading branch information
1 parent
7567fa9
commit 5e77be3
Showing
4 changed files
with
94 additions
and
13 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
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,25 @@ | ||
package plugins | ||
|
||
|
||
import ( | ||
"github.com/cactus/go-statsd-client/statsd" | ||
) | ||
|
||
type StatsdCollectorClient struct { | ||
client statsd.Statter | ||
sampleRate float32 | ||
} | ||
|
||
// StatsdCollectorConfig provides configuration that the Statsd client will need. | ||
type StatsdCollectorConfig struct { | ||
// StatsdAddr is the tcp address of the Statsd server | ||
StatsdAddr string | ||
// Prefix is the prefix that will be prepended to all metrics sent from this collector. | ||
Prefix string | ||
// StatsdSampleRate sets statsd sampling. If 0, defaults to 1.0. (no sampling) | ||
SampleRate float32 | ||
} | ||
|
||
func InitializeStatsdCollector(config *StatsdCollectorConfig) (*StatsdCollectorClient, error) { | ||
return &StatsdCollectorClient{}, nil | ||
} |
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,65 @@ | ||
package plugins | ||
|
||
import ( | ||
"github.com/cactus/go-statsd-client/statsd" | ||
"github.com/stretchr/testify/assert" | ||
"testing" | ||
"time" | ||
) | ||
|
||
func TestInitializeStatsdCollector(t *testing.T) { | ||
scc, err := InitializeStatsdCollector(&StatsdCollectorConfig{}) | ||
assert.Nil(t, err) | ||
assert.NotNil(t, scc) | ||
} | ||
|
||
type mockStatsdClient struct { | ||
} | ||
|
||
func (msc *mockStatsdClient) Inc(string, int64, float32) error { | ||
panic("implement me") | ||
} | ||
|
||
func (msc *mockStatsdClient) Dec(string, int64, float32) error { | ||
panic("implement me") | ||
} | ||
|
||
func (msc *mockStatsdClient) Gauge(string, int64, float32) error { | ||
panic("implement me") | ||
} | ||
|
||
func (msc *mockStatsdClient) GaugeDelta(string, int64, float32) error { | ||
panic("implement me") | ||
} | ||
|
||
func (msc *mockStatsdClient) Timing(string, int64, float32) error { | ||
panic("implement me") | ||
} | ||
|
||
func (msc *mockStatsdClient) TimingDuration(string, time.Duration, float32) error { | ||
panic("implement me") | ||
} | ||
|
||
func (msc *mockStatsdClient) Set(string, string, float32) error { | ||
panic("implement me") | ||
} | ||
|
||
func (msc *mockStatsdClient) SetInt(string, int64, float32) error { | ||
panic("implement me") | ||
} | ||
|
||
func (msc *mockStatsdClient) Raw(string, string, float32) error { | ||
panic("implement me") | ||
} | ||
|
||
func (msc *mockStatsdClient) NewSubStatter(string) statsd.SubStatter { | ||
panic("implement me") | ||
} | ||
|
||
func (msc *mockStatsdClient) SetPrefix(string) { | ||
panic("implement me") | ||
} | ||
|
||
func (msc *mockStatsdClient) Close() error { | ||
panic("implement me") | ||
} |