// https://docs.rs/hornet/0.1.0/src/hornet/client/metric/mod.rs.html#398
13748
func (m *metricUnit) CountScale() CountUnit {
	d := m.CountDim()
	if d == 0 {
		panic("no count scale on unit")
	}

	return CountUnit(1<<20 | (uint32((m.repr>>8)&0xF))>>8)
}
266189
func makeMetricsRequest(client *http.Client, url string) (producers.MetricsMessage, error) {
	l := logrus.WithFields(logrus.Fields{"plugin": "http-helper"})

	l.Infof("Making request to %s", url)
	mm := producers.MetricsMessage{}

	resp, err := client.Get(url)
	if err != nil {
		l.Errorf("Encountered error requesting data, %s", err.Error())
		return mm, err
	}

	// 204 No Content is not an error code; we handle it explicitly
	if resp.StatusCode == http.StatusNoContent {
		l.Warnf("Empty response received from endpoint: %s", url)
		return mm, nil
	}

	defer resp.Body.Close()
	err = json.NewDecoder(resp.Body).Decode(&mm)
	return mm, errors.Wrapf(err, "could not decode metrics response: %s", url)
}
24792
func Modf(f float32) (int float32, frac float32) {
	return engomath.Modf(f)
}
1274768
func (builder *MetricBuilder) Metric(metric Metric) *MetricMetricBuilder {
	newMetric := MetricMetricBuilder{
		Metric{
			ID:          metric.ID,
			Name:        metric.Name,
			Description: metric.Description,
			Counter:     metric.Counter,
			CounterMax:  metric.CounterMax,
			ResetValue:  metric.ResetValue,
			Unit:        metric.Unit,
		},
		make(map[string][]string),
	}
	builder.metrics = append(builder.metrics, newMetric)
	return &builder.metrics[len(builder.metrics)-1]
}
794866
func (c *Clientset) MetricsV1beta1() metricsv1beta1.MetricsV1beta1Interface {
	return &fakemetricsv1beta1.FakeMetricsV1beta1{Fake: &c.Fake}
}
726882
func (fi FileInfo) HumanModTime(format string) string {
	return fi.ModTime.Format(format)
}
792071
func (f *File) ModTime() time.Time {
	return time.Unix(int64(f.ino.Mtime), 0)
}
700474
func (c *Clientset) MetricsV1alpha1() metricsv1alpha1.MetricsV1alpha1Interface {
	return &fakemetricsv1alpha1.FakeMetricsV1alpha1{Fake: &c.Fake}
}
1040443
func (c *ServicedCli) initMetric() {
	c.app.Commands = append(c.app.Commands, cli.Command{
		Name:        "metric",
		Usage:       "Interact with metrics",
		Description: "",
		Subcommands: []cli.Command{
			{
				Name:         "push",
				Usage:        "Push a metric value",
				Description:  "serviced metric push METRICNAME VALUE",
				Before:       c.cmdMetric,
			},
		},
	})
}
1063999
func NopMetrics() *Metrics {
	return &Metrics{
		Peers:                 discard.NewGauge(),
		PeerReceiveBytesTotal: discard.NewCounter(),
		PeerSendBytesTotal:    discard.NewCounter(),
		PeerPendingSendBytes:  discard.NewGauge(),
		NumTxs:                discard.NewGauge(),
	}
}
934753
func metricsInterceptor(ctx context.Context, invocation *enigma.Invocation, proceed enigma.InterceptorContinuation) *enigma.InvocationResponse {
	ctxWithMetrics, metricsCollector := enigma.WithMetricsCollector(ctx)

	response := proceed(ctxWithMetrics, invocation)

	metrics := metricsCollector.Metrics()
	fmt.Println(response.RequestID, invocation.RemoteObject.Type, invocation.Method, metrics.ToString())
	return response
}
197451
func (s *HTTPServer) MetricsRequest(resp http.ResponseWriter, req *http.Request) (interface{}, error) {
	if req.Method != "GET" {
		return nil, CodedError(405, ErrInvalidMethod)
	}

	if format := req.URL.Query().Get("format"); format == "prometheus" {
		s.prometheusHandler().ServeHTTP(resp, req)
		return nil, nil
	}

	return s.agent.InmemSink.DisplayMetrics(resp, req)
}
362422
func (c *MetricsCommand) Init(args []string) error {
	if !c.All && len(args) == 0 {
		return errors.New("you need to specify at least one unit or application")
	} else if c.All && len(args) > 0 {
		return errors.New("cannot use --all with additional entities")
	}
	c.Tags = make([]string, len(args))
	for i, arg := range args {
		if names.IsValidUnit(arg) {
			c.Tags[i] = names.NewUnitTag(arg).String()
		} else if names.IsValidApplication(arg) {
			c.Tags[i] = names.NewApplicationTag(arg).String()
		} else {
			return errors.Errorf("%q is not a valid unit or application", args[0])
		}
	}
	return nil
}
681256
func (mc *metricCatalog) RmUnloadedPluginMetrics(lp *loadedPlugin) {
	mc.mutex.Lock()
	defer mc.mutex.Unlock()
	mc.tree.DeleteByPlugin(lp)

	// Update metric catalog keys
	mc.keys = []string{}
	mts := mc.tree.gatherMetricTypes()
	for _, m := range mts {
		mc.keys = append(mc.keys, m.Namespace().String())
	}
}
75426
func (a *HistoricalApi) clusterMetrics(request *restful.Request, response *restful.Response) {
	key := core.HistoricalKey{ObjectType: core.MetricSetTypeCluster}
	a.processMetricRequest(key, request, response)
}
1105755
func ToRequestedMetrics(mts []*Metric) []core.RequestedMetric {
	metrics := make([]core.RequestedMetric, len(mts))
	for i, mt := range mts {
		metrics[i] = ToCoreMetric(mt)
	}
	return metrics
}
739497
func newStatMetricDatum(name string, observations []float64, unitName string) (stats cloudwatch.MetricDatum, allZero bool) {
	allZero, min, max, sum := calculateStats(observations)
	stats = cloudwatch.MetricDatum{
		MetricName: name,
		Dimensions: Dimensions,
		Timestamp:  time.Now(),
		Unit:       unitName,
		StatisticValues: []cloudwatch.StatisticSet{
			cloudwatch.StatisticSet{
				Maximum:     max,
				Minimum:     min,
				SampleCount: float64(len(observations)),
				Sum:         sum,
			},
		},
	}
	return
}