all: go fmt from Go1.19

This commit is contained in:
Aliaksandr Valialkin 2022-08-08 17:15:06 +03:00
parent c6c6640e5b
commit 4ca082233a
No known key found for this signature in database
GPG Key ID: A72BEC6CD3D0DED1
8 changed files with 155 additions and 125 deletions

View File

@ -11,9 +11,9 @@ import (
// name must be valid Prometheus-compatible metric with possible labels. // name must be valid Prometheus-compatible metric with possible labels.
// For instance, // For instance,
// //
// * foo // - foo
// * foo{bar="baz"} // - foo{bar="baz"}
// * foo{bar="baz",aaa="b"} // - foo{bar="baz",aaa="b"}
// //
// The returned counter is safe to use from concurrent goroutines. // The returned counter is safe to use from concurrent goroutines.
func NewCounter(name string) *Counter { func NewCounter(name string) *Counter {
@ -65,9 +65,9 @@ func (c *Counter) marshalTo(prefix string, w io.Writer) {
// name must be valid Prometheus-compatible metric with possible labels. // name must be valid Prometheus-compatible metric with possible labels.
// For instance, // For instance,
// //
// * foo // - foo
// * foo{bar="baz"} // - foo{bar="baz"}
// * foo{bar="baz",aaa="b"} // - foo{bar="baz",aaa="b"}
// //
// The returned counter is safe to use from concurrent goroutines. // The returned counter is safe to use from concurrent goroutines.
// //

View File

@ -11,9 +11,9 @@ import (
// name must be valid Prometheus-compatible metric with possible labels. // name must be valid Prometheus-compatible metric with possible labels.
// For instance, // For instance,
// //
// * foo // - foo
// * foo{bar="baz"} // - foo{bar="baz"}
// * foo{bar="baz",aaa="b"} // - foo{bar="baz",aaa="b"}
// //
// The returned counter is safe to use from concurrent goroutines. // The returned counter is safe to use from concurrent goroutines.
func NewFloatCounter(name string) *FloatCounter { func NewFloatCounter(name string) *FloatCounter {
@ -70,9 +70,9 @@ func (fc *FloatCounter) marshalTo(prefix string, w io.Writer) {
// name must be valid Prometheus-compatible metric with possible labels. // name must be valid Prometheus-compatible metric with possible labels.
// For instance, // For instance,
// //
// * foo // - foo
// * foo{bar="baz"} // - foo{bar="baz"}
// * foo{bar="baz",aaa="b"} // - foo{bar="baz",aaa="b"}
// //
// The returned FloatCounter is safe to use from concurrent goroutines. // The returned FloatCounter is safe to use from concurrent goroutines.
// //

View File

@ -11,9 +11,9 @@ import (
// name must be valid Prometheus-compatible metric with possible labels. // name must be valid Prometheus-compatible metric with possible labels.
// For instance, // For instance,
// //
// * foo // - foo
// * foo{bar="baz"} // - foo{bar="baz"}
// * foo{bar="baz",aaa="b"} // - foo{bar="baz",aaa="b"}
// //
// f must be safe for concurrent calls. // f must be safe for concurrent calls.
// //
@ -53,9 +53,9 @@ func (g *Gauge) marshalTo(prefix string, w io.Writer) {
// name must be valid Prometheus-compatible metric with possible labels. // name must be valid Prometheus-compatible metric with possible labels.
// For instance, // For instance,
// //
// * foo // - foo
// * foo{bar="baz"} // - foo{bar="baz"}
// * foo{bar="baz",aaa="b"} // - foo{bar="baz",aaa="b"}
// //
// The returned gauge is safe to use from concurrent goroutines. // The returned gauge is safe to use from concurrent goroutines.
// //

View File

@ -143,9 +143,9 @@ func (h *Histogram) VisitNonZeroBuckets(f func(vmrange string, count uint64)) {
// name must be valid Prometheus-compatible metric with possible labels. // name must be valid Prometheus-compatible metric with possible labels.
// For instance, // For instance,
// //
// * foo // - foo
// * foo{bar="baz"} // - foo{bar="baz"}
// * foo{bar="baz",aaa="b"} // - foo{bar="baz",aaa="b"}
// //
// The returned histogram is safe to use from concurrent goroutines. // The returned histogram is safe to use from concurrent goroutines.
func NewHistogram(name string) *Histogram { func NewHistogram(name string) *Histogram {
@ -159,9 +159,9 @@ func NewHistogram(name string) *Histogram {
// name must be valid Prometheus-compatible metric with possible labels. // name must be valid Prometheus-compatible metric with possible labels.
// For instance, // For instance,
// //
// * foo // - foo
// * foo{bar="baz"} // - foo{bar="baz"}
// * foo{bar="baz",aaa="b"} // - foo{bar="baz",aaa="b"}
// //
// The returned histogram is safe to use from concurrent goroutines. // The returned histogram is safe to use from concurrent goroutines.
// //

View File

@ -67,7 +67,6 @@ func UnregisterSet(s *Set) {
// http.HandleFunc("/metrics", func(w http.ResponseWriter, req *http.Request) { // http.HandleFunc("/metrics", func(w http.ResponseWriter, req *http.Request) {
// metrics.WritePrometheus(w, true) // metrics.WritePrometheus(w, true)
// }) // })
//
func WritePrometheus(w io.Writer, exposeProcessMetrics bool) { func WritePrometheus(w io.Writer, exposeProcessMetrics bool) {
registeredSetsLock.Lock() registeredSetsLock.Lock()
sets := make([]*Set, 0, len(registeredSets)) sets := make([]*Set, 0, len(registeredSets))
@ -93,40 +92,71 @@ func WritePrometheus(w io.Writer, exposeProcessMetrics bool) {
// running process. Below is a short description for the exposed `process_*` metrics: // running process. Below is a short description for the exposed `process_*` metrics:
// //
// - process_cpu_seconds_system_total - CPU time spent in syscalls // - process_cpu_seconds_system_total - CPU time spent in syscalls
//
// - process_cpu_seconds_user_total - CPU time spent in userspace // - process_cpu_seconds_user_total - CPU time spent in userspace
//
// - process_cpu_seconds_total - CPU time spent by the process // - process_cpu_seconds_total - CPU time spent by the process
//
// - process_major_pagefaults_total - page faults resulted in disk IO // - process_major_pagefaults_total - page faults resulted in disk IO
//
// - process_minor_pagefaults_total - page faults resolved without disk IO // - process_minor_pagefaults_total - page faults resolved without disk IO
//
// - process_resident_memory_bytes - recently accessed memory (aka RSS or resident memory) // - process_resident_memory_bytes - recently accessed memory (aka RSS or resident memory)
//
// - process_resident_memory_peak_bytes - the maximum RSS memory usage // - process_resident_memory_peak_bytes - the maximum RSS memory usage
//
// - process_resident_memory_anon_bytes - RSS for memory-mapped files // - process_resident_memory_anon_bytes - RSS for memory-mapped files
//
// - process_resident_memory_file_bytes - RSS for memory allocated by the process // - process_resident_memory_file_bytes - RSS for memory allocated by the process
//
// - process_resident_memory_shared_bytes - RSS for memory shared between multiple processes // - process_resident_memory_shared_bytes - RSS for memory shared between multiple processes
//
// - process_virtual_memory_bytes - virtual memory usage // - process_virtual_memory_bytes - virtual memory usage
//
// - process_virtual_memory_peak_bytes - the maximum virtual memory usage // - process_virtual_memory_peak_bytes - the maximum virtual memory usage
//
// - process_num_threads - the number of threads // - process_num_threads - the number of threads
//
// - process_start_time_seconds - process start time as unix timestamp // - process_start_time_seconds - process start time as unix timestamp
// //
// - process_io_read_bytes_total - the number of bytes read via syscalls // - process_io_read_bytes_total - the number of bytes read via syscalls
//
// - process_io_written_bytes_total - the number of bytes written via syscalls // - process_io_written_bytes_total - the number of bytes written via syscalls
//
// - process_io_read_syscalls_total - the number of read syscalls // - process_io_read_syscalls_total - the number of read syscalls
//
// - process_io_write_syscalls_total - the number of write syscalls // - process_io_write_syscalls_total - the number of write syscalls
//
// - process_io_storage_read_bytes_total - the number of bytes actually read from disk // - process_io_storage_read_bytes_total - the number of bytes actually read from disk
//
// - process_io_storage_written_bytes_total - the number of bytes actually written to disk // - process_io_storage_written_bytes_total - the number of bytes actually written to disk
// //
// - go_memstats_alloc_bytes - memory usage for Go objects in the heap // - go_memstats_alloc_bytes - memory usage for Go objects in the heap
//
// - go_memstats_alloc_bytes_total - the cumulative counter for total size of allocated Go objects // - go_memstats_alloc_bytes_total - the cumulative counter for total size of allocated Go objects
//
// - go_memstats_frees_total - the cumulative counter for number of freed Go objects // - go_memstats_frees_total - the cumulative counter for number of freed Go objects
//
// - go_memstats_gc_cpu_fraction - the fraction of CPU spent in Go garbage collector // - go_memstats_gc_cpu_fraction - the fraction of CPU spent in Go garbage collector
//
// - go_memstats_gc_sys_bytes - the size of Go garbage collector metadata // - go_memstats_gc_sys_bytes - the size of Go garbage collector metadata
//
// - go_memstats_heap_alloc_bytes - the same as go_memstats_alloc_bytes // - go_memstats_heap_alloc_bytes - the same as go_memstats_alloc_bytes
//
// - go_memstats_heap_idle_bytes - idle memory ready for new Go object allocations // - go_memstats_heap_idle_bytes - idle memory ready for new Go object allocations
//
// - go_memstats_heap_objects - the number of Go objects in the heap // - go_memstats_heap_objects - the number of Go objects in the heap
//
// - go_memstats_heap_sys_bytes - memory requested for Go objects from the OS // - go_memstats_heap_sys_bytes - memory requested for Go objects from the OS
//
// - go_memstats_mallocs_total - the number of allocations for Go objects // - go_memstats_mallocs_total - the number of allocations for Go objects
//
// - go_memstats_next_gc_bytes - the target heap size when the next garbage collection should start // - go_memstats_next_gc_bytes - the target heap size when the next garbage collection should start
//
// - go_memstats_stack_inuse_bytes - memory used for goroutine stacks // - go_memstats_stack_inuse_bytes - memory used for goroutine stacks
//
// - go_memstats_stack_sys_bytes - memory requested fromthe OS for goroutine stacks // - go_memstats_stack_sys_bytes - memory requested fromthe OS for goroutine stacks
//
// - go_memstats_sys_bytes - memory requested by Go runtime from the OS // - go_memstats_sys_bytes - memory requested by Go runtime from the OS
// //
// The WriteProcessMetrics func is usually called in combination with writing Set metrics // The WriteProcessMetrics func is usually called in combination with writing Set metrics

View File

@ -60,7 +60,7 @@ func InitPush(pushURL string, interval time.Duration, extraLabels string, pushPr
// extraLabels may contain comma-separated list of `label="value"` labels, which will be added // extraLabels may contain comma-separated list of `label="value"` labels, which will be added
// to all the metrics before pushing them to pushURL. // to all the metrics before pushing them to pushURL.
// //
/// The metrics are pushed to pushURL in Prometheus text exposition format. // / The metrics are pushed to pushURL in Prometheus text exposition format.
// See https://github.com/prometheus/docs/blob/main/content/docs/instrumenting/exposition_formats.md#text-based-format // See https://github.com/prometheus/docs/blob/main/content/docs/instrumenting/exposition_formats.md#text-based-format
// //
// It is recommended pushing metrics to /api/v1/import/prometheus endpoint according to // It is recommended pushing metrics to /api/v1/import/prometheus endpoint according to

72
set.go
View File

@ -60,9 +60,9 @@ func (s *Set) WritePrometheus(w io.Writer) {
// name must be valid Prometheus-compatible metric with possible labels. // name must be valid Prometheus-compatible metric with possible labels.
// For instance, // For instance,
// //
// * foo // - foo
// * foo{bar="baz"} // - foo{bar="baz"}
// * foo{bar="baz",aaa="b"} // - foo{bar="baz",aaa="b"}
// //
// The returned histogram is safe to use from concurrent goroutines. // The returned histogram is safe to use from concurrent goroutines.
func (s *Set) NewHistogram(name string) *Histogram { func (s *Set) NewHistogram(name string) *Histogram {
@ -77,9 +77,9 @@ func (s *Set) NewHistogram(name string) *Histogram {
// name must be valid Prometheus-compatible metric with possible labels. // name must be valid Prometheus-compatible metric with possible labels.
// For instance, // For instance,
// //
// * foo // - foo
// * foo{bar="baz"} // - foo{bar="baz"}
// * foo{bar="baz",aaa="b"} // - foo{bar="baz",aaa="b"}
// //
// The returned histogram is safe to use from concurrent goroutines. // The returned histogram is safe to use from concurrent goroutines.
// //
@ -118,9 +118,9 @@ func (s *Set) GetOrCreateHistogram(name string) *Histogram {
// name must be valid Prometheus-compatible metric with possible labels. // name must be valid Prometheus-compatible metric with possible labels.
// For instance, // For instance,
// //
// * foo // - foo
// * foo{bar="baz"} // - foo{bar="baz"}
// * foo{bar="baz",aaa="b"} // - foo{bar="baz",aaa="b"}
// //
// The returned counter is safe to use from concurrent goroutines. // The returned counter is safe to use from concurrent goroutines.
func (s *Set) NewCounter(name string) *Counter { func (s *Set) NewCounter(name string) *Counter {
@ -135,9 +135,9 @@ func (s *Set) NewCounter(name string) *Counter {
// name must be valid Prometheus-compatible metric with possible labels. // name must be valid Prometheus-compatible metric with possible labels.
// For instance, // For instance,
// //
// * foo // - foo
// * foo{bar="baz"} // - foo{bar="baz"}
// * foo{bar="baz",aaa="b"} // - foo{bar="baz",aaa="b"}
// //
// The returned counter is safe to use from concurrent goroutines. // The returned counter is safe to use from concurrent goroutines.
// //
@ -176,9 +176,9 @@ func (s *Set) GetOrCreateCounter(name string) *Counter {
// name must be valid Prometheus-compatible metric with possible labels. // name must be valid Prometheus-compatible metric with possible labels.
// For instance, // For instance,
// //
// * foo // - foo
// * foo{bar="baz"} // - foo{bar="baz"}
// * foo{bar="baz",aaa="b"} // - foo{bar="baz",aaa="b"}
// //
// The returned FloatCounter is safe to use from concurrent goroutines. // The returned FloatCounter is safe to use from concurrent goroutines.
func (s *Set) NewFloatCounter(name string) *FloatCounter { func (s *Set) NewFloatCounter(name string) *FloatCounter {
@ -193,9 +193,9 @@ func (s *Set) NewFloatCounter(name string) *FloatCounter {
// name must be valid Prometheus-compatible metric with possible labels. // name must be valid Prometheus-compatible metric with possible labels.
// For instance, // For instance,
// //
// * foo // - foo
// * foo{bar="baz"} // - foo{bar="baz"}
// * foo{bar="baz",aaa="b"} // - foo{bar="baz",aaa="b"}
// //
// The returned FloatCounter is safe to use from concurrent goroutines. // The returned FloatCounter is safe to use from concurrent goroutines.
// //
@ -235,9 +235,9 @@ func (s *Set) GetOrCreateFloatCounter(name string) *FloatCounter {
// name must be valid Prometheus-compatible metric with possible labels. // name must be valid Prometheus-compatible metric with possible labels.
// For instance, // For instance,
// //
// * foo // - foo
// * foo{bar="baz"} // - foo{bar="baz"}
// * foo{bar="baz",aaa="b"} // - foo{bar="baz",aaa="b"}
// //
// f must be safe for concurrent calls. // f must be safe for concurrent calls.
// //
@ -259,9 +259,9 @@ func (s *Set) NewGauge(name string, f func() float64) *Gauge {
// name must be valid Prometheus-compatible metric with possible labels. // name must be valid Prometheus-compatible metric with possible labels.
// For instance, // For instance,
// //
// * foo // - foo
// * foo{bar="baz"} // - foo{bar="baz"}
// * foo{bar="baz",aaa="b"} // - foo{bar="baz",aaa="b"}
// //
// The returned gauge is safe to use from concurrent goroutines. // The returned gauge is safe to use from concurrent goroutines.
// //
@ -305,9 +305,9 @@ func (s *Set) GetOrCreateGauge(name string, f func() float64) *Gauge {
// name must be valid Prometheus-compatible metric with possible labels. // name must be valid Prometheus-compatible metric with possible labels.
// For instance, // For instance,
// //
// * foo // - foo
// * foo{bar="baz"} // - foo{bar="baz"}
// * foo{bar="baz",aaa="b"} // - foo{bar="baz",aaa="b"}
// //
// The returned summary is safe to use from concurrent goroutines. // The returned summary is safe to use from concurrent goroutines.
func (s *Set) NewSummary(name string) *Summary { func (s *Set) NewSummary(name string) *Summary {
@ -320,9 +320,9 @@ func (s *Set) NewSummary(name string) *Summary {
// name must be valid Prometheus-compatible metric with possible labels. // name must be valid Prometheus-compatible metric with possible labels.
// For instance, // For instance,
// //
// * foo // - foo
// * foo{bar="baz"} // - foo{bar="baz"}
// * foo{bar="baz",aaa="b"} // - foo{bar="baz",aaa="b"}
// //
// The returned summary is safe to use from concurrent goroutines. // The returned summary is safe to use from concurrent goroutines.
func (s *Set) NewSummaryExt(name string, window time.Duration, quantiles []float64) *Summary { func (s *Set) NewSummaryExt(name string, window time.Duration, quantiles []float64) *Summary {
@ -349,9 +349,9 @@ func (s *Set) NewSummaryExt(name string, window time.Duration, quantiles []float
// name must be valid Prometheus-compatible metric with possible labels. // name must be valid Prometheus-compatible metric with possible labels.
// For instance, // For instance,
// //
// * foo // - foo
// * foo{bar="baz"} // - foo{bar="baz"}
// * foo{bar="baz",aaa="b"} // - foo{bar="baz",aaa="b"}
// //
// The returned summary is safe to use from concurrent goroutines. // The returned summary is safe to use from concurrent goroutines.
// //
@ -367,9 +367,9 @@ func (s *Set) GetOrCreateSummary(name string) *Summary {
// name must be valid Prometheus-compatible metric with possible labels. // name must be valid Prometheus-compatible metric with possible labels.
// For instance, // For instance,
// //
// * foo // - foo
// * foo{bar="baz"} // - foo{bar="baz"}
// * foo{bar="baz",aaa="b"} // - foo{bar="baz",aaa="b"}
// //
// The returned summary is safe to use from concurrent goroutines. // The returned summary is safe to use from concurrent goroutines.
// //

View File

@ -36,9 +36,9 @@ type Summary struct {
// name must be valid Prometheus-compatible metric with possible labels. // name must be valid Prometheus-compatible metric with possible labels.
// For instance, // For instance,
// //
// * foo // - foo
// * foo{bar="baz"} // - foo{bar="baz"}
// * foo{bar="baz",aaa="b"} // - foo{bar="baz",aaa="b"}
// //
// The returned summary is safe to use from concurrent goroutines. // The returned summary is safe to use from concurrent goroutines.
func NewSummary(name string) *Summary { func NewSummary(name string) *Summary {
@ -51,9 +51,9 @@ func NewSummary(name string) *Summary {
// name must be valid Prometheus-compatible metric with possible labels. // name must be valid Prometheus-compatible metric with possible labels.
// For instance, // For instance,
// //
// * foo // - foo
// * foo{bar="baz"} // - foo{bar="baz"}
// * foo{bar="baz",aaa="b"} // - foo{bar="baz",aaa="b"}
// //
// The returned summary is safe to use from concurrent goroutines. // The returned summary is safe to use from concurrent goroutines.
func NewSummaryExt(name string, window time.Duration, quantiles []float64) *Summary { func NewSummaryExt(name string, window time.Duration, quantiles []float64) *Summary {
@ -140,9 +140,9 @@ func (sm *Summary) updateQuantiles() {
// name must be valid Prometheus-compatible metric with possible labels. // name must be valid Prometheus-compatible metric with possible labels.
// For instance, // For instance,
// //
// * foo // - foo
// * foo{bar="baz"} // - foo{bar="baz"}
// * foo{bar="baz",aaa="b"} // - foo{bar="baz",aaa="b"}
// //
// The returned summary is safe to use from concurrent goroutines. // The returned summary is safe to use from concurrent goroutines.
// //
@ -158,9 +158,9 @@ func GetOrCreateSummary(name string) *Summary {
// name must be valid Prometheus-compatible metric with possible labels. // name must be valid Prometheus-compatible metric with possible labels.
// For instance, // For instance,
// //
// * foo // - foo
// * foo{bar="baz"} // - foo{bar="baz"}
// * foo{bar="baz",aaa="b"} // - foo{bar="baz",aaa="b"}
// //
// The returned summary is safe to use from concurrent goroutines. // The returned summary is safe to use from concurrent goroutines.
// //