Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func IsNormalDisconnect ¶ added in v1.13.1
isNormalDisconnect returns true if the error indicates a normal client disconnect rather than an actual error condition
Types ¶
type Backend ¶ added in v1.13.1
type Backend 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
}
Backend abstracts the log querying mechanism
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 LogEntry ¶
type LogEntry struct {
// Common fields from jsonPayload
Message string
TraceID string
SessionID string
UserID string
IPAddress string
OutputModule string
OutputModuleHash string
StartBlock int64
StopBlock uint64
Cursor string
ProductionMode bool
FinalBlocksOnly bool
NoopMode 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)
type QueryOptions ¶
type QueryOptions struct {
UserID string
TraceID string
Namespace string
StartTime time.Time
EndTime time.Time
}
QueryOptions contains parameters for querying connection logs
Either UserID or TraceID must be set. UserID matches all requests for an organization; TraceID matches a single request via Cloud Logging SEARCH().