Skip to content

Commit

Permalink
obey linter
Browse files Browse the repository at this point in the history
  • Loading branch information
mterhar committed Dec 14, 2024
1 parent 8372460 commit 6230172
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 17 deletions.
3 changes: 1 addition & 2 deletions receiver/libhoneyreceiver/encoder.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,10 @@ import (
"bytes"

"github.com/gogo/protobuf/jsonpb"
spb "google.golang.org/genproto/googleapis/rpc/status"

"go.opentelemetry.io/collector/pdata/plog/plogotlp"
"go.opentelemetry.io/collector/pdata/pmetric/pmetricotlp"
"go.opentelemetry.io/collector/pdata/ptrace/ptraceotlp"
spb "google.golang.org/genproto/googleapis/rpc/status"
)

const (
Expand Down
1 change: 0 additions & 1 deletion receiver/libhoneyreceiver/internal/eventtime/eventtime.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ func GetEventTime(etHeader string) time.Time {
sec, dec := math.Modf(epochFloat)
eventTime = time.Unix(int64(sec), int64(dec*(1e9)))
}

}
} else {
epochFloat, err := strconv.ParseFloat(etHeader, 64)
Expand Down
8 changes: 4 additions & 4 deletions receiver/libhoneyreceiver/internal/simplespan/simplespan.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,10 +44,10 @@ type AttributesConfig struct {
}

type SimpleSpan struct {
Samplerate int `json:"samplerate" msgpack:"samplerate"`
MsgPackTimestamp *time.Time `msgpack:"time"`
Time string `json:"time"` // should not be trusted. use MsgPackTimestamp
Data map[string]interface{} `json:"data" msgpack:"data"`
Samplerate int `json:"samplerate" msgpack:"samplerate"`
MsgPackTimestamp *time.Time `msgpack:"time"`
Time string `json:"time"` // should not be trusted. use MsgPackTimestamp
Data map[string]any `json:"data" msgpack:"data"`
}

// Overrides unmarshall to make sure the MsgPackTimestamp is set
Expand Down
6 changes: 3 additions & 3 deletions receiver/libhoneyreceiver/libhoneyparser.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ func getDatasetFromRequest(path string) (string, error) {
return dataset, nil
}

func toPsomething(dataset string, ss []simplespan.SimpleSpan, cfg Config, logger zap.Logger) (plog.Logs, error) {
func toPsomething(dataset string, ss []simplespan.SimpleSpan, cfg Config, logger zap.Logger) plog.Logs {
foundServices := simplespan.ServiceHistory{}
foundServices.NameCount = make(map[string]int)
foundScopes := simplespan.ScopeHistory{}
Expand Down Expand Up @@ -103,7 +103,7 @@ func toPsomething(dataset string, ss []simplespan.SimpleSpan, cfg Config, logger
logService, _ := span.GetService(cfg.FieldMapConfig, &foundServices, dataset)
logScopeKey, _ := span.GetScope(cfg.FieldMapConfig, &foundScopes, logService) // adds a new found scope if needed
newLog := foundScopes.Scope[logScopeKey].ScopeLogs.AppendEmpty()
span.ToPLogRecord(&newLog, &already_used_fields, logger)
err := span.ToPLogRecord(&newLog, &already_used_fields, logger)
if err != nil {
logger.Warn("log could not be converted from libhoney to plog", zap.String("span.object", span.DebugString()))
}
Expand All @@ -125,5 +125,5 @@ func toPsomething(dataset string, ss []simplespan.SimpleSpan, cfg Config, logger
}
}

return resultLogs, nil
return resultLogs
}
16 changes: 9 additions & 7 deletions receiver/libhoneyreceiver/receiver.go
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,10 @@ func (r *libhoneyReceiver) startHTTPServer(ctx context.Context, host component.H
return
}
authRawBody, _ := io.ReadAll(authResp.Body)
resp.Write(authRawBody)
_, err = resp.Write(authRawBody)
if err != nil {
r.settings.Logger.Info("couldn't write http response")
}
})
}

Expand Down Expand Up @@ -201,7 +204,10 @@ func (r *libhoneyReceiver) handleSomething(resp http.ResponseWriter, req *http.R
case "application/x-msgpack", "application/msgpack":
decoder := msgpack.NewDecoder(bytes.NewReader(body))
decoder.UseLooseInterfaceDecoding(true)
decoder.Decode(&simpleSpans)
err = decoder.Decode(&simpleSpans)
if err != nil {
r.settings.Logger.Info("messagepack decoding failed")
}
if len(simpleSpans) > 0 {
r.settings.Logger.Debug("Decoding with msgpack worked", zap.Time("timestamp.first.msgpacktimestamp", *simpleSpans[0].MsgPackTimestamp), zap.String("timestamp.first.time", simpleSpans[0].Time))
r.settings.Logger.Debug("span zero", zap.String("span.data", simpleSpans[0].DebugString()))
Expand All @@ -216,11 +222,7 @@ func (r *libhoneyReceiver) handleSomething(resp http.ResponseWriter, req *http.R
}
}

otlpLogs, err := toPsomething(dataset, simpleSpans, *r.cfg, *r.settings.Logger)
if err != nil {
errorutil.HTTPError(resp, err)
return
}
otlpLogs := toPsomething(dataset, simpleSpans, *r.cfg, *r.settings.Logger)

numLogs := otlpLogs.LogRecordCount()
if numLogs > 0 {
Expand Down

0 comments on commit 6230172

Please sign in to comment.