Skip to content

Commit

Permalink
Fix more golint warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
Felixoid committed Sep 29, 2021
1 parent e5be3d2 commit d0b41be
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 18 deletions.
12 changes: 6 additions & 6 deletions carbon/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ type App struct {
Pickle receiver.Receiver
Grpc receiver.Receiver
Prometheus receiver.Receiver
TelegrafHttpJson receiver.Receiver
TelegrafHTTPJSON receiver.Receiver
Collector *Collector // (!!!) Should be re-created on every change config/modules
writeChan chan *RowBinary.WriteBuffer
exit chan bool
Expand Down Expand Up @@ -129,9 +129,9 @@ func (app *App) stopListeners() {
logger.Debug("finished", zap.String("module", "prometheus"))
}

if app.TelegrafHttpJson != nil {
app.TelegrafHttpJson.Stop()
app.TelegrafHttpJson = nil
if app.TelegrafHTTPJSON != nil {
app.TelegrafHTTPJSON.Stop()
app.TelegrafHTTPJSON = nil
logger.Debug("finished", zap.String("module", "telegraf_http_json"))
}
}
Expand Down Expand Up @@ -336,7 +336,7 @@ func (app *App) Start() (err error) {
}

if conf.TelegrafHTTPJSON.Enabled {
app.TelegrafHttpJson, err = receiver.New(
app.TelegrafHTTPJSON, err = receiver.New(
"telegraf+http+json://"+conf.TelegrafHTTPJSON.Listen,
app.Config.TagDesc,
receiver.WriteChan(app.writeChan),
Expand All @@ -350,7 +350,7 @@ func (app *App) Start() (err error) {
return
}

http.HandleFunc("/debug/receive/telegraf_http_json/dropped/", app.TelegrafHttpJson.DroppedHandler)
http.HandleFunc("/debug/receive/telegraf_http_json/dropped/", app.TelegrafHTTPJSON.DroppedHandler)
}
/* RECEIVER end */

Expand Down
4 changes: 2 additions & 2 deletions carbon/collector.go
Original file line number Diff line number Diff line change
Expand Up @@ -101,8 +101,8 @@ func NewCollector(app *App) *Collector {
c.stats = append(c.stats, moduleCallback("prometheus", app.Prometheus))
}

if app.TelegrafHttpJson != nil {
c.stats = append(c.stats, moduleCallback("telegraf_http_json", app.TelegrafHttpJson))
if app.TelegrafHTTPJSON != nil {
c.stats = append(c.stats, moduleCallback("telegraf_http_json", app.TelegrafHTTPJSON))
}

for n, u := range app.Uploaders {
Expand Down
2 changes: 1 addition & 1 deletion receiver/receiver.go
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@ func New(dsn string, config tags.TagConfig, opts ...Option) (Receiver, error) {
return nil, err
}

r := &TelegrafHttpJson{
r := &TelegrafHTTPJSON{
Base: NewBase(logger, config),
}
r.applyOptions(opts...)
Expand Down
18 changes: 9 additions & 9 deletions receiver/telegraf_http_json.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,18 +17,18 @@ import (
"go.uber.org/zap"
)

type TelegrafHttpMetric struct {
type TelegrafHTTPMetric struct {
Name string `json:"name"`
Timestamp int64 `json:"timestamp"`
Fields map[string]interface{} `json:"fields"`
Tags map[string]string `json:"tags"`
}

type TelegrafHttpPayload struct {
Metrics []TelegrafHttpMetric `json:"metrics"`
type TelegrafHTTPPayload struct {
Metrics []TelegrafHTTPMetric `json:"metrics"`
}

type TelegrafHttpJson struct {
type TelegrafHTTPJSON struct {
Base
listener *net.TCPListener
}
Expand Down Expand Up @@ -73,14 +73,14 @@ func TelegrafEncodeTags(tags map[string]string) string {
return res.String()
}

func (rcv *TelegrafHttpJson) ServeHTTP(w http.ResponseWriter, r *http.Request) {
func (rcv *TelegrafHTTPJSON) ServeHTTP(w http.ResponseWriter, r *http.Request) {
body, err := ioutil.ReadAll(r.Body)
if err != nil {
http.Error(w, err.Error(), http.StatusInternalServerError)
return
}

var data TelegrafHttpPayload
var data TelegrafHTTPPayload
err = json.Unmarshal(body, &data)
if err != nil {
http.Error(w, err.Error(), http.StatusInternalServerError)
Expand Down Expand Up @@ -144,19 +144,19 @@ metricsLoop:
}

// Addr returns binded socket address. For bind port 0 in tests
func (rcv *TelegrafHttpJson) Addr() net.Addr {
func (rcv *TelegrafHTTPJSON) Addr() net.Addr {
if rcv.listener == nil {
return nil
}
return rcv.listener.Addr()
}

func (rcv *TelegrafHttpJson) Stat(send func(metric string, value float64)) {
func (rcv *TelegrafHTTPJSON) Stat(send func(metric string, value float64)) {
rcv.SendStat(send, "samplesReceived", "errors", "futureDropped", "pastDropped", "tooLongDropped")
}

// Listen bind port. Receive messages and send to out channel
func (rcv *TelegrafHttpJson) Listen(addr *net.TCPAddr) error {
func (rcv *TelegrafHTTPJSON) Listen(addr *net.TCPAddr) error {
return rcv.StartFunc(func() error {

tcpListener, err := net.ListenTCP("tcp", addr)
Expand Down

0 comments on commit d0b41be

Please sign in to comment.