record

package
v0.0.0-...-767c769 Latest Latest
Warning

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

Go to latest
Published: Oct 3, 2019 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Overview

Package record describes Metric Records that store some data about each imported metric in App Engine Datastore.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CleanupRecords

func CleanupRecords(ctx context.Context, valid []string) error

CleanupRecords removes obsolete metric records from Datastore.

Types

type DatastoreMetricRecord

type DatastoreMetricRecord 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
}

DatastoreMetricRecord defines a Datastore entity that is used to store status information about an imported metric.

func NewDatastoreMetricRecord

func NewDatastoreMetricRecord(ctx context.Context, name, query string) (*DatastoreMetricRecord, error)

NewDatastoreMetricRecord returns a Datastore-based metric record for a given metric name.

func (*DatastoreMetricRecord) GetCounterStartTime

func (m *DatastoreMetricRecord) GetCounterStartTime() time.Time

GetCounterStartTime returns CounterStartTime.

func (*DatastoreMetricRecord) GetLastUpdate

func (m *DatastoreMetricRecord) GetLastUpdate() time.Time

GetLastUpdate returns LastUpdate timestamp.

func (*DatastoreMetricRecord) SetCounterStartTime

func (m *DatastoreMetricRecord) SetCounterStartTime(ctx context.Context, start time.Time) error

SetCounterStartTime sets CounterStartTime and persists metric data.

func (*DatastoreMetricRecord) UpdateError

func (m *DatastoreMetricRecord) UpdateError(ctx context.Context, e error) error

UpdateError updates metric status in Datastore with a given error message.

func (*DatastoreMetricRecord) UpdateSuccess

func (m *DatastoreMetricRecord) UpdateSuccess(ctx context.Context, points int, msg string) error

UpdateSuccess updates metric status in Datastore with a given message.

type MetricRecord

type MetricRecord interface {
	UpdateError(ctx context.Context, e error) error
	UpdateSuccess(ctx context.Context, points int, msg string) error
	GetLastUpdate() time.Time
	GetCounterStartTime() time.Time
	SetCounterStartTime(ctx context.Context, start time.Time) error
}

MetricRecord is an interface implemented by DatastoreMetricRecord.

Jump to

Keyboard shortcuts

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