appoptics

package
v0.0.0-...-48a44ca Latest Latest
Warning

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

Go to latest
Published: Jan 2, 2019 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BatchMeasurements

func BatchMeasurements(prepChan <-chan []*Measurement,
	pushChan chan<- []*Measurement, stopChan <-chan struct{}, batchSize int, logger adapter.Logger)

BatchMeasurements reads slices of Measurement types off a channel populated by the web handler and packages them into batches conforming to the limitations imposed by the API.

func PersistBatches

func PersistBatches(lc ServiceAccessor, pushChan <-chan []*Measurement,
	stopChan <-chan struct{}, logger adapter.Logger)

PersistBatches reads maximal slices of Measurement types off a channel and persists them to the remote AppOptics API. Errors are placed on the error channel.

Types

type Client

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

Client implements ServiceAccessor

func NewClient

func NewClient(token string, logger adapter.Logger) *Client

NewClient creates a new client to interact with appoptics

func (*Client) Do

func (c *Client) Do(req *http.Request, respData interface{}) (*http.Response, error)

Do performs the HTTP request on the wire, taking an optional second parameter for containing a response

func (*Client) MeasurementsService

func (c *Client) MeasurementsService() MeasurementsCommunicator

MeasurementsService represents the subset of the API that deals with AppOptics Measurements

func (*Client) NewRequest

func (c *Client) NewRequest(method, path string, body interface{}) (*http.Request, error)

NewRequest standardizes the request being sent

type ErrorResponse

type ErrorResponse struct {
	// Errors holds the error information from the API
	Errors interface{} `json:"errors"`
}

ErrorResponse represents the response body returned when the API reports an error

func (*ErrorResponse) Error

func (e *ErrorResponse) Error() string

Error makes ErrorResponse satisfy the error interface and can be used to serialize error responses back to the client

type Measurement

type Measurement struct {
	// Name is the name of the Metric this Measurement is associated with
	Name string `json:"name"`
	// Tags add dimensionality to data, similar to Labels in Prometheus
	Tags MeasurementTags `json:"tags,omitempty"`
	// Time is the UNIX epoch timestamp of the Measurement
	Time int64 `json:"time"`
	// Value is the value of the
	Value float64 `json:"value"`
}

Measurement corresponds to the AppOptics API type of the same name TODO: support the full set of Measurement fields

type MeasurementPayload

type MeasurementPayload struct {
	Measurements []*Measurement `json:"measurements"`
}

MeasurementPayload is the construct we POST to the API

type MeasurementTags

type MeasurementTags map[string]string

MeasurementTags is used to store the tags (labels)

type MeasurementsCommunicator

type MeasurementsCommunicator interface {
	Create([]*Measurement) (*http.Response, error)
}

MeasurementsCommunicator defines an interface for communicating with the Measurements portion of the AppOptics API

type MeasurementsService

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

MeasurementsService implements MeasurementsCommunicator

func (*MeasurementsService) Create

func (ms *MeasurementsService) Create(mc []*Measurement) (*http.Response, error)

Create persists the given MeasurementCollection to AppOptics

type ServiceAccessor

type ServiceAccessor interface {
	// MeasurementsService implements an interface for dealing with  Measurements
	MeasurementsService() MeasurementsCommunicator
}

ServiceAccessor defines an interface for talking to AppOptics via domain-specific service constructs

Jump to

Keyboard shortcuts

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