observer

package
v3.0.3 Latest Latest
Warning

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

Go to latest
Published: Mar 5, 2022 License: AGPL-3.0 Imports: 27 Imported by: 0

Documentation

Overview

Package observer provides clone monitoring.

Package observer provides clone monitoring.

Package observer provides clone monitoring.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BuildArtifactFilename

func BuildArtifactFilename(artifactType string) string

BuildArtifactFilename builds an artifact filename.

func InitConnection

func InitConnection(clone *models.Clone, socketDir string) (*pgx.Conn, error)

InitConnection creates a new connection to the clone database.

func IsAvailableArtifactType

func IsAvailableArtifactType(artifactType string) bool

IsAvailableArtifactType checks if artifact type is available.

Types

type Config

type Config struct {
	ReplacementRules map[string]string `yaml:"replacementRules"`
}

Config defines configuration options for observer.

type DBSize

type DBSize struct {
	Total       string      `json:"total"`
	Diff        string      `json:"diff"`
	ObjectsStat ObjectsStat `json:"objects_stat"`
}

DBSize represents summary statistics about database size.

type Duration

type Duration struct {
	Total            string    `json:"total"`
	StartedAt        time.Time `json:"started_at"`
	FinishedAt       time.Time `json:"finished_at"`
	MaxQueryDuration string    `json:"query_duration_longest"`
}

Duration represents summary statistics about session duration.

type Locks

type Locks struct {
	TotalInterval   int `json:"total_interval"`
	WarningInterval int `json:"warning_interval"`
}

Locks represents summary statistics about locks.

type LogErrors

type LogErrors struct {
	Count   int    `json:"count"`
	Message string `json:"message"`
}

LogErrors contains details about log errors statistics.

type ObjectsStat

type ObjectsStat struct {
	Count               int   `json:"count"`
	RowEstimateSum      int64 `json:"row_estimate_sum"`
	TotalSizeBytesSum   int64 `json:"total_size_bytes_sum"`
	TableSizeBytesSum   int64 `json:"table_size_bytes_sum"`
	IndexesSizeBytesSum int64 `json:"indexes_size_bytes_sum"`
	ToastSizeBytesSum   int64 `json:"toast_size_bytes_sum"`
}

ObjectsStat represents summary statistics about objects size.

type Observer

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

Observer manages observation sessions.

func NewObserver

func NewObserver(dockerClient *client.Client, cfg *Config, pm *pool.Manager) *Observer

NewObserver creates an Observer instance.

func (*Observer) AddObservingClone

func (o *Observer) AddObservingClone(cloneID string, port uint, session *ObservingClone)

AddObservingClone adds a new observing session to storage.

func (*Observer) GetCloneLog

func (o *Observer) GetCloneLog(ctx context.Context, port string, obsClone *ObservingClone) ([]byte, error)

GetCloneLog gets clone logs. TODO (akartasov): Split log to chunks.

func (*Observer) GetObservingClone

func (o *Observer) GetObservingClone(cloneID string) (*ObservingClone, error)

GetObservingClone returns an observation session from storage.

func (*Observer) RemoveObservingClone

func (o *Observer) RemoveObservingClone(cloneID string)

RemoveObservingClone removes an observing clone from storage.

type ObservingClone

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

ObservingClone describes an entity containing observability sessions.

func NewObservingClone

func NewObservingClone(config types.Config, sudb *pgx.Conn) *ObservingClone

NewObservingClone creates a new observing clone.

func (*ObservingClone) AddArtifact

func (c *ObservingClone) AddArtifact(sessionID uint64)

AddArtifact adds a new observation session to storage.

func (*ObservingClone) BuildArtifactPath

func (c *ObservingClone) BuildArtifactPath(sessionID uint64, artifactType string) string

BuildArtifactPath generates a full path to the artifact file.

func (*ObservingClone) CheckDuration

func (c *ObservingClone) CheckDuration() bool

CheckDuration checks duration of the operation.

func (*ObservingClone) CheckLocks

func (c *ObservingClone) CheckLocks() bool

CheckLocks checks long-lasting locks during the operation.

func (*ObservingClone) CheckOverallSuccess

func (c *ObservingClone) CheckOverallSuccess() bool

CheckOverallSuccess checks overall success of queries.

func (*ObservingClone) CheckPerformanceRequirements

func (c *ObservingClone) CheckPerformanceRequirements() error

CheckPerformanceRequirements checks monitoring data and returns an error if any of performance requires was not satisfied.

func (*ObservingClone) Config

func (c *ObservingClone) Config() types.Config

Config returns config of the observing clone.

func (*ObservingClone) CsvFields

func (c *ObservingClone) CsvFields() string

CsvFields returns a comma-separated list of available csv fields.

func (*ObservingClone) GetArtifactList

func (c *ObservingClone) GetArtifactList() []uint64

GetArtifactList returns available artifact session IDs for the requested clone.

func (*ObservingClone) Init

func (c *ObservingClone) Init(clone *models.Clone, sessionID uint64, startedAt time.Time, tags map[string]string) error

Init initializes observation session.

func (*ObservingClone) IsExistArtifacts

func (c *ObservingClone) IsExistArtifacts(sessionID uint64) bool

IsExistArtifacts checks if observation session artifacts exist.

func (*ObservingClone) ReadSummary

func (c *ObservingClone) ReadSummary(sessionID uint64) ([]byte, error)

ReadSummary reads summary file.

func (*ObservingClone) RunSession

func (c *ObservingClone) RunSession() error

RunSession runs observing session.

func (*ObservingClone) Session

func (c *ObservingClone) Session() *Session

Session returns the current observability session.

func (*ObservingClone) SetOverallError

func (c *ObservingClone) SetOverallError(overallErrors bool)

SetOverallError notes the presence of errors during the session.

func (*ObservingClone) Stop

func (c *ObservingClone) Stop() error

Stop stops an observation session.

type ReplacementRule

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

ReplacementRule describes replacement rules.

type Session

type Session struct {
	SessionID  uint64                    `json:"session_id"`
	StartedAt  time.Time                 `json:"started_at"`
	FinishedAt time.Time                 `json:"finished_at"`
	Config     types.Config              `json:"config"`
	Tags       map[string]string         `json:"tags"`
	Artifacts  []string                  `json:"artifacts,omitempty"`
	Result     *models.ObservationResult `json:"result,omitempty"`
	// contains filtered or unexported fields
}

Session describes a session of service monitoring.

func NewSession

func NewSession(sessionID uint64, startedAt time.Time, config types.Config, tags map[string]string) *Session

NewSession creates a new observing session.

func (Session) IsFinished

func (s Session) IsFinished() bool

IsFinished checks if the value FinishedAt is zero.

type State

type State struct {
	InitialDBSize    int64
	CurrentDBSize    int64
	MaxDBQueryTimeMS float64
	ObjectStat       ObjectsStat
	LogErrors        LogErrors
	OverallError     bool
}

State contains database state of the session.

type SummaryArtifact

type SummaryArtifact struct {
	SessionID     uint64    `json:"session_id"`
	CloneID       string    `json:"clone_id"`
	Duration      Duration  `json:"duration"`
	DBSize        DBSize    `json:"db_size"`
	Locks         Locks     `json:"locks"`
	LogErrors     LogErrors `json:"log_errors"`
	ArtifactTypes []string  `json:"artifact_types"`
}

SummaryArtifact represents session summary.

Jump to

Keyboard shortcuts

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