@@ -23,6 +23,7 @@ import (
23
23
24
24
"google.golang.org/grpc/grpclog"
25
25
"google.golang.org/grpc/internal"
26
+ "google.golang.org/grpc/stats"
26
27
)
27
28
28
29
func init () {
@@ -34,15 +35,15 @@ var logger = grpclog.Component("metrics-registry")
34
35
// DefaultMetrics are the default metrics registered through global metrics
35
36
// registry. This is written to at initialization time only, and is read only
36
37
// after initialization.
37
- var DefaultMetrics = NewMetrics ()
38
+ var DefaultMetrics = stats . NewMetricSet ()
38
39
39
40
// MetricDescriptor is the data for a registered metric.
40
41
type MetricDescriptor struct {
41
42
// The name of this metric. This name must be unique across the whole binary
42
43
// (including any per call metrics). See
43
44
// https://github.com/grpc/proposal/blob/master/A79-non-per-call-metrics-architecture.md#metric-instrument-naming-conventions
44
45
// for metric naming conventions.
45
- Name Metric
46
+ Name string
46
47
// The description of this metric.
47
48
Description string
48
49
// The unit (e.g. entries, seconds) of this metric.
@@ -154,27 +155,27 @@ func (h *Int64GaugeHandle) Record(recorder MetricsRecorder, incr int64, labels .
154
155
}
155
156
156
157
// registeredMetrics are the registered metric descriptor names.
157
- var registeredMetrics = make (map [Metric ]bool )
158
+ var registeredMetrics = make (map [string ]bool )
158
159
159
160
// metricsRegistry contains all of the registered metrics.
160
161
//
161
162
// This is written to only at init time, and read only after that.
162
- var metricsRegistry = make (map [Metric ]* MetricDescriptor )
163
+ var metricsRegistry = make (map [string ]* MetricDescriptor )
163
164
164
165
// DescriptorForMetric returns the MetricDescriptor from the global registry.
165
166
//
166
167
// Returns nil if MetricDescriptor not present.
167
- func DescriptorForMetric (metric Metric ) * MetricDescriptor {
168
- return metricsRegistry [metric ]
168
+ func DescriptorForMetric (metricName string ) * MetricDescriptor {
169
+ return metricsRegistry [metricName ]
169
170
}
170
171
171
- func registerMetric (name Metric , def bool ) {
172
- if registeredMetrics [name ] {
173
- logger .Fatalf ("metric %v already registered" , name )
172
+ func registerMetric (metricName string , def bool ) {
173
+ if registeredMetrics [metricName ] {
174
+ logger .Fatalf ("metric %v already registered" , metricName )
174
175
}
175
- registeredMetrics [name ] = true
176
+ registeredMetrics [metricName ] = true
176
177
if def {
177
- DefaultMetrics = DefaultMetrics .Add (name )
178
+ DefaultMetrics = DefaultMetrics .Add (metricName )
178
179
}
179
180
}
180
181
@@ -256,8 +257,8 @@ func snapshotMetricsRegistryForTesting() func() {
256
257
oldRegisteredMetrics := registeredMetrics
257
258
oldMetricsRegistry := metricsRegistry
258
259
259
- registeredMetrics = make (map [Metric ]bool )
260
- metricsRegistry = make (map [Metric ]* MetricDescriptor )
260
+ registeredMetrics = make (map [string ]bool )
261
+ metricsRegistry = make (map [string ]* MetricDescriptor )
261
262
maps .Copy (registeredMetrics , registeredMetrics )
262
263
maps .Copy (metricsRegistry , metricsRegistry )
263
264
0 commit comments