Skip to content

Commit

Permalink
[Ajat|Baskara] add InitializeStatsdCollector function
Browse files Browse the repository at this point in the history
  • Loading branch information
ajatprabha committed Jul 1, 2019
1 parent 7567fa9 commit 5e77be3
Show file tree
Hide file tree
Showing 4 changed files with 94 additions and 13 deletions.
1 change: 1 addition & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ require (
github.com/anthonynsimon/bild v0.10.0
github.com/aws/aws-sdk-go v1.20.0
github.com/axw/gocov v0.0.0-20170322000131-3a69a0d2a4ef // indirect
github.com/cactus/go-statsd-client/statsd v0.0.0-20190501063751-9a7692639588
github.com/gojektech/heimdall v5.0.2+incompatible
github.com/gopherjs/gopherjs v0.0.0-20190430165422-3e4dfb77656c // indirect
github.com/gorilla/mux v1.7.2
Expand Down
16 changes: 3 additions & 13 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,11 @@ github.com/aws/aws-sdk-go v1.19.41 h1:veutzvQP/lOmYmtX26S9mTFJLO6sp7/UsxFcCjglu4
github.com/aws/aws-sdk-go v1.19.41/go.mod h1:KmX6BPdI08NWTb3/sm4ZGu5ShLoqVDhKgpiN924inxo=
github.com/aws/aws-sdk-go v1.20.0 h1:t74VM7opfCwwbe+wg6eys4a2wLqky6Znitr7BsqYPUg=
github.com/aws/aws-sdk-go v1.20.0/go.mod h1:KmX6BPdI08NWTb3/sm4ZGu5ShLoqVDhKgpiN924inxo=
github.com/axw/gocov v0.0.0-20170322000131-3a69a0d2a4ef h1:kh7Fi8sfEY7aCl42VEEvGv7lez2YCOmO120N1fASWGc=
github.com/axw/gocov v0.0.0-20170322000131-3a69a0d2a4ef/go.mod h1:pc6XrbIn8RLeVSNzXCZKXNst+RTE5Ju/nySYl1Wc0B4=
github.com/beorn7/perks v0.0.0-20180321164747-3a771d992973/go.mod h1:Dwedo/Wpr24TaqPxmxbtue+5NUziq4I4S80YR8gNf3Q=
github.com/beorn7/perks v1.0.0/go.mod h1:KWe93zE9D1o94FZ5RNwFwVgaQK1VOXiVxmqh+CedLV8=
github.com/cactus/go-statsd-client/statsd v0.0.0-20190501063751-9a7692639588 h1:6yVhh6P5OsW6HutPt7z2ggDgZczgUtSl2kGRe+DslPU=
github.com/cactus/go-statsd-client/statsd v0.0.0-20190501063751-9a7692639588/go.mod h1:3/sdo8I67TaOslRGJ6FqQC/ynu+wg7H6IE4WYtr51hk=
github.com/cespare/xxhash v1.1.0/go.mod h1:XrSqR1VqqWfGrhpAt58auRo0WTKS1nRRg3ghfAqPWnc=
github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDkc90ppPyw=
github.com/coreos/bbolt v1.3.2/go.mod h1:iRUV2dpdMOn7Bo10OQBFzIJO9kkE559Wcmn+qkEiiKk=
Expand Down Expand Up @@ -153,6 +154,7 @@ golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn
golang.org/x/net v0.0.0-20190522155817-f3200d17e092/go.mod h1:HSz+uSET+XFnRR8LxR5pz3Of3rY3CfYBVs4xY44aLks=
golang.org/x/net v0.0.0-20190603091049-60506f45cf65 h1:+rhAzEzT3f4JtomfC371qB+0Ola2caSKcY69NUBZrRQ=
golang.org/x/net v0.0.0-20190603091049-60506f45cf65/go.mod h1:HSz+uSET+XFnRR8LxR5pz3Of3rY3CfYBVs4xY44aLks=
golang.org/x/net v0.0.0-20190613194153-d28f0bde5980 h1:dfGZHvZk057jK2MCeWus/TowKpJ8y4AmooUzdBSR9GU=
golang.org/x/net v0.0.0-20190613194153-d28f0bde5980/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U=
golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
Expand All @@ -169,10 +171,6 @@ golang.org/x/sys v0.0.0-20190422165155-953cdadca894 h1:Cz4ceDQGXuKRnVBDTS23GTn/p
golang.org/x/sys v0.0.0-20190422165155-953cdadca894/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20190602015325-4c4f7f33c9ed h1:uPxWBzB3+mlnjy9W58qY1j/cjyFjutgw/Vhan2zLy/A=
golang.org/x/sys v0.0.0-20190602015325-4c4f7f33c9ed/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20190606203320-7fc4e5ec1444 h1:/d2cWp6PSamH4jDPFLyO150psQdqvtoNX8Zjg3AQ31g=
golang.org/x/sys v0.0.0-20190606203320-7fc4e5ec1444/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20190613124609-5ed2794edfdc h1:x+/QxSNkVFAC+v4pL1f6mZr1z+qgi+FoR8ccXZPVC10=
golang.org/x/sys v0.0.0-20190613124609-5ed2794edfdc/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20190614084037-d442b75600c5 h1:tQrtnaPeNyfkuD2UMixVD6lAa7WngkIFvtWcdzNeq80=
golang.org/x/sys v0.0.0-20190614084037-d442b75600c5/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20190616124812-15dcb6c0061f h1:25KHgbfyiSm6vwQLbM3zZIe1v9p/3ea4Rz+nnM5K/i4=
Expand Down Expand Up @@ -206,11 +204,3 @@ gopkg.in/yaml.v2 v2.2.1/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
gopkg.in/yaml.v2 v2.2.2 h1:ZCJp+EgiOT7lHqUV2J862kp8Qj64Jo6az82+3Td9dZw=
gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
honnef.co/go/tools v0.0.0-20190102054323-c2f93a96b099/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4=
***REMOVED***/darkroom/processor v0.0.0-20190604220844-8998e602f28b h1:dvtmqlsN34VyZcAXP1ircct0NGgWqpLJqm7IfoiQnYM=
***REMOVED***/darkroom/processor v0.0.0-20190604220844-8998e602f28b/go.mod h1:TErx/48SxCZLmQq6p07/vta7ShgvMmVIdXf/F9qMUSw=
***REMOVED***/darkroom/processor v0.0.0-20190612103256-1f5dcc37d42e h1:i2oJSgi3r3QaZO+kASiERlZ2qCdjMI7uIw32EQDPS/U=
***REMOVED***/darkroom/processor v0.0.0-20190612103256-1f5dcc37d42e/go.mod h1:NgSqk17vuDzUgj52m8M4Z+dalMC6NNTF3X33sxC9xvI=
***REMOVED***/darkroom/storage v0.0.0-20190612112358-fbb223f17cd6 h1:BTdbY8rCvxTJ9CSUkkGnANOaCDaHjnnAST/xzBYdkUE=
***REMOVED***/darkroom/storage v0.0.0-20190612112358-fbb223f17cd6/go.mod h1:+VBb5Se0pdqt67J9YKYAoljSUk4R1YWJWcJ6w92Jwsw=
***REMOVED***/darkroom/storage v0.0.0-20190613152558-7fe54b92b0d4 h1:oNflc4xiwLM6W4UxeC16GhdYJfCsTyax8gO5EDmeGqc=
***REMOVED***/darkroom/storage v0.0.0-20190613152558-7fe54b92b0d4/go.mod h1:+VBb5Se0pdqt67J9YKYAoljSUk4R1YWJWcJ6w92Jwsw=
25 changes: 25 additions & 0 deletions pkg/plugins/statsd_collector.go
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
}
65 changes: 65 additions & 0 deletions pkg/plugins/statsd_collector_test.go
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")
}

0 comments on commit 5e77be3

Please sign in to comment.