stats

package
v0.2.1 Latest Latest
Warning

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

Go to latest
Published: Feb 16, 2020 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// StatTypeMin focus 1 minute
	StatTypeMin statType = iota
	// StatType10Min focus 10 minutes
	StatType10Min
	// StatTypeHour focus 1 hour
	StatTypeHour
)

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

func (*Client) GetStats

func (c *Client) GetStats(ctx context.Context, t statType) []*Stat

GetStats returns Stat collection with specific time period

type Stat

type Stat 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"`
}

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

type Worker

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

Worker of stats collector

func NewWorker

func NewWorker(client *Client, statType statType, 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 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