Documentation ¶
Index ¶
- func Emulator(ctx context.Context) <-chan struct{}
- type Manager
- type Options
- type StoredMetricRecord
- func (m *StoredMetricRecord) GetCounterStartTime() time.Time
- func (m *StoredMetricRecord) GetLastUpdate() time.Time
- func (m *StoredMetricRecord) SetCounterStartTime(ctx context.Context, start time.Time) error
- func (m *StoredMetricRecord) UpdateError(ctx context.Context, e error) error
- func (m *StoredMetricRecord) UpdateSuccess(ctx context.Context, points int, msg string) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Emulator ¶
Emulator instantiates datastore emulator for use in tests.
Background: this was devised due to aetest package no longer being available for 1.12+ runtimes as dev_appserver.py cannot run runtimes past go111, see: https://github.com/googleapis/google-cloud-go/issues/644
Usage: ctx, cancel := context.WithCancel(context.Background()) // Save the emulator's quit channel. quit := Emulator(ctx) code := m.Run() cancel() // Wait for channel close <-quit
Types ¶
type Manager ¶
Manager struct implementing the storage.Manager interface
func (*Manager) CleanupRecords ¶
CleanupRecords removes obsolete metric records from Datastore.
`keep` represents metrics to be kept, all others will be purged
func (*Manager) Close ¶
Close function exists here for compatibility as Datastore doesn't need to be closed
func (*Manager) NewMetricRecord ¶
func (d *Manager) NewMetricRecord(ctx context.Context, name, query string) (storage.MetricRecord, error)
NewMetricRecord returns a Datastore-based metric record for a given metric name.
type Options ¶
type Options struct { // Project sets the GCP project to use for communicating to datastore. Project string }
Options holds settings specific to datastore
type StoredMetricRecord ¶
type StoredMetricRecord struct { Name string Query string LastUpdate time.Time // last time we wrote any points to SD. LastAttempt time.Time // last time we attempted an update. LastStatus string // CounterStartTime is used to keep start timestamp for cumulative metrics. CounterStartTime time.Time // Storage provides access to Storage *Manager }
StoredMetricRecord defines a Datastore entity that is used to store status information about an imported metric.
func (*StoredMetricRecord) GetCounterStartTime ¶
func (m *StoredMetricRecord) GetCounterStartTime() time.Time
GetCounterStartTime returns CounterStartTime.
func (*StoredMetricRecord) GetLastUpdate ¶
func (m *StoredMetricRecord) GetLastUpdate() time.Time
GetLastUpdate returns LastUpdate timestamp.
func (*StoredMetricRecord) SetCounterStartTime ¶
SetCounterStartTime sets CounterStartTime and persists metric data.
func (*StoredMetricRecord) UpdateError ¶
func (m *StoredMetricRecord) UpdateError(ctx context.Context, e error) error
UpdateError updates metric status in Datastore with a given error message.
func (*StoredMetricRecord) UpdateSuccess ¶
UpdateSuccess updates metric status in Datastore with a given message.