Back to

package stats

v0.0.0 (18d6e10)
Latest Go to latest
Published: Nov 15, 2019 | License: MIT | Module:


Taken from RakutenTech nozzle Thanks to them



const (
	// DefaultPort is default port to listen
	DefaultPort = "8080"

	// EnvPort is environmental variable to change port to listen
	EnvPort = "PORT"
const (
	EnvCFInstanceIndex = "CF_INSTANCE_INDEX"

type Server

type Server struct {
	Logger *log.Logger
	Stats  *Stats

Server is used for various debugging. It opens runtime stats, pprof and appliclation stats.

func (*Server) Start

func (s *Server) Start()

Start starts listening.

type Stats

type Stats struct {
	Consume                uint64 `json:"consume"`
	ConsumePerSec          uint64 `json:"consume_per_sec"`
	ConsumeFail            uint64 `json:"consume_fail"`
	ConsumeHttpStartStop   uint64 `json:"consume_http_start_stop"`
	ConsumeValueMetric     uint64 `json:"consume_value_metric"`
	ConsumeCounterEvent    uint64 `json:"consume_counter_event"`
	ConsumeLogMessage      uint64 `json:"consume_log_message"`
	ConsumeError           uint64 `json:"consume_error"`
	ConsumeContainerMetric uint64 `json:"consume_container_metric"`
	ConsumeUnknown         uint64 `json:"consume_unknown"`
	Ignored                uint64 `json:"ignored"`
	Forwarded              uint64 `json:"forwarded"`

	Publish       uint64 `json:"publish"`
	PublishPerSec uint64 `json:"publish_per_sec"`

	// This is same as the number of dropped message
	PublishFail uint64 `json:"publish_fail"`

	SlowConsumerAlert uint64 `json:"slow_consumer_alert"`

	// SubInputBuffer is used to count number of current
	// buffer on subInput.
	SubInputBuffer int64 `json:"subinupt_buffer"`

	// InstanceID is ID for nozzle instance.
	// This is used to identify stats from different instances.
	// By default, it's defaultInstanceID
	InstanceID int `json:"instance_id"`

Stats stores various stats infomation easyjson:json

func NewStats

func NewStats() *Stats

func (*Stats) Dec

func (s *Stats) Dec(statsType StatsType)

func (*Stats) Inc

func (s *Stats) Inc(statsType StatsType)

func (*Stats) Json

func (s *Stats) Json() ([]byte, error)

func (Stats) MarshalEasyJSON

func (v Stats) MarshalEasyJSON(w *jwriter.Writer)

MarshalEasyJSON supports easyjson.Marshaler interface

func (Stats) MarshalJSON

func (v Stats) MarshalJSON() ([]byte, error)

MarshalJSON supports json.Marshaler interface

func (*Stats) PerSec

func (s *Stats) PerSec()

func (*Stats) UnmarshalEasyJSON

func (v *Stats) UnmarshalEasyJSON(l *jlexer.Lexer)

UnmarshalEasyJSON supports easyjson.Unmarshaler interface

func (*Stats) UnmarshalJSON

func (v *Stats) UnmarshalJSON(data []byte) error

UnmarshalJSON supports json.Unmarshaler interface

type StatsType

type StatsType int
const (
	Consume                StatsType = iota // messages received
	ConsumeFail                             // messages failed to be consumed
	ConsumeHttpStartStop                    // HttpStartStop messages received
	ConsumeValueMetric                      // ValueMetric messages received
	ConsumeCounterEvent                     // CounterEvent messages received
	ConsumeLogMessage                       // LogMessage messages received
	ConsumeError                            // Error messages received
	ConsumeContainerMetric                  // ContainerMetric messages received
	ConsumeUnknown                          // unknown type messages received
	Ignored                                 // messages dropped because of no forwarding rule
	Forwarded                               // messages
	Publish                                 // messages
	PublishFail                             // messages
	SlowConsumerAlert                       // slow consumer alerts emitted by noaa?
	SubInputBuffer                          // messages in buffer
Documentation was rendered with GOOS=linux and GOARCH=amd64.

Jump to identifier

Keyboard shortcuts

? : This menu
f or F : Jump to identifier