logs

package
v1.13.0 Latest Latest
Warning

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

Go to latest
Published: Feb 20, 2026 License: Apache-2.0 Imports: 19 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewToolsLogsCmd

func NewToolsLogsCmd(logger *zap.Logger) *cobra.Command

NewToolsLogsCmd returns the parent "logs" command for Substreams logs analysis tools

func NewToolsLogsConnectionsCmd

func NewToolsLogsConnectionsCmd(logger *zap.Logger) *cobra.Command

NewToolsLogsConnectionsCmd returns the "connections" subcommand

Types

type ConnectionLog

type ConnectionLog struct {
	// From incoming request
	TraceID          string
	UserID           string
	IPAddress        string
	OutputModule     string
	OutputModuleHash string
	StartBlock       int64
	StopBlock        uint64
	ProductionMode   bool
	Timestamp        time.Time

	// From resource labels (backend-specific, extracted by backend)
	Namespace   string
	ClusterName string
	PodName     string

	// From stats (nil if not yet received)
	Stats *ConnectionStats

	// IsOrphan indicates this is a stats-only record with no matching incoming request
	IsOrphan bool
}

ConnectionLog represents a single connection (may be partial if stats not yet received)

func (*ConnectionLog) Duration

func (c *ConnectionLog) Duration() time.Duration

Duration returns the duration of the connection For active connections, returns time since start For closed connections, returns the actual duration

func (*ConnectionLog) Status

func (c *ConnectionLog) Status() ConnectionStatus

Status returns the connection status based on whether stats are present and if there's an error

type ConnectionStats

type ConnectionStats struct {
	TotalBlocksProcessed uint64
	BlockRatePerSec      string
	TimeToFirstData      float64
	ResolvedStartBlock   uint64
	Error                string
	EndTimestamp         time.Time
	Duration             time.Duration // Request duration (from parallel_duration)
}

ConnectionStats contains statistics from the request stats log

type ConnectionStatus

type ConnectionStatus string

Connection status constants

const (
	StatusActive ConnectionStatus = "active"
	StatusClosed ConnectionStatus = "closed"
	StatusError  ConnectionStatus = "error"
	StatusOrphan ConnectionStatus = "orphan"
)

type CorrelationResult

type CorrelationResult struct {
	Connections   []*ConnectionLog
	MaxConcurrent int // Maximum number of connections active at the same time (orphans use range start as start time)
}

CorrelationResult holds the result of correlating incoming requests with stats

func CorrelateConnections

func CorrelateConnections(entries []LogEntry, queryStartTime time.Time) *CorrelationResult

CorrelateConnections matches incoming request logs with their corresponding stats logs by trace_id. Returns correlated connections including orphaned stats records. queryStartTime is used as the timestamp for orphaned records (for sorting purposes).

type GCPBackend

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

GCPBackend implements LogBackend using Google Cloud Logging

func NewGCPBackend

func NewGCPBackend(ctx context.Context, projectID string, logger *zap.Logger) (*GCPBackend, error)

NewGCPBackend creates a new GCP Cloud Logging backend

func (*GCPBackend) Close

func (b *GCPBackend) Close() error

Close releases resources held by the backend

func (*GCPBackend) QueryLogs

func (b *GCPBackend) QueryLogs(ctx context.Context, opts QueryOptions) ([]LogEntry, error)

QueryLogs queries Cloud Logging for connection-related log entries

type LogBackend

type LogBackend interface {
	// QueryLogs returns all log entries matching the criteria
	// Returns both incoming requests and stats logs for correlation
	QueryLogs(ctx context.Context, opts QueryOptions) ([]LogEntry, error)

	// Close releases any resources held by the backend
	Close() error
}

LogBackend abstracts the log querying mechanism

type LogEntry

type LogEntry struct {
	// Common fields from jsonPayload
	Message          string
	TraceID          string
	UserID           string
	IPAddress        string
	OutputModule     string
	OutputModuleHash string
	StartBlock       int64
	StopBlock        uint64
	ProductionMode   bool
	Timestamp        string

	// Stats-specific fields (only present for "substreams request stats")
	Tier                 string
	TotalBlocksProcessed uint64
	BlockRatePerSec      string
	TimeToFirstData      float64
	ResolvedStartBlock   uint64
	Error                string
	Duration             float64 // Request duration in seconds

	// Resource labels (backend extracts these from envelope)
	Namespace   string
	ClusterName string
	PodName     string
}

LogEntry represents a raw log entry from any backend The backend extracts jsonPayload fields into this struct

func (*LogEntry) IsIncomingRequest

func (e *LogEntry) IsIncomingRequest() bool

IsIncomingRequest returns true if this is an incoming request log

func (*LogEntry) IsRequestStats

func (e *LogEntry) IsRequestStats() bool

IsRequestStats returns true if this is a request stats log (tier1 only)

type QueryOptions

type QueryOptions struct {
	UserID    string
	Namespace string
	StartTime time.Time
	EndTime   time.Time
}

QueryOptions contains parameters for querying connection logs

Jump to

Keyboard shortcuts

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