mirror of
				https://github.com/superseriousbusiness/gotosocial.git
				synced 2025-10-30 21:12:24 -05:00 
			
		
		
		
	[chore]: Bump github.com/prometheus/client_golang from 1.17.0 to 1.18.0 (#2507)
Bumps [github.com/prometheus/client_golang](https://github.com/prometheus/client_golang) from 1.17.0 to 1.18.0. - [Release notes](https://github.com/prometheus/client_golang/releases) - [Changelog](https://github.com/prometheus/client_golang/blob/main/CHANGELOG.md) - [Commits](https://github.com/prometheus/client_golang/compare/v1.17.0...v1.18.0) --- updated-dependencies: - dependency-name: github.com/prometheus/client_golang dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
This commit is contained in:
		
					parent
					
						
							
								10660e566d
							
						
					
				
			
			
				commit
				
					
						d9127f5630
					
				
			
		
					 23 changed files with 235 additions and 58 deletions
				
			
		
							
								
								
									
										56
									
								
								vendor/github.com/prometheus/client_golang/prometheus/histogram.go
									
										
									
										generated
									
									
										vendored
									
									
								
							
							
						
						
									
										56
									
								
								vendor/github.com/prometheus/client_golang/prometheus/histogram.go
									
										
									
										generated
									
									
										vendored
									
									
								
							|  | @ -475,6 +475,9 @@ type HistogramOpts struct { | |||
| 
 | ||||
| 	// now is for testing purposes, by default it's time.Now. | ||||
| 	now func() time.Time | ||||
| 
 | ||||
| 	// afterFunc is for testing purposes, by default it's time.AfterFunc. | ||||
| 	afterFunc func(time.Duration, func()) *time.Timer | ||||
| } | ||||
| 
 | ||||
| // HistogramVecOpts bundles the options to create a HistogramVec metric. | ||||
|  | @ -526,7 +529,9 @@ func newHistogram(desc *Desc, opts HistogramOpts, labelValues ...string) Histogr | |||
| 	if opts.now == nil { | ||||
| 		opts.now = time.Now | ||||
| 	} | ||||
| 
 | ||||
| 	if opts.afterFunc == nil { | ||||
| 		opts.afterFunc = time.AfterFunc | ||||
| 	} | ||||
| 	h := &histogram{ | ||||
| 		desc:                            desc, | ||||
| 		upperBounds:                     opts.Buckets, | ||||
|  | @ -536,6 +541,7 @@ func newHistogram(desc *Desc, opts HistogramOpts, labelValues ...string) Histogr | |||
| 		nativeHistogramMinResetDuration: opts.NativeHistogramMinResetDuration, | ||||
| 		lastResetTime:                   opts.now(), | ||||
| 		now:                             opts.now, | ||||
| 		afterFunc:                       opts.afterFunc, | ||||
| 	} | ||||
| 	if len(h.upperBounds) == 0 && opts.NativeHistogramBucketFactor <= 1 { | ||||
| 		h.upperBounds = DefBuckets | ||||
|  | @ -716,9 +722,16 @@ type histogram struct { | |||
| 	nativeHistogramMinResetDuration time.Duration | ||||
| 	// lastResetTime is protected by mtx. It is also used as created timestamp. | ||||
| 	lastResetTime time.Time | ||||
| 	// resetScheduled is protected by mtx. It is true if a reset is | ||||
| 	// scheduled for a later time (when nativeHistogramMinResetDuration has | ||||
| 	// passed). | ||||
| 	resetScheduled bool | ||||
| 
 | ||||
| 	// now is for testing purposes, by default it's time.Now. | ||||
| 	now func() time.Time | ||||
| 
 | ||||
| 	// afterFunc is for testing purposes, by default it's time.AfterFunc. | ||||
| 	afterFunc func(time.Duration, func()) *time.Timer | ||||
| } | ||||
| 
 | ||||
| func (h *histogram) Desc() *Desc { | ||||
|  | @ -874,21 +887,31 @@ func (h *histogram) limitBuckets(counts *histogramCounts, value float64, bucket | |||
| 	if h.maybeReset(hotCounts, coldCounts, coldIdx, value, bucket) { | ||||
| 		return | ||||
| 	} | ||||
| 	// One of the other strategies will happen. To undo what they will do as | ||||
| 	// soon as enough time has passed to satisfy | ||||
| 	// h.nativeHistogramMinResetDuration, schedule a reset at the right time | ||||
| 	// if we haven't done so already. | ||||
| 	if h.nativeHistogramMinResetDuration > 0 && !h.resetScheduled { | ||||
| 		h.resetScheduled = true | ||||
| 		h.afterFunc(h.nativeHistogramMinResetDuration-h.now().Sub(h.lastResetTime), h.reset) | ||||
| 	} | ||||
| 
 | ||||
| 	if h.maybeWidenZeroBucket(hotCounts, coldCounts) { | ||||
| 		return | ||||
| 	} | ||||
| 	h.doubleBucketWidth(hotCounts, coldCounts) | ||||
| } | ||||
| 
 | ||||
| // maybeReset resets the whole histogram if at least h.nativeHistogramMinResetDuration | ||||
| // has been passed. It returns true if the histogram has been reset. The caller | ||||
| // must have locked h.mtx. | ||||
| // maybeReset resets the whole histogram if at least | ||||
| // h.nativeHistogramMinResetDuration has been passed. It returns true if the | ||||
| // histogram has been reset. The caller must have locked h.mtx. | ||||
| func (h *histogram) maybeReset( | ||||
| 	hot, cold *histogramCounts, coldIdx uint64, value float64, bucket int, | ||||
| ) bool { | ||||
| 	// We are using the possibly mocked h.now() rather than | ||||
| 	// time.Since(h.lastResetTime) to enable testing. | ||||
| 	if h.nativeHistogramMinResetDuration == 0 || | ||||
| 	if h.nativeHistogramMinResetDuration == 0 || // No reset configured. | ||||
| 		h.resetScheduled || // Do not interefere if a reset is already scheduled. | ||||
| 		h.now().Sub(h.lastResetTime) < h.nativeHistogramMinResetDuration { | ||||
| 		return false | ||||
| 	} | ||||
|  | @ -906,6 +929,29 @@ func (h *histogram) maybeReset( | |||
| 	return true | ||||
| } | ||||
| 
 | ||||
| // reset resets the whole histogram. It locks h.mtx itself, i.e. it has to be | ||||
| // called without having locked h.mtx. | ||||
| func (h *histogram) reset() { | ||||
| 	h.mtx.Lock() | ||||
| 	defer h.mtx.Unlock() | ||||
| 
 | ||||
| 	n := atomic.LoadUint64(&h.countAndHotIdx) | ||||
| 	hotIdx := n >> 63 | ||||
| 	coldIdx := (^n) >> 63 | ||||
| 	hot := h.counts[hotIdx] | ||||
| 	cold := h.counts[coldIdx] | ||||
| 	// Completely reset coldCounts. | ||||
| 	h.resetCounts(cold) | ||||
| 	// Make coldCounts the new hot counts while resetting countAndHotIdx. | ||||
| 	n = atomic.SwapUint64(&h.countAndHotIdx, coldIdx<<63) | ||||
| 	count := n & ((1 << 63) - 1) | ||||
| 	waitForCooldown(count, hot) | ||||
| 	// Finally, reset the formerly hot counts, too. | ||||
| 	h.resetCounts(hot) | ||||
| 	h.lastResetTime = h.now() | ||||
| 	h.resetScheduled = false | ||||
| } | ||||
| 
 | ||||
| // maybeWidenZeroBucket widens the zero bucket until it includes the existing | ||||
| // buckets closest to the zero bucket (which could be two, if an equidistant | ||||
| // negative and a positive bucket exists, but usually it's only one bucket to be | ||||
|  |  | |||
							
								
								
									
										2
									
								
								vendor/github.com/prometheus/client_golang/prometheus/labels.go
									
										
									
										generated
									
									
										vendored
									
									
								
							
							
						
						
									
										2
									
								
								vendor/github.com/prometheus/client_golang/prometheus/labels.go
									
										
									
										generated
									
									
										vendored
									
									
								
							|  | @ -165,6 +165,8 @@ func validateValuesInLabels(labels Labels, expectedNumberOfValues int) error { | |||
| 
 | ||||
| func validateLabelValues(vals []string, expectedNumberOfValues int) error { | ||||
| 	if len(vals) != expectedNumberOfValues { | ||||
| 		// The call below makes vals escape, copy them to avoid that. | ||||
| 		vals := append([]string(nil), vals...) | ||||
| 		return fmt.Errorf( | ||||
| 			"%w: expected %d label values but got %d in %#v", | ||||
| 			errInconsistentCardinality, expectedNumberOfValues, | ||||
|  |  | |||
							
								
								
									
										4
									
								
								vendor/github.com/prometheus/client_golang/prometheus/process_collector_other.go
									
										
									
										generated
									
									
										vendored
									
									
								
							
							
						
						
									
										4
									
								
								vendor/github.com/prometheus/client_golang/prometheus/process_collector_other.go
									
										
									
										generated
									
									
										vendored
									
									
								
							|  | @ -11,8 +11,8 @@ | |||
| // See the License for the specific language governing permissions and | ||||
| // limitations under the License. | ||||
| 
 | ||||
| //go:build !windows && !js | ||||
| // +build !windows,!js | ||||
| //go:build !windows && !js && !wasip1 | ||||
| // +build !windows,!js,!wasip1 | ||||
| 
 | ||||
| package prometheus | ||||
| 
 | ||||
|  |  | |||
							
								
								
									
										26
									
								
								vendor/github.com/prometheus/client_golang/prometheus/process_collector_wasip1.go
									
										
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										26
									
								
								vendor/github.com/prometheus/client_golang/prometheus/process_collector_wasip1.go
									
										
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							|  | @ -0,0 +1,26 @@ | |||
| // Copyright 2023 The Prometheus Authors | ||||
| // Licensed under the Apache License, Version 2.0 (the "License"); | ||||
| // you may not use this file except in compliance with the License. | ||||
| // You may obtain a copy of the License at | ||||
| // | ||||
| // http://www.apache.org/licenses/LICENSE-2.0 | ||||
| // | ||||
| // Unless required by applicable law or agreed to in writing, software | ||||
| // distributed under the License is distributed on an "AS IS" BASIS, | ||||
| // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||||
| // See the License for the specific language governing permissions and | ||||
| // limitations under the License. | ||||
| 
 | ||||
| //go:build wasip1 | ||||
| // +build wasip1 | ||||
| 
 | ||||
| package prometheus | ||||
| 
 | ||||
| func canCollectProcess() bool { | ||||
| 	return false | ||||
| } | ||||
| 
 | ||||
| func (*processCollector) processCollect(chan<- Metric) { | ||||
| 	// noop on this platform | ||||
| 	return | ||||
| } | ||||
							
								
								
									
										2
									
								
								vendor/github.com/prometheus/common/expfmt/decode.go
									
										
									
										generated
									
									
										vendored
									
									
								
							
							
						
						
									
										2
									
								
								vendor/github.com/prometheus/common/expfmt/decode.go
									
										
									
										generated
									
									
										vendored
									
									
								
							|  | @ -22,7 +22,7 @@ import ( | |||
| 
 | ||||
| 	dto "github.com/prometheus/client_model/go" | ||||
| 
 | ||||
| 	"github.com/matttproud/golang_protobuf_extensions/pbutil" | ||||
| 	"github.com/matttproud/golang_protobuf_extensions/v2/pbutil" | ||||
| 	"github.com/prometheus/common/model" | ||||
| ) | ||||
| 
 | ||||
|  |  | |||
							
								
								
									
										2
									
								
								vendor/github.com/prometheus/common/expfmt/encode.go
									
										
									
										generated
									
									
										vendored
									
									
								
							
							
						
						
									
										2
									
								
								vendor/github.com/prometheus/common/expfmt/encode.go
									
										
									
										generated
									
									
										vendored
									
									
								
							|  | @ -18,7 +18,7 @@ import ( | |||
| 	"io" | ||||
| 	"net/http" | ||||
| 
 | ||||
| 	"github.com/matttproud/golang_protobuf_extensions/pbutil" | ||||
| 	"github.com/matttproud/golang_protobuf_extensions/v2/pbutil" | ||||
| 	"github.com/prometheus/common/internal/bitbucket.org/ww/goautoneg" | ||||
| 	"google.golang.org/protobuf/encoding/prototext" | ||||
| 
 | ||||
|  |  | |||
							
								
								
									
										2
									
								
								vendor/github.com/prometheus/procfs/Makefile.common
									
										
									
										generated
									
									
										vendored
									
									
								
							
							
						
						
									
										2
									
								
								vendor/github.com/prometheus/procfs/Makefile.common
									
										
									
										generated
									
									
										vendored
									
									
								
							|  | @ -61,7 +61,7 @@ PROMU_URL     := https://github.com/prometheus/promu/releases/download/v$(PROMU_ | |||
| SKIP_GOLANGCI_LINT := | ||||
| GOLANGCI_LINT := | ||||
| GOLANGCI_LINT_OPTS ?= | ||||
| GOLANGCI_LINT_VERSION ?= v1.53.3 | ||||
| GOLANGCI_LINT_VERSION ?= v1.54.2 | ||||
| # golangci-lint only supports linux, darwin and windows platforms on i386/amd64. | ||||
| # windows isn't included here because of the path separator being different. | ||||
| ifeq ($(GOHOSTOS),$(filter $(GOHOSTOS),linux darwin)) | ||||
|  |  | |||
							
								
								
									
										4
									
								
								vendor/github.com/prometheus/procfs/fs_statfs_notype.go
									
										
									
										generated
									
									
										vendored
									
									
								
							
							
						
						
									
										4
									
								
								vendor/github.com/prometheus/procfs/fs_statfs_notype.go
									
										
									
										generated
									
									
										vendored
									
									
								
							|  | @ -11,8 +11,8 @@ | |||
| // See the License for the specific language governing permissions and | ||||
| // limitations under the License. | ||||
| 
 | ||||
| //go:build netbsd || openbsd || solaris || windows || nostatfs | ||||
| // +build netbsd openbsd solaris windows nostatfs | ||||
| //go:build !freebsd && !linux | ||||
| // +build !freebsd,!linux | ||||
| 
 | ||||
| package procfs | ||||
| 
 | ||||
|  |  | |||
							
								
								
									
										4
									
								
								vendor/github.com/prometheus/procfs/fs_statfs_type.go
									
										
									
										generated
									
									
										vendored
									
									
								
							
							
						
						
									
										4
									
								
								vendor/github.com/prometheus/procfs/fs_statfs_type.go
									
										
									
										generated
									
									
										vendored
									
									
								
							|  | @ -11,8 +11,8 @@ | |||
| // See the License for the specific language governing permissions and | ||||
| // limitations under the License. | ||||
| 
 | ||||
| //go:build !netbsd && !openbsd && !solaris && !windows && !nostatfs | ||||
| // +build !netbsd,!openbsd,!solaris,!windows,!nostatfs | ||||
| //go:build freebsd || linux | ||||
| // +build freebsd linux | ||||
| 
 | ||||
| package procfs | ||||
| 
 | ||||
|  |  | |||
							
								
								
									
										83
									
								
								vendor/github.com/prometheus/procfs/mountstats.go
									
										
									
										generated
									
									
										vendored
									
									
								
							
							
						
						
									
										83
									
								
								vendor/github.com/prometheus/procfs/mountstats.go
									
										
									
										generated
									
									
										vendored
									
									
								
							|  | @ -44,6 +44,14 @@ const ( | |||
| 
 | ||||
| 	fieldTransport11TCPLen = 13 | ||||
| 	fieldTransport11UDPLen = 10 | ||||
| 
 | ||||
| 	// kernel version >= 4.14 MaxLen | ||||
| 	// See: https://elixir.bootlin.com/linux/v6.4.8/source/net/sunrpc/xprtrdma/xprt_rdma.h#L393 | ||||
| 	fieldTransport11RDMAMaxLen = 28 | ||||
| 
 | ||||
| 	// kernel version <= 4.2 MinLen | ||||
| 	// See: https://elixir.bootlin.com/linux/v4.2.8/source/net/sunrpc/xprtrdma/xprt_rdma.h#L331 | ||||
| 	fieldTransport11RDMAMinLen = 20 | ||||
| ) | ||||
| 
 | ||||
| // A Mount is a device mount parsed from /proc/[pid]/mountstats. | ||||
|  | @ -233,6 +241,33 @@ type NFSTransportStats struct { | |||
| 	// A running counter, incremented on each request as the current size of the | ||||
| 	// pending queue. | ||||
| 	CumulativePendingQueue uint64 | ||||
| 
 | ||||
| 	// Stats below only available with stat version 1.1. | ||||
| 	// Transport over RDMA | ||||
| 
 | ||||
| 	// accessed when sending a call | ||||
| 	ReadChunkCount   uint64 | ||||
| 	WriteChunkCount  uint64 | ||||
| 	ReplyChunkCount  uint64 | ||||
| 	TotalRdmaRequest uint64 | ||||
| 
 | ||||
| 	// rarely accessed error counters | ||||
| 	PullupCopyCount      uint64 | ||||
| 	HardwayRegisterCount uint64 | ||||
| 	FailedMarshalCount   uint64 | ||||
| 	BadReplyCount        uint64 | ||||
| 	MrsRecovered         uint64 | ||||
| 	MrsOrphaned          uint64 | ||||
| 	MrsAllocated         uint64 | ||||
| 	EmptySendctxQ        uint64 | ||||
| 
 | ||||
| 	// accessed when receiving a reply | ||||
| 	TotalRdmaReply    uint64 | ||||
| 	FixupCopyCount    uint64 | ||||
| 	ReplyWaitsForSend uint64 | ||||
| 	LocalInvNeeded    uint64 | ||||
| 	NomsgCallCount    uint64 | ||||
| 	BcallCount        uint64 | ||||
| } | ||||
| 
 | ||||
| // parseMountStats parses a /proc/[pid]/mountstats file and returns a slice | ||||
|  | @ -587,14 +622,17 @@ func parseNFSTransportStats(ss []string, statVersion string) (*NFSTransportStats | |||
| 			expectedLength = fieldTransport11TCPLen | ||||
| 		} else if protocol == "udp" { | ||||
| 			expectedLength = fieldTransport11UDPLen | ||||
| 		} else if protocol == "rdma" { | ||||
| 			expectedLength = fieldTransport11RDMAMinLen | ||||
| 		} else { | ||||
| 			return nil, fmt.Errorf("%w: invalid NFS protocol \"%s\" in stats 1.1 statement: %v", ErrFileParse, protocol, ss) | ||||
| 		} | ||||
| 		if len(ss) != expectedLength { | ||||
| 			return nil, fmt.Errorf("%w: invalid NFS transport stats 1.1 statement: %v", ErrFileParse, ss) | ||||
| 		if (len(ss) != expectedLength && (protocol == "tcp" || protocol == "udp")) || | ||||
| 			(protocol == "rdma" && len(ss) < expectedLength) { | ||||
| 			return nil, fmt.Errorf("%w: invalid NFS transport stats 1.1 statement: %v, protocol: %v", ErrFileParse, ss, protocol) | ||||
| 		} | ||||
| 	default: | ||||
| 		return nil, fmt.Errorf("%s: Unrecognized NFS transport stats version: %q", ErrFileParse, statVersion) | ||||
| 		return nil, fmt.Errorf("%s: Unrecognized NFS transport stats version: %q, protocol: %v", ErrFileParse, statVersion, protocol) | ||||
| 	} | ||||
| 
 | ||||
| 	// Allocate enough for v1.1 stats since zero value for v1.1 stats will be okay | ||||
|  | @ -604,7 +642,9 @@ func parseNFSTransportStats(ss []string, statVersion string) (*NFSTransportStats | |||
| 	// Note: slice length must be set to length of v1.1 stats to avoid a panic when | ||||
| 	// only v1.0 stats are present. | ||||
| 	// See: https://github.com/prometheus/node_exporter/issues/571. | ||||
| 	ns := make([]uint64, fieldTransport11TCPLen) | ||||
| 	// | ||||
| 	// Note: NFS Over RDMA slice length is fieldTransport11RDMAMaxLen | ||||
| 	ns := make([]uint64, fieldTransport11RDMAMaxLen+3) | ||||
| 	for i, s := range ss { | ||||
| 		n, err := strconv.ParseUint(s, 10, 64) | ||||
| 		if err != nil { | ||||
|  | @ -622,9 +662,14 @@ func parseNFSTransportStats(ss []string, statVersion string) (*NFSTransportStats | |||
| 	// we set them to 0 here. | ||||
| 	if protocol == "udp" { | ||||
| 		ns = append(ns[:2], append(make([]uint64, 3), ns[2:]...)...) | ||||
| 	} else if protocol == "tcp" { | ||||
| 		ns = append(ns[:fieldTransport11TCPLen], make([]uint64, fieldTransport11RDMAMaxLen-fieldTransport11TCPLen+3)...) | ||||
| 	} else if protocol == "rdma" { | ||||
| 		ns = append(ns[:fieldTransport10TCPLen], append(make([]uint64, 3), ns[fieldTransport10TCPLen:]...)...) | ||||
| 	} | ||||
| 
 | ||||
| 	return &NFSTransportStats{ | ||||
| 		// NFS xprt over tcp or udp | ||||
| 		Protocol:                 protocol, | ||||
| 		Port:                     ns[0], | ||||
| 		Bind:                     ns[1], | ||||
|  | @ -636,8 +681,32 @@ func parseNFSTransportStats(ss []string, statVersion string) (*NFSTransportStats | |||
| 		BadTransactionIDs:        ns[7], | ||||
| 		CumulativeActiveRequests: ns[8], | ||||
| 		CumulativeBacklog:        ns[9], | ||||
| 		MaximumRPCSlotsUsed:      ns[10], | ||||
| 		CumulativeSendingQueue:   ns[11], | ||||
| 		CumulativePendingQueue:   ns[12], | ||||
| 
 | ||||
| 		// NFS xprt over tcp or udp | ||||
| 		// And statVersion 1.1 | ||||
| 		MaximumRPCSlotsUsed:    ns[10], | ||||
| 		CumulativeSendingQueue: ns[11], | ||||
| 		CumulativePendingQueue: ns[12], | ||||
| 
 | ||||
| 		// NFS xprt over rdma | ||||
| 		// And stat Version 1.1 | ||||
| 		ReadChunkCount:       ns[13], | ||||
| 		WriteChunkCount:      ns[14], | ||||
| 		ReplyChunkCount:      ns[15], | ||||
| 		TotalRdmaRequest:     ns[16], | ||||
| 		PullupCopyCount:      ns[17], | ||||
| 		HardwayRegisterCount: ns[18], | ||||
| 		FailedMarshalCount:   ns[19], | ||||
| 		BadReplyCount:        ns[20], | ||||
| 		MrsRecovered:         ns[21], | ||||
| 		MrsOrphaned:          ns[22], | ||||
| 		MrsAllocated:         ns[23], | ||||
| 		EmptySendctxQ:        ns[24], | ||||
| 		TotalRdmaReply:       ns[25], | ||||
| 		FixupCopyCount:       ns[26], | ||||
| 		ReplyWaitsForSend:    ns[27], | ||||
| 		LocalInvNeeded:       ns[28], | ||||
| 		NomsgCallCount:       ns[29], | ||||
| 		BcallCount:           ns[30], | ||||
| 	}, nil | ||||
| } | ||||
|  |  | |||
							
								
								
									
										8
									
								
								vendor/github.com/prometheus/procfs/proc_fdinfo.go
									
										
									
										generated
									
									
										vendored
									
									
								
							
							
						
						
									
										8
									
								
								vendor/github.com/prometheus/procfs/proc_fdinfo.go
									
										
									
										generated
									
									
										vendored
									
									
								
							|  | @ -26,6 +26,7 @@ var ( | |||
| 	rPos          = regexp.MustCompile(`^pos:\s+(\d+)$`) | ||||
| 	rFlags        = regexp.MustCompile(`^flags:\s+(\d+)$`) | ||||
| 	rMntID        = regexp.MustCompile(`^mnt_id:\s+(\d+)$`) | ||||
| 	rIno          = regexp.MustCompile(`^ino:\s+(\d+)$`) | ||||
| 	rInotify      = regexp.MustCompile(`^inotify`) | ||||
| 	rInotifyParts = regexp.MustCompile(`^inotify\s+wd:([0-9a-f]+)\s+ino:([0-9a-f]+)\s+sdev:([0-9a-f]+)(?:\s+mask:([0-9a-f]+))?`) | ||||
| ) | ||||
|  | @ -40,6 +41,8 @@ type ProcFDInfo struct { | |||
| 	Flags string | ||||
| 	// Mount point ID | ||||
| 	MntID string | ||||
| 	// Inode number | ||||
| 	Ino string | ||||
| 	// List of inotify lines (structured) in the fdinfo file (kernel 3.8+ only) | ||||
| 	InotifyInfos []InotifyInfo | ||||
| } | ||||
|  | @ -51,7 +54,7 @@ func (p Proc) FDInfo(fd string) (*ProcFDInfo, error) { | |||
| 		return nil, err | ||||
| 	} | ||||
| 
 | ||||
| 	var text, pos, flags, mntid string | ||||
| 	var text, pos, flags, mntid, ino string | ||||
| 	var inotify []InotifyInfo | ||||
| 
 | ||||
| 	scanner := bufio.NewScanner(bytes.NewReader(data)) | ||||
|  | @ -63,6 +66,8 @@ func (p Proc) FDInfo(fd string) (*ProcFDInfo, error) { | |||
| 			flags = rFlags.FindStringSubmatch(text)[1] | ||||
| 		} else if rMntID.MatchString(text) { | ||||
| 			mntid = rMntID.FindStringSubmatch(text)[1] | ||||
| 		} else if rIno.MatchString(text) { | ||||
| 			ino = rIno.FindStringSubmatch(text)[1] | ||||
| 		} else if rInotify.MatchString(text) { | ||||
| 			newInotify, err := parseInotifyInfo(text) | ||||
| 			if err != nil { | ||||
|  | @ -77,6 +82,7 @@ func (p Proc) FDInfo(fd string) (*ProcFDInfo, error) { | |||
| 		Pos:          pos, | ||||
| 		Flags:        flags, | ||||
| 		MntID:        mntid, | ||||
| 		Ino:          ino, | ||||
| 		InotifyInfos: inotify, | ||||
| 	} | ||||
| 
 | ||||
|  |  | |||
							
								
								
									
										20
									
								
								vendor/github.com/prometheus/procfs/proc_maps.go
									
										
									
										generated
									
									
										vendored
									
									
								
							
							
						
						
									
										20
									
								
								vendor/github.com/prometheus/procfs/proc_maps.go
									
										
									
										generated
									
									
										vendored
									
									
								
							|  | @ -63,17 +63,17 @@ type ProcMap struct { | |||
| // parseDevice parses the device token of a line and converts it to a dev_t | ||||
| // (mkdev) like structure. | ||||
| func parseDevice(s string) (uint64, error) { | ||||
| 	toks := strings.Split(s, ":") | ||||
| 	if len(toks) < 2 { | ||||
| 		return 0, fmt.Errorf("%w: unexpected number of fields, expected: 2, got: %q", ErrFileParse, len(toks)) | ||||
| 	i := strings.Index(s, ":") | ||||
| 	if i == -1 { | ||||
| 		return 0, fmt.Errorf("%w: expected separator `:` in %s", ErrFileParse, s) | ||||
| 	} | ||||
| 
 | ||||
| 	major, err := strconv.ParseUint(toks[0], 16, 0) | ||||
| 	major, err := strconv.ParseUint(s[0:i], 16, 0) | ||||
| 	if err != nil { | ||||
| 		return 0, err | ||||
| 	} | ||||
| 
 | ||||
| 	minor, err := strconv.ParseUint(toks[1], 16, 0) | ||||
| 	minor, err := strconv.ParseUint(s[i+1:], 16, 0) | ||||
| 	if err != nil { | ||||
| 		return 0, err | ||||
| 	} | ||||
|  | @ -93,17 +93,17 @@ func parseAddress(s string) (uintptr, error) { | |||
| 
 | ||||
| // parseAddresses parses the start-end address. | ||||
| func parseAddresses(s string) (uintptr, uintptr, error) { | ||||
| 	toks := strings.Split(s, "-") | ||||
| 	if len(toks) < 2 { | ||||
| 		return 0, 0, fmt.Errorf("%w: invalid address", ErrFileParse) | ||||
| 	idx := strings.Index(s, "-") | ||||
| 	if idx == -1 { | ||||
| 		return 0, 0, fmt.Errorf("%w: expected separator `-` in %s", ErrFileParse, s) | ||||
| 	} | ||||
| 
 | ||||
| 	saddr, err := parseAddress(toks[0]) | ||||
| 	saddr, err := parseAddress(s[0:idx]) | ||||
| 	if err != nil { | ||||
| 		return 0, 0, err | ||||
| 	} | ||||
| 
 | ||||
| 	eaddr, err := parseAddress(toks[1]) | ||||
| 	eaddr, err := parseAddress(s[idx+1:]) | ||||
| 	if err != nil { | ||||
| 		return 0, 0, err | ||||
| 	} | ||||
|  |  | |||
							
								
								
									
										21
									
								
								vendor/github.com/prometheus/procfs/proc_status.go
									
										
									
										generated
									
									
										vendored
									
									
								
							
							
						
						
									
										21
									
								
								vendor/github.com/prometheus/procfs/proc_status.go
									
										
									
										generated
									
									
										vendored
									
									
								
							|  | @ -23,7 +23,7 @@ import ( | |||
| ) | ||||
| 
 | ||||
| // ProcStatus provides status information about the process, | ||||
| // read from /proc/[pid]/stat. | ||||
| // read from /proc/[pid]/status. | ||||
| type ProcStatus struct { | ||||
| 	// The process ID. | ||||
| 	PID int | ||||
|  | @ -32,6 +32,8 @@ type ProcStatus struct { | |||
| 
 | ||||
| 	// Thread group ID. | ||||
| 	TGID int | ||||
| 	// List of Pid namespace. | ||||
| 	NSpids []uint64 | ||||
| 
 | ||||
| 	// Peak virtual memory size. | ||||
| 	VmPeak uint64 // nolint:revive | ||||
|  | @ -127,6 +129,8 @@ func (s *ProcStatus) fillStatus(k string, vString string, vUint uint64, vUintByt | |||
| 		copy(s.UIDs[:], strings.Split(vString, "\t")) | ||||
| 	case "Gid": | ||||
| 		copy(s.GIDs[:], strings.Split(vString, "\t")) | ||||
| 	case "NSpid": | ||||
| 		s.NSpids = calcNSPidsList(vString) | ||||
| 	case "VmPeak": | ||||
| 		s.VmPeak = vUintBytes | ||||
| 	case "VmSize": | ||||
|  | @ -200,3 +204,18 @@ func calcCpusAllowedList(cpuString string) []uint64 { | |||
| 	sort.Slice(g, func(i, j int) bool { return g[i] < g[j] }) | ||||
| 	return g | ||||
| } | ||||
| 
 | ||||
| func calcNSPidsList(nspidsString string) []uint64 { | ||||
| 	s := strings.Split(nspidsString, " ") | ||||
| 	var nspids []uint64 | ||||
| 
 | ||||
| 	for _, nspid := range s { | ||||
| 		nspid, _ := strconv.ParseUint(nspid, 10, 64) | ||||
| 		if nspid == 0 { | ||||
| 			continue | ||||
| 		} | ||||
| 		nspids = append(nspids, nspid) | ||||
| 	} | ||||
| 
 | ||||
| 	return nspids | ||||
| } | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue