From 42ec8f7d69f33b3ac81e40c79170a4c4c2662779 Mon Sep 17 00:00:00 2001 From: Josh Carp Date: Thu, 6 Jul 2023 22:05:22 -0400 Subject: [PATCH] pkg/metrics: use experimental native histograms. Bump client_golang to latest and optionally enable prometheus native histograms using the default exponential bucket factor. Note that native histograms currently use the protobuf exposition format, so we add content negotiation to the prometheus exporter. Note: just an experiment! --- DEPS.bzl | 86 ++++++++++++------- build/bazelutil/distdir_files.bzl | 24 +++--- go.mod | 20 ++--- go.sum | 40 +++++---- pkg/ccl/sqlproxyccl/BUILD.bazel | 1 + pkg/ccl/sqlproxyccl/server.go | 6 +- .../clusterstats/mocks_generated_test.go | 26 ++++-- pkg/cmd/roachtest/tests/drt_generated_test.go | 26 ++++-- pkg/kv/kvserver/BUILD.bazel | 1 + pkg/kv/kvserver/client_tenant_test.go | 3 +- pkg/roachprod/prometheus/prometheus.go | 4 +- pkg/server/BUILD.bazel | 1 + pkg/server/load_endpoint.go | 7 +- pkg/server/load_endpoint_test.go | 6 +- pkg/server/status.go | 8 +- pkg/server/status/BUILD.bazel | 2 + pkg/server/status/recorder.go | 5 +- pkg/server/status/recorder_test.go | 11 +-- pkg/testutils/metrictestutils/BUILD.bazel | 5 +- pkg/testutils/metrictestutils/metrics_text.go | 3 +- pkg/util/metric/BUILD.bazel | 1 + pkg/util/metric/aggmetric/BUILD.bazel | 1 + pkg/util/metric/aggmetric/agg_metric_test.go | 3 +- pkg/util/metric/metric.go | 31 +++++++ pkg/util/metric/prometheus_exporter.go | 9 +- pkg/util/metric/prometheus_exporter_test.go | 3 +- 26 files changed, 216 insertions(+), 117 deletions(-) diff --git a/DEPS.bzl b/DEPS.bzl index 3f72b11970ac..dce15c53b33a 100644 --- a/DEPS.bzl +++ b/DEPS.bzl @@ -124,6 +124,16 @@ def go_deps(): "https://storage.googleapis.com/cockroach-godeps/gomod/github.com/akavel/rsrc/com_github_akavel_rsrc-v0.8.0.zip", ], ) + go_repository( + name = "com_github_alecthomas_kingpin_v2", + build_file_proto_mode = "disable_global", + importpath = "github.com/alecthomas/kingpin/v2", + sha256 = "2a322681d79461dd793c1e8a98adf062f6ef554abcd3ab06981eef94d79c136b", + strip_prefix = "github.com/alecthomas/kingpin/v2@v2.3.1", + urls = [ + "https://storage.googleapis.com/cockroach-godeps/gomod/github.com/alecthomas/kingpin/v2/com_github_alecthomas_kingpin_v2-v2.3.1.zip", + ], + ) go_repository( name = "com_github_alecthomas_template", build_file_proto_mode = "disable_global", @@ -138,10 +148,10 @@ def go_deps(): name = "com_github_alecthomas_units", build_file_proto_mode = "disable_global", importpath = "github.com/alecthomas/units", - sha256 = "461b05eb19b6023664d6502cb4fbf093a99a9ee2a36c43b4da5ca1287c495ff7", - strip_prefix = "github.com/alecthomas/units@v0.0.0-20210208195552-ff826a37aa15", + sha256 = "b62437d74a523089af46ba0115ece1ce11bca5e321fe1e1d4c976ecca6ee78aa", + strip_prefix = "github.com/alecthomas/units@v0.0.0-20211218093645-b94a6e3cc137", urls = [ - "https://storage.googleapis.com/cockroach-godeps/gomod/github.com/alecthomas/units/com_github_alecthomas_units-v0.0.0-20210208195552-ff826a37aa15.zip", + "https://storage.googleapis.com/cockroach-godeps/gomod/github.com/alecthomas/units/com_github_alecthomas_units-v0.0.0-20211218093645-b94a6e3cc137.zip", ], ) go_repository( @@ -3066,10 +3076,10 @@ def go_deps(): name = "com_github_go_kit_log", build_file_proto_mode = "disable_global", importpath = "github.com/go-kit/log", - sha256 = "e0676df7357654a000008dfad3b6b211cba3595f32d3e220edd63a4c9d0d9254", - strip_prefix = "github.com/go-kit/log@v0.1.0", + sha256 = "52634b502b9d0aa945833d93582cffc1bdd9bfa39810e7c70d0688e330b75198", + strip_prefix = "github.com/go-kit/log@v0.2.1", urls = [ - "https://storage.googleapis.com/cockroach-godeps/gomod/github.com/go-kit/log/com_github_go_kit_log-v0.1.0.zip", + "https://storage.googleapis.com/cockroach-godeps/gomod/github.com/go-kit/log/com_github_go_kit_log-v0.2.1.zip", ], ) go_repository( @@ -3724,10 +3734,10 @@ def go_deps(): patches = [ "@com_github_cockroachdb_cockroach//build/patches:com_github_golang_protobuf.patch", ], - sha256 = "5d1c817bebc1202ab3b42a418e584e0008e8027baf212ce69c2ae3e9e7b8c64b", - strip_prefix = "github.com/golang/protobuf@v1.5.2", + sha256 = "93bda6e88d4a0a493a98b481de67a10000a755d15f16a800b49a6b96d1bd6f81", + strip_prefix = "github.com/golang/protobuf@v1.5.3", urls = [ - "https://storage.googleapis.com/cockroach-godeps/gomod/github.com/golang/protobuf/com_github_golang_protobuf-v1.5.2.zip", + "https://storage.googleapis.com/cockroach-godeps/gomod/github.com/golang/protobuf/com_github_golang_protobuf-v1.5.3.zip", ], ) go_repository( @@ -6053,10 +6063,10 @@ def go_deps(): name = "com_github_matttproud_golang_protobuf_extensions", build_file_proto_mode = "disable_global", importpath = "github.com/matttproud/golang_protobuf_extensions", - sha256 = "232df417d378e10bb1dcdd533c493647a247f62d9fe2b13c636d9647ff13384a", - strip_prefix = "github.com/matttproud/golang_protobuf_extensions@v1.0.2-0.20181231171920-c182affec369", + sha256 = "0b44aabaa9aea5d28e667849ad4d9821351466c3591dd7beddb2d025db6d55f2", + strip_prefix = "github.com/matttproud/golang_protobuf_extensions@v1.0.4", urls = [ - "https://storage.googleapis.com/cockroach-godeps/gomod/github.com/matttproud/golang_protobuf_extensions/com_github_matttproud_golang_protobuf_extensions-v1.0.2-0.20181231171920-c182affec369.zip", + "https://storage.googleapis.com/cockroach-godeps/gomod/github.com/matttproud/golang_protobuf_extensions/com_github_matttproud_golang_protobuf_extensions-v1.0.4.zip", ], ) go_repository( @@ -7393,10 +7403,10 @@ def go_deps(): name = "com_github_prometheus_client_golang", build_file_proto_mode = "disable_global", importpath = "github.com/prometheus/client_golang", - sha256 = "d9bbfcdcb5f63812b6766884a0f5ad5b1f9a675375d28e307573f49e2ef96b7b", - strip_prefix = "github.com/prometheus/client_golang@v1.12.1", + sha256 = "0167cee686b836da39815e4a7ea64ecc245f6a3fb9b3c3f729941ed55da7dd4f", + strip_prefix = "github.com/prometheus/client_golang@v1.16.0", urls = [ - "https://storage.googleapis.com/cockroach-godeps/gomod/github.com/prometheus/client_golang/com_github_prometheus_client_golang-v1.12.1.zip", + "https://storage.googleapis.com/cockroach-godeps/gomod/github.com/prometheus/client_golang/com_github_prometheus_client_golang-v1.16.0.zip", ], ) go_repository( @@ -7406,20 +7416,20 @@ def go_deps(): ], build_file_proto_mode = "default", importpath = "github.com/prometheus/client_model", - sha256 = "44fc58fe25ed9b122b6755e8d356d5f199592f959af3b87a3b636c6eb82b43c5", - strip_prefix = "github.com/prometheus/client_model@v0.2.1-0.20210607210712-147c58e9608a", + sha256 = "2a1d147754959287fc34a7bb7c333b3d6fe0ca0d7db1606c49e8f48fd0311547", + strip_prefix = "github.com/prometheus/client_model@v0.3.0", urls = [ - "https://storage.googleapis.com/cockroach-godeps/gomod/github.com/prometheus/client_model/com_github_prometheus_client_model-v0.2.1-0.20210607210712-147c58e9608a.zip", + "https://storage.googleapis.com/cockroach-godeps/gomod/github.com/prometheus/client_model/com_github_prometheus_client_model-v0.3.0.zip", ], ) go_repository( name = "com_github_prometheus_common", build_file_proto_mode = "disable_global", importpath = "github.com/prometheus/common", - sha256 = "9630b9bbfcf1746a01c8aff0262271c60cf891fa1cd48a8ed9149de557dc98d6", - strip_prefix = "github.com/prometheus/common@v0.32.1", + sha256 = "7a4ef12402a8a153c47c085cadf362bdc2ffe4761e50d6ab2c49e4d64044bc85", + strip_prefix = "github.com/prometheus/common@v0.42.0", urls = [ - "https://storage.googleapis.com/cockroach-godeps/gomod/github.com/prometheus/common/com_github_prometheus_common-v0.32.1.zip", + "https://storage.googleapis.com/cockroach-godeps/gomod/github.com/prometheus/common/com_github_prometheus_common-v0.42.0.zip", ], ) go_repository( @@ -7446,10 +7456,10 @@ def go_deps(): name = "com_github_prometheus_procfs", build_file_proto_mode = "disable_global", importpath = "github.com/prometheus/procfs", - sha256 = "3e37c9f62738a493dd28283179d802749050353df0bca161df7cec4ed43e6f1a", - strip_prefix = "github.com/prometheus/procfs@v0.7.3", + sha256 = "3f7a5c30bbcd2adcc7ec62896b69a3792ca1603cf0998fa06d2b872a74ed13b0", + strip_prefix = "github.com/prometheus/procfs@v0.10.1", urls = [ - "https://storage.googleapis.com/cockroach-godeps/gomod/github.com/prometheus/procfs/com_github_prometheus_procfs-v0.7.3.zip", + "https://storage.googleapis.com/cockroach-godeps/gomod/github.com/prometheus/procfs/com_github_prometheus_procfs-v0.10.1.zip", ], ) go_repository( @@ -8726,6 +8736,16 @@ def go_deps(): "https://storage.googleapis.com/cockroach-godeps/gomod/github.com/xeipuuv/gojsonschema/com_github_xeipuuv_gojsonschema-v1.2.0.zip", ], ) + go_repository( + name = "com_github_xhit_go_str2duration", + build_file_proto_mode = "disable_global", + importpath = "github.com/xhit/go-str2duration", + sha256 = "87df7da9ed9a48a2da6b3df14d33a567a9e6ed2454e4cbd694baa7ec82ca7ec1", + strip_prefix = "github.com/xhit/go-str2duration@v1.2.0", + urls = [ + "https://storage.googleapis.com/cockroach-godeps/gomod/github.com/xhit/go-str2duration/com_github_xhit_go_str2duration-v1.2.0.zip", + ], + ) go_repository( name = "com_github_xiang90_probing", build_file_proto_mode = "disable_global", @@ -11060,10 +11080,10 @@ def go_deps(): name = "org_golang_google_protobuf", build_file_proto_mode = "disable_global", importpath = "google.golang.org/protobuf", - sha256 = "bf386bcd36987f898e70c8330c6f7ada03e5112909f0a92b7510961403bf61da", - strip_prefix = "google.golang.org/protobuf@v1.28.1", + sha256 = "8fb83b4d6e898c75a8d305dd46d46bb975d0a7ebab1e0042acdf25e3273d50e4", + strip_prefix = "google.golang.org/protobuf@v1.30.0", urls = [ - "https://storage.googleapis.com/cockroach-godeps/gomod/google.golang.org/protobuf/org_golang_google_protobuf-v1.28.1.zip", + "https://storage.googleapis.com/cockroach-godeps/gomod/google.golang.org/protobuf/org_golang_google_protobuf-v1.30.0.zip", ], ) go_repository( @@ -11180,20 +11200,20 @@ def go_deps(): name = "org_golang_x_sync", build_file_proto_mode = "disable_global", importpath = "golang.org/x/sync", - sha256 = "f510bec6009e19882d19953e7273137d34df86c65949345d72f123a255c2ecd2", - strip_prefix = "golang.org/x/sync@v0.1.0", + sha256 = "ee0df4572dd73665767964ff809b12f0d41e3a0740220d44d418a19989a0363b", + strip_prefix = "golang.org/x/sync@v0.2.0", urls = [ - "https://storage.googleapis.com/cockroach-godeps/gomod/golang.org/x/sync/org_golang_x_sync-v0.1.0.zip", + "https://storage.googleapis.com/cockroach-godeps/gomod/golang.org/x/sync/org_golang_x_sync-v0.2.0.zip", ], ) go_repository( name = "org_golang_x_sys", build_file_proto_mode = "disable_global", importpath = "golang.org/x/sys", - sha256 = "8c15860e3850e3cea5a7186bb79b8cf98f513d9ac5498099d3bddfd49c6dfc3f", - strip_prefix = "golang.org/x/sys@v0.6.0", + sha256 = "2588b3a645838390e341f1007f8679f5e1117b5d5ac9467ef832d148b2219a38", + strip_prefix = "golang.org/x/sys@v0.8.0", urls = [ - "https://storage.googleapis.com/cockroach-godeps/gomod/golang.org/x/sys/org_golang_x_sys-v0.6.0.zip", + "https://storage.googleapis.com/cockroach-godeps/gomod/golang.org/x/sys/org_golang_x_sys-v0.8.0.zip", ], ) go_repository( diff --git a/build/bazelutil/distdir_files.bzl b/build/bazelutil/distdir_files.bzl index c38c01c09a70..02d3ba7bf2dc 100644 --- a/build/bazelutil/distdir_files.bzl +++ b/build/bazelutil/distdir_files.bzl @@ -205,8 +205,9 @@ DISTDIR_FILES = { "https://storage.googleapis.com/cockroach-godeps/gomod/github.com/ajg/form/com_github_ajg_form-v1.5.1.zip": "b063b07639670ce9b6a0065b4dc35ef9e4cebc0c601be27f5494a3e6a87eb78b", "https://storage.googleapis.com/cockroach-godeps/gomod/github.com/ajstarks/svgo/com_github_ajstarks_svgo-v0.0.0-20210923152817-c3b6e2f0c527.zip": "d58dcf4f11896cb22cec4db53ca17df342c6da4cc3a084c270f2da9e1eb351a7", "https://storage.googleapis.com/cockroach-godeps/gomod/github.com/akavel/rsrc/com_github_akavel_rsrc-v0.8.0.zip": "13954a09edc3a680d633c5ea7b4be902df3a70ca1720b349faadca44dc0c7ecc", + "https://storage.googleapis.com/cockroach-godeps/gomod/github.com/alecthomas/kingpin/v2/com_github_alecthomas_kingpin_v2-v2.3.1.zip": "2a322681d79461dd793c1e8a98adf062f6ef554abcd3ab06981eef94d79c136b", "https://storage.googleapis.com/cockroach-godeps/gomod/github.com/alecthomas/template/com_github_alecthomas_template-v0.0.0-20190718012654-fb15b899a751.zip": "25e3be7192932d130d0af31ce5bcddae887647ba4afcfb32009c3b9b79dbbdb3", - "https://storage.googleapis.com/cockroach-godeps/gomod/github.com/alecthomas/units/com_github_alecthomas_units-v0.0.0-20210208195552-ff826a37aa15.zip": "461b05eb19b6023664d6502cb4fbf093a99a9ee2a36c43b4da5ca1287c495ff7", + "https://storage.googleapis.com/cockroach-godeps/gomod/github.com/alecthomas/units/com_github_alecthomas_units-v0.0.0-20211218093645-b94a6e3cc137.zip": "b62437d74a523089af46ba0115ece1ce11bca5e321fe1e1d4c976ecca6ee78aa", "https://storage.googleapis.com/cockroach-godeps/gomod/github.com/alessio/shellescape/com_github_alessio_shellescape-v1.4.1.zip": "e28d444e73b803a15cf83e6179149d34c6c132baa60cb8137e5f0aea50a543bf", "https://storage.googleapis.com/cockroach-godeps/gomod/github.com/alexbrainman/sspi/com_github_alexbrainman_sspi-v0.0.0-20210105120005-909beea2cc74.zip": "f094ecfc4554a9ca70f0ade41747123f3161a15fb1a6112305b99731befc8648", "https://storage.googleapis.com/cockroach-godeps/gomod/github.com/alexflint/go-filemutex/com_github_alexflint_go_filemutex-v0.0.0-20171022225611-72bdc8eae2ae.zip": "f3517f75266ac4651b0b421dd970a68d5645c929062f2d67b9e1e4685562b690", @@ -465,7 +466,7 @@ DISTDIR_FILES = { "https://storage.googleapis.com/cockroach-godeps/gomod/github.com/go-gl/glfw/v3.3/glfw/com_github_go_gl_glfw_v3_3_glfw-v0.0.0-20200222043503-6f7a984d4dc4.zip": "2f6a1963397cb7c3df66257a45d75fae860aa9b9eec17825d8101c1e1313da5b", "https://storage.googleapis.com/cockroach-godeps/gomod/github.com/go-ini/ini/com_github_go_ini_ini-v1.25.4.zip": "2ec52de9f1c96133e9f81b8250fdc99ca0729c0d429e318d7c8836b7a6ba5f60", "https://storage.googleapis.com/cockroach-godeps/gomod/github.com/go-kit/kit/com_github_go_kit_kit-v0.10.0.zip": "dbdc933092b036483ca332f8c7c13e8b7d029192e79354d4f5a581ef3c364816", - "https://storage.googleapis.com/cockroach-godeps/gomod/github.com/go-kit/log/com_github_go_kit_log-v0.1.0.zip": "e0676df7357654a000008dfad3b6b211cba3595f32d3e220edd63a4c9d0d9254", + "https://storage.googleapis.com/cockroach-godeps/gomod/github.com/go-kit/log/com_github_go_kit_log-v0.2.1.zip": "52634b502b9d0aa945833d93582cffc1bdd9bfa39810e7c70d0688e330b75198", "https://storage.googleapis.com/cockroach-godeps/gomod/github.com/go-latex/latex/com_github_go_latex_latex-v0.0.0-20210823091927-c0d11ff05a81.zip": "c58be686b31679ad0a51a5d70e60df92fb4bb50a16727caa58b4a67b33f16509", "https://storage.googleapis.com/cockroach-godeps/gomod/github.com/go-logfmt/logfmt/com_github_go_logfmt_logfmt-v0.5.1.zip": "9e030cd09b584e59a2f5baaa24cf600520757d732af0f8993cc412dd3086703a", "https://storage.googleapis.com/cockroach-godeps/gomod/github.com/go-logr/logr/com_github_go_logr_logr-v0.4.0.zip": "be0f7eff89f0e40ff70715d864e0adbfc2be25b37d161c1ba71acd051c5716ea", @@ -532,7 +533,7 @@ DISTDIR_FILES = { "https://storage.googleapis.com/cockroach-godeps/gomod/github.com/golang/glog/com_github_golang_glog-v1.0.0.zip": "ae8dfead198447a555409e4e942bd4aae2210b18bc90ff8f032ab09a9940e8f8", "https://storage.googleapis.com/cockroach-godeps/gomod/github.com/golang/groupcache/com_github_golang_groupcache-v0.0.0-20210331224755-41bb18bfe9da.zip": "b27034e8fc013627543e1ad098cfc65329f2896df3da5cf3266cc9166f93f3a5", "https://storage.googleapis.com/cockroach-godeps/gomod/github.com/golang/mock/com_github_golang_mock-v1.6.0.zip": "fa25916b546f90da49418f436e3a61e4c5dae898cf3c82b0007b5a6fab74261b", - "https://storage.googleapis.com/cockroach-godeps/gomod/github.com/golang/protobuf/com_github_golang_protobuf-v1.5.2.zip": "5d1c817bebc1202ab3b42a418e584e0008e8027baf212ce69c2ae3e9e7b8c64b", + "https://storage.googleapis.com/cockroach-godeps/gomod/github.com/golang/protobuf/com_github_golang_protobuf-v1.5.3.zip": "93bda6e88d4a0a493a98b481de67a10000a755d15f16a800b49a6b96d1bd6f81", "https://storage.googleapis.com/cockroach-godeps/gomod/github.com/golang/snappy/com_github_golang_snappy-v0.0.4.zip": "ea4545ca44ee990554094df6de440386a440a5bd99106e048939409d63beb423", "https://storage.googleapis.com/cockroach-godeps/gomod/github.com/golangci/lint-1/com_github_golangci_lint_1-v0.0.0-20181222135242-d2cdd8c08219.zip": "2806ffd1a35b26a29b4cea86eb5ae421636b317e33e261fc1c20f9cf8fec2db5", "https://storage.googleapis.com/cockroach-godeps/gomod/github.com/gomodule/redigo/com_github_gomodule_redigo-v1.7.1-0.20190724094224-574c33c3df38.zip": "f665942b590c65e87284d681ea2784d0b9873c644756f4716a9972dc0d8e804e", @@ -750,7 +751,7 @@ DISTDIR_FILES = { "https://storage.googleapis.com/cockroach-godeps/gomod/github.com/mattn/go-tty/com_github_mattn_go_tty-v0.0.0-20180907095812-13ff1204f104.zip": "e7384ae06bb54cc8f615d86e6397b11849be12c270d66460856f3fc6ad72aacb", "https://storage.googleapis.com/cockroach-godeps/gomod/github.com/mattn/go-zglob/com_github_mattn_go_zglob-v0.0.3.zip": "8ef2dfc44aa352edd72e50287b7ac836c4c48fa439ca2648d8c1a4067f49e504", "https://storage.googleapis.com/cockroach-godeps/gomod/github.com/mattn/goveralls/com_github_mattn_goveralls-v0.0.2.zip": "3df5b7ebfb61edd9a098895aae7009a927a2fe91f73f38f48467a7b9e6c006f7", - "https://storage.googleapis.com/cockroach-godeps/gomod/github.com/matttproud/golang_protobuf_extensions/com_github_matttproud_golang_protobuf_extensions-v1.0.2-0.20181231171920-c182affec369.zip": "232df417d378e10bb1dcdd533c493647a247f62d9fe2b13c636d9647ff13384a", + "https://storage.googleapis.com/cockroach-godeps/gomod/github.com/matttproud/golang_protobuf_extensions/com_github_matttproud_golang_protobuf_extensions-v1.0.4.zip": "0b44aabaa9aea5d28e667849ad4d9821351466c3591dd7beddb2d025db6d55f2", "https://storage.googleapis.com/cockroach-godeps/gomod/github.com/mediocregopher/radix/v3/com_github_mediocregopher_radix_v3-v3.4.2.zip": "5be7566cd32610078fa12461b09b674061efb955b2400625ba8ebf3f6182c287", "https://storage.googleapis.com/cockroach-godeps/gomod/github.com/mgutz/ansi/com_github_mgutz_ansi-v0.0.0-20200706080929-d51e80ef957d.zip": "2e0c063f9597cb225904292981732f10298e95aa22a1b815297e318ba103dc1d", "https://storage.googleapis.com/cockroach-godeps/gomod/github.com/mibk/dupl/com_github_mibk_dupl-v1.0.0.zip": "73f61090c1cbee024b771fc60804cbedc5c2861f232bd34eff719afd9ac6e098", @@ -877,12 +878,12 @@ DISTDIR_FILES = { "https://storage.googleapis.com/cockroach-godeps/gomod/github.com/prashantv/protectmem/com_github_prashantv_protectmem-v0.0.0-20171002184600-e20412882b3a.zip": "53d930afbb812eb68b665dcbd96ac371ff600c8821cf5e43628ab283457881e9", "https://storage.googleapis.com/cockroach-godeps/gomod/github.com/pressly/goose/v3/com_github_pressly_goose_v3-v3.5.3.zip": "0f0c74470d454d3530f6b7da4007a3b27beb38b9b059badd98715dc88f535f6f", "https://storage.googleapis.com/cockroach-godeps/gomod/github.com/prometheus/alertmanager/com_github_prometheus_alertmanager-v0.23.0.zip": "1c51abe35f12ebc11de46e0d888c93fe8e85b146ced1c2ab2a49dd97cf2b1c6a", - "https://storage.googleapis.com/cockroach-godeps/gomod/github.com/prometheus/client_golang/com_github_prometheus_client_golang-v1.12.1.zip": "d9bbfcdcb5f63812b6766884a0f5ad5b1f9a675375d28e307573f49e2ef96b7b", - "https://storage.googleapis.com/cockroach-godeps/gomod/github.com/prometheus/client_model/com_github_prometheus_client_model-v0.2.1-0.20210607210712-147c58e9608a.zip": "44fc58fe25ed9b122b6755e8d356d5f199592f959af3b87a3b636c6eb82b43c5", - "https://storage.googleapis.com/cockroach-godeps/gomod/github.com/prometheus/common/com_github_prometheus_common-v0.32.1.zip": "9630b9bbfcf1746a01c8aff0262271c60cf891fa1cd48a8ed9149de557dc98d6", + "https://storage.googleapis.com/cockroach-godeps/gomod/github.com/prometheus/client_golang/com_github_prometheus_client_golang-v1.16.0.zip": "0167cee686b836da39815e4a7ea64ecc245f6a3fb9b3c3f729941ed55da7dd4f", + "https://storage.googleapis.com/cockroach-godeps/gomod/github.com/prometheus/client_model/com_github_prometheus_client_model-v0.3.0.zip": "2a1d147754959287fc34a7bb7c333b3d6fe0ca0d7db1606c49e8f48fd0311547", + "https://storage.googleapis.com/cockroach-godeps/gomod/github.com/prometheus/common/com_github_prometheus_common-v0.42.0.zip": "7a4ef12402a8a153c47c085cadf362bdc2ffe4761e50d6ab2c49e4d64044bc85", "https://storage.googleapis.com/cockroach-godeps/gomod/github.com/prometheus/common/sigv4/com_github_prometheus_common_sigv4-v0.1.0.zip": "e76ec796837158dc2624343f88da4ba3c5d9d4b45e66b359358eba5db39846dd", "https://storage.googleapis.com/cockroach-godeps/gomod/github.com/prometheus/exporter-toolkit/com_github_prometheus_exporter_toolkit-v0.6.1.zip": "bac6a6c26e51c687abaf14e06b4a99eaa876380d917ff6b9bce38461ee4f95aa", - "https://storage.googleapis.com/cockroach-godeps/gomod/github.com/prometheus/procfs/com_github_prometheus_procfs-v0.7.3.zip": "3e37c9f62738a493dd28283179d802749050353df0bca161df7cec4ed43e6f1a", + "https://storage.googleapis.com/cockroach-godeps/gomod/github.com/prometheus/procfs/com_github_prometheus_procfs-v0.10.1.zip": "3f7a5c30bbcd2adcc7ec62896b69a3792ca1603cf0998fa06d2b872a74ed13b0", "https://storage.googleapis.com/cockroach-godeps/gomod/github.com/prometheus/prometheus/com_github_prometheus_prometheus-v1.8.2-0.20210914090109-37468d88dce8.zip": "934ceb931a2f3065c3aae015afcb49a9ed52043dfe29ae41a3a3e6299db1448a", "https://storage.googleapis.com/cockroach-godeps/gomod/github.com/prometheus/statsd_exporter/com_github_prometheus_statsd_exporter-v0.21.0.zip": "aa848ade6fb019df4f7992808a1d6aa48d6b8276017970af4aabc1bd337c2dc3", "https://storage.googleapis.com/cockroach-godeps/gomod/github.com/prometheus/tsdb/com_github_prometheus_tsdb-v0.7.1.zip": "360ce38297a00439c4bfbbded7b750f6d45582d581cde70572a003bcbc8b0c7b", @@ -998,6 +999,7 @@ DISTDIR_FILES = { "https://storage.googleapis.com/cockroach-godeps/gomod/github.com/xeipuuv/gojsonpointer/com_github_xeipuuv_gojsonpointer-v0.0.0-20190905194746-02993c407bfb.zip": "11b54f0bc358b09261075c3e15cd14d57102f3ab1ba88c345c53eab6aaf228de", "https://storage.googleapis.com/cockroach-godeps/gomod/github.com/xeipuuv/gojsonreference/com_github_xeipuuv_gojsonreference-v0.0.0-20180127040603-bd5ef7bd5415.zip": "7ec98f4df894413f4dc58c8df330ca8b24ff425b05a8e1074c3028c99f7e45e7", "https://storage.googleapis.com/cockroach-godeps/gomod/github.com/xeipuuv/gojsonschema/com_github_xeipuuv_gojsonschema-v1.2.0.zip": "55c8ce068257aa0d263aad7470113dafcd50f955ee754fc853c2fdcd31ad096f", + "https://storage.googleapis.com/cockroach-godeps/gomod/github.com/xhit/go-str2duration/com_github_xhit_go_str2duration-v1.2.0.zip": "87df7da9ed9a48a2da6b3df14d33a567a9e6ed2454e4cbd694baa7ec82ca7ec1", "https://storage.googleapis.com/cockroach-godeps/gomod/github.com/xiang90/probing/com_github_xiang90_probing-v0.0.0-20190116061207-43a291ad63a2.zip": "437bdc666239fda4581b592b068001f08269c68c70699a721bff9334412d4181", "https://storage.googleapis.com/cockroach-godeps/gomod/github.com/xlab/treeprint/com_github_xlab_treeprint-v1.1.0.zip": "4334f3a6e37e92cdd18688a59710663a0f3bff61b225f236fa1be8875e483152", "https://storage.googleapis.com/cockroach-godeps/gomod/github.com/xordataexchange/crypt/com_github_xordataexchange_crypt-v0.0.3-0.20170626215501-b2862e3d0a77.zip": "46dc29ef77d77a2bc3e7bd70c94dbaeec0062dd3bd6fcacbaab785c15dcd625b", @@ -1053,8 +1055,8 @@ DISTDIR_FILES = { "https://storage.googleapis.com/cockroach-godeps/gomod/golang.org/x/net/org_golang_x_net-v0.8.0.zip": "c28918deb668906821c4e3b5da3643c262ff4ccc48b1b2e021ce188694af9dba", "https://storage.googleapis.com/cockroach-godeps/gomod/golang.org/x/oauth2/org_golang_x_oauth2-v0.5.0.zip": "4d9d9ce8d2f55b7d2ffb3697ed811a54606e881bb7fbbd84d3d9c42fc404ae3c", "https://storage.googleapis.com/cockroach-godeps/gomod/golang.org/x/perf/org_golang_x_perf-v0.0.0-20230113213139-801c7ef9e5c5.zip": "bc1b902e645fdd5d210b7db8f3280833af225b131dab5842d7a6d32a676f80f5", - "https://storage.googleapis.com/cockroach-godeps/gomod/golang.org/x/sync/org_golang_x_sync-v0.1.0.zip": "f510bec6009e19882d19953e7273137d34df86c65949345d72f123a255c2ecd2", - "https://storage.googleapis.com/cockroach-godeps/gomod/golang.org/x/sys/org_golang_x_sys-v0.6.0.zip": "8c15860e3850e3cea5a7186bb79b8cf98f513d9ac5498099d3bddfd49c6dfc3f", + "https://storage.googleapis.com/cockroach-godeps/gomod/golang.org/x/sync/org_golang_x_sync-v0.2.0.zip": "ee0df4572dd73665767964ff809b12f0d41e3a0740220d44d418a19989a0363b", + "https://storage.googleapis.com/cockroach-godeps/gomod/golang.org/x/sys/org_golang_x_sys-v0.8.0.zip": "2588b3a645838390e341f1007f8679f5e1117b5d5ac9467ef832d148b2219a38", "https://storage.googleapis.com/cockroach-godeps/gomod/golang.org/x/term/org_golang_x_term-v0.6.0.zip": "3699084ad1104a6a0a027a0871e67987304d73a6abb2770c8f7e5ce3d7c1d314", "https://storage.googleapis.com/cockroach-godeps/gomod/golang.org/x/text/org_golang_x_text-v0.8.0.zip": "194ba27fd7a743d7778e17788e43619499885adcf6a322da4095814a83e73a77", "https://storage.googleapis.com/cockroach-godeps/gomod/golang.org/x/tools/org_golang_x_tools-v0.7.0.zip": "e43c6cc63a85dc30cd1794846ae96a44e81e458e88e436474c3bbbdbef80941a", @@ -1069,7 +1071,7 @@ DISTDIR_FILES = { "https://storage.googleapis.com/cockroach-godeps/gomod/google.golang.org/grpc/cmd/protoc-gen-go-grpc/org_golang_google_grpc_cmd_protoc_gen_go_grpc-v1.1.0.zip": "13877d86cbfa30bde4d62fef2bc58dd56377dcb502c16cf78197f6934193009a", "https://storage.googleapis.com/cockroach-godeps/gomod/google.golang.org/grpc/examples/org_golang_google_grpc_examples-v0.0.0-20210324172016-702608ffae4d.zip": "f5cad7b05a93557c91864a02890a35c6bc5c394897222978cff2b880a78f7a11", "https://storage.googleapis.com/cockroach-godeps/gomod/google.golang.org/grpc/org_golang_google_grpc-v1.53.0.zip": "27eac6302376021eee524ddce487571a0686eb3868aaf93981ea6767e1929d6b", - "https://storage.googleapis.com/cockroach-godeps/gomod/google.golang.org/protobuf/org_golang_google_protobuf-v1.28.1.zip": "bf386bcd36987f898e70c8330c6f7ada03e5112909f0a92b7510961403bf61da", + "https://storage.googleapis.com/cockroach-godeps/gomod/google.golang.org/protobuf/org_golang_google_protobuf-v1.30.0.zip": "8fb83b4d6e898c75a8d305dd46d46bb975d0a7ebab1e0042acdf25e3273d50e4", "https://storage.googleapis.com/cockroach-godeps/gomod/gopkg.in/DataDog/dd-trace-go.v1/in_gopkg_datadog_dd_trace_go_v1-v1.17.0.zip": "2ebcc818df0b2d560a61037da4492ae7effbaed67de94339a1d3a72728d2cb09", "https://storage.googleapis.com/cockroach-godeps/gomod/gopkg.in/airbrake/gobrake.v2/in_gopkg_airbrake_gobrake_v2-v2.0.9.zip": "2db903664908e5a9afafefba94821b9579bbf271e2929c1f0b7b1fdd23f7bbcf", "https://storage.googleapis.com/cockroach-godeps/gomod/gopkg.in/alecthomas/kingpin.v2/in_gopkg_alecthomas_kingpin_v2-v2.2.6.zip": "638080591aefe7d2642f2575b627d534c692606f02ea54ba89f42db112ba8839", diff --git a/go.mod b/go.mod index 2f1a297a50fc..80ac32d57c1b 100644 --- a/go.mod +++ b/go.mod @@ -11,7 +11,7 @@ require ( github.com/gogo/protobuf v1.3.2 github.com/golang/geo v0.0.0-20200319012246-673a6f80352d github.com/golang/mock v1.6.0 - github.com/golang/protobuf v1.5.2 + github.com/golang/protobuf v1.5.3 github.com/golang/snappy v0.0.4 github.com/google/btree v1.0.1 github.com/google/pprof v0.0.0-20210827144239-02619b876842 @@ -22,15 +22,15 @@ require ( golang.org/x/mod v0.9.0 // indirect golang.org/x/net v0.8.0 golang.org/x/oauth2 v0.5.0 - golang.org/x/sync v0.1.0 - golang.org/x/sys v0.6.0 + golang.org/x/sync v0.2.0 + golang.org/x/sys v0.8.0 golang.org/x/text v0.8.0 golang.org/x/time v0.1.0 golang.org/x/tools v0.7.0 google.golang.org/api v0.110.0 google.golang.org/genproto v0.0.0-20230227214838-9b19f0bdc514 google.golang.org/grpc v1.53.0 - google.golang.org/protobuf v1.28.1 + google.golang.org/protobuf v1.30.0 ) // If any of the following dependencies get updated as a side-effect @@ -198,9 +198,9 @@ require ( github.com/pkg/errors v0.9.1 github.com/pmezard/go-difflib v1.0.0 github.com/pressly/goose/v3 v3.5.3 - github.com/prometheus/client_golang v1.12.1 - github.com/prometheus/client_model v0.2.1-0.20210607210712-147c58e9608a - github.com/prometheus/common v0.32.1 + github.com/prometheus/client_golang v1.16.0 + github.com/prometheus/client_model v0.3.0 + github.com/prometheus/common v0.42.0 github.com/prometheus/prometheus v1.8.2-0.20210914090109-37468d88dce8 github.com/pseudomuto/protoc-gen-doc v1.3.2 github.com/rcrowley/go-metrics v0.0.0-20201227073835-cf1acfcdf475 @@ -282,7 +282,7 @@ require ( github.com/fatih/structs v1.1.0 // indirect github.com/felixge/httpsnoop v1.0.1 // indirect github.com/ghodss/yaml v1.0.0 // indirect - github.com/go-kit/log v0.1.0 // indirect + github.com/go-kit/log v0.2.1 // indirect github.com/go-logfmt/logfmt v0.5.1 // indirect github.com/go-ole/go-ole v1.2.6 // indirect github.com/go-openapi/analysis v0.20.0 // indirect @@ -340,7 +340,7 @@ require ( github.com/mattn/go-colorable v0.1.13 // indirect github.com/mattn/go-localereader v0.0.1 // indirect github.com/mattn/go-runewidth v0.0.14 // indirect - github.com/matttproud/golang_protobuf_extensions v1.0.2-0.20181231171920-c182affec369 // indirect + github.com/matttproud/golang_protobuf_extensions v1.0.4 // indirect github.com/minio/asm2plan9s v0.0.0-20200509001527-cdd76441f9d8 // indirect github.com/minio/c2goasm v0.0.0-20190812172519-36a3d3bbc4f3 // indirect github.com/minio/md5-simd v1.1.2 // indirect @@ -364,7 +364,7 @@ require ( github.com/pkg/profile v1.6.0 // indirect github.com/power-devops/perfstat v0.0.0-20210106213030-5aafc221ea8c // indirect github.com/pquerna/cachecontrol v0.0.0-20200921180117-858c6e7e6b7e // indirect - github.com/prometheus/procfs v0.7.3 // indirect + github.com/prometheus/procfs v0.10.1 // indirect github.com/pseudomuto/protokit v0.2.0 // indirect github.com/rivo/uniseg v0.2.0 // indirect github.com/rogpeppe/go-internal v1.9.0 // indirect diff --git a/go.sum b/go.sum index eeb7152749a6..1985217e8762 100644 --- a/go.sum +++ b/go.sum @@ -264,8 +264,8 @@ github.com/alecthomas/template v0.0.0-20190718012654-fb15b899a751/go.mod h1:LOuy github.com/alecthomas/units v0.0.0-20151022065526-2efee857e7cf/go.mod h1:ybxpYRFXyAe+OPACYpWeL0wqObRcbAqCMya13uyzqw0= github.com/alecthomas/units v0.0.0-20190717042225-c3de453c63f4/go.mod h1:ybxpYRFXyAe+OPACYpWeL0wqObRcbAqCMya13uyzqw0= github.com/alecthomas/units v0.0.0-20190924025748-f65c72e2690d/go.mod h1:rBZYJk541a8SKzHPHnH3zbiI+7dagKZ0cgpgrD7Fyho= -github.com/alecthomas/units v0.0.0-20210208195552-ff826a37aa15 h1:AUNCr9CiJuwrRYS3XieqF+Z9B9gNxo/eANAJCF2eiN4= github.com/alecthomas/units v0.0.0-20210208195552-ff826a37aa15/go.mod h1:OMCwj8VM1Kc9e19TLln2VL61YJF0x1XFtfdL4JdbSyE= +github.com/alecthomas/units v0.0.0-20211218093645-b94a6e3cc137 h1:s6gZFSlWYmbqAuRjVTiNNhvNRfY2Wxp9nhfyel4rklc= github.com/alessio/shellescape v1.4.1 h1:V7yhSDDn8LP4lc4jS8pFkt0zCnzVJlG5JXy9BVKJUX0= github.com/alessio/shellescape v1.4.1/go.mod h1:PZAiSCk0LJaZkiCSkPv8qIobYglO3FPpyFjDCtHLS30= github.com/alexbrainman/sspi v0.0.0-20210105120005-909beea2cc74 h1:Kk6a4nehpJ3UuJRqlA3JxYxBZEqCeOmATOvrbT4p9RA= @@ -826,8 +826,9 @@ github.com/go-ini/ini v1.25.4/go.mod h1:ByCAeIL28uOIIG0E3PJtZPDL8WnHpFKFOtgjp+3I github.com/go-kit/kit v0.8.0/go.mod h1:xBxKIO96dXMWWy0MnWVtmwkA9/13aqxPnvrjFYMA2as= github.com/go-kit/kit v0.9.0/go.mod h1:xBxKIO96dXMWWy0MnWVtmwkA9/13aqxPnvrjFYMA2as= github.com/go-kit/kit v0.10.0/go.mod h1:xUsJbQ/Fp4kEt7AFgCuvyX4a71u8h9jB8tj/ORgOZ7o= -github.com/go-kit/log v0.1.0 h1:DGJh0Sm43HbOeYDNnVZFl8BvcYVvjD5bqYJvp0REbwQ= github.com/go-kit/log v0.1.0/go.mod h1:zbhenjAZHb184qTLMA9ZjW7ThYL0H2mk7Q6pNt4vbaY= +github.com/go-kit/log v0.2.1 h1:MRVx0/zhvdseW+Gza6N9rVzU/IVzaeE1SFI4raAhmBU= +github.com/go-kit/log v0.2.1/go.mod h1:NwTd00d/i8cPZ3xOwwiv2PO5MOcx78fFErGNcVmBjv0= github.com/go-latex/latex v0.0.0-20210118124228-b3d85cf34e07/go.mod h1:CO1AlKB2CSIqUrmQPqA0gdRIlnLEY0gK5JGjh37zN5U= github.com/go-latex/latex v0.0.0-20210823091927-c0d11ff05a81/go.mod h1:SX0U8uGpxhq9o2S/CELCSUxEWWAuoCUcVCQWv7G2OCk= github.com/go-logfmt/logfmt v0.3.0/go.mod h1:Qt1PoO58o5twSAckw1HlFXLmHsOX5/0LbT9GBnD5lWE= @@ -1094,8 +1095,9 @@ github.com/golang/protobuf v1.4.2/go.mod h1:oDoupMAO8OvCJWAcko0GGGIgR6R6ocIYbsSw github.com/golang/protobuf v1.4.3/go.mod h1:oDoupMAO8OvCJWAcko0GGGIgR6R6ocIYbsSw735rRwI= github.com/golang/protobuf v1.5.0/go.mod h1:FsONVRAS9T7sI+LIUmWTfcYkHO4aIWwzhcaSAoJOfIk= github.com/golang/protobuf v1.5.1/go.mod h1:DopwsBzvsk0Fs44TXzsVbJyPhcCPeIwnvohx4u74HPM= -github.com/golang/protobuf v1.5.2 h1:ROPKBNFfQgOUMifHyP+KYbvpjbdoFNs+aK7DXlji0Tw= github.com/golang/protobuf v1.5.2/go.mod h1:XVQd3VNwM+JqD3oG2Ue2ip4fOMUkwXdXDdiuN0vRsmY= +github.com/golang/protobuf v1.5.3 h1:KhyjKVUg7Usr/dYsdSqoFveMYd5ko72D+zANwlG1mmg= +github.com/golang/protobuf v1.5.3/go.mod h1:XVQd3VNwM+JqD3oG2Ue2ip4fOMUkwXdXDdiuN0vRsmY= github.com/golang/snappy v0.0.0-20170215233205-553a64147049/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q= github.com/golang/snappy v0.0.0-20180518054509-2e65f85255db/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q= github.com/golang/snappy v0.0.1/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q= @@ -1668,8 +1670,9 @@ github.com/mattn/go-zglob v0.0.3/go.mod h1:9fxibJccNxU2cnpIKLRRFA7zX7qhkJIQWBb44 github.com/mattn/goveralls v0.0.2 h1:7eJB6EqsPhRVxvwEXGnqdO2sJI0PTsrWoTMXEk9/OQc= github.com/mattn/goveralls v0.0.2/go.mod h1:8d1ZMHsd7fW6IRPKQh46F2WRpyib5/X4FOpevwGNQEw= github.com/matttproud/golang_protobuf_extensions v1.0.1/go.mod h1:D8He9yQNgCq6Z5Ld7szi9bcBfOoFv/3dc6xSMkL2PC0= -github.com/matttproud/golang_protobuf_extensions v1.0.2-0.20181231171920-c182affec369 h1:I0XW9+e1XWDxdcEniV4rQAIOPUGDq67JSCiRCgGCZLI= github.com/matttproud/golang_protobuf_extensions v1.0.2-0.20181231171920-c182affec369/go.mod h1:BSXmuO+STAnVfrANrmjBb36TMTDstsz7MSK+HVaYKv4= +github.com/matttproud/golang_protobuf_extensions v1.0.4 h1:mmDVorXM7PCGKw94cs5zkfA9PSy5pEvNWRP0ET0TIVo= +github.com/matttproud/golang_protobuf_extensions v1.0.4/go.mod h1:BSXmuO+STAnVfrANrmjBb36TMTDstsz7MSK+HVaYKv4= github.com/mediocregopher/radix/v3 v3.4.2/go.mod h1:8FL3F6UQRXHXIBSPUs5h0RybMF8i4n7wVopoX3x7Bv8= github.com/mgutz/ansi v0.0.0-20200706080929-d51e80ef957d/go.mod h1:01TrycV0kFyexm33Z7vhZRXopbI8J3TDReVlkTgMUxE= github.com/mibk/dupl v1.0.0 h1:aZc3jqrF9n0tUHwHt/+jsRxA8cRgA0Gdl56M7W7PoqE= @@ -1968,8 +1971,8 @@ github.com/prometheus/client_golang v1.5.1/go.mod h1:e9GMxYsXl05ICDXkRhurwBS4Q3O github.com/prometheus/client_golang v1.6.0/go.mod h1:ZLOG9ck3JLRdB5MgO8f+lLTe83AXG6ro35rLTxvnIl4= github.com/prometheus/client_golang v1.7.1/go.mod h1:PY5Wy2awLA44sXw4AOSfFBetzPP4j5+D6mVACh+pe2M= github.com/prometheus/client_golang v1.11.0/go.mod h1:Z6t4BnS23TR94PD6BsDNk8yVqroYurpAkEiz0P2BEV0= -github.com/prometheus/client_golang v1.12.1 h1:ZiaPsmm9uiBeaSMRznKsCDNtPCS0T3JVDGF+06gjBzk= -github.com/prometheus/client_golang v1.12.1/go.mod h1:3Z9XVyYiZYEO+YQWt3RD2R3jrbd179Rt297l4aS6nDY= +github.com/prometheus/client_golang v1.16.0 h1:yk/hx9hDbrGHovbci4BY+pRMfSuuat626eFsHb7tmT8= +github.com/prometheus/client_golang v1.16.0/go.mod h1:Zsulrv/L9oM40tJ7T815tM89lFEugiJ9HzIqaAx4LKc= github.com/prometheus/client_model v0.0.0-20171117100541-99fa1f4be8e5/go.mod h1:MbSGuTsp3dbXC40dX6PRTWyKYBIrTGTE9sqQNg2J8bo= github.com/prometheus/client_model v0.0.0-20180712105110-5c3871d89910/go.mod h1:MbSGuTsp3dbXC40dX6PRTWyKYBIrTGTE9sqQNg2J8bo= github.com/prometheus/client_model v0.0.0-20190115171406-56726106282f/go.mod h1:MbSGuTsp3dbXC40dX6PRTWyKYBIrTGTE9sqQNg2J8bo= @@ -1977,8 +1980,8 @@ github.com/prometheus/client_model v0.0.0-20190129233127-fd36f4220a90/go.mod h1: github.com/prometheus/client_model v0.0.0-20190812154241-14fe0d1b01d4/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA= github.com/prometheus/client_model v0.1.0/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA= github.com/prometheus/client_model v0.2.0/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA= -github.com/prometheus/client_model v0.2.1-0.20210607210712-147c58e9608a h1:CmF68hwI0XsOQ5UwlBopMi2Ow4Pbg32akc4KIVCOm+Y= -github.com/prometheus/client_model v0.2.1-0.20210607210712-147c58e9608a/go.mod h1:LDGWKZIo7rky3hgvBe+caln+Dr3dPggB5dvjtD7w9+w= +github.com/prometheus/client_model v0.3.0 h1:UBgGFHqYdG/TPFD1B1ogZywDqEkwp3fBMvqdiQ7Xew4= +github.com/prometheus/client_model v0.3.0/go.mod h1:LDGWKZIo7rky3hgvBe+caln+Dr3dPggB5dvjtD7w9+w= github.com/prometheus/common v0.0.0-20180110214958-89604d197083/go.mod h1:daVV7qP5qjZbuso7PdcryaAu0sAZbrN9i7WWcTMWvro= github.com/prometheus/common v0.0.0-20181113130724-41aa239b4cce/go.mod h1:daVV7qP5qjZbuso7PdcryaAu0sAZbrN9i7WWcTMWvro= github.com/prometheus/common v0.0.0-20181126121408-4724e9255275/go.mod h1:daVV7qP5qjZbuso7PdcryaAu0sAZbrN9i7WWcTMWvro= @@ -1992,8 +1995,8 @@ github.com/prometheus/common v0.10.0/go.mod h1:Tlit/dnDKsSWFlCLTWaA1cyBgKHSMdTB8 github.com/prometheus/common v0.26.0/go.mod h1:M7rCNAaPfAosfx8veZJCuw84e35h3Cfd9VFqTh1DIvc= github.com/prometheus/common v0.29.0/go.mod h1:vu+V0TpY+O6vW9J44gczi3Ap/oXXR10b+M/gUGO4Hls= github.com/prometheus/common v0.30.0/go.mod h1:vu+V0TpY+O6vW9J44gczi3Ap/oXXR10b+M/gUGO4Hls= -github.com/prometheus/common v0.32.1 h1:hWIdL3N2HoUx3B8j3YN9mWor0qhY/NlEKZEaXxuIRh4= -github.com/prometheus/common v0.32.1/go.mod h1:vu+V0TpY+O6vW9J44gczi3Ap/oXXR10b+M/gUGO4Hls= +github.com/prometheus/common v0.42.0 h1:EKsfXEYo4JpWMHH5cg+KOUWeuJSov1Id8zGR8eeI1YM= +github.com/prometheus/common v0.42.0/go.mod h1:xBwqVerjNdUDjgODMpudtOMwlOwf2SaTr1yjz4b7Zbc= github.com/prometheus/common/sigv4 v0.1.0 h1:qoVebwtwwEhS85Czm2dSROY5fTo2PAPEVdDeppTwGX4= github.com/prometheus/common/sigv4 v0.1.0/go.mod h1:2Jkxxk9yYvCkE5G1sQT7GuEXm57JrvHu9k5YwTjsNtI= github.com/prometheus/exporter-toolkit v0.6.1/go.mod h1:ZUBIj498ePooX9t/2xtDjeQYwvRpiPP2lh5u4iblj2g= @@ -2012,8 +2015,8 @@ github.com/prometheus/procfs v0.0.11/go.mod h1:lV6e/gmhEcM9IjHGsFOCxxuZ+z1YqCvr4 github.com/prometheus/procfs v0.1.3/go.mod h1:lV6e/gmhEcM9IjHGsFOCxxuZ+z1YqCvr4OA4YeYWdaU= github.com/prometheus/procfs v0.2.0/go.mod h1:lV6e/gmhEcM9IjHGsFOCxxuZ+z1YqCvr4OA4YeYWdaU= github.com/prometheus/procfs v0.6.0/go.mod h1:cz+aTbrPOrUb4q7XlbU9ygM+/jj0fzG6c1xBZuNvfVA= -github.com/prometheus/procfs v0.7.3 h1:4jVXhlkAyzOScmCkXBTOLRLTz8EeU+eyjrwB/EPq0VU= -github.com/prometheus/procfs v0.7.3/go.mod h1:cz+aTbrPOrUb4q7XlbU9ygM+/jj0fzG6c1xBZuNvfVA= +github.com/prometheus/procfs v0.10.1 h1:kYK1Va/YMlutzCGazswoHKo//tZVlFpKYh+PymziUAg= +github.com/prometheus/procfs v0.10.1/go.mod h1:nwNm2aOCAYw8uTR/9bWRREkZFxAUcWzPHWJq+XBB/FM= github.com/prometheus/prometheus v0.0.0-20200609090129-a6600f564e3c/go.mod h1:S5n0C6tSgdnwWshBUceRx5G1OsjLv/EeZ9t3wIfEtsY= github.com/prometheus/prometheus v1.8.2-0.20210914090109-37468d88dce8 h1:U8ZpFGP11pZi0ZavWWGeAqck3dVT9AY6zbr4fbBftjA= github.com/prometheus/prometheus v1.8.2-0.20210914090109-37468d88dce8/go.mod h1:02eURgmH1YsgJ2TtWNUGMQMCnLxmtHH9nOgvYxIjGAo= @@ -2619,8 +2622,8 @@ golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9/go.mod h1:RxMgew5VJxzue5/jJ golang.org/x/sync v0.0.0-20201207232520-09787c993a3a/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20210220032951-036812b2e83c/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.1.0 h1:wsuoTGHzEhffawBOhz5CYhcrV4IdKZbEyZjBMuTp12o= -golang.org/x/sync v0.1.0/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.2.0 h1:PUR+T4wwASmuSTYdKjYHI5TD22Wy5ogLU5qZCOLxBrI= +golang.org/x/sync v0.2.0/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sys v0.0.0-20170830134202-bb24a47a89ea/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20180810173357-98c5dad5d1a0/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20180823144017-11551d06cbcc/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= @@ -2754,7 +2757,6 @@ golang.org/x/sys v0.0.0-20211019181941-9d821ace8654/go.mod h1:oPkhp1MJrh7nUepCBc golang.org/x/sys v0.0.0-20211025201205-69cdffdb9359/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20211116061358-0a5406a5449c/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20211216021012-1d35b9e2eb4e/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20220114195835-da31bd327af9/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220204135822-1c1b9b1eba6a/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220209214540-3681064d5158/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220405210540-1e041c57c461/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= @@ -2764,8 +2766,8 @@ golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a/go.mod h1:oPkhp1MJrh7nUepCBc golang.org/x/sys v0.0.0-20220715151400-c0bba94af5f8/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.6.0 h1:MVltZSvRTcU2ljQOhs94SXPftV6DCNnZViHeQps87pQ= -golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.8.0 h1:EBmGv8NaZBZTWvrbjNoL6HVt+IVy3QDQpJs7VRIw3tU= +golang.org/x/sys v0.8.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/term v0.0.0-20201117132131-f5c789dd3221/go.mod h1:Nr5EML6q2oocZ2LXRh80K7BxOlk5/8JxuGnuhpl+muw= golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= golang.org/x/term v0.0.0-20210220032956-6a3ed077a48d/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= @@ -3083,8 +3085,8 @@ google.golang.org/protobuf v1.25.1-0.20200805231151-a709e31e5d12/go.mod h1:9JNX7 google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw= google.golang.org/protobuf v1.26.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc= google.golang.org/protobuf v1.27.1/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc= -google.golang.org/protobuf v1.28.1 h1:d0NfwRgPtno5B1Wa6L2DAG+KivqkdutMf1UhdNx175w= -google.golang.org/protobuf v1.28.1/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I= +google.golang.org/protobuf v1.30.0 h1:kPPoIgf3TsEvrm0PFe15JQ+570QVxYzEvvHqChK+cng= +google.golang.org/protobuf v1.30.0/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I= gopkg.in/DataDog/dd-trace-go.v1 v1.17.0/go.mod h1:DVp8HmDh8PuTu2Z0fVVlBsyWaC++fzwVCaGWylTe3tg= gopkg.in/airbrake/gobrake.v2 v2.0.9/go.mod h1:/h5ZAUhDkGaJfjzjKLSjv6zCL6O0LLBxU4K+aSYdM/U= gopkg.in/alecthomas/kingpin.v2 v2.2.6/go.mod h1:FMv+mEhP44yOT+4EoQTLFTRgOQ1FBLkstjWtayDeSgw= diff --git a/pkg/ccl/sqlproxyccl/BUILD.bazel b/pkg/ccl/sqlproxyccl/BUILD.bazel index a8a6cec2b1d1..a99d96362092 100644 --- a/pkg/ccl/sqlproxyccl/BUILD.bazel +++ b/pkg/ccl/sqlproxyccl/BUILD.bazel @@ -49,6 +49,7 @@ go_library( "@com_github_cockroachdb_logtags//:logtags", "@com_github_jackc_pgproto3_v2//:pgproto3", "@com_github_pires_go_proxyproto//:go-proxyproto", + "@com_github_prometheus_common//expfmt", "@org_golang_google_grpc//:go_default_library", "@org_golang_google_grpc//codes", "@org_golang_google_grpc//credentials/insecure", diff --git a/pkg/ccl/sqlproxyccl/server.go b/pkg/ccl/sqlproxyccl/server.go index 1d2f92643143..448dd387e927 100644 --- a/pkg/ccl/sqlproxyccl/server.go +++ b/pkg/ccl/sqlproxyccl/server.go @@ -25,6 +25,7 @@ import ( "github.com/cockroachdb/errors" "github.com/cockroachdb/logtags" proxyproto "github.com/pires/go-proxyproto" + "github.com/prometheus/common/expfmt" ) var ( @@ -106,11 +107,12 @@ func (s *Server) handleHealth(w http.ResponseWriter, r *http.Request) { } func (s *Server) handleVars(w http.ResponseWriter, r *http.Request) { - w.Header().Set(httputil.ContentTypeHeader, httputil.PlaintextContentType) + contentType := expfmt.Negotiate(r.Header) + w.Header().Set(httputil.ContentTypeHeader, string(contentType)) scrape := func(pm *metric.PrometheusExporter) { pm.ScrapeRegistry(s.metricsRegistry, true /* includeChildMetrics*/) } - if err := s.prometheusExporter.ScrapeAndPrintAsText(w, scrape); err != nil { + if err := s.prometheusExporter.ScrapeAndPrintAsText(w, contentType, scrape); err != nil { log.Errorf(r.Context(), "%v", err) http.Error(w, err.Error(), http.StatusInternalServerError) } diff --git a/pkg/cmd/roachtest/clusterstats/mocks_generated_test.go b/pkg/cmd/roachtest/clusterstats/mocks_generated_test.go index 087a6ea93dbb..ab751cf0f691 100644 --- a/pkg/cmd/roachtest/clusterstats/mocks_generated_test.go +++ b/pkg/cmd/roachtest/clusterstats/mocks_generated_test.go @@ -38,9 +38,13 @@ func (m *MockClient) EXPECT() *MockClientMockRecorder { } // Query mocks base method. -func (m *MockClient) Query(arg0 context.Context, arg1 string, arg2 time.Time) (model.Value, v1.Warnings, error) { +func (m *MockClient) Query(arg0 context.Context, arg1 string, arg2 time.Time, arg3 ...v1.Option) (model.Value, v1.Warnings, error) { m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "Query", arg0, arg1, arg2) + varargs := []interface{}{arg0, arg1, arg2} + for _, a := range arg3 { + varargs = append(varargs, a) + } + ret := m.ctrl.Call(m, "Query", varargs...) ret0, _ := ret[0].(model.Value) ret1, _ := ret[1].(v1.Warnings) ret2, _ := ret[2].(error) @@ -48,15 +52,20 @@ func (m *MockClient) Query(arg0 context.Context, arg1 string, arg2 time.Time) (m } // Query indicates an expected call of Query. -func (mr *MockClientMockRecorder) Query(arg0, arg1, arg2 interface{}) *gomock.Call { +func (mr *MockClientMockRecorder) Query(arg0, arg1, arg2 interface{}, arg3 ...interface{}) *gomock.Call { mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Query", reflect.TypeOf((*MockClient)(nil).Query), arg0, arg1, arg2) + varargs := append([]interface{}{arg0, arg1, arg2}, arg3...) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Query", reflect.TypeOf((*MockClient)(nil).Query), varargs...) } // QueryRange mocks base method. -func (m *MockClient) QueryRange(arg0 context.Context, arg1 string, arg2 v1.Range) (model.Value, v1.Warnings, error) { +func (m *MockClient) QueryRange(arg0 context.Context, arg1 string, arg2 v1.Range, arg3 ...v1.Option) (model.Value, v1.Warnings, error) { m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "QueryRange", arg0, arg1, arg2) + varargs := []interface{}{arg0, arg1, arg2} + for _, a := range arg3 { + varargs = append(varargs, a) + } + ret := m.ctrl.Call(m, "QueryRange", varargs...) ret0, _ := ret[0].(model.Value) ret1, _ := ret[1].(v1.Warnings) ret2, _ := ret[2].(error) @@ -64,7 +73,8 @@ func (m *MockClient) QueryRange(arg0 context.Context, arg1 string, arg2 v1.Range } // QueryRange indicates an expected call of QueryRange. -func (mr *MockClientMockRecorder) QueryRange(arg0, arg1, arg2 interface{}) *gomock.Call { +func (mr *MockClientMockRecorder) QueryRange(arg0, arg1, arg2 interface{}, arg3 ...interface{}) *gomock.Call { mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "QueryRange", reflect.TypeOf((*MockClient)(nil).QueryRange), arg0, arg1, arg2) + varargs := append([]interface{}{arg0, arg1, arg2}, arg3...) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "QueryRange", reflect.TypeOf((*MockClient)(nil).QueryRange), varargs...) } diff --git a/pkg/cmd/roachtest/tests/drt_generated_test.go b/pkg/cmd/roachtest/tests/drt_generated_test.go index 1a4ffe1b74c6..68b021e4054a 100644 --- a/pkg/cmd/roachtest/tests/drt_generated_test.go +++ b/pkg/cmd/roachtest/tests/drt_generated_test.go @@ -38,9 +38,13 @@ func (m *MockClient) EXPECT() *MockClientMockRecorder { } // Query mocks base method. -func (m *MockClient) Query(arg0 context.Context, arg1 string, arg2 time.Time) (model.Value, v1.Warnings, error) { +func (m *MockClient) Query(arg0 context.Context, arg1 string, arg2 time.Time, arg3 ...v1.Option) (model.Value, v1.Warnings, error) { m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "Query", arg0, arg1, arg2) + varargs := []interface{}{arg0, arg1, arg2} + for _, a := range arg3 { + varargs = append(varargs, a) + } + ret := m.ctrl.Call(m, "Query", varargs...) ret0, _ := ret[0].(model.Value) ret1, _ := ret[1].(v1.Warnings) ret2, _ := ret[2].(error) @@ -48,15 +52,20 @@ func (m *MockClient) Query(arg0 context.Context, arg1 string, arg2 time.Time) (m } // Query indicates an expected call of Query. -func (mr *MockClientMockRecorder) Query(arg0, arg1, arg2 interface{}) *gomock.Call { +func (mr *MockClientMockRecorder) Query(arg0, arg1, arg2 interface{}, arg3 ...interface{}) *gomock.Call { mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Query", reflect.TypeOf((*MockClient)(nil).Query), arg0, arg1, arg2) + varargs := append([]interface{}{arg0, arg1, arg2}, arg3...) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Query", reflect.TypeOf((*MockClient)(nil).Query), varargs...) } // QueryRange mocks base method. -func (m *MockClient) QueryRange(arg0 context.Context, arg1 string, arg2 v1.Range) (model.Value, v1.Warnings, error) { +func (m *MockClient) QueryRange(arg0 context.Context, arg1 string, arg2 v1.Range, arg3 ...v1.Option) (model.Value, v1.Warnings, error) { m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "QueryRange", arg0, arg1, arg2) + varargs := []interface{}{arg0, arg1, arg2} + for _, a := range arg3 { + varargs = append(varargs, a) + } + ret := m.ctrl.Call(m, "QueryRange", varargs...) ret0, _ := ret[0].(model.Value) ret1, _ := ret[1].(v1.Warnings) ret2, _ := ret[2].(error) @@ -64,7 +73,8 @@ func (m *MockClient) QueryRange(arg0 context.Context, arg1 string, arg2 v1.Range } // QueryRange indicates an expected call of QueryRange. -func (mr *MockClientMockRecorder) QueryRange(arg0, arg1, arg2 interface{}) *gomock.Call { +func (mr *MockClientMockRecorder) QueryRange(arg0, arg1, arg2 interface{}, arg3 ...interface{}) *gomock.Call { mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "QueryRange", reflect.TypeOf((*MockClient)(nil).QueryRange), arg0, arg1, arg2) + varargs := append([]interface{}{arg0, arg1, arg2}, arg3...) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "QueryRange", reflect.TypeOf((*MockClient)(nil).QueryRange), varargs...) } diff --git a/pkg/kv/kvserver/BUILD.bazel b/pkg/kv/kvserver/BUILD.bazel index 44066d570f75..32428854927e 100644 --- a/pkg/kv/kvserver/BUILD.bazel +++ b/pkg/kv/kvserver/BUILD.bazel @@ -509,6 +509,7 @@ go_test( "@com_github_kr_pretty//:pretty", "@com_github_lib_pq//:pq", "@com_github_olekukonko_tablewriter//:tablewriter", + "@com_github_prometheus_common//expfmt", "@com_github_stretchr_testify//assert", "@com_github_stretchr_testify//require", "@io_etcd_go_raft_v3//:raft", diff --git a/pkg/kv/kvserver/client_tenant_test.go b/pkg/kv/kvserver/client_tenant_test.go index 3ced0e2f285f..7563c8c2f5f2 100644 --- a/pkg/kv/kvserver/client_tenant_test.go +++ b/pkg/kv/kvserver/client_tenant_test.go @@ -45,6 +45,7 @@ import ( "github.com/cockroachdb/cockroach/pkg/util/timeutil" "github.com/cockroachdb/cockroach/pkg/util/uuid" "github.com/cockroachdb/errors" + "github.com/prometheus/common/expfmt" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" ) @@ -103,7 +104,7 @@ func TestTenantsStorageMetricsOnSplit(t *testing.T) { ex.ScrapeRegistry(store.Registry(), true /* includeChildMetrics */) } var in bytes.Buffer - if err := ex.ScrapeAndPrintAsText(&in, scrape); err != nil { + if err := ex.ScrapeAndPrintAsText(&in, expfmt.FmtText, scrape); err != nil { t.Fatalf("failed to print prometheus data: %v", err) } if seen != 2 { diff --git a/pkg/roachprod/prometheus/prometheus.go b/pkg/roachprod/prometheus/prometheus.go index 22a59af72a24..14b5b4adfcb8 100644 --- a/pkg/roachprod/prometheus/prometheus.go +++ b/pkg/roachprod/prometheus/prometheus.go @@ -31,8 +31,8 @@ const defaultWorkloadPort = 2112 // Client is an interface allowing queries against Prometheus. type Client interface { - Query(ctx context.Context, query string, ts time.Time) (model.Value, promv1.Warnings, error) - QueryRange(ctx context.Context, query string, r promv1.Range) (model.Value, promv1.Warnings, error) + Query(ctx context.Context, query string, ts time.Time, opts ...promv1.Option) (model.Value, promv1.Warnings, error) + QueryRange(ctx context.Context, query string, r promv1.Range, opts ...promv1.Option) (model.Value, promv1.Warnings, error) } // ScrapeNode is a node to scrape from. diff --git a/pkg/server/BUILD.bazel b/pkg/server/BUILD.bazel index ac9537cba1a9..ebd079d39744 100644 --- a/pkg/server/BUILD.bazel +++ b/pkg/server/BUILD.bazel @@ -350,6 +350,7 @@ go_library( "@com_github_marusama_semaphore//:semaphore", "@com_github_nightlyone_lockfile//:lockfile", "@com_github_nytimes_gziphandler//:gziphandler", + "@com_github_prometheus_common//expfmt", "@in_gopkg_yaml_v2//:yaml_v2", "@io_etcd_go_raft_v3//:raft", "@org_golang_google_grpc//:go_default_library", diff --git a/pkg/server/load_endpoint.go b/pkg/server/load_endpoint.go index 16b410c887c2..df013c862023 100644 --- a/pkg/server/load_endpoint.go +++ b/pkg/server/load_endpoint.go @@ -23,6 +23,7 @@ import ( "github.com/cockroachdb/cockroach/pkg/util/metric" "github.com/cockroachdb/cockroach/pkg/util/timeutil" "github.com/cockroachdb/errors" + "github.com/prometheus/common/expfmt" ) var ( @@ -112,13 +113,15 @@ func (le *loadEndpoint) ServeHTTP(w http.ResponseWriter, r *http.Request) { le.cpuNowNanos.Update(timeutil.Now().UnixNano()) le.uptimeSeconds.Update(float64(timeutil.Now().UnixNano()-le.initTimeNanos) / 1e9) - if err := le.exporterLoad.ScrapeAndPrintAsText(w, le.scrapeLoadVarsIntoPrometheus); err != nil { + contentType := expfmt.Negotiate(r.Header) + + if err := le.exporterLoad.ScrapeAndPrintAsText(w, contentType, le.scrapeLoadVarsIntoPrometheus); err != nil { log.Errorf(r.Context(), "%v", err) http.Error(w, err.Error(), http.StatusInternalServerError) return } - if err := le.exporterVars.ScrapeAndPrintAsText(w, le.mainMetricSource.ScrapeIntoPrometheus); err != nil { + if err := le.exporterVars.ScrapeAndPrintAsText(w, contentType, le.mainMetricSource.ScrapeIntoPrometheus); err != nil { log.Errorf(r.Context(), "%v", err) http.Error(w, err.Error(), http.StatusInternalServerError) return diff --git a/pkg/server/load_endpoint_test.go b/pkg/server/load_endpoint_test.go index 9a3ebce0671f..4ccafb98b506 100644 --- a/pkg/server/load_endpoint_test.go +++ b/pkg/server/load_endpoint_test.go @@ -29,9 +29,9 @@ import ( type testMetricSource struct{} -func (t testMetricSource) MarshalJSON() ([]byte, error) { return nil, nil } -func (t testMetricSource) PrintAsText(writer io.Writer) error { return nil } -func (t testMetricSource) ScrapeIntoPrometheus(pm *metric.PrometheusExporter) {} +func (t testMetricSource) MarshalJSON() ([]byte, error) { return nil, nil } +func (t testMetricSource) PrintAsText(writer io.Writer, contentType expfmt.Format) error { return nil } +func (t testMetricSource) ScrapeIntoPrometheus(pm *metric.PrometheusExporter) {} func extractPrometheusMetrics( t *testing.T, w *httptest.ResponseRecorder, diff --git a/pkg/server/status.go b/pkg/server/status.go index 2fad36d60b2d..66cb7784979e 100644 --- a/pkg/server/status.go +++ b/pkg/server/status.go @@ -84,6 +84,7 @@ import ( "github.com/cockroachdb/errors" "github.com/google/pprof/profile" gwruntime "github.com/grpc-ecosystem/grpc-gateway/runtime" + "github.com/prometheus/common/expfmt" raft "go.etcd.io/raft/v3" "google.golang.org/grpc" "google.golang.org/grpc/codes" @@ -130,7 +131,7 @@ var ( type metricMarshaler interface { json.Marshaler - PrintAsText(io.Writer) error + PrintAsText(io.Writer, expfmt.Format) error ScrapeIntoPrometheus(pm *metric.PrometheusExporter) } @@ -2322,8 +2323,9 @@ type varsHandler struct { func (h varsHandler) handleVars(w http.ResponseWriter, r *http.Request) { ctx := r.Context() - w.Header().Set(httputil.ContentTypeHeader, httputil.PlaintextContentType) - err := h.metricSource.PrintAsText(w) + contentType := expfmt.Negotiate(r.Header) + w.Header().Set(httputil.ContentTypeHeader, string(contentType)) + err := h.metricSource.PrintAsText(w, contentType) if err != nil { log.Errorf(ctx, "%v", err) http.Error(w, err.Error(), http.StatusInternalServerError) diff --git a/pkg/server/status/BUILD.bazel b/pkg/server/status/BUILD.bazel index 54ff9feb8907..fa4ad6d8754e 100644 --- a/pkg/server/status/BUILD.bazel +++ b/pkg/server/status/BUILD.bazel @@ -73,6 +73,7 @@ go_library( "@com_github_dustin_go_humanize//:go-humanize", "@com_github_elastic_gosigar//:gosigar", "@com_github_prometheus_client_model//go", + "@com_github_prometheus_common//expfmt", "@com_github_shirou_gopsutil_v3//cpu", "@com_github_shirou_gopsutil_v3//net", ] + select({ @@ -159,6 +160,7 @@ go_test( "//pkg/util/timeutil", "@com_github_kr_pretty//:pretty", "@com_github_prometheus_client_model//go", + "@com_github_prometheus_common//expfmt", "@com_github_shirou_gopsutil_v3//net", "@com_github_stretchr_testify//require", ], diff --git a/pkg/server/status/recorder.go b/pkg/server/status/recorder.go index e12718196a5b..f3682aa134a9 100644 --- a/pkg/server/status/recorder.go +++ b/pkg/server/status/recorder.go @@ -52,6 +52,7 @@ import ( "github.com/dustin/go-humanize" "github.com/elastic/gosigar" prometheusgo "github.com/prometheus/client_model/go" + "github.com/prometheus/common/expfmt" ) const ( @@ -311,9 +312,9 @@ func (mr *MetricsRecorder) ScrapeIntoPrometheus(pm *metric.PrometheusExporter) { // PrintAsText writes the current metrics values as plain-text to the writer. // We write metrics to a temporary buffer which is then copied to the writer. // This is to avoid hanging requests from holding the lock. -func (mr *MetricsRecorder) PrintAsText(w io.Writer) error { +func (mr *MetricsRecorder) PrintAsText(w io.Writer, contentType expfmt.Format) error { var buf bytes.Buffer - if err := mr.prometheusExporter.ScrapeAndPrintAsText(&buf, mr.ScrapeIntoPrometheus); err != nil { + if err := mr.prometheusExporter.ScrapeAndPrintAsText(&buf, contentType, mr.ScrapeIntoPrometheus); err != nil { return err } _, err := buf.WriteTo(w) diff --git a/pkg/server/status/recorder_test.go b/pkg/server/status/recorder_test.go index 587b52c6a2a8..a59dbfd16e23 100644 --- a/pkg/server/status/recorder_test.go +++ b/pkg/server/status/recorder_test.go @@ -37,6 +37,7 @@ import ( "github.com/cockroachdb/cockroach/pkg/util/timeutil" "github.com/kr/pretty" prometheusgo "github.com/prometheus/client_model/go" + "github.com/prometheus/common/expfmt" "github.com/stretchr/testify/require" ) @@ -154,14 +155,14 @@ func TestMetricsRecorderLabels(t *testing.T) { recorder.AddTenantRegistry(tenantID, regTenant) buf := bytes.NewBuffer([]byte{}) - err = recorder.PrintAsText(buf) + err = recorder.PrintAsText(buf, expfmt.FmtText) require.NoError(t, err) require.Contains(t, buf.String(), `some_metric{node_id="7",tenant="system"} 123`) require.Contains(t, buf.String(), `some_metric{node_id="7",tenant="application"} 456`) bufTenant := bytes.NewBuffer([]byte{}) - err = recorderTenant.PrintAsText(bufTenant) + err = recorderTenant.PrintAsText(bufTenant, expfmt.FmtText) require.NoError(t, err) require.NotContains(t, bufTenant.String(), `some_metric{node_id="7",tenant="system"} 123`) @@ -172,14 +173,14 @@ func TestMetricsRecorderLabels(t *testing.T) { appNameContainer.Set("application2") buf = bytes.NewBuffer([]byte{}) - err = recorder.PrintAsText(buf) + err = recorder.PrintAsText(buf, expfmt.FmtText) require.NoError(t, err) require.Contains(t, buf.String(), `some_metric{node_id="7",tenant="system"} 123`) require.Contains(t, buf.String(), `some_metric{node_id="7",tenant="application2"} 456`) bufTenant = bytes.NewBuffer([]byte{}) - err = recorderTenant.PrintAsText(bufTenant) + err = recorderTenant.PrintAsText(bufTenant, expfmt.FmtText) require.NoError(t, err) require.NotContains(t, bufTenant.String(), `some_metric{node_id="7",tenant="system"} 123`) @@ -672,7 +673,7 @@ func TestMetricsRecorder(t *testing.T) { if _, err := recorder.MarshalJSON(); err != nil { t.Error(err) } - _ = recorder.PrintAsText(io.Discard) + _ = recorder.PrintAsText(io.Discard, expfmt.FmtText) _ = recorder.GetTimeSeriesData() wg.Done() }() diff --git a/pkg/testutils/metrictestutils/BUILD.bazel b/pkg/testutils/metrictestutils/BUILD.bazel index 3070d18c5eff..07f701807a56 100644 --- a/pkg/testutils/metrictestutils/BUILD.bazel +++ b/pkg/testutils/metrictestutils/BUILD.bazel @@ -6,5 +6,8 @@ go_library( srcs = ["metrics_text.go"], importpath = "github.com/cockroachdb/cockroach/pkg/testutils/metrictestutils", visibility = ["//visibility:public"], - deps = ["//pkg/util/metric"], + deps = [ + "//pkg/util/metric", + "@com_github_prometheus_common//expfmt", + ], ) diff --git a/pkg/testutils/metrictestutils/metrics_text.go b/pkg/testutils/metrictestutils/metrics_text.go index baf3718d4c8d..cb45b5166dd5 100644 --- a/pkg/testutils/metrictestutils/metrics_text.go +++ b/pkg/testutils/metrictestutils/metrics_text.go @@ -18,6 +18,7 @@ import ( "strings" "github.com/cockroachdb/cockroach/pkg/util/metric" + "github.com/prometheus/common/expfmt" ) // GetMetricsText scrapes a metrics registry, filters out the metrics according @@ -28,7 +29,7 @@ func GetMetricsText(registry *metric.Registry, re *regexp.Regexp) (string, error ex.ScrapeRegistry(registry, true /* includeChildMetrics */) } var in bytes.Buffer - if err := ex.ScrapeAndPrintAsText(&in, scrape); err != nil { + if err := ex.ScrapeAndPrintAsText(&in, expfmt.FmtText, scrape); err != nil { return "", err } sc := bufio.NewScanner(&in) diff --git a/pkg/util/metric/BUILD.bazel b/pkg/util/metric/BUILD.bazel index b07dd49b6b97..e229759a192a 100644 --- a/pkg/util/metric/BUILD.bazel +++ b/pkg/util/metric/BUILD.bazel @@ -63,6 +63,7 @@ go_test( "@com_github_kr_pretty//:pretty", "@com_github_prometheus_client_golang//prometheus", "@com_github_prometheus_client_model//go", + "@com_github_prometheus_common//expfmt", "@com_github_stretchr_testify//require", ], ) diff --git a/pkg/util/metric/aggmetric/BUILD.bazel b/pkg/util/metric/aggmetric/BUILD.bazel index 9e9a82252b2d..4cb9d8695ca7 100644 --- a/pkg/util/metric/aggmetric/BUILD.bazel +++ b/pkg/util/metric/aggmetric/BUILD.bazel @@ -35,6 +35,7 @@ go_test( "//pkg/util/leaktest", "//pkg/util/metric", "@com_github_prometheus_client_model//go", + "@com_github_prometheus_common//expfmt", "@com_github_stretchr_testify//require", ], ) diff --git a/pkg/util/metric/aggmetric/agg_metric_test.go b/pkg/util/metric/aggmetric/agg_metric_test.go index 73652961ddea..c9bac090d26e 100644 --- a/pkg/util/metric/aggmetric/agg_metric_test.go +++ b/pkg/util/metric/aggmetric/agg_metric_test.go @@ -25,6 +25,7 @@ import ( "github.com/cockroachdb/cockroach/pkg/util/metric" "github.com/cockroachdb/cockroach/pkg/util/metric/aggmetric" prometheusgo "github.com/prometheus/client_model/go" + "github.com/prometheus/common/expfmt" "github.com/stretchr/testify/require" ) @@ -38,7 +39,7 @@ func TestAggMetric(t *testing.T) { scrape := func(ex *metric.PrometheusExporter) { ex.ScrapeRegistry(r, true /* includeChildMetrics */) } - require.NoError(t, ex.ScrapeAndPrintAsText(&in, scrape)) + require.NoError(t, ex.ScrapeAndPrintAsText(&in, expfmt.FmtText, scrape)) var lines []string for sc := bufio.NewScanner(&in); sc.Scan(); { if !bytes.HasPrefix(sc.Bytes(), []byte{'#'}) { diff --git a/pkg/util/metric/metric.go b/pkg/util/metric/metric.go index e3508c2ebdb3..0183462be662 100644 --- a/pkg/util/metric/metric.go +++ b/pkg/util/metric/metric.go @@ -206,6 +206,29 @@ func HdrEnabled() bool { return hdrEnabled } +// useNativeHistogramsEnvVar can be used to enable the Prometheus native +// histogram feature, which represents a histogram as a single time series +// rather than a collection of per-bucket counter series. If enabled, both +// conventional and native histograms are exported. +const useNativeHistogramsEnvVar = "COCKROACH_ENABLE_NATIVE_HISTOGRAMS" + +var nativeHistogramsEnabled = envutil.EnvOrDefaultBool(useNativeHistogramsEnvVar, false) + +// nativeHistogramsBucketFactorEnvVar can be used to override the default +// bucket size exponential factor for Prometheus native histograms, if enabled. +// If not set, use the default factor of 1.1. +const nativeHistogramsBucketFactorEnvVar = "COCKROACH_NATIVE_HISTOGRAMS_BUCKET_FACTOR" + +var nativeHistogramsBucketFactor = envutil.EnvOrDefaultFloat64(nativeHistogramsBucketFactorEnvVar, 1.1) + +// nativeHistogramsBucketCountMultiplierEnvVar can be used to override the +// default maximum bucket count for Prometheus native histograms, if enabled. +// The maximum bucket count is set to the number of conventional buckets for +// the histogram metric multiplied by the multiplier, which defaults to 1.0. +const nativeHistogramsBucketCountMultiplierEnvVar = "COCKROACH_NATIVE_HISTOGRAMS_BUCKET_COUNT_MULTIPLIER" + +var nativeHistogramsBucketCountMultiplier = envutil.EnvOrDefaultFloat64(nativeHistogramsBucketCountMultiplierEnvVar, 1) + type HistogramMode byte const ( @@ -272,6 +295,10 @@ func newHistogram(meta Metadata, duration time.Duration, buckets []float64) *His opts := prometheus.HistogramOpts{ Buckets: buckets, } + if nativeHistogramsEnabled { + opts.NativeHistogramBucketFactor = nativeHistogramsBucketFactor + opts.NativeHistogramMaxBucketNumber = uint32(float64(len(buckets)) * nativeHistogramsBucketCountMultiplier) + } cum := prometheus.NewHistogram(opts) h := &Histogram{ Metadata: meta, @@ -475,6 +502,10 @@ func NewManualWindowHistogram( opts := prometheus.HistogramOpts{ Buckets: buckets, } + if nativeHistogramsEnabled { + opts.NativeHistogramBucketFactor = nativeHistogramsBucketFactor + opts.NativeHistogramMaxBucketNumber = uint32(float64(len(buckets)) * nativeHistogramsBucketCountMultiplier) + } cum := prometheus.NewHistogram(opts) prev := &prometheusgo.Metric{} if err := cum.Write(prev); err != nil { diff --git a/pkg/util/metric/prometheus_exporter.go b/pkg/util/metric/prometheus_exporter.go index 5468dda217f2..a8e2951e7c04 100644 --- a/pkg/util/metric/prometheus_exporter.go +++ b/pkg/util/metric/prometheus_exporter.go @@ -111,9 +111,10 @@ func (pm *PrometheusExporter) ScrapeRegistry(registry *Registry, includeChildMet // printAsText writes all metrics in the families map to the io.Writer in // prometheus' text format. It removes individual metrics from the families // as it goes, readying the families for another found of registry additions. -func (pm *PrometheusExporter) printAsText(w io.Writer) error { +func (pm *PrometheusExporter) printAsText(w io.Writer, contentType expfmt.Format) error { + enc := expfmt.NewEncoder(w, contentType) for _, family := range pm.families { - if _, err := expfmt.MetricFamilyToText(w, family); err != nil { + if err := enc.Encode(family); err != nil { return err } } @@ -127,12 +128,12 @@ func (pm *PrometheusExporter) printAsText(w io.Writer) error { // as it goes, readying the families for another found of registry additions. // It does this under lock so it is thread safe and can be called concurrently. func (pm *PrometheusExporter) ScrapeAndPrintAsText( - w io.Writer, scrapeFunc func(*PrometheusExporter), + w io.Writer, contentType expfmt.Format, scrapeFunc func(*PrometheusExporter), ) error { pm.muScrapeAndPrint.Lock() defer pm.muScrapeAndPrint.Unlock() scrapeFunc(pm) - return pm.printAsText(w) + return pm.printAsText(w, contentType) } // Verify GraphiteExporter implements Gatherer interface. diff --git a/pkg/util/metric/prometheus_exporter_test.go b/pkg/util/metric/prometheus_exporter_test.go index f65c0e878016..a587801af7f5 100644 --- a/pkg/util/metric/prometheus_exporter_test.go +++ b/pkg/util/metric/prometheus_exporter_test.go @@ -15,6 +15,7 @@ import ( "strings" "testing" + "github.com/prometheus/common/expfmt" "github.com/stretchr/testify/require" ) @@ -122,7 +123,7 @@ func TestPrometheusExporter(t *testing.T) { // Test ScrapeAndPrintAsText var buf bytes.Buffer pe = MakePrometheusExporter() - err = pe.ScrapeAndPrintAsText(&buf, func(exporter *PrometheusExporter) { + err = pe.ScrapeAndPrintAsText(&buf, expfmt.FmtText, func(exporter *PrometheusExporter) { exporter.ScrapeRegistry(r1, true) }) require.NoError(t, err)