mtail

package
v0.0.0-...-5655933 Latest Latest
Warning

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

Go to latest
Published: Oct 20, 2023 License: MIT Imports: 25 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var CompileOnly = &niladicOption{
	func(m *Server) error {
		m.rOpts = append(m.rOpts, runtime.CompileOnly())
		m.compileOnly = true
		return nil
	},
}

CompileOnly sets compile-only mode in the Server.

View Source
var DumpAst = &niladicOption{
	func(m *Server) error {
		m.rOpts = append(m.rOpts, runtime.DumpAst())
		return nil
	},
}

DumpAst instructs the Server's compiler to print the AST after parsing.

View Source
var DumpAstTypes = &niladicOption{
	func(m *Server) error {
		m.rOpts = append(m.rOpts, runtime.DumpAstTypes())
		return nil
	},
}

DumpAstTypes instructs the Server's copmiler to print the AST after type checking.

View Source
var DumpBytecode = &niladicOption{
	func(m *Server) error {
		m.rOpts = append(m.rOpts, runtime.DumpBytecode())
		return nil
	},
}

DumpBytecode instructs the Server's compiuler to print the program bytecode after code generation.

View Source
var EmitMetricTimestamp = &niladicOption{
	func(m *Server) error {
		m.eOpts = append(m.eOpts, exporter.EmitTimestamp())
		return nil
	},
}

EmitMetricTimestamp tells the Server to export the metric's timestamp.

View Source
var ErrDuplicateHTTPBindAddress = errors.New("HTTP server bind address already supplied")
View Source
var LogRuntimeErrors = &niladicOption{
	func(m *Server) error {
		m.rOpts = append(m.rOpts, runtime.LogRuntimeErrors())
		return nil
	},
}

LogRuntimeErrors instructs the VM to emit runtime errors to the log.

View Source
var OmitMetricSource = &niladicOption{
	func(m *Server) error {
		m.rOpts = append(m.rOpts, runtime.OmitMetricSource())
		return nil
	},
}

OmitMetricSource sets the Server to not link created metrics to their source program.

View Source
var OmitProgLabel = &niladicOption{
	func(m *Server) error {
		m.eOpts = append(m.eOpts, exporter.OmitProgLabel())
		return nil
	},
}

OmitProgLabel sets the Server to not put the program name as a label in exported metrics.

View Source
var OneShot = &niladicOption{
	func(m *Server) error {
		m.rOpts = append(m.rOpts, runtime.ErrorsAbort())
		m.tOpts = append(m.tOpts, tailer.OneShot)
		m.oneShot = true
		return nil
	},
}

OneShot sets one-shot mode in the Server.

View Source
var SyslogUseCurrentYear = &niladicOption{
	func(m *Server) error {
		m.rOpts = append(m.rOpts, runtime.SyslogUseCurrentYear())
		return nil
	},
}

SyslogUseCurrentYear instructs the Server to use the current year for year-less log timestamp during parsing.

Functions

func FaviconHandler

func FaviconHandler(w http.ResponseWriter, r *http.Request)

FaviconHandler is used to serve up the favicon.ico for mtail's http server.

Types

type BindUnixSocket

type BindUnixSocket string

BindUnixSocket sets the UNIX socket path in Server.

type BuildInfo

type BuildInfo struct {
	Version string
}

BuildInfo records the compile-time information for use when reporting the mtail version.

func (BuildInfo) String

func (b BuildInfo) String() string

type IgnoreRegexPattern

type IgnoreRegexPattern string

IgnoreRegexPattern sets the regex pattern to ignore files.

type JaegerReporter

type JaegerReporter string

JaegerReporter creates a new jaeger reporter that sends to the given Jaeger endpoint address.

type MaxRecursionDepth

type MaxRecursionDepth int

MaxRecursionDepth sets the maximum depth the abstract syntax tree built during lexation can have.

type MaxRegexpLength

type MaxRegexpLength int

MaxRegexpLength sets the maximum length an mtail regular expression can have, in terms of characters.

type MetricPushInterval

type MetricPushInterval time.Duration

MetricPushInterval sets the interval between metrics pushes to passive collectors.

type Option

type Option interface {
	// contains filtered or unexported methods
}

Option configures mtail.Server.

func BindAddress

func BindAddress(address, port string) Option

BindAddress sets the HTTP server address in Server.

func LogPathPatterns

func LogPathPatterns(patterns ...string) Option

LogPathPatterns sets the patterns to find log paths in the Server.

func LogPatternPollWaker

func LogPatternPollWaker(w waker.Waker) Option

LogPatternPollWaker triggers polls on the filesystem for new logs that match the log glob patterns.

func LogstreamPollWaker

func LogstreamPollWaker(w waker.Waker) Option

LogstreamPollWaker triggers polls on the filesystem for new logs that match the log glob streams.

func OverrideLocation

func OverrideLocation(loc *time.Location) Option

OverrideLocation sets the timezone location for log timestamps without any such information.

func StaleLogGcWaker

func StaleLogGcWaker(w waker.Waker) Option

StaleLogGcWaker triggers garbage collection runs for stale logs in the tailer.

type ProgramPath

type ProgramPath string

ProgramPath sets the path to find mtail programs in the Server.

type Server

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

Server contains the state of the main mtail program.

func New

func New(ctx context.Context, store *metrics.Store, options ...Option) (*Server, error)

New creates a Server from the supplied Options. The Server is started by the time New returns, it watches the LogPatterns for files, starts tailing their changes and sends any new lines found to the virtual machines loaded from ProgramPath. If OneShot mode is enabled, it will exit after reading each log file from start to finish. TODO(jaq): this doesn't need to be a constructor anymore, it could start and block until quit, once TestServer.PollWatched is addressed.

func (*Server) GetRegistry

func (m *Server) GetRegistry() *prometheus.Registry

func (*Server) Run

func (m *Server) Run() error

Run awaits mtail's shutdown. TODO(jaq): remove this once the test server is able to trigger polls on the components.

func (*Server) ServeHTTP

func (m *Server) ServeHTTP(w http.ResponseWriter, r *http.Request)

ServeHTTP satisfies the http.Handler interface, and is used to serve the root page of mtail for online status reporting.

func (*Server) SetOption

func (m *Server) SetOption(options ...Option) error

SetOption takes one or more option functions and applies them in order to MtailServer.

func (*Server) Wait

func (m *Server) Wait()

type SetBuildInfo

type SetBuildInfo BuildInfo

SetBuildInfo sets the mtail program build information in the Server.

type TestServer

type TestServer struct {
	*Server

	// Set this to change the poll deadline when using DoOrTimeout within this TestServer.
	DoOrTimeoutDeadline time.Duration
	// contains filtered or unexported fields
}

func TestMakeServer

func TestMakeServer(tb testing.TB, wakers int, options ...Option) *TestServer

TestMakeServer makes a new TestServer for use in tests, but does not start the server. If an error occurs during creation, a testing.Fatal is issued.

func TestStartServer

func TestStartServer(tb testing.TB, wakers int, options ...Option) (*TestServer, func())

TestStartServer creates a new TestServer and starts it running. It returns the server, and a stop function.

func (*TestServer) ExpectExpvarDeltaWithDeadline

func (ts *TestServer) ExpectExpvarDeltaWithDeadline(name string, want int64) func()

ExpectExpvarDeltaWithDeadline returns a deferrable function which tests if the expvar metric with name has changed by delta within the given deadline, once the function begins. Before returning, it fetches the original value for comparison.

func (*TestServer) ExpectMapExpvarDeltaWithDeadline

func (ts *TestServer) ExpectMapExpvarDeltaWithDeadline(name, key string, want int64) func()

ExpectMapExpvarMetricDeltaWithDeadline returns a deferrable function which tests if the expvar map metric with name and key has changed by delta within the given deadline, once the function begins. Before returning, it fetches the original value for comparison.

func (*TestServer) ExpectProgMetricDeltaWithDeadline

func (ts *TestServer) ExpectProgMetricDeltaWithDeadline(name, prog string, want int64) func()

ExpectProgMetricDeltaWithDeadline tests that a given program metric increases by want within the deadline. It assumes that the named metric is an Int type datum.Datum.

func (*TestServer) GetExpvar

func (ts *TestServer) GetExpvar(name string) expvar.Var

GetExpvar is a helper function on TestServer that acts like TestGetExpvar.

func (*TestServer) GetProgramMetric

func (ts *TestServer) GetProgramMetric(name, prog string) datum.Datum

GetProgramMetric fetches the datum of the program metric name.

func (*TestServer) PollWatched

func (ts *TestServer) PollWatched(n int)

Poll all watched objects for updates. The parameter n indicates how many logstreams to wait on before waking them.

func (*TestServer) Start

func (ts *TestServer) Start() func()

Start starts the TestServer and returns a stop function.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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