Skip to content
This repository has been archived by the owner on Sep 10, 2020. It is now read-only.

Commit

Permalink
Export Counter and Gauge types
Browse files Browse the repository at this point in the history
It seems like I can use these types anonymously with the := operator, but I can't put them into a struct to pass them around. It seems like it would be more useful to export the types. Unless I am missing something?
  • Loading branch information
PSUdaemon committed Oct 9, 2014
1 parent e6ba76e commit f896837
Showing 1 changed file with 9 additions and 9 deletions.
18 changes: 9 additions & 9 deletions instrument.go
Expand Up @@ -4,36 +4,36 @@ import (
"sync/atomic"
)

type counter struct {
type Counter struct {
value uint64
}

func (c *counter) Inc() {
func (c *Counter) Inc() {
atomic.AddUint64(&c.value, 1)
}

func NewCounter(name string) *counter {
c := new(counter)
func NewCounter(name string) *Counter {
c := new(Counter)
Publish(name, func() interface{} {
return c.value
})
return c
}

type gauge struct {
type Gauge struct {
value int64
}

func (g *gauge) Inc() {
func (g *Gauge) Inc() {
atomic.AddInt64(&g.value, 1)
}

func (g *gauge) Dec() {
func (g *Gauge) Dec() {
atomic.AddInt64(&g.value, -1)
}

func NewGauge(name string) *gauge {
g := new(gauge)
func NewGauge(name string) *Gauge {
g := new(Gauge)
Publish(name, func() interface{} {
return g.value
})
Expand Down

0 comments on commit f896837

Please sign in to comment.