Skip to content

Commit 8e66952

Browse files
Matt LaPlantecopybara-github
authored andcommitted
Export additional metric struct fields.
PiperOrigin-RevId: 384751880
1 parent 506bb27 commit 8e66952

1 file changed

Lines changed: 16 additions & 15 deletions

File tree

metrics/metrics.go

Lines changed: 16 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -17,22 +17,23 @@ package metrics
1717

1818
import "sync"
1919

20-
type metricData struct {
20+
// MetricData stores metric information.
21+
type MetricData struct {
2122
name string
2223
service string
2324
}
2425

2526
// Bool implements a Bool-type metric.
2627
type Bool struct {
27-
value bool
28+
Value bool
2829
mu sync.Mutex
29-
data *metricData
30+
Data *MetricData
3031
}
3132

3233
// NewBool sets the metric to a new Bool value.
3334
func NewBool(name, service string) (*Bool, error) {
3435
return &Bool{
35-
data: &metricData{
36+
Data: &MetricData{
3637
name: name,
3738
service: service,
3839
},
@@ -44,21 +45,21 @@ func (b *Bool) Set(value bool) error {
4445
b.mu.Lock()
4546
defer b.mu.Unlock()
4647

47-
b.value = value
48+
b.Value = value
4849
return nil
4950
}
5051

5152
// Int implements a Int-type metric.
5253
type Int struct {
53-
value int64
54+
Value int64
5455
mu sync.Mutex
55-
data *metricData
56+
Data *MetricData
5657
}
5758

5859
// NewInt sets the metric to a new Int value.
5960
func NewInt(name, service string) (*Int, error) {
6061
return &Int{
61-
data: &metricData{
62+
Data: &MetricData{
6263
name: name,
6364
service: service,
6465
},
@@ -70,14 +71,14 @@ func (i *Int) Set(value int64) error {
7071
i.mu.Lock()
7172
defer i.mu.Unlock()
7273

73-
i.value = value
74+
i.Value = value
7475
return nil
7576
}
7677

7778
// NewCounter sets the metric to a new Int value.
7879
func NewCounter(name, service string) (*Int, error) {
7980
return &Int{
80-
data: &metricData{
81+
Data: &MetricData{
8182
name: name,
8283
service: service,
8384
},
@@ -89,21 +90,21 @@ func (i *Int) Increment() error {
8990
i.mu.Lock()
9091
defer i.mu.Unlock()
9192

92-
i.value++
93+
i.Value++
9394
return nil
9495
}
9596

9697
// String implements a String-type metric.
9798
type String struct {
98-
value string
99+
Value string
99100
mu sync.Mutex
100-
data *metricData
101+
Data *MetricData
101102
}
102103

103104
// NewString sets the metric to a new string value.
104105
func NewString(name, service string) (*String, error) {
105106
return &String{
106-
data: &metricData{
107+
Data: &MetricData{
107108
name: name,
108109
service: service,
109110
},
@@ -115,6 +116,6 @@ func (s *String) Set(value string) error {
115116
s.mu.Lock()
116117
defer s.mu.Unlock()
117118

118-
s.value = value
119+
s.Value = value
119120
return nil
120121
}

0 commit comments

Comments
 (0)