Skip to content

Commit

Permalink
linting errors fixed
Browse files Browse the repository at this point in the history
  • Loading branch information
khushijain21 committed Jan 9, 2025
1 parent 5ca4fae commit 9d4dfa0
Showing 1 changed file with 13 additions and 5 deletions.
18 changes: 13 additions & 5 deletions libbeat/otelbeat/beatconverter/beatconverter.go
Original file line number Diff line number Diff line change
Expand Up @@ -159,31 +159,39 @@ func httpPPROFEndpoint(accessString string, conf *confmap.Conf) error {
if v := conf.Get(accessString + "::http::pprof::enabled"); v != nil {
if v.(bool) {
var httpHost string
var httpPort int
var httpPort uint64

// Get http.host if set
if v := conf.Get(accessString + "::http::host"); v != nil {
httpHost = v.(string)
httpHost = v.(string) //nolint:errheck //we know this will always be a string

Check failure on line 166 in libbeat/otelbeat/beatconverter/beatconverter.go

View workflow job for this annotation

GitHub Actions / lint (windows)

Error return value is not checked (errcheck)
} else {
httpHost = "localhost"
}

// Get http.port if set
if v := conf.Get(accessString + "::http::port"); v != nil {
httpPort = v.(int)
switch v := v.(type) {
case uint64:
httpPort = v
case int: // we have only have this case from tests
httpPort = uint64(v) // Convert int to uint64
}
} else {
httpPort = 5066
}

// add pprof extension
out := map[string]any{
"extensions": map[string]any{
"pprof": map[string]any{
"endpoint": httpHost + ":" + strconv.Itoa(httpPort),
"endpoint": httpHost + ":" + strconv.FormatUint(httpPort, 10),
},
},
"service": map[string]any{
"extensions": []string{"pprof"}},
}

err := conf.Merge(confmap.NewFromStringMap(out))

if err != nil {
return err
}
Expand Down

0 comments on commit 9d4dfa0

Please sign in to comment.