stats

package module
v0.0.0-...-a049b20 Latest Latest
Warning

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

Go to latest
Published: Jul 29, 2020 License: MIT Imports: 8 Imported by: 0

README

stats

metricsの名前がかぶらないように適当にまとめたやつ

Documentation

Index

Constants

View Source
const (
	// OCReportInterval is the interval for OpenCensus to send stats data to
	// Stackdriver Monitoring via its exporter.
	// NOTE: this value should not be no less than 1 minute. Detailes are in the doc.
	// https://cloud.google.com/monitoring/custom-metrics/creating-metrics#writing-ts
	OCReportInterval = 60 * time.Second

	// Measure namess for respecitive OpenCensus Measure
	LogSize       = "logsize"
	RedisStatus   = "redis-status"
	SpannerStatus = "spanner-status"

	// Units are used to define Measures of OpenCensus.
	ByteSizeUnit = "byte"
	CountUnit    = "count"

	// ResouceNamespace is used for the exporter to have resource labels.
	ResourceNamespace = "sinmetal"
)

Variables

View Source
var (
	// Measure variables
	MLogSize            = stats.Int64(LogSize, "logSize", ByteSizeUnit)
	MRedisStatusCount   = stats.Int64(RedisStatus, "redis status", CountUnit)
	MSpannerStatusCount = stats.Int64(SpannerStatus, "spanner status", CountUnit)

	RedisStatusCountView = &view.View{
		Name:        RedisStatus,
		Description: "redis status count",
		TagKeys:     []tag.Key{KeySource},
		Measure:     MRedisStatusCount,
		Aggregation: view.Count(),
	}

	SpannerStatusCountView = &view.View{
		Name:        SpannerStatus,
		Description: "spanner status count",
		TagKeys:     []tag.Key{KeySource},
		Measure:     MSpannerStatusCount,
		Aggregation: view.Count(),
	}

	LogSizeView = &view.View{
		Name:        LogSize,
		Measure:     MLogSize,
		TagKeys:     []tag.Key{KeySource},
		Description: "log size",
		Aggregation: view.Sum(),
	}

	LogSizeViews = []*view.View{
		LogSizeView,
	}

	StatusViews = []*view.View{
		RedisStatusCountView,
		SpannerStatusCountView,
	}

	// KeySource is the key for label in "generic_node",
	KeySource, _ = tag.NewKey("source")
)

Functions

func CountRedisStatus

func CountRedisStatus(ctx context.Context, id string) error

func CountSpannerStatus

func CountSpannerStatus(ctx context.Context, id string) error

func GetMetricType

func GetMetricType(v *view.View) string

func InitExporter

func InitExporter(project string, location string, namespace string, node string, labels *stackdriver.Labels) *stackdriver.Exporter

func InitOpenCensusStats

func InitOpenCensusStats(exporter *stackdriver.Exporter) error

func RecordMeasurement

func RecordMeasurement(id string, logSize int64) error

Types

type GenericNodeMonitoredResource

type GenericNodeMonitoredResource struct {
	Location    string
	NamespaceId string
	NodeId      string
}

func NewGenericNodeMonitoredResource

func NewGenericNodeMonitoredResource(location, namespace, node string) *GenericNodeMonitoredResource

func (*GenericNodeMonitoredResource) MonitoredResource

func (mr *GenericNodeMonitoredResource) MonitoredResource() (string, map[string]string)

Jump to

Keyboard shortcuts

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