stats

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Aug 13, 2021 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

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

Client wrapped *spanner.Client for easy to use stats collect

func NewClient

func NewClient(ctx context.Context, projectID, instanceID, databaseID, credentialFile string) (*Client, error)

NewClient is constructor of Client

type LockStat added in v0.1.1

type LockStat struct {
	IntervalEnd        time.Time `spanner:"INTERVAL_END"`
	RowRangeStartKey   []byte    `spanner:"ROW_RANGE_START_KEY"`
	LockWaitSeconds    float64   `spanner:"LOCK_WAIT_SECONDS"`
	SampleLockRequests []struct {
		LockMode string `spanner:"lock_mode"`
		Column   string `spanner:"column"`
	} `spanner:"SAMPLE_LOCK_REQUESTS"`
}

LockStat track the lock columns during a specific time period followed https://cloud.google.com/spanner/docs/introspection/lock-statistics

type QueryStat added in v0.1.1

type QueryStat struct {
	IntervalEnd       time.Time `spanner:"INTERVAL_END"`
	Text              string    `spanner:"TEXT"`
	TextTruncated     bool      `spanner:"TEXT_TRUNCATED"`
	TextFingerprint   int64     `spanner:"TEXT_FINGERPRINT"`
	ExecutionCount    int64     `spanner:"EXECUTION_COUNT"`
	AvgLatencySeconds float64   `spanner:"AVG_LATENCY_SECONDS"`
	AvgRows           float64   `spanner:"AVG_ROWS"`
	AvgBytes          float64   `spanner:"AVG_BYTES"`
	AvgRowsScanned    float64   `spanner:"AVG_ROWS_SCANNED"`
	AvgCPUSeconds     float64   `spanner:"AVG_CPU_SECONDS"`
}

QueryStat track the queries with the highest CPU usage during a specific time period followed https://cloud.google.com/spanner/docs/query-stats-tables

type StatDuration added in v0.2.0

type StatDuration int
const (
	// StatDurationMin focus 1 minute
	StatDurationMin StatDuration = iota
	// StatDuration10Min focus 10 minutes
	StatDuration10Min
	// StatDurationHour focus 1 hour
	StatDurationHour
)

func (StatDuration) Duration added in v0.2.0

func (s StatDuration) Duration() time.Duration

func (StatDuration) String added in v0.2.0

func (s StatDuration) String() string

type TransactionStat added in v0.1.1

type TransactionStat struct {
	IntervalEnd                   time.Time `spanner:"INTERVAL_END"`
	Fprint                        int64     `spanner:"FPRINT"`
	ReadColumns                   []string  `spanner:"READ_COLUMNS"`
	WriteConstructiveColumns      []string  `spanner:"WRITE_CONSTRUCTIVE_COLUMNS"`
	WriteDeleteTables             []string  `spanner:"WRITE_DELETE_TABLES"`
	CommitAttemptCount            int64     `spanner:"COMMIT_ATTEMPT_COUNT"`
	CommitFailedPreconditionCount int64     `spanner:"COMMIT_FAILED_PRECONDITION_COUNT"`
	CommitAbortCount              int64     `spanner:"COMMIT_ABORT_COUNT"`
	AvgParticipants               float64   `spanner:"AVG_PARTICIPANTS"`
	AvgTotalLatencySeconds        float64   `spanner:"AVG_TOTAL_LATENCY_SECONDS"`
	AvgCommitLatencySeconds       float64   `spanner:"AVG_COMMIT_LATENCY_SECONDS"`
	AvgBytes                      float64   `spanner:"AVG_BYTES"`
}

TransactionStat track the transactions during a specific time period followed https://cloud.google.com/spanner/docs/introspection/transaction-statistics

type Worker

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

Worker of stats collector

func NewWorker

func NewWorker(client *Client, statType StatDuration, writer Writer) *Worker

NewWorker returns the new stats collector

func (*Worker) Start

func (w *Worker) Start(ctx context.Context)

Start the stats collector

func (*Worker) Stop

func (w *Worker) Stop()

Stop the stats collector

type Writer

type Writer interface {
	// Write stats collection to anything
	Write([]stat)
}

Writer for stats collection

func NewOpenTelemetryWriter added in v0.1.1

func NewOpenTelemetryWriter() Writer

NewOpenTelemetryWriter return new Writer of OpenTelemetry

func NewZapWriter

func NewZapWriter(logger *zap.Logger) Writer

NewZapWriter return new Writer of *zap.Logger

Jump to

Keyboard shortcuts

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