requestlog

package
v0.0.0-...-1b8c519 Latest Latest
Warning

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

Go to latest
Published: Jan 20, 2015 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func WithRequestLog

func WithRequestLog(ctx context.Context) context.Context

Types

type ExecutionEvent

type ExecutionEvent byte

ExecutionEvent is an event that represents success or failure of different stages of command execution.

const (
	// Success event happens when a command was successfully executed.
	Success ExecutionEvent = iota
	// Failure event happens when a command returned and error or panicked
	// when executing.
	Failure
	// Timeout event happens when a command took too long to execute.
	Timeout
	// ShortCircuited event happens when the circuit breaker for the command
	// is closed.
	ShortCircuited
	// SemaphoreRejected event happens if there are too many concurrent requests
	// for the executed commands.
	SemaphoreRejected
	// ResponseFromCache event happens when the response for the command came
	// from previously executed command cache.
	ResponseFromCache

	// FallbackSuccess happens when the fallback logic of a command executed
	// successfully.
	FallbackSuccess
	// FallbakcFailure event happens when the fallback logic returned and error
	// or panicked while executing.
	FallbackFailure
)

func (ExecutionEvent) String

func (e ExecutionEvent) String() (s string)

String returns a string representation of an execution event.

type ExecutionInfo

type ExecutionInfo struct {
	// contains filtered or unexported fields
}

ExecutionInfo holds the execution duration and events that happened during command execution.

func NewExecutionInfo

func NewExecutionInfo(
	commandName string,
	executionTime time.Duration,
	events []ExecutionEvent) ExecutionInfo

NewExecutionInfo construct a new ExecutionInfo for command name.

func (*ExecutionInfo) CommandName

func (e *ExecutionInfo) CommandName() string

CommandName returns a command name that this execution info belongs to.

func (*ExecutionInfo) Events

func (e *ExecutionInfo) Events() []ExecutionEvent

Events returns a slice of events that happend in the order that they occurred.

func (*ExecutionInfo) ExecutionTime

func (e *ExecutionInfo) ExecutionTime() time.Duration

ExecutionTime returns the duration that was spent executing the command.

type RequestLog

type RequestLog struct {
	// contains filtered or unexported fields
}

RequestLog keeps a history of request execution information in the order that requests occurred. It is safe to access RequestLog from multiple threads simultaneously.

func FromContext

func FromContext(ctx context.Context) *RequestLog

func (*RequestLog) AddExecutionInfo

func (l *RequestLog) AddExecutionInfo(info ExecutionInfo)

AddExecutionInfo add the execution of executed command to the request log.

func (*RequestLog) LastRequest

func (l *RequestLog) LastRequest() *ExecutionInfo

LastRequest returns the execution info of the latest request added to the log.

func (*RequestLog) Size

func (l *RequestLog) Size() int

Size returns the number of request logs currently in the logger.

func (*RequestLog) String

func (l *RequestLog) String() string

String returns a nice string representation of the commands in the log. Used for command execution logging.

Jump to

Keyboard shortcuts

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