Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func NewToolsLogsCmd ¶
NewToolsLogsCmd returns the parent "logs" command for Substreams logs analysis tools
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 ¶
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 ¶
IsIncomingRequest returns true if this is an incoming request log
func (*LogEntry) IsRequestStats ¶
IsRequestStats returns true if this is a request stats log (tier1 only)