reqlog

package
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Oct 11, 2026 License: Apache-2.0 Imports: 3 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package reqlog records every API call and data-plane request as a structured entry (FR-CORE-061) and keeps the most recent ones in memory for the admin API (FR-CORE-045).

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Entry

type Entry struct {
	Time     time.Time `json:"time"`
	Service  string    `json:"service"`
	Protocol string    `json:"protocol"` // http, grpc, dns, postgres, tcp, udp
	Method   string    `json:"method"`
	// Resource is the resource acted on: the one whose permission an API
	// call checked first, the answering DNS zone, the Cloud SQL instance or
	// the Cloud NAT gateway.
	Resource  string `json:"resource,omitempty"`
	Principal string `json:"principal,omitempty"`
	// Status is protocol-specific: the HTTP status, gRPC code or DNS
	// rcode; for connections (postgres, NAT) 0 when admitted and 1 when
	// refused, with the reason in Code.
	Status    int     `json:"status"`
	Code      string  `json:"code,omitempty"`
	LatencyMS float64 `json:"latencyMs"`
}

Entry is one logged request.

type Log

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

Log is a bounded ring buffer of entries that also writes to a logger.

func New

func New(size int, log *slog.Logger) *Log

New returns a log keeping the last size entries.

func (*Log) Add

func (l *Log) Add(e Entry)

Add records e. A nil Log discards it.

func (*Log) Clear

func (l *Log) Clear()

Clear drops all entries.

func (*Log) Entries

func (l *Log) Entries(service string) []Entry

Entries returns the retained entries, oldest first, optionally filtered by service.

func (*Log) OnAdd added in v0.2.0

func (l *Log) OnAdd(fn func(Entry))

OnAdd sets a function called with every entry added. Set it before the Log is used.

Jump to

Keyboard shortcuts

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