Skip to content
This repository has been archived by the owner on Aug 3, 2023. It is now read-only.

add metrics #12

Merged
merged 12 commits into from
Mar 29, 2017
Merged

add metrics #12

merged 12 commits into from
Mar 29, 2017

Conversation

upamune
Copy link
Contributor

@upamune upamune commented Mar 28, 2017

No description provided.


import metrics "github.com/rcrowley/go-metrics"

type Metrics struct {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[golint]

  • [golint] exported type Metrics should have comment or be unexported

clientCounterName = "counter"
)

func New() (Metrics, error) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[golint]

  • [golint] exported function New should have comment or be unexported

return m, nil
}

func (m *Metrics) IncClientCount() {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[golint]

  • [golint] exported method Metrics.IncClientCount should have comment or be unexported

metrics.GetOrRegisterCounter(clientCounterName, m.registry).Inc(int64(1))
}

func (m *Metrics) DecClientCount() {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[golint]

  • [golint] exported method Metrics.DecClientCount should have comment or be unexported

metrics "github.com/rcrowley/go-metrics"
)

type Metrics struct {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[golint]

  • [golint] exported type Metrics should have comment or be unexported

clientCounterName = "counter"
)

func New() (Metrics, error) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[golint]

  • [golint] exported function New should have comment or be unexported

return m, nil
}

func (m *Metrics) IncClientCount() {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[golint]

  • [golint] exported method Metrics.IncClientCount should have comment or be unexported

metrics.GetOrRegisterCounter(clientCounterName, m.registry).Inc(int64(1))
}

func (m *Metrics) DecClientCount() {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[golint]

  • [golint] exported method Metrics.DecClientCount should have comment or be unexported

metrics.GetOrRegisterCounter(clientCounterName, m.registry).Dec(int64(1))
}

func (m *Metrics) WriteJSON(w io.Writer) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[golint]

  • [golint] exported method Metrics.WriteJSON should have comment or be unexported

"github.com/openfresh/plasma/metrics"
)

func NewMetricsServer(config config.Config, metrics []metrics.Metrics) *http.Server {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[golint]

  • [golint] exported function NewMetricsServer should have comment or be unexported

metrics.GetOrRegisterCounter(clientCounterName, m.registry).Dec(int64(1))
}

func (m *Metrics) GetClientCount() int64 {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[golint]

  • [golint] exported method Metrics.GetClientCount should have comment or be unexported

return metrics.GetOrRegisterCounter(clientCounterName, m.registry).Count()
}

func (m *Metrics) WriteJSON(w io.Writer) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[golint]

  • [golint] exported method Metrics.WriteJSON should have comment or be unexported

"github.com/openfresh/plasma/metrics"
)

func NewMetricsServer(config config.Config, metrics []metrics.Metrics) *http.Server {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[golint]

  • [golint] exported function NewMetricsServer should have comment or be unexported

)

const (
GRPC = "grpc"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[golint]

  • [golint] exported const GRPC should have comment (or a comment on this block) or be unexported

SSE = "sse"
)

type Metrics struct {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[golint]

  • [golint] exported type Metrics should have comment or be unexported

registry = metrics.NewRegistry()
}

type Registry metrics.Registry
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[golint]

  • [golint] exported type Registry should have comment or be unexported


type Registry metrics.Registry

func New(metricsType string) (Metrics, error) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[golint]

  • [golint] exported function New should have comment or be unexported

return m, nil
}

func GetRegistry() metrics.Registry {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[golint]

  • [golint] exported function GetRegistry should have comment or be unexported

return strings.Join(append([]string{m.Type}, names...), ":")
}

func (m *Metrics) IncClientCount() {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[golint]

  • [golint] exported method Metrics.IncClientCount should have comment or be unexported

metrics.GetOrRegisterCounter(name, m.registry).Inc(int64(1))
}

func (m *Metrics) DecClientCount() {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[golint]

  • [golint] exported method Metrics.DecClientCount should have comment or be unexported

metrics.GetOrRegisterCounter(name, m.registry).Dec(int64(1))
}

func (m *Metrics) GetClientCount() int64 {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[golint]

  • [golint] exported method Metrics.GetClientCount should have comment or be unexported

return metrics.GetOrRegisterCounter(name, m.registry).Count()
}

func (m *Metrics) WriteJSON(w io.Writer) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[golint]

  • [golint] exported method Metrics.WriteJSON should have comment or be unexported

server/meta.go Outdated
metrics "github.com/rcrowley/go-metrics"
)

func NewMetaServer(opt Option) *http.Server {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[golint]

  • [golint] exported function NewMetaServer should have comment or be unexported

"net/http"
)

func HTTPHandler(w http.ResponseWriter, r *http.Request) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[golint]

  • [golint] exported function HTTPHandler should have comment or be unexported

"time"
)

type Stats struct {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[golint]

  • [golint] exported type Stats should have comment or be unexported

metrics/stats.go Outdated
GoVersion string `json:"go_version"`
GoOs string `json:"go_os"`
GoArch string `json:"go_arch"`
CpuNum int `json:"cpu_num"`
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[golint]

  • [golint] struct field CpuNum should be CPUNum

metrics/stats.go Outdated
t.Time = tm
}

var nsInMs float64 = float64(time.Millisecond)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[golint]

  • [golint] should omit type float64 from declaration of var nsInMs; it will be inferred from the right-hand side

metrics/stats.go Outdated

// NOTE: The following three variables need to be changed to atomic
var lastSampleTime safeTime
var lastPauseNs uint64 = 0
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[golint]

  • [golint] should drop = 0 from declaration of var lastPauseNs; it is the zero value

metrics/stats.go Outdated
// NOTE: The following three variables need to be changed to atomic
var lastSampleTime safeTime
var lastPauseNs uint64 = 0
var lastNumGc uint32 = 0
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[golint]

  • [golint] should drop = 0 from declaration of var lastNumGc; it is the zero value

metrics/stats.go Outdated
var lastPauseNs uint64 = 0
var lastNumGc uint32 = 0

var connections int64 = 0
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[golint]

  • [golint] should drop = 0 from declaration of var connections; it is the zero value

metrics/stats.go Outdated

var connections int64 = 0

func IncConnection() {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[golint]

  • [golint] exported function IncConnection should have comment or be unexported

atomic.AddInt64(&connections, 1)
}

func DecConnection() {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[golint]

  • [golint] exported function DecConnection should have comment or be unexported

atomic.AddInt64(&connections, -1)
}

func GetConnection() int64 {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[golint]

  • [golint] exported function GetConnection should have comment or be unexported

return atomic.LoadInt64(&connections)
}

func GetStats() *Stats {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[golint]

  • [golint] exported function GetStats should have comment or be unexported

@upamune upamune changed the title [wip] add metrics add metrics Mar 29, 2017
@upamune upamune merged commit b4e7285 into master Mar 29, 2017
@upamune upamune deleted the feature/metrics branch March 29, 2017 10:20
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants