// guessIsMetricsReq - returns true if incoming request looks
// like metrics request
546937
func guessIsMetricsReq(req *http.Request) bool {
	if req == nil {
		return false
	}
	aType := getRequestAuthType(req)
	return aType == authTypeAnonymous &&
		req.URL.Path == minioReservedBucketPath+prometheusMetricsPath
}
804666
func calcCacheSize(epoch int) uint64 {
	size := cacheInitBytes + cacheGrowthBytes*uint64(epoch) - hashBytes
	for !new(big.Int).SetUint64(size / hashBytes).ProbablyPrime(1) { // Always accurate for n < 2^64
		size -= 2 * hashBytes
	}
	return size
}
780830
func calculateSigma(dimensions, guesses int) float64 {
	return math.Pow(3*math.Pow(float64(guesses), 1/float64(dimensions)), -1)
}
873948
func (h Dense) EstimateCardinality() uint64 {
	var V int
	var invSum float64
	for i := 0; i < len(h); i += 3 {
		x0, x1, x2 := h[i], h[i+1], h[i+2]
		v0, v1, v2 := x0>>2, x1>>2, x2>>2
		xL0, xL1, xL2 := x0&3, x1&3, x2&3
		v3 := xL0<<4 ^ xL1<<2 ^ xL2
		invSum += lookup[v0]
		invSum += lookup[v1]
		invSum += lookup[v2]
		invSum += lookup[v3]
		if v0 == 0 {
			V++
		}
		if v1 == 0 {
			V++
		}
		if v2 == 0 {
			V++
		}
		if v3 == 0 {
			V++
		}
	}

	est := h.correctedEstimate(invSum, V)
	card := math.Floor(est + 0.5)
	if card > math.MaxUint64 {
		return math.MaxUint64
	}
	return uint64(card)
}
1339159
func (c *cubicSender) BandwidthEstimate() Bandwidth {
	srtt := c.rttStats.SmoothedRTT()
	if srtt == 0 {
		// If we haven't measured an rtt, the bandwidth estimate is unknown.
		return 0
	}
	return BandwidthFromDelta(c.GetCongestionWindow(), srtt)
}
1237233
func (ef *FeeEstimator) newEstimateFeeSet() *estimateFeeSet {
	set := &estimateFeeSet{}

	capacity := 0
	for i, b := range ef.bin {
		l := len(b)
		set.bin[i] = uint32(l)
		capacity += l
	}

	set.feeRate = make([]SatoshiPerByte, capacity)

	i := 0
	for _, b := range ef.bin {
		for _, o := range b {
			set.feeRate[i] = o.feeRate
			i++
		}
	}

	sort.Sort(set)

	return set
}
746978
func newFileMetrics(labels prometheus.Labels) *fileMetrics {
	var names []string
	for k := range labels {
		names = append(names, k)
	}
	names = append(names, "level")
	sort.Strings(names)

	return &fileMetrics{
		DiskSize: prometheus.NewGaugeVec(prometheus.GaugeOpts{
			Namespace: namespace,
			Subsystem: fileStoreSubsystem,
			Name:      "disk_bytes",
			Help:      "Number of bytes TSM files using on disk.",
		}, names),
		Files: prometheus.NewGaugeVec(prometheus.GaugeOpts{
			Namespace: namespace,
			Subsystem: fileStoreSubsystem,
			Name:      "total",
			Help:      "Number of files.",
		}, names),
	}
}
304004
func (m1 Mat2) ApproxFuncEqual(m2 Mat2, eq func(float64, float64) bool) bool {
	for i := range m1 {
		if !eq(m1[i], m2[i]) {
			return false
		}
	}
	return true
}
265034
func (q1 Quat) ApproxEqual(q2 Quat) bool {
	return FloatEqual(q1.W, q2.W) && q1.V.ApproxEqual(q2.V)
}
282661
func NopMetrics() *Metrics {
	return &Metrics{
		Size:         discard.NewGauge(),
		TxSizeBytes:  discard.NewHistogram(),
		FailedTxs:    discard.NewCounter(),
		RecheckTimes: discard.NewCounter(),
	}
}
98512
func callMetrics(metricsAPI *metricsAPI, clock func() time.Time, timingMetrics bool) callrules.Rule {
	timed := metricsAPI.callLatency
	if !timingMetrics {
		timed = nil
	}
	harness := xmetrics.NewHarness(metricsAPI.callCount, metricsAPI.callErrorCount, timed, clock)
	return callrules.Metrics(harness, nil)
}
569846
func (o *VCenterHypervisor) VRSMetrics(info *bambou.FetchingInfo) (VRSMetricsList, *bambou.Error) {

	var list VRSMetricsList
	err := bambou.CurrentSession().FetchChildren(o, VRSMetricsIdentity, &list, info)
	return list, err
}
734514
func (c *TagValueSeriesIDCache) measurementContainsSets(name []byte) bool {
	_, ok := c.cache[string(name)]
	return ok
}
850324
func IsAcceptableMetric(metric samplers.InterMetric, sink MetricSink) bool {
	if metric.Sinks == nil {
		return true
	}
	return metric.Sinks.RouteTo(sink.Name())
}
876181
func OnStartupMetrics() error {
	metricsOnce.Do(func() {
		prometheus.MustRegister(RequestCount)
		prometheus.MustRegister(RequestDuration)
	})
	return nil
}
1132764
func guessIsHealthCheckReq(req *http.Request) bool {
	if req == nil {
		return false
	}
	aType := getRequestAuthType(req)
	return aType == authTypeAnonymous && (req.Method == http.MethodGet || req.Method == http.MethodHead) &&
		(req.URL.Path == healthCheckPathPrefix+healthCheckLivenessPath ||
			req.URL.Path == healthCheckPathPrefix+healthCheckReadinessPath)
}
1137125
func isAlphaNumericUnderscore(r rune) bool {
	return r == '_' || unicode.IsLetter(r) || unicode.IsDigit(r)
}