logz

package module
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Aug 17, 2020 License: MIT Imports: 4 Imported by: 3

README

logz

This library provides in-process aggregated collector of messages and web page to report them. They are useful for last mile observability of logs.

logz is inspired by OpenCensus zPages.

Build Status Coverage Status GoDevDoc Code lines Comments

Features

  • High performance and low resource consumption.
  • Adapter for go.uber.org/zap.
  • HTTP handler to serve aggregated messages.

Screenshot

Example

zc := zap.NewDevelopmentConfig()
zz, lo := zzap.NewOption(logz.Config{
    MaxCardinality: 5,
    MaxSamples:     10,
})

l, err := zc.Build(zz)
if err != nil {
    panic(err)
}

l.Debug("starting example")
l.Sugar().Infow("sample info", "one", 1, "two", 2)
l.Error("unexpected end of the world")

l.Info("starting server at http://localhost:6060/")
err = http.ListenAndServe("0.0.0.0:6060", logzpage.Handler(lo...))
if err != nil {
    l.Fatal(err.Error())
}

Documentation

Overview

Package logz provides events observer.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Bucket

type Bucket struct {
	From  time.Time
	To    time.Time
	Count uint64
}

Bucket contains count of events in time interval.

type Config

type Config struct {
	Name             string
	MaxCardinality   uint32
	MaxSamples       uint32
	SamplingInterval time.Duration
	DistResolution   int
}

Config defines observer configuration.

type Entry

type Entry struct {
	Message string
	Count   uint64
	Samples []interface{}
	First   time.Time
	Last    time.Time

	MaxBucketCount int
	Buckets        []Bucket
}

Entry contains aggregated information about message.

type Observer

type Observer struct {
	Config
	// contains filtered or unexported fields
}

Observer keeps track of messages.

func (*Observer) Find

func (l *Observer) Find(msg string) Entry

Find lookups entry by message.

func (*Observer) GetEntries

func (l *Observer) GetEntries() []Entry

GetEntries returns a list of observed event entries.

func (*Observer) ObserveMessage

func (l *Observer) ObserveMessage(msg string, data interface{})

ObserveMessage updates aggregated information about message.

func (*Observer) Other

func (l *Observer) Other(withSamples bool) Entry

Other returns entry for other events.

Directories

Path Synopsis
Package logzpage provides http handler to expose observed log samples.
Package logzpage provides http handler to expose observed log samples.
Package zzap provides zpage observer for "go.uber.org/zap" logger.
Package zzap provides zpage observer for "go.uber.org/zap" logger.

Jump to

Keyboard shortcuts

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