metrics.go

 1/*
 2 *
 3 * Copyright 2024 gRPC authors.
 4 *
 5 * Licensed under the Apache License, Version 2.0 (the "License");
 6 * you may not use this file except in compliance with the License.
 7 * You may obtain a copy of the License at
 8 *
 9 *     http://www.apache.org/licenses/LICENSE-2.0
10 *
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
16 *
17 */
18
19// Package stats contains experimental metrics/stats API's.
20package stats
21
22import "google.golang.org/grpc/stats"
23
24// MetricsRecorder records on metrics derived from metric registry.
25type MetricsRecorder interface {
26	// RecordInt64Count records the measurement alongside labels on the int
27	// count associated with the provided handle.
28	RecordInt64Count(handle *Int64CountHandle, incr int64, labels ...string)
29	// RecordFloat64Count records the measurement alongside labels on the float
30	// count associated with the provided handle.
31	RecordFloat64Count(handle *Float64CountHandle, incr float64, labels ...string)
32	// RecordInt64Histo records the measurement alongside labels on the int
33	// histo associated with the provided handle.
34	RecordInt64Histo(handle *Int64HistoHandle, incr int64, labels ...string)
35	// RecordFloat64Histo records the measurement alongside labels on the float
36	// histo associated with the provided handle.
37	RecordFloat64Histo(handle *Float64HistoHandle, incr float64, labels ...string)
38	// RecordInt64Gauge records the measurement alongside labels on the int
39	// gauge associated with the provided handle.
40	RecordInt64Gauge(handle *Int64GaugeHandle, incr int64, labels ...string)
41}
42
43// Metrics is an experimental legacy alias of the now-stable stats.MetricSet.
44// Metrics will be deleted in a future release.
45type Metrics = stats.MetricSet
46
47// Metric was replaced by direct usage of strings.
48type Metric = string
49
50// NewMetrics is an experimental legacy alias of the now-stable
51// stats.NewMetricSet.  NewMetrics will be deleted in a future release.
52func NewMetrics(metrics ...Metric) *Metrics {
53	return stats.NewMetricSet(metrics...)
54}