metrics

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Feb 7, 2022 License: AGPL-3.0 Imports: 1 Imported by: 12

Documentation

Overview

Package metrics defines the format that will be used to send metric batches to the collector and receive updates.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type EnvResponse

type EnvResponse struct {
	AcknowledgedBatches []string              `json:"acks,omitempty"`
	ModelStatus         ModelStatus           `json:"model-status,omitempty"`
	UnitStatuses        map[string]UnitStatus `json:"unit-statuses,omitempty"`
}

EnvResponse contains the response data relevant to a concrete environment.

type EnvironmentResponses

type EnvironmentResponses map[string]EnvResponse

EnvironmentResponses is a map of model UUID to wireformat responses.

func (EnvironmentResponses) Ack

func (e EnvironmentResponses) Ack(modelUUID, batchUUID string)

Ack adds the specified the batch UUID to the list of acknowledged batches for the specified environment. If the model UUID or batch UUID is nil, the batch will not be acknowledged.

func (EnvironmentResponses) SetModelStatus

func (e EnvironmentResponses) SetModelStatus(modelUUID, status, info string)

SetModelStatus sets the model meter status.

func (EnvironmentResponses) SetUnitStatus

func (e EnvironmentResponses) SetUnitStatus(modelUUID, unitName, status, info string)

SetUnitStatus sets the unit meter status.

type MeterStatus

type MeterStatus struct {
	Status string `json:"status"`
	Info   string `json:"info"`
}

MeterStatus represents the meter status information.

type Metric

type Metric struct {
	Key    string            `json:"key"`
	Value  string            `json:"value"`
	Time   time.Time         `json:"time"`
	Labels map[string]string `json:"labels,omitempty"`
}

Metric represents a single Metric.

type MetricBatch

type MetricBatch struct {
	UUID                string    `json:"uuid"`
	ModelUUID           string    `json:"env-uuid"`
	ModelName           string    `json:"model-name"`
	UnitName            string    `json:"unit-name"`
	CharmUrl            string    `json:"charm-url"`
	Created             time.Time `json:"created"`
	Metrics             []Metric  `json:"metrics"`
	Credentials         []byte    `json:"credentials"`
	ResellerCredentials []byte    `json:"reseller-credentials"`
	SLACredentials      []byte    `json:"sla-credentials"`
}

MetricBatch is a batch of metrics that will be sent to the metric collector

type ModelStatus

type ModelStatus struct {
	Status string `json:"status"`
	Info   string `json:"info"`
}

ModelStatus represents the status of a model.

type Response

type Response struct {
	UUID           string               `json:"uuid"`
	EnvResponses   EnvironmentResponses `json:"env-responses"`
	NewGracePeriod time.Duration        `json:"new-grace-period"`
}

Response represents the response from the metrics collector.

type UnitStatus

type UnitStatus struct {
	Status string `json:"status"`
	Info   string `json:"info"`
}

UnitStatus represents the status of a unit.

type UserResponse

type UserResponse struct {
	Status              MeterStatus `json:"status"`
	AcknowledgedBatches []string    `json:"acks,omitempty"`
}

UserResponse is the response to a single user's metric batches.

type UserResponses

type UserResponses map[string]UserResponse

UserResponses is a set of meter status and batch acknowledgement responses. Keyed off username.

type UserStatusResponse

type UserStatusResponse struct {
	UUID          string        `json:"uuid"`
	UserResponses UserResponses `json:"user-responses"`
}

UserStatusResponse represents the response from the metrics collector that reports user meter statuses.

Jump to

Keyboard shortcuts

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