From 12fe204ea6c2abce9cba287497c80cb45ee657fe Mon Sep 17 00:00:00 2001 From: Krasi Georgiev Date: Wed, 22 Aug 2018 13:41:11 +0300 Subject: [PATCH] move runtime debug funcs in own package (#4494) To make local debuging with `go run` easyer moved all files into a dedicate package `runtime`. This allows running prometheus just by using `go run main.go` instead of passing mani files like `go run main.go limits_default.go ...` Signed-off-by: Krasi Georgiev --- cmd/prometheus/main.go | 7 ++++--- {cmd/prometheus => pkg/runtime}/limits_default.go | 2 +- {cmd/prometheus => pkg/runtime}/limits_windows.go | 2 +- {cmd/prometheus => pkg/runtime}/uname_default.go | 2 +- {cmd/prometheus => pkg/runtime}/uname_linux.go | 2 +- {cmd/prometheus => pkg/runtime}/uname_linux_int8.go | 2 +- {cmd/prometheus => pkg/runtime}/uname_linux_uint8.go | 2 +- {cmd/prometheus => pkg/runtime}/vmlimits_default.go | 2 +- {cmd/prometheus => pkg/runtime}/vmlimits_openbsd.go | 2 +- 9 files changed, 12 insertions(+), 11 deletions(-) rename {cmd/prometheus => pkg/runtime}/limits_default.go (98%) rename {cmd/prometheus => pkg/runtime}/limits_windows.go (97%) rename {cmd/prometheus => pkg/runtime}/uname_default.go (97%) rename {cmd/prometheus => pkg/runtime}/uname_linux.go (98%) rename {cmd/prometheus => pkg/runtime}/uname_linux_int8.go (98%) rename {cmd/prometheus => pkg/runtime}/uname_linux_uint8.go (98%) rename {cmd/prometheus => pkg/runtime}/vmlimits_default.go (98%) rename {cmd/prometheus => pkg/runtime}/vmlimits_openbsd.go (97%) diff --git a/cmd/prometheus/main.go b/cmd/prometheus/main.go index 16227eddb..d090464a3 100644 --- a/cmd/prometheus/main.go +++ b/cmd/prometheus/main.go @@ -39,6 +39,7 @@ import ( "github.com/prometheus/client_golang/prometheus" "github.com/prometheus/common/model" "github.com/prometheus/common/version" + prom_runtime "github.com/prometheus/prometheus/pkg/runtime" "gopkg.in/alecthomas/kingpin.v2" k8s_runtime "k8s.io/apimachinery/pkg/util/runtime" @@ -229,9 +230,9 @@ func main() { level.Info(logger).Log("msg", "Starting Prometheus", "version", version.Info()) level.Info(logger).Log("build_context", version.BuildContext()) - level.Info(logger).Log("host_details", Uname()) - level.Info(logger).Log("fd_limits", FdLimits()) - level.Info(logger).Log("vm_limits", VmLimits()) + level.Info(logger).Log("host_details", prom_runtime.Uname()) + level.Info(logger).Log("fd_limits", prom_runtime.FdLimits()) + level.Info(logger).Log("vm_limits", prom_runtime.VmLimits()) var ( localStorage = &tsdb.ReadyStorage{} diff --git a/cmd/prometheus/limits_default.go b/pkg/runtime/limits_default.go similarity index 98% rename from cmd/prometheus/limits_default.go rename to pkg/runtime/limits_default.go index 054b72525..fb32d4b05 100644 --- a/cmd/prometheus/limits_default.go +++ b/pkg/runtime/limits_default.go @@ -13,7 +13,7 @@ // +build !windows -package main +package runtime import ( "fmt" diff --git a/cmd/prometheus/limits_windows.go b/pkg/runtime/limits_windows.go similarity index 97% rename from cmd/prometheus/limits_windows.go rename to pkg/runtime/limits_windows.go index d18d58041..32387131d 100644 --- a/cmd/prometheus/limits_windows.go +++ b/pkg/runtime/limits_windows.go @@ -13,7 +13,7 @@ // +build windows -package main +package runtime // FdLimits not supported on Windows func FdLimits() string { diff --git a/cmd/prometheus/uname_default.go b/pkg/runtime/uname_default.go similarity index 97% rename from cmd/prometheus/uname_default.go rename to pkg/runtime/uname_default.go index bc7f0502c..595a4a28c 100644 --- a/cmd/prometheus/uname_default.go +++ b/pkg/runtime/uname_default.go @@ -13,7 +13,7 @@ // +build !linux -package main +package runtime import "runtime" diff --git a/cmd/prometheus/uname_linux.go b/pkg/runtime/uname_linux.go similarity index 98% rename from cmd/prometheus/uname_linux.go rename to pkg/runtime/uname_linux.go index 4a4305663..aa6fa6ee0 100644 --- a/cmd/prometheus/uname_linux.go +++ b/pkg/runtime/uname_linux.go @@ -11,7 +11,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -package main +package runtime import ( "log" diff --git a/cmd/prometheus/uname_linux_int8.go b/pkg/runtime/uname_linux_int8.go similarity index 98% rename from cmd/prometheus/uname_linux_int8.go rename to pkg/runtime/uname_linux_int8.go index 210e55c93..aa6680a59 100644 --- a/cmd/prometheus/uname_linux_int8.go +++ b/pkg/runtime/uname_linux_int8.go @@ -14,7 +14,7 @@ // +build 386 amd64 arm64 mips64 mips64le mips mipsle // +build linux -package main +package runtime func charsToString(ca []int8) string { s := make([]byte, 0, len(ca)) diff --git a/cmd/prometheus/uname_linux_uint8.go b/pkg/runtime/uname_linux_uint8.go similarity index 98% rename from cmd/prometheus/uname_linux_uint8.go rename to pkg/runtime/uname_linux_uint8.go index e7282923e..d52d521f7 100644 --- a/cmd/prometheus/uname_linux_uint8.go +++ b/pkg/runtime/uname_linux_uint8.go @@ -14,7 +14,7 @@ // +build arm ppc64 ppc64le s390x // +build linux -package main +package runtime func charsToString(ca []uint8) string { s := make([]byte, 0, len(ca)) diff --git a/cmd/prometheus/vmlimits_default.go b/pkg/runtime/vmlimits_default.go similarity index 98% rename from cmd/prometheus/vmlimits_default.go rename to pkg/runtime/vmlimits_default.go index 5a3a6802d..60ab7757b 100644 --- a/cmd/prometheus/vmlimits_default.go +++ b/pkg/runtime/vmlimits_default.go @@ -14,7 +14,7 @@ // +build !windows // +build !openbsd -package main +package runtime import ( "syscall" diff --git a/cmd/prometheus/vmlimits_openbsd.go b/pkg/runtime/vmlimits_openbsd.go similarity index 97% rename from cmd/prometheus/vmlimits_openbsd.go rename to pkg/runtime/vmlimits_openbsd.go index b033e6421..981f1bcf8 100644 --- a/cmd/prometheus/vmlimits_openbsd.go +++ b/pkg/runtime/vmlimits_openbsd.go @@ -13,7 +13,7 @@ // +build openbsd -package main +package runtime import ( "syscall"