vendor: bump prometheus/client_golang v1.1.0
full diff: https://github.com/prometheus/client_golang/compare/v0.9.4...v1.1.0 Using v1.1.0, because version v1.2.0 and up use versioned import paths for the github.com/cespare/xxhash/v2 dependency (prometheus/client_golang#657), which causes vendoring with vndr to break due to the v2 in the import-path. Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
This commit is contained in:
		| @@ -33,7 +33,7 @@ github.com/opencontainers/image-spec                d60099175f88c47cd379c4738d15 | ||||
| github.com/opencontainers/runc                      d736ef14f0288d6993a1845745d6756cfc9ddd5a # v1.0.0-rc9 | ||||
| github.com/opencontainers/runtime-spec              29686dbc5559d93fb1ef402eeda3e35c38d75af4 # v1.0.1-59-g29686db | ||||
| github.com/pkg/errors                               ba968bfe8b2f7e042a574c888954fccecfa385b4 # v0.8.1 | ||||
| github.com/prometheus/client_golang                 2641b987480bca71fb39738eb8c8b0d577cb1d76 # v0.9.4 | ||||
| github.com/prometheus/client_golang                 170205fb58decfd011f1550d4cfb737230d7ae4f # v1.1.0 | ||||
| github.com/prometheus/client_model                  d1d2010b5beead3fa1c5f271a5cf626e40b3ad6e # v0.1.0 | ||||
| github.com/prometheus/common                        287d3e634a1e550c9e463dd7e5a75a422c614505 # v0.7.0 | ||||
| github.com/prometheus/procfs                        6d489fc7f1d9cd890a250f3ea3431b1744b9623f # v0.0.8 | ||||
|   | ||||
							
								
								
									
										48
									
								
								vendor/github.com/prometheus/client_golang/README.md
									
									
									
										generated
									
									
										vendored
									
									
								
							
							
						
						
									
										48
									
								
								vendor/github.com/prometheus/client_golang/README.md
									
									
									
										generated
									
									
										vendored
									
									
								
							| @@ -11,41 +11,23 @@ Prometheus HTTP API. | ||||
|  | ||||
| __This library requires Go1.9 or later.__ | ||||
|  | ||||
| ## Important note about releases, versioning, tagging, and stability | ||||
| ## Important note about releases and stability | ||||
|  | ||||
| In this repository, we used to mostly ignore the many coming and going | ||||
| dependency management tools for Go and instead wait for a tool that most of the | ||||
| community would converge on. Our bet is that this tool has arrived now in the | ||||
| form of [Go | ||||
| Modules](https://github.com/golang/go/wiki/Modules#how-to-upgrade-and-downgrade-dependencies). | ||||
| This repository generally follows [Semantic | ||||
| Versioning](https://semver.org/). However, the API client in | ||||
| prometheus/client_golang/api/… is still considered experimental. Breaking | ||||
| changes of the API client will _not_ trigger a new major release. The same is | ||||
| true for selected other new features explicitly marked as **EXPERIMENTAL** in | ||||
| CHANGELOG.md. | ||||
|  | ||||
| To make full use of what Go Modules are offering, the previous versioning | ||||
| roadmap for this repository had to be changed. In particular, Go Modules | ||||
| finally provide a way for incompatible versions of the same package to coexist | ||||
| in the same binary. For that, however, the versions must be tagged with | ||||
| different major versions of 1 or greater (following [Semantic | ||||
| Versioning](https://semver.org/)). Thus, we decided to abandon the original | ||||
| plan of introducing a lot of breaking changes _before_ releasing v1 of this | ||||
| repository, mostly driven by the widespread use this repository already has and | ||||
| the relatively stable state it is in. | ||||
|  | ||||
| To leverage the mechanism Go Modules offers for a transition between major | ||||
| version, the current plan is the following: | ||||
|  | ||||
| - The v0.9.x series of releases will see a small number of bugfix releases to | ||||
|   deal with a few remaining minor issues (#543, #542, #539). | ||||
| - After that, all features currently marked as _deprecated_ will be removed, | ||||
|   and the result will be released as v1.0.0. | ||||
| - The planned breaking changes previously gathered as part of the v0.10 | ||||
|   milestone will now go into the v2 milestone. The v2 development happens in a | ||||
|   [separate branch](https://github.com/prometheus/client_golang/tree/dev-v2) | ||||
|   for the time being. v2 releases off that branch will happen once sufficient | ||||
|   stability is reached. v1 and v2 will coexist for a while to enable a | ||||
|   convenient transition. | ||||
| - The API client in prometheus/client_golang/api/… is still considered | ||||
|   experimental. While it will be tagged alongside the rest of the code | ||||
|   according to the plan above, we cannot strictly guarantee semver semantics | ||||
|   for it. | ||||
| Features that require breaking changes in the stable parts of the repository | ||||
| are being batched up and tracked in the [v2 | ||||
| milestone](https://github.com/prometheus/client_golang/milestone/2). The v2 | ||||
| development happens in a [separate | ||||
| branch](https://github.com/prometheus/client_golang/tree/dev-v2) for the time | ||||
| being. v2 releases off that branch will happen once sufficient stability is | ||||
| reached. In view of the widespread use of this repository, v1 and v2 will | ||||
| coexist for a while to enable a convenient transition. | ||||
|  | ||||
| ## Instrumenting applications | ||||
|  | ||||
|   | ||||
							
								
								
									
										14
									
								
								vendor/github.com/prometheus/client_golang/go.mod
									
									
									
										generated
									
									
										vendored
									
									
								
							
							
						
						
									
										14
									
								
								vendor/github.com/prometheus/client_golang/go.mod
									
									
									
										generated
									
									
										vendored
									
									
								
							| @@ -1,13 +1,11 @@ | ||||
| module github.com/prometheus/client_golang | ||||
|  | ||||
| require ( | ||||
| 	github.com/beorn7/perks v1.0.0 | ||||
| 	github.com/golang/protobuf v1.3.1 | ||||
| 	github.com/json-iterator/go v1.1.6 | ||||
| 	github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect | ||||
| 	github.com/modern-go/reflect2 v1.0.1 // indirect | ||||
| 	github.com/beorn7/perks v1.0.1 | ||||
| 	github.com/golang/protobuf v1.3.2 | ||||
| 	github.com/json-iterator/go v1.1.7 | ||||
| 	github.com/prometheus/client_model v0.0.0-20190129233127-fd36f4220a90 | ||||
| 	github.com/prometheus/common v0.4.1 | ||||
| 	github.com/prometheus/procfs v0.0.2 | ||||
| 	github.com/stretchr/testify v1.3.0 // indirect | ||||
| 	github.com/prometheus/common v0.6.0 | ||||
| 	github.com/prometheus/procfs v0.0.3 | ||||
| 	golang.org/x/sys v0.0.0-20190801041406-cbf593c0f2f3 | ||||
| ) | ||||
|   | ||||
							
								
								
									
										1
									
								
								vendor/github.com/prometheus/client_golang/prometheus/doc.go
									
									
									
										generated
									
									
										vendored
									
									
								
							
							
						
						
									
										1
									
								
								vendor/github.com/prometheus/client_golang/prometheus/doc.go
									
									
									
										generated
									
									
										vendored
									
									
								
							| @@ -183,7 +183,6 @@ | ||||
| // method can then expose the gathered metrics in some way. Usually, the metrics | ||||
| // are served via HTTP on the /metrics endpoint. That's happening in the example | ||||
| // above. The tools to expose metrics via HTTP are in the promhttp sub-package. | ||||
| // (The top-level functions in the prometheus package are deprecated.) | ||||
| // | ||||
| // Pushing to the Pushgateway | ||||
| // | ||||
|   | ||||
							
								
								
									
										505
									
								
								vendor/github.com/prometheus/client_golang/prometheus/http.go
									
									
									
										generated
									
									
										vendored
									
									
								
							
							
						
						
									
										505
									
								
								vendor/github.com/prometheus/client_golang/prometheus/http.go
									
									
									
										generated
									
									
										vendored
									
									
								
							| @@ -1,505 +0,0 @@ | ||||
| // Copyright 2014 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. | ||||
|  | ||||
| package prometheus | ||||
|  | ||||
| import ( | ||||
| 	"bufio" | ||||
| 	"compress/gzip" | ||||
| 	"io" | ||||
| 	"net" | ||||
| 	"net/http" | ||||
| 	"strconv" | ||||
| 	"strings" | ||||
| 	"sync" | ||||
| 	"time" | ||||
|  | ||||
| 	"github.com/prometheus/common/expfmt" | ||||
| ) | ||||
|  | ||||
| // TODO(beorn7): Remove this whole file. It is a partial mirror of | ||||
| // promhttp/http.go (to avoid circular import chains) where everything HTTP | ||||
| // related should live. The functions here are just for avoiding | ||||
| // breakage. Everything is deprecated. | ||||
|  | ||||
| const ( | ||||
| 	contentTypeHeader     = "Content-Type" | ||||
| 	contentEncodingHeader = "Content-Encoding" | ||||
| 	acceptEncodingHeader  = "Accept-Encoding" | ||||
| ) | ||||
|  | ||||
| var gzipPool = sync.Pool{ | ||||
| 	New: func() interface{} { | ||||
| 		return gzip.NewWriter(nil) | ||||
| 	}, | ||||
| } | ||||
|  | ||||
| // Handler returns an HTTP handler for the DefaultGatherer. It is | ||||
| // already instrumented with InstrumentHandler (using "prometheus" as handler | ||||
| // name). | ||||
| // | ||||
| // Deprecated: Please note the issues described in the doc comment of | ||||
| // InstrumentHandler. You might want to consider using promhttp.Handler instead. | ||||
| func Handler() http.Handler { | ||||
| 	return InstrumentHandler("prometheus", UninstrumentedHandler()) | ||||
| } | ||||
|  | ||||
| // UninstrumentedHandler returns an HTTP handler for the DefaultGatherer. | ||||
| // | ||||
| // Deprecated: Use promhttp.HandlerFor(DefaultGatherer, promhttp.HandlerOpts{}) | ||||
| // instead. See there for further documentation. | ||||
| func UninstrumentedHandler() http.Handler { | ||||
| 	return http.HandlerFunc(func(rsp http.ResponseWriter, req *http.Request) { | ||||
| 		mfs, err := DefaultGatherer.Gather() | ||||
| 		if err != nil { | ||||
| 			httpError(rsp, err) | ||||
| 			return | ||||
| 		} | ||||
|  | ||||
| 		contentType := expfmt.Negotiate(req.Header) | ||||
| 		header := rsp.Header() | ||||
| 		header.Set(contentTypeHeader, string(contentType)) | ||||
|  | ||||
| 		w := io.Writer(rsp) | ||||
| 		if gzipAccepted(req.Header) { | ||||
| 			header.Set(contentEncodingHeader, "gzip") | ||||
| 			gz := gzipPool.Get().(*gzip.Writer) | ||||
| 			defer gzipPool.Put(gz) | ||||
|  | ||||
| 			gz.Reset(w) | ||||
| 			defer gz.Close() | ||||
|  | ||||
| 			w = gz | ||||
| 		} | ||||
|  | ||||
| 		enc := expfmt.NewEncoder(w, contentType) | ||||
|  | ||||
| 		for _, mf := range mfs { | ||||
| 			if err := enc.Encode(mf); err != nil { | ||||
| 				httpError(rsp, err) | ||||
| 				return | ||||
| 			} | ||||
| 		} | ||||
| 	}) | ||||
| } | ||||
|  | ||||
| var instLabels = []string{"method", "code"} | ||||
|  | ||||
| type nower interface { | ||||
| 	Now() time.Time | ||||
| } | ||||
|  | ||||
| type nowFunc func() time.Time | ||||
|  | ||||
| func (n nowFunc) Now() time.Time { | ||||
| 	return n() | ||||
| } | ||||
|  | ||||
| var now nower = nowFunc(func() time.Time { | ||||
| 	return time.Now() | ||||
| }) | ||||
|  | ||||
| // InstrumentHandler wraps the given HTTP handler for instrumentation. It | ||||
| // registers four metric collectors (if not already done) and reports HTTP | ||||
| // metrics to the (newly or already) registered collectors: http_requests_total | ||||
| // (CounterVec), http_request_duration_microseconds (Summary), | ||||
| // http_request_size_bytes (Summary), http_response_size_bytes (Summary). Each | ||||
| // has a constant label named "handler" with the provided handlerName as | ||||
| // value. http_requests_total is a metric vector partitioned by HTTP method | ||||
| // (label name "method") and HTTP status code (label name "code"). | ||||
| // | ||||
| // Deprecated: InstrumentHandler has several issues. Use the tooling provided in | ||||
| // package promhttp instead. The issues are the following: (1) It uses Summaries | ||||
| // rather than Histograms. Summaries are not useful if aggregation across | ||||
| // multiple instances is required. (2) It uses microseconds as unit, which is | ||||
| // deprecated and should be replaced by seconds. (3) The size of the request is | ||||
| // calculated in a separate goroutine. Since this calculator requires access to | ||||
| // the request header, it creates a race with any writes to the header performed | ||||
| // during request handling.  httputil.ReverseProxy is a prominent example for a | ||||
| // handler performing such writes. (4) It has additional issues with HTTP/2, cf. | ||||
| // https://github.com/prometheus/client_golang/issues/272. | ||||
| func InstrumentHandler(handlerName string, handler http.Handler) http.HandlerFunc { | ||||
| 	return InstrumentHandlerFunc(handlerName, handler.ServeHTTP) | ||||
| } | ||||
|  | ||||
| // InstrumentHandlerFunc wraps the given function for instrumentation. It | ||||
| // otherwise works in the same way as InstrumentHandler (and shares the same | ||||
| // issues). | ||||
| // | ||||
| // Deprecated: InstrumentHandlerFunc is deprecated for the same reasons as | ||||
| // InstrumentHandler is. Use the tooling provided in package promhttp instead. | ||||
| func InstrumentHandlerFunc(handlerName string, handlerFunc func(http.ResponseWriter, *http.Request)) http.HandlerFunc { | ||||
| 	return InstrumentHandlerFuncWithOpts( | ||||
| 		SummaryOpts{ | ||||
| 			Subsystem:   "http", | ||||
| 			ConstLabels: Labels{"handler": handlerName}, | ||||
| 			Objectives:  map[float64]float64{0.5: 0.05, 0.9: 0.01, 0.99: 0.001}, | ||||
| 		}, | ||||
| 		handlerFunc, | ||||
| 	) | ||||
| } | ||||
|  | ||||
| // InstrumentHandlerWithOpts works like InstrumentHandler (and shares the same | ||||
| // issues) but provides more flexibility (at the cost of a more complex call | ||||
| // syntax). As InstrumentHandler, this function registers four metric | ||||
| // collectors, but it uses the provided SummaryOpts to create them. However, the | ||||
| // fields "Name" and "Help" in the SummaryOpts are ignored. "Name" is replaced | ||||
| // by "requests_total", "request_duration_microseconds", "request_size_bytes", | ||||
| // and "response_size_bytes", respectively. "Help" is replaced by an appropriate | ||||
| // help string. The names of the variable labels of the http_requests_total | ||||
| // CounterVec are "method" (get, post, etc.), and "code" (HTTP status code). | ||||
| // | ||||
| // If InstrumentHandlerWithOpts is called as follows, it mimics exactly the | ||||
| // behavior of InstrumentHandler: | ||||
| // | ||||
| //     prometheus.InstrumentHandlerWithOpts( | ||||
| //         prometheus.SummaryOpts{ | ||||
| //              Subsystem:   "http", | ||||
| //              ConstLabels: prometheus.Labels{"handler": handlerName}, | ||||
| //         }, | ||||
| //         handler, | ||||
| //     ) | ||||
| // | ||||
| // Technical detail: "requests_total" is a CounterVec, not a SummaryVec, so it | ||||
| // cannot use SummaryOpts. Instead, a CounterOpts struct is created internally, | ||||
| // and all its fields are set to the equally named fields in the provided | ||||
| // SummaryOpts. | ||||
| // | ||||
| // Deprecated: InstrumentHandlerWithOpts is deprecated for the same reasons as | ||||
| // InstrumentHandler is. Use the tooling provided in package promhttp instead. | ||||
| func InstrumentHandlerWithOpts(opts SummaryOpts, handler http.Handler) http.HandlerFunc { | ||||
| 	return InstrumentHandlerFuncWithOpts(opts, handler.ServeHTTP) | ||||
| } | ||||
|  | ||||
| // InstrumentHandlerFuncWithOpts works like InstrumentHandlerFunc (and shares | ||||
| // the same issues) but provides more flexibility (at the cost of a more complex | ||||
| // call syntax). See InstrumentHandlerWithOpts for details how the provided | ||||
| // SummaryOpts are used. | ||||
| // | ||||
| // Deprecated: InstrumentHandlerFuncWithOpts is deprecated for the same reasons | ||||
| // as InstrumentHandler is. Use the tooling provided in package promhttp instead. | ||||
| func InstrumentHandlerFuncWithOpts(opts SummaryOpts, handlerFunc func(http.ResponseWriter, *http.Request)) http.HandlerFunc { | ||||
| 	reqCnt := NewCounterVec( | ||||
| 		CounterOpts{ | ||||
| 			Namespace:   opts.Namespace, | ||||
| 			Subsystem:   opts.Subsystem, | ||||
| 			Name:        "requests_total", | ||||
| 			Help:        "Total number of HTTP requests made.", | ||||
| 			ConstLabels: opts.ConstLabels, | ||||
| 		}, | ||||
| 		instLabels, | ||||
| 	) | ||||
| 	if err := Register(reqCnt); err != nil { | ||||
| 		if are, ok := err.(AlreadyRegisteredError); ok { | ||||
| 			reqCnt = are.ExistingCollector.(*CounterVec) | ||||
| 		} else { | ||||
| 			panic(err) | ||||
| 		} | ||||
| 	} | ||||
|  | ||||
| 	opts.Name = "request_duration_microseconds" | ||||
| 	opts.Help = "The HTTP request latencies in microseconds." | ||||
| 	reqDur := NewSummary(opts) | ||||
| 	if err := Register(reqDur); err != nil { | ||||
| 		if are, ok := err.(AlreadyRegisteredError); ok { | ||||
| 			reqDur = are.ExistingCollector.(Summary) | ||||
| 		} else { | ||||
| 			panic(err) | ||||
| 		} | ||||
| 	} | ||||
|  | ||||
| 	opts.Name = "request_size_bytes" | ||||
| 	opts.Help = "The HTTP request sizes in bytes." | ||||
| 	reqSz := NewSummary(opts) | ||||
| 	if err := Register(reqSz); err != nil { | ||||
| 		if are, ok := err.(AlreadyRegisteredError); ok { | ||||
| 			reqSz = are.ExistingCollector.(Summary) | ||||
| 		} else { | ||||
| 			panic(err) | ||||
| 		} | ||||
| 	} | ||||
|  | ||||
| 	opts.Name = "response_size_bytes" | ||||
| 	opts.Help = "The HTTP response sizes in bytes." | ||||
| 	resSz := NewSummary(opts) | ||||
| 	if err := Register(resSz); err != nil { | ||||
| 		if are, ok := err.(AlreadyRegisteredError); ok { | ||||
| 			resSz = are.ExistingCollector.(Summary) | ||||
| 		} else { | ||||
| 			panic(err) | ||||
| 		} | ||||
| 	} | ||||
|  | ||||
| 	return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { | ||||
| 		now := time.Now() | ||||
|  | ||||
| 		delegate := &responseWriterDelegator{ResponseWriter: w} | ||||
| 		out := computeApproximateRequestSize(r) | ||||
|  | ||||
| 		_, cn := w.(http.CloseNotifier) | ||||
| 		_, fl := w.(http.Flusher) | ||||
| 		_, hj := w.(http.Hijacker) | ||||
| 		_, rf := w.(io.ReaderFrom) | ||||
| 		var rw http.ResponseWriter | ||||
| 		if cn && fl && hj && rf { | ||||
| 			rw = &fancyResponseWriterDelegator{delegate} | ||||
| 		} else { | ||||
| 			rw = delegate | ||||
| 		} | ||||
| 		handlerFunc(rw, r) | ||||
|  | ||||
| 		elapsed := float64(time.Since(now)) / float64(time.Microsecond) | ||||
|  | ||||
| 		method := sanitizeMethod(r.Method) | ||||
| 		code := sanitizeCode(delegate.status) | ||||
| 		reqCnt.WithLabelValues(method, code).Inc() | ||||
| 		reqDur.Observe(elapsed) | ||||
| 		resSz.Observe(float64(delegate.written)) | ||||
| 		reqSz.Observe(float64(<-out)) | ||||
| 	}) | ||||
| } | ||||
|  | ||||
| func computeApproximateRequestSize(r *http.Request) <-chan int { | ||||
| 	// Get URL length in current goroutine for avoiding a race condition. | ||||
| 	// HandlerFunc that runs in parallel may modify the URL. | ||||
| 	s := 0 | ||||
| 	if r.URL != nil { | ||||
| 		s += len(r.URL.String()) | ||||
| 	} | ||||
|  | ||||
| 	out := make(chan int, 1) | ||||
|  | ||||
| 	go func() { | ||||
| 		s += len(r.Method) | ||||
| 		s += len(r.Proto) | ||||
| 		for name, values := range r.Header { | ||||
| 			s += len(name) | ||||
| 			for _, value := range values { | ||||
| 				s += len(value) | ||||
| 			} | ||||
| 		} | ||||
| 		s += len(r.Host) | ||||
|  | ||||
| 		// N.B. r.Form and r.MultipartForm are assumed to be included in r.URL. | ||||
|  | ||||
| 		if r.ContentLength != -1 { | ||||
| 			s += int(r.ContentLength) | ||||
| 		} | ||||
| 		out <- s | ||||
| 		close(out) | ||||
| 	}() | ||||
|  | ||||
| 	return out | ||||
| } | ||||
|  | ||||
| type responseWriterDelegator struct { | ||||
| 	http.ResponseWriter | ||||
|  | ||||
| 	status      int | ||||
| 	written     int64 | ||||
| 	wroteHeader bool | ||||
| } | ||||
|  | ||||
| func (r *responseWriterDelegator) WriteHeader(code int) { | ||||
| 	r.status = code | ||||
| 	r.wroteHeader = true | ||||
| 	r.ResponseWriter.WriteHeader(code) | ||||
| } | ||||
|  | ||||
| func (r *responseWriterDelegator) Write(b []byte) (int, error) { | ||||
| 	if !r.wroteHeader { | ||||
| 		r.WriteHeader(http.StatusOK) | ||||
| 	} | ||||
| 	n, err := r.ResponseWriter.Write(b) | ||||
| 	r.written += int64(n) | ||||
| 	return n, err | ||||
| } | ||||
|  | ||||
| type fancyResponseWriterDelegator struct { | ||||
| 	*responseWriterDelegator | ||||
| } | ||||
|  | ||||
| func (f *fancyResponseWriterDelegator) CloseNotify() <-chan bool { | ||||
| 	//lint:ignore SA1019 http.CloseNotifier is deprecated but we don't want to | ||||
| 	//remove support from client_golang yet. | ||||
| 	return f.ResponseWriter.(http.CloseNotifier).CloseNotify() | ||||
| } | ||||
|  | ||||
| func (f *fancyResponseWriterDelegator) Flush() { | ||||
| 	f.ResponseWriter.(http.Flusher).Flush() | ||||
| } | ||||
|  | ||||
| func (f *fancyResponseWriterDelegator) Hijack() (net.Conn, *bufio.ReadWriter, error) { | ||||
| 	return f.ResponseWriter.(http.Hijacker).Hijack() | ||||
| } | ||||
|  | ||||
| func (f *fancyResponseWriterDelegator) ReadFrom(r io.Reader) (int64, error) { | ||||
| 	if !f.wroteHeader { | ||||
| 		f.WriteHeader(http.StatusOK) | ||||
| 	} | ||||
| 	n, err := f.ResponseWriter.(io.ReaderFrom).ReadFrom(r) | ||||
| 	f.written += n | ||||
| 	return n, err | ||||
| } | ||||
|  | ||||
| func sanitizeMethod(m string) string { | ||||
| 	switch m { | ||||
| 	case "GET", "get": | ||||
| 		return "get" | ||||
| 	case "PUT", "put": | ||||
| 		return "put" | ||||
| 	case "HEAD", "head": | ||||
| 		return "head" | ||||
| 	case "POST", "post": | ||||
| 		return "post" | ||||
| 	case "DELETE", "delete": | ||||
| 		return "delete" | ||||
| 	case "CONNECT", "connect": | ||||
| 		return "connect" | ||||
| 	case "OPTIONS", "options": | ||||
| 		return "options" | ||||
| 	case "NOTIFY", "notify": | ||||
| 		return "notify" | ||||
| 	default: | ||||
| 		return strings.ToLower(m) | ||||
| 	} | ||||
| } | ||||
|  | ||||
| func sanitizeCode(s int) string { | ||||
| 	switch s { | ||||
| 	case 100: | ||||
| 		return "100" | ||||
| 	case 101: | ||||
| 		return "101" | ||||
|  | ||||
| 	case 200: | ||||
| 		return "200" | ||||
| 	case 201: | ||||
| 		return "201" | ||||
| 	case 202: | ||||
| 		return "202" | ||||
| 	case 203: | ||||
| 		return "203" | ||||
| 	case 204: | ||||
| 		return "204" | ||||
| 	case 205: | ||||
| 		return "205" | ||||
| 	case 206: | ||||
| 		return "206" | ||||
|  | ||||
| 	case 300: | ||||
| 		return "300" | ||||
| 	case 301: | ||||
| 		return "301" | ||||
| 	case 302: | ||||
| 		return "302" | ||||
| 	case 304: | ||||
| 		return "304" | ||||
| 	case 305: | ||||
| 		return "305" | ||||
| 	case 307: | ||||
| 		return "307" | ||||
|  | ||||
| 	case 400: | ||||
| 		return "400" | ||||
| 	case 401: | ||||
| 		return "401" | ||||
| 	case 402: | ||||
| 		return "402" | ||||
| 	case 403: | ||||
| 		return "403" | ||||
| 	case 404: | ||||
| 		return "404" | ||||
| 	case 405: | ||||
| 		return "405" | ||||
| 	case 406: | ||||
| 		return "406" | ||||
| 	case 407: | ||||
| 		return "407" | ||||
| 	case 408: | ||||
| 		return "408" | ||||
| 	case 409: | ||||
| 		return "409" | ||||
| 	case 410: | ||||
| 		return "410" | ||||
| 	case 411: | ||||
| 		return "411" | ||||
| 	case 412: | ||||
| 		return "412" | ||||
| 	case 413: | ||||
| 		return "413" | ||||
| 	case 414: | ||||
| 		return "414" | ||||
| 	case 415: | ||||
| 		return "415" | ||||
| 	case 416: | ||||
| 		return "416" | ||||
| 	case 417: | ||||
| 		return "417" | ||||
| 	case 418: | ||||
| 		return "418" | ||||
|  | ||||
| 	case 500: | ||||
| 		return "500" | ||||
| 	case 501: | ||||
| 		return "501" | ||||
| 	case 502: | ||||
| 		return "502" | ||||
| 	case 503: | ||||
| 		return "503" | ||||
| 	case 504: | ||||
| 		return "504" | ||||
| 	case 505: | ||||
| 		return "505" | ||||
|  | ||||
| 	case 428: | ||||
| 		return "428" | ||||
| 	case 429: | ||||
| 		return "429" | ||||
| 	case 431: | ||||
| 		return "431" | ||||
| 	case 511: | ||||
| 		return "511" | ||||
|  | ||||
| 	default: | ||||
| 		return strconv.Itoa(s) | ||||
| 	} | ||||
| } | ||||
|  | ||||
| // gzipAccepted returns whether the client will accept gzip-encoded content. | ||||
| func gzipAccepted(header http.Header) bool { | ||||
| 	a := header.Get(acceptEncodingHeader) | ||||
| 	parts := strings.Split(a, ",") | ||||
| 	for _, part := range parts { | ||||
| 		part = strings.TrimSpace(part) | ||||
| 		if part == "gzip" || strings.HasPrefix(part, "gzip;") { | ||||
| 			return true | ||||
| 		} | ||||
| 	} | ||||
| 	return false | ||||
| } | ||||
|  | ||||
| // httpError removes any content-encoding header and then calls http.Error with | ||||
| // the provided error and http.StatusInternalServerErrer. Error contents is | ||||
| // supposed to be uncompressed plain text. However, same as with a plain | ||||
| // http.Error, any header settings will be void if the header has already been | ||||
| // sent. The error message will still be written to the writer, but it will | ||||
| // probably be of limited use. | ||||
| func httpError(rsp http.ResponseWriter, err error) { | ||||
| 	rsp.Header().Del(contentEncodingHeader) | ||||
| 	http.Error( | ||||
| 		rsp, | ||||
| 		"An error has occurred while serving metrics:\n\n"+err.Error(), | ||||
| 		http.StatusInternalServerError, | ||||
| 	) | ||||
| } | ||||
							
								
								
									
										61
									
								
								vendor/github.com/prometheus/client_golang/prometheus/process_collector.go
									
									
									
										generated
									
									
										vendored
									
									
								
							
							
						
						
									
										61
									
								
								vendor/github.com/prometheus/client_golang/prometheus/process_collector.go
									
									
									
										generated
									
									
										vendored
									
									
								
							| @@ -16,8 +16,6 @@ package prometheus | ||||
| import ( | ||||
| 	"errors" | ||||
| 	"os" | ||||
|  | ||||
| 	"github.com/prometheus/procfs" | ||||
| ) | ||||
|  | ||||
| type processCollector struct { | ||||
| @@ -59,20 +57,9 @@ type ProcessCollectorOpts struct { | ||||
| // collector for the current process with an empty namespace string and no error | ||||
| // reporting. | ||||
| // | ||||
| // Currently, the collector depends on a Linux-style proc filesystem and | ||||
| // therefore only exports metrics for Linux. | ||||
| // | ||||
| // Note: An older version of this function had the following signature: | ||||
| // | ||||
| //     NewProcessCollector(pid int, namespace string) Collector | ||||
| // | ||||
| // Most commonly, it was called as | ||||
| // | ||||
| //     NewProcessCollector(os.Getpid(), "") | ||||
| // | ||||
| // The following call of the current version is equivalent to the above: | ||||
| // | ||||
| //     NewProcessCollector(ProcessCollectorOpts{}) | ||||
| // The collector only works on operating systems with a Linux-style proc | ||||
| // filesystem and on Microsoft Windows. On other operating systems, it will not | ||||
| // collect any metrics. | ||||
| func NewProcessCollector(opts ProcessCollectorOpts) Collector { | ||||
| 	ns := "" | ||||
| 	if len(opts.Namespace) > 0 { | ||||
| @@ -126,7 +113,7 @@ func NewProcessCollector(opts ProcessCollectorOpts) Collector { | ||||
| 	} | ||||
|  | ||||
| 	// Set up process metric collection if supported by the runtime. | ||||
| 	if _, err := procfs.NewDefaultFS(); err == nil { | ||||
| 	if canCollectProcess() { | ||||
| 		c.collectFn = c.processCollect | ||||
| 	} else { | ||||
| 		c.collectFn = func(ch chan<- Metric) { | ||||
| @@ -153,46 +140,6 @@ func (c *processCollector) Collect(ch chan<- Metric) { | ||||
| 	c.collectFn(ch) | ||||
| } | ||||
|  | ||||
| func (c *processCollector) processCollect(ch chan<- Metric) { | ||||
| 	pid, err := c.pidFn() | ||||
| 	if err != nil { | ||||
| 		c.reportError(ch, nil, err) | ||||
| 		return | ||||
| 	} | ||||
|  | ||||
| 	p, err := procfs.NewProc(pid) | ||||
| 	if err != nil { | ||||
| 		c.reportError(ch, nil, err) | ||||
| 		return | ||||
| 	} | ||||
|  | ||||
| 	if stat, err := p.Stat(); err == nil { | ||||
| 		ch <- MustNewConstMetric(c.cpuTotal, CounterValue, stat.CPUTime()) | ||||
| 		ch <- MustNewConstMetric(c.vsize, GaugeValue, float64(stat.VirtualMemory())) | ||||
| 		ch <- MustNewConstMetric(c.rss, GaugeValue, float64(stat.ResidentMemory())) | ||||
| 		if startTime, err := stat.StartTime(); err == nil { | ||||
| 			ch <- MustNewConstMetric(c.startTime, GaugeValue, startTime) | ||||
| 		} else { | ||||
| 			c.reportError(ch, c.startTime, err) | ||||
| 		} | ||||
| 	} else { | ||||
| 		c.reportError(ch, nil, err) | ||||
| 	} | ||||
|  | ||||
| 	if fds, err := p.FileDescriptorsLen(); err == nil { | ||||
| 		ch <- MustNewConstMetric(c.openFDs, GaugeValue, float64(fds)) | ||||
| 	} else { | ||||
| 		c.reportError(ch, c.openFDs, err) | ||||
| 	} | ||||
|  | ||||
| 	if limits, err := p.Limits(); err == nil { | ||||
| 		ch <- MustNewConstMetric(c.maxFDs, GaugeValue, float64(limits.OpenFiles)) | ||||
| 		ch <- MustNewConstMetric(c.maxVsize, GaugeValue, float64(limits.AddressSpace)) | ||||
| 	} else { | ||||
| 		c.reportError(ch, nil, err) | ||||
| 	} | ||||
| } | ||||
|  | ||||
| func (c *processCollector) reportError(ch chan<- Metric, desc *Desc, err error) { | ||||
| 	if !c.reportErrors { | ||||
| 		return | ||||
|   | ||||
							
								
								
									
										65
									
								
								vendor/github.com/prometheus/client_golang/prometheus/process_collector_other.go
									
									
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										65
									
								
								vendor/github.com/prometheus/client_golang/prometheus/process_collector_other.go
									
									
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							| @@ -0,0 +1,65 @@ | ||||
| // Copyright 2019 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. | ||||
|  | ||||
| // +build !windows | ||||
|  | ||||
| package prometheus | ||||
|  | ||||
| import ( | ||||
| 	"github.com/prometheus/procfs" | ||||
| ) | ||||
|  | ||||
| func canCollectProcess() bool { | ||||
| 	_, err := procfs.NewDefaultFS() | ||||
| 	return err == nil | ||||
| } | ||||
|  | ||||
| func (c *processCollector) processCollect(ch chan<- Metric) { | ||||
| 	pid, err := c.pidFn() | ||||
| 	if err != nil { | ||||
| 		c.reportError(ch, nil, err) | ||||
| 		return | ||||
| 	} | ||||
|  | ||||
| 	p, err := procfs.NewProc(pid) | ||||
| 	if err != nil { | ||||
| 		c.reportError(ch, nil, err) | ||||
| 		return | ||||
| 	} | ||||
|  | ||||
| 	if stat, err := p.Stat(); err == nil { | ||||
| 		ch <- MustNewConstMetric(c.cpuTotal, CounterValue, stat.CPUTime()) | ||||
| 		ch <- MustNewConstMetric(c.vsize, GaugeValue, float64(stat.VirtualMemory())) | ||||
| 		ch <- MustNewConstMetric(c.rss, GaugeValue, float64(stat.ResidentMemory())) | ||||
| 		if startTime, err := stat.StartTime(); err == nil { | ||||
| 			ch <- MustNewConstMetric(c.startTime, GaugeValue, startTime) | ||||
| 		} else { | ||||
| 			c.reportError(ch, c.startTime, err) | ||||
| 		} | ||||
| 	} else { | ||||
| 		c.reportError(ch, nil, err) | ||||
| 	} | ||||
|  | ||||
| 	if fds, err := p.FileDescriptorsLen(); err == nil { | ||||
| 		ch <- MustNewConstMetric(c.openFDs, GaugeValue, float64(fds)) | ||||
| 	} else { | ||||
| 		c.reportError(ch, c.openFDs, err) | ||||
| 	} | ||||
|  | ||||
| 	if limits, err := p.Limits(); err == nil { | ||||
| 		ch <- MustNewConstMetric(c.maxFDs, GaugeValue, float64(limits.OpenFiles)) | ||||
| 		ch <- MustNewConstMetric(c.maxVsize, GaugeValue, float64(limits.AddressSpace)) | ||||
| 	} else { | ||||
| 		c.reportError(ch, nil, err) | ||||
| 	} | ||||
| } | ||||
							
								
								
									
										112
									
								
								vendor/github.com/prometheus/client_golang/prometheus/process_collector_windows.go
									
									
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										112
									
								
								vendor/github.com/prometheus/client_golang/prometheus/process_collector_windows.go
									
									
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							| @@ -0,0 +1,112 @@ | ||||
| // Copyright 2019 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. | ||||
|  | ||||
| package prometheus | ||||
|  | ||||
| import ( | ||||
| 	"syscall" | ||||
| 	"unsafe" | ||||
|  | ||||
| 	"golang.org/x/sys/windows" | ||||
| ) | ||||
|  | ||||
| func canCollectProcess() bool { | ||||
| 	return true | ||||
| } | ||||
|  | ||||
| var ( | ||||
| 	modpsapi    = syscall.NewLazyDLL("psapi.dll") | ||||
| 	modkernel32 = syscall.NewLazyDLL("kernel32.dll") | ||||
|  | ||||
| 	procGetProcessMemoryInfo  = modpsapi.NewProc("GetProcessMemoryInfo") | ||||
| 	procGetProcessHandleCount = modkernel32.NewProc("GetProcessHandleCount") | ||||
| ) | ||||
|  | ||||
| type processMemoryCounters struct { | ||||
| 	// https://docs.microsoft.com/en-us/windows/desktop/api/psapi/ns-psapi-_process_memory_counters_ex | ||||
| 	_                          uint32 | ||||
| 	PageFaultCount             uint32 | ||||
| 	PeakWorkingSetSize         uint64 | ||||
| 	WorkingSetSize             uint64 | ||||
| 	QuotaPeakPagedPoolUsage    uint64 | ||||
| 	QuotaPagedPoolUsage        uint64 | ||||
| 	QuotaPeakNonPagedPoolUsage uint64 | ||||
| 	QuotaNonPagedPoolUsage     uint64 | ||||
| 	PagefileUsage              uint64 | ||||
| 	PeakPagefileUsage          uint64 | ||||
| 	PrivateUsage               uint64 | ||||
| } | ||||
|  | ||||
| func getProcessMemoryInfo(handle windows.Handle) (processMemoryCounters, error) { | ||||
| 	mem := processMemoryCounters{} | ||||
| 	r1, _, err := procGetProcessMemoryInfo.Call( | ||||
| 		uintptr(handle), | ||||
| 		uintptr(unsafe.Pointer(&mem)), | ||||
| 		uintptr(unsafe.Sizeof(mem)), | ||||
| 	) | ||||
| 	if r1 != 1 { | ||||
| 		return mem, err | ||||
| 	} else { | ||||
| 		return mem, nil | ||||
| 	} | ||||
| } | ||||
|  | ||||
| func getProcessHandleCount(handle windows.Handle) (uint32, error) { | ||||
| 	var count uint32 | ||||
| 	r1, _, err := procGetProcessHandleCount.Call( | ||||
| 		uintptr(handle), | ||||
| 		uintptr(unsafe.Pointer(&count)), | ||||
| 	) | ||||
| 	if r1 != 1 { | ||||
| 		return 0, err | ||||
| 	} else { | ||||
| 		return count, nil | ||||
| 	} | ||||
| } | ||||
|  | ||||
| func (c *processCollector) processCollect(ch chan<- Metric) { | ||||
| 	h, err := windows.GetCurrentProcess() | ||||
| 	if err != nil { | ||||
| 		c.reportError(ch, nil, err) | ||||
| 		return | ||||
| 	} | ||||
|  | ||||
| 	var startTime, exitTime, kernelTime, userTime windows.Filetime | ||||
| 	err = windows.GetProcessTimes(h, &startTime, &exitTime, &kernelTime, &userTime) | ||||
| 	if err != nil { | ||||
| 		c.reportError(ch, nil, err) | ||||
| 		return | ||||
| 	} | ||||
| 	ch <- MustNewConstMetric(c.startTime, GaugeValue, float64(startTime.Nanoseconds()/1e9)) | ||||
| 	ch <- MustNewConstMetric(c.cpuTotal, CounterValue, fileTimeToSeconds(kernelTime)+fileTimeToSeconds(userTime)) | ||||
|  | ||||
| 	mem, err := getProcessMemoryInfo(h) | ||||
| 	if err != nil { | ||||
| 		c.reportError(ch, nil, err) | ||||
| 		return | ||||
| 	} | ||||
| 	ch <- MustNewConstMetric(c.vsize, GaugeValue, float64(mem.PrivateUsage)) | ||||
| 	ch <- MustNewConstMetric(c.rss, GaugeValue, float64(mem.WorkingSetSize)) | ||||
|  | ||||
| 	handles, err := getProcessHandleCount(h) | ||||
| 	if err != nil { | ||||
| 		c.reportError(ch, nil, err) | ||||
| 		return | ||||
| 	} | ||||
| 	ch <- MustNewConstMetric(c.openFDs, GaugeValue, float64(handles)) | ||||
| 	ch <- MustNewConstMetric(c.maxFDs, GaugeValue, float64(16*1024*1024)) // Windows has a hard-coded max limit, not per-process. | ||||
| } | ||||
|  | ||||
| func fileTimeToSeconds(ft windows.Filetime) float64 { | ||||
| 	return float64(uint64(ft.HighDateTime)<<32+uint64(ft.LowDateTime)) / 1e7 | ||||
| } | ||||
							
								
								
									
										10
									
								
								vendor/github.com/prometheus/client_golang/prometheus/registry.go
									
									
									
										generated
									
									
										vendored
									
									
								
							
							
						
						
									
										10
									
								
								vendor/github.com/prometheus/client_golang/prometheus/registry.go
									
									
									
										generated
									
									
										vendored
									
									
								
							| @@ -325,10 +325,18 @@ func (r *Registry) Register(c Collector) error { | ||||
| 		return nil | ||||
| 	} | ||||
| 	if existing, exists := r.collectorsByID[collectorID]; exists { | ||||
| 		switch e := existing.(type) { | ||||
| 		case *wrappingCollector: | ||||
| 			return AlreadyRegisteredError{ | ||||
| 			ExistingCollector: existing, | ||||
| 				ExistingCollector: e.unwrapRecursively(), | ||||
| 				NewCollector:      c, | ||||
| 			} | ||||
| 		default: | ||||
| 			return AlreadyRegisteredError{ | ||||
| 				ExistingCollector: e, | ||||
| 				NewCollector:      c, | ||||
| 			} | ||||
| 		} | ||||
| 	} | ||||
| 	// If the collectorID is new, but at least one of the descs existed | ||||
| 	// before, we are in trouble. | ||||
|   | ||||
							
								
								
									
										22
									
								
								vendor/github.com/prometheus/client_golang/prometheus/summary.go
									
									
									
										generated
									
									
										vendored
									
									
								
							
							
						
						
									
										22
									
								
								vendor/github.com/prometheus/client_golang/prometheus/summary.go
									
									
									
										generated
									
									
										vendored
									
									
								
							| @@ -58,17 +58,9 @@ type Summary interface { | ||||
| 	Observe(float64) | ||||
| } | ||||
|  | ||||
| // DefObjectives are the default Summary quantile values. | ||||
| // | ||||
| // Deprecated: DefObjectives will not be used as the default objectives in | ||||
| // v1.0.0 of the library. The default Summary will have no quantiles then. | ||||
| var ( | ||||
| 	DefObjectives = map[float64]float64{0.5: 0.05, 0.9: 0.01, 0.99: 0.001} | ||||
|  | ||||
| 	errQuantileLabelNotAllowed = fmt.Errorf( | ||||
| var errQuantileLabelNotAllowed = fmt.Errorf( | ||||
| 	"%q is not allowed as label name in summaries", quantileLabel, | ||||
| ) | ||||
| ) | ||||
|  | ||||
| // Default values for SummaryOpts. | ||||
| const ( | ||||
| @@ -123,14 +115,8 @@ type SummaryOpts struct { | ||||
| 	// Objectives defines the quantile rank estimates with their respective | ||||
| 	// absolute error. If Objectives[q] = e, then the value reported for q | ||||
| 	// will be the φ-quantile value for some φ between q-e and q+e.  The | ||||
| 	// default value is DefObjectives. It is used if Objectives is left at | ||||
| 	// its zero value (i.e. nil). To create a Summary without Objectives, | ||||
| 	// set it to an empty map (i.e. map[float64]float64{}). | ||||
| 	// | ||||
| 	// Note that the current value of DefObjectives is deprecated. It will | ||||
| 	// be replaced by an empty map in v1.0.0 of the library. Please | ||||
| 	// explicitly set Objectives to the desired value to avoid problems | ||||
| 	// during the transition. | ||||
| 	// default value is an empty map, resulting in a summary without | ||||
| 	// quantiles. | ||||
| 	Objectives map[float64]float64 | ||||
|  | ||||
| 	// MaxAge defines the duration for which an observation stays relevant | ||||
| @@ -199,7 +185,7 @@ func newSummary(desc *Desc, opts SummaryOpts, labelValues ...string) Summary { | ||||
| 	} | ||||
|  | ||||
| 	if opts.Objectives == nil { | ||||
| 		opts.Objectives = DefObjectives | ||||
| 		opts.Objectives = map[float64]float64{} | ||||
| 	} | ||||
|  | ||||
| 	if opts.MaxAge < 0 { | ||||
|   | ||||
							
								
								
									
										21
									
								
								vendor/github.com/prometheus/client_golang/prometheus/wrap.go
									
									
									
										generated
									
									
										vendored
									
									
								
							
							
						
						
									
										21
									
								
								vendor/github.com/prometheus/client_golang/prometheus/wrap.go
									
									
									
										generated
									
									
										vendored
									
									
								
							| @@ -32,6 +32,12 @@ import ( | ||||
| // WrapRegistererWith provides a way to add fixed labels to a subset of | ||||
| // Collectors. It should not be used to add fixed labels to all metrics exposed. | ||||
| // | ||||
| // Conflicts between Collectors registered through the original Registerer with | ||||
| // Collectors registered through the wrapping Registerer will still be | ||||
| // detected. Any AlreadyRegisteredError returned by the Register method of | ||||
| // either Registerer will contain the ExistingCollector in the form it was | ||||
| // provided to the respective registry. | ||||
| // | ||||
| // The Collector example demonstrates a use of WrapRegistererWith. | ||||
| func WrapRegistererWith(labels Labels, reg Registerer) Registerer { | ||||
| 	return &wrappingRegisterer{ | ||||
| @@ -54,6 +60,12 @@ func WrapRegistererWith(labels Labels, reg Registerer) Registerer { | ||||
| // (see NewGoCollector) and the process collector (see NewProcessCollector). (In | ||||
| // fact, those metrics are already prefixed with “go_” or “process_”, | ||||
| // respectively.) | ||||
| // | ||||
| // Conflicts between Collectors registered through the original Registerer with | ||||
| // Collectors registered through the wrapping Registerer will still be | ||||
| // detected. Any AlreadyRegisteredError returned by the Register method of | ||||
| // either Registerer will contain the ExistingCollector in the form it was | ||||
| // provided to the respective registry. | ||||
| func WrapRegistererWithPrefix(prefix string, reg Registerer) Registerer { | ||||
| 	return &wrappingRegisterer{ | ||||
| 		wrappedRegisterer: reg, | ||||
| @@ -123,6 +135,15 @@ func (c *wrappingCollector) Describe(ch chan<- *Desc) { | ||||
| 	} | ||||
| } | ||||
|  | ||||
| func (c *wrappingCollector) unwrapRecursively() Collector { | ||||
| 	switch wc := c.wrappedCollector.(type) { | ||||
| 	case *wrappingCollector: | ||||
| 		return wc.unwrapRecursively() | ||||
| 	default: | ||||
| 		return wc | ||||
| 	} | ||||
| } | ||||
|  | ||||
| type wrappingMetric struct { | ||||
| 	wrappedMetric Metric | ||||
| 	prefix        string | ||||
|   | ||||
		Reference in New Issue
	
	Block a user
	 Sebastiaan van Stijn
					Sebastiaan van Stijn