From 9d4dfa064a09b7eaf5dd85bee07ca55da8dcb56b Mon Sep 17 00:00:00 2001 From: Khushi Jain Date: Thu, 9 Jan 2025 16:10:37 +0530 Subject: [PATCH] linting errors fixed --- .../otelbeat/beatconverter/beatconverter.go | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/libbeat/otelbeat/beatconverter/beatconverter.go b/libbeat/otelbeat/beatconverter/beatconverter.go index 02be14f11c5e..9da10ae69d47 100644 --- a/libbeat/otelbeat/beatconverter/beatconverter.go +++ b/libbeat/otelbeat/beatconverter/beatconverter.go @@ -159,23 +159,32 @@ 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 } 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{ @@ -183,7 +192,6 @@ func httpPPROFEndpoint(accessString string, conf *confmap.Conf) error { } err := conf.Merge(confmap.NewFromStringMap(out)) - if err != nil { return err }