observability

package
v0.0.2 Latest Latest
Warning

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

Go to latest
Published: Dec 4, 2025 License: Apache-2.0 Imports: 26 Imported by: 0

Documentation

Index

Constants

View Source
const DefaultLogReadLimit = 1000
View Source
const UnixPathMax = 108

Variables

Functions

func CGroupPathForPid

func CGroupPathForPid(pid uint32) (string, error)

func TestInject

func TestInject(reg *asm.Registry)

Types

type BoundPort

type BoundPort struct {
	Addr netip.Addr
	Port int
}

type DebugLogWriter

type DebugLogWriter struct {
	Log *slog.Logger
}

func (*DebugLogWriter) WriteEntry

func (d *DebugLogWriter) WriteEntry(entity string, le LogEntry) error

type EntityStatus

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

func (*EntityStatus) Id

func (e *EntityStatus) Id() string

type Inet6Addr

type Inet6Addr [16]byte

Inet6Addr is struct in6_addr, from uapi/linux/in6.h.

type InetAddr

type InetAddr [4]byte

type LogEntry

type LogEntry struct {
	Timestamp  time.Time
	Stream     LogStream
	TraceID    string
	Attributes map[string]string
	Body       string
}

type LogReader

type LogReader struct {
	Address string        `asm:"victorialogs-address"`
	Timeout time.Duration `asm:"victorialogs-timeout"`
	// contains filtered or unexported fields
}

func (*LogReader) Populated

func (l *LogReader) Populated() error

func (*LogReader) Read

func (l *LogReader) Read(ctx context.Context, id string, opts ...LogReaderOption) ([]LogEntry, error)

func (*LogReader) ReadBySandbox

func (l *LogReader) ReadBySandbox(ctx context.Context, sandboxID string, opts ...LogReaderOption) ([]LogEntry, error)

func (*LogReader) ReadStream

func (l *LogReader) ReadStream(ctx context.Context, target LogTarget, logCh chan<- LogEntry, opts ...LogReaderOption) error

ReadStream queries historical logs and sends them to a channel as they're parsed. Unlike Read(), this has no limit and streams results incrementally.

func (*LogReader) TailStream

func (l *LogReader) TailStream(ctx context.Context, target LogTarget, logCh chan<- LogEntry, opts ...LogReaderOption) error

TailStream connects to VictoriaLogs tail endpoint for live tailing. Blocks until context is cancelled.

type LogReaderOption

type LogReaderOption func(*logReadOpts)

func WithFromTime

func WithFromTime(t time.Time) LogReaderOption

func WithLimit

func WithLimit(l int) LogReaderOption

type LogStream

type LogStream string
const (
	Stdout  LogStream = "stdout"
	Stderr  LogStream = "stderr"
	Error   LogStream = "error"
	UserOOB LogStream = "user-oob"
)

type LogTarget

type LogTarget struct {
	EntityID  string
	SandboxID string
}

LogTarget specifies what logs to query - either by entity ID or sandbox ID.

type LogWriter

type LogWriter interface {
	WriteEntry(entity string, le LogEntry) error
}

type LogsMaintainer

type LogsMaintainer struct {
}

func (*LogsMaintainer) Setup

func (m *LogsMaintainer) Setup(ctx context.Context) error

type PersistentLogReader

type PersistentLogReader struct {
	Address string        `asm:"victorialogs-address"`
	Timeout time.Duration `asm:"victorialogs-timeout"`
	// contains filtered or unexported fields
}

func (*PersistentLogReader) Populated

func (l *PersistentLogReader) Populated() error

func (*PersistentLogReader) Read

func (l *PersistentLogReader) Read(ctx context.Context, id string) ([]LogEntry, error)

type PersistentLogWriter

type PersistentLogWriter struct {
	Address string        `asm:"victorialogs-address"`
	Timeout time.Duration `asm:"victorialogs-timeout"`
	// contains filtered or unexported fields
}

func (*PersistentLogWriter) Client

func (l *PersistentLogWriter) Client() *http.Client

func (*PersistentLogWriter) Populated

func (l *PersistentLogWriter) Populated() error

func (*PersistentLogWriter) WriteEntry

func (l *PersistentLogWriter) WriteEntry(entity string, le LogEntry) error

type PortStatus

type PortStatus string
const (
	PortStatusBound   PortStatus = "bound"
	PortStatusUnbound PortStatus = "unbound"
	PortStatusActive  PortStatus = "active"
)

type PortTracker

type PortTracker interface {
	SetPortStatus(containerID string, bp BoundPort, status PortStatus)
}

type ResourcesMonitor

type ResourcesMonitor struct {
	Writer *metrics.VictoriaMetricsWriter `asm:"victoriametrics-writer"`
	Reader *metrics.VictoriaMetricsReader `asm:"victoriametrics-reader"`
	Log    *slog.Logger
}

func (*ResourcesMonitor) LastestUsage

func (m *ResourcesMonitor) LastestUsage(id string) (float64, uint64, error)

func (*ResourcesMonitor) Monitor

func (m *ResourcesMonitor) Monitor(ctx context.Context, id, cgroupPath string) error

func (*ResourcesMonitor) Setup

func (m *ResourcesMonitor) Setup(ctx context.Context) error

type RunSCMonitor

type RunSCMonitor struct {
	Log   *slog.Logger
	Ports PortTracker
	// contains filtered or unexported fields
}

func (*RunSCMonitor) Close

func (r *RunSCMonitor) Close() error

func (*RunSCMonitor) Messages

func (r *RunSCMonitor) Messages() uint64

func (*RunSCMonitor) Monitor

func (r *RunSCMonitor) Monitor(ctx context.Context) error

func (*RunSCMonitor) NewClient

func (r *RunSCMonitor) NewClient() (monitor.MessageHandler, error)

func (*RunSCMonitor) SetEndpoint

func (r *RunSCMonitor) SetEndpoint(endpoint string)

func (*RunSCMonitor) WritePodInit

func (r *RunSCMonitor) WritePodInit(path string) error

type SockAddr

type SockAddr interface {
	Port() int
	Address() netip.Addr
}

type SockAddrInet

type SockAddrInet struct {
	Family  uint16
	NetPort uint16
	Addr    InetAddr
	// contains filtered or unexported fields
}

func (*SockAddrInet) Address

func (s *SockAddrInet) Address() netip.Addr

func (*SockAddrInet) Port

func (s *SockAddrInet) Port() int

func (*SockAddrInet) String

func (s *SockAddrInet) String() string

type SockAddrInet6

type SockAddrInet6 struct {
	Family   uint16
	NetPort  uint16
	Flowinfo uint32
	Addr     [16]byte
	Scope_id uint32
}

SockAddrInet6 is struct sockaddr_in6, from uapi/linux/in6.h.

func (*SockAddrInet6) Address

func (s *SockAddrInet6) Address() netip.Addr

func (*SockAddrInet6) Port

func (s *SockAddrInet6) Port() int

func (*SockAddrInet6) String

func (s *SockAddrInet6) String() string

type SockAddrUnix

type SockAddrUnix struct {
	Family uint16
	Path   [UnixPathMax]int8
}

SockAddrUnix is struct sockaddr_un, from uapi/linux/un.h.

type StatusMonitor

type StatusMonitor struct {
	Log *slog.Logger
	// contains filtered or unexported fields
}

func (*StatusMonitor) EntityBoundPorts

func (s *StatusMonitor) EntityBoundPorts(entity string) ([]BoundPort, error)

func (*StatusMonitor) FindBoundPort

func (s *StatusMonitor) FindBoundPort(bp BoundPort) ([]*EntityStatus, error)

func (*StatusMonitor) Populated

func (s *StatusMonitor) Populated() error

func (*StatusMonitor) SetPortStatus

func (s *StatusMonitor) SetPortStatus(entity string, port BoundPort, status PortStatus)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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