lokitest

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Nov 6, 2026 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Overview

Package lokitest is a fake Loki 3 for the tests of the packages that open a Loki source (the session, the engine through it): an http.Handler over in-memory entries that answers the requests locklog sends (labels, label values, query_range for streams and for the metric form, the instant metric query), with Loki's paging (limit over all streams, forward, end excluded) and categorized labels, behind basic authentication unless Open.

The loki package's own tests have a richer fake of their own; this one only needs to be faithful to the subset a session reads.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Entry

type Entry struct {
	TS     int64 // Unix nanoseconds
	Labels map[string]string
	Meta   map[string]string
	Line   string
}

Entry is one log entry.

type Server

type Server struct {
	Entries []Entry
	// User and Password authenticate a request (basic); Open serves every
	// request without credentials.
	User, Password string
	Open           bool
	// contains filtered or unexported fields
}

Server is the fake. Set its fields before serving.

func (*Server) MetricQueries added in v0.2.0

func (f *Server) MetricQueries() int

MetricQueries returns the number of metric queries served (the count_over_time sums locklog sends), log queries excluded.

func (*Server) Requests

func (f *Server) Requests() []string

Requests returns the path of every request served.

func (*Server) ServeHTTP

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

ServeHTTP implements http.Handler.

Jump to

Keyboard shortcuts

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