clevels

package
v1.0.2 Latest Latest
Warning

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

Go to latest
Published: Sep 17, 2020 License: MIT Imports: 10 Imported by: 0

Documentation

Overview

Package clevels includes utilities for identifying log criticality and system austerity, which can be used to sample logs.

Index

Constants

View Source
const AusterityBuffer = 100

AusterityBuffer ensures that high-volume services will never block when trying to read the system austerity level, even if the process that updates the cache is slow. The tradeoff is that, when the system austerity level is changed, it will read an extra $AusterityBuffer log lines before the change takes effect.

Variables

View Source
var AusterityFile string

AusterityFile is the full path to a file that contains the current system austerity level.

View Source
var CacheInterval = 30 * time.Second
View Source
var InvalidAusterityLevel = errors.New("Invalid austerity level")
View Source
var SystemAusterityLevel = make(chan AusterityLevel, AusterityBuffer)

To determine the current austerity level, read from SystemAusterityLevel. Austerity is updated according to CacheInterval, and this channel is buffered (size AusterityBuffer) to avoid blocking a critical code path. As a result, services which have a low log volume will take longer to have their austerity level changes come into effect.

Functions

func ReportAusterity

func ReportAusterity(l AusterityLevel)

func SendSystemAusterityLevel

func SendSystemAusterityLevel()

Types

type AusterityLevel

type AusterityLevel int
const (
	Sheddable AusterityLevel = iota
	SheddablePlus
	Critical
	CriticalPlus
)

There are four levels of logs. The names and definitions are adapted from Google's usage.

For more information, see Chapter 21 of Site Reliability Engineering by Beyer, Jones, Petoff, and Murphy

Sheddable is the least-important, and we can expect frequent partial unavailability of Sheddable logs as well as occassional full unavailability without disruption.

SheddablePlus is the default level, and we can expect occasional partial availability and rare full unavailability.

Critical is used for lines for which partial unavailability is rare.

CriticalPlus is used for lines which should only be unavailable in the most extreme circumstances.

const DefaultAusterity AusterityLevel = Sheddable

The default system austerity level, in case we are unable to determine it from the state file

const DefaultCriticality AusterityLevel = SheddablePlus

The default criticality line for any log line that doesn't have an explicit clevel tag

func Criticality

func Criticality(line string) AusterityLevel

criticality parses the criticality level of a log line. Defaults to the value of DefaultCriticality.

func JSONCriticality

func JSONCriticality(line json.LogLine) AusterityLevel

func LoadLevel

func LoadLevel() (AusterityLevel, error)

LoadLevel loads the AusterityFile and parses it to determine the system austerity level. If it encounters an error, it will return the DefaultAusterity.

func ParseLevel

func ParseLevel(r io.Reader) (AusterityLevel, error)

func (AusterityLevel) AusterityLevel

func (a AusterityLevel) AusterityLevel() string

func (AusterityLevel) String

func (i AusterityLevel) String() string

Jump to

Keyboard shortcuts

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