stats

package
v0.1.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 22, 2021 License: Apache-2.0 Imports: 4 Imported by: 14

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	RPCStart  = newEvent(rpcStart, LevelBase)
	RPCFinish = newEvent(rpcFinish, LevelBase)

	ServerHandleStart  = newEvent(serverHandleStart, LevelDetailed)
	ServerHandleFinish = newEvent(serverHandleFinish, LevelDetailed)
	ClientConnStart    = newEvent(clientConnStart, LevelDetailed)
	ClientConnFinish   = newEvent(clientConnFinish, LevelDetailed)
	ReadStart          = newEvent(readStart, LevelDetailed)
	ReadFinish         = newEvent(readFinish, LevelDetailed)
	WaitReadStart      = newEvent(waitReadStart, LevelDetailed)
	WaitReadFinish     = newEvent(waitReadFinish, LevelDetailed)
	WriteStart         = newEvent(writeStart, LevelDetailed)
	WriteFinish        = newEvent(writeFinish, LevelDetailed)
)

Predefined events.

View Source
var (
	ErrNotAllowed = errors.New("event definition is not allowed after initialization")
	ErrDuplicated = errors.New("event name is already defined")
)

errors

Functions

func FinishInitialization

func FinishInitialization()

FinishInitialization freezes all events defined and prevents further definitions to be added.

func MaxEventNum

func MaxEventNum() int

MaxEventNum returns the number of event defined.

Types

type Event

type Event interface {
	Index() EventIndex
	Level() Level
}

Event is used to indicate a specific event.

func DefineNewEvent

func DefineNewEvent(name string, level Level) (Event, error)

DefineNewEvent allows user to add event definitions during program initialization.

type EventIndex

type EventIndex int

EventIndex indicates a unique event.

type Level

type Level int

Level sets the record level.

const (
	LevelDisabled Level = iota
	LevelBase
	LevelDetailed
)

Event levels.

type Status

type Status int8

Status is used to indicate the status of an event.

const (
	StatusInfo  Status = 1
	StatusWarn  Status = 2
	StatusError Status = 3
)

Predefined status.

type Tracer

type Tracer interface {
	Start(ctx context.Context) context.Context
	Finish(ctx context.Context)
}

Tracer is executed at the start and finish of an RPC.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL