Documentation
¶
Index ¶
- Constants
- Variables
- func ContextWithMeasurementSet(ctx context.Context) context.Context
- func MetricWithTags(name string, tags map[string]interface{}) string
- func RecordRuntimeMetrics(m *MeasurementSet)
- type Aggregator
- type Alert
- type AlertCondition
- type AlertRequest
- type AlertStatus
- type AlertsCommunicator
- type AlertsListResponse
- type AlertsService
- func (as *AlertsService) AssociateToService(alertId, serviceId int) error
- func (as *AlertsService) Create(a *AlertRequest) (*Alert, error)
- func (as *AlertsService) Delete(id int) error
- func (as *AlertsService) DisassociateFromService(alertId, serviceId int) error
- func (as *AlertsService) List() (*AlertsListResponse, error)
- func (as *AlertsService) Retrieve(id int) (*Alert, error)
- func (as *AlertsService) Status(id int) (*AlertStatus, error)
- func (as *AlertsService) Update(a *AlertRequest) error
- type AnnotationEvent
- type AnnotationLink
- type AnnotationStream
- type AnnotationsCommunicator
- type AnnotationsService
- func (as *AnnotationsService) Create(event *AnnotationEvent, streamName string) (*AnnotationEvent, error)
- func (as *AnnotationsService) Delete(streamName string) error
- func (as *AnnotationsService) List(streamNameSearch *string) (*ListAnnotationsResponse, error)
- func (as *AnnotationsService) Retrieve(retReq *RetrieveAnnotationsRequest) (*AnnotationStream, error)
- func (as *AnnotationsService) RetrieveEvent(streamName string, id int) (*AnnotationEvent, error)
- func (as *AnnotationsService) UpdateEvent(streamName string, id int, link *AnnotationLink) (*AnnotationLink, error)
- func (as *AnnotationsService) UpdateStream(streamName, displayName string) error
- type ApiToken
- type ApiTokensCommunicator
- type ApiTokensResponse
- type ApiTokensService
- func (ts *ApiTokensService) Create(at *ApiToken) (*ApiToken, error)
- func (ts *ApiTokensService) Delete(id int) error
- func (ts *ApiTokensService) List() (*ApiTokensResponse, error)
- func (ts *ApiTokensService) Retrieve(name string) (*ApiTokensResponse, error)
- func (ts *ApiTokensService) Update(at *ApiToken) (*ApiToken, error)
- type BatchPersister
- func (bp *BatchPersister) BatchAndPersistMeasurementsForever()
- func (bp *BatchPersister) MaximumPushInterval() int
- func (bp *BatchPersister) MeasurementsErrorChannel() chan<- error
- func (bp *BatchPersister) MeasurementsSink() chan<- []Measurement
- func (bp *BatchPersister) MeasurementsStopBatchingChannel() chan<- struct{}
- func (bp *BatchPersister) SetMaximumPushInterval(ms int)
- type Chart
- type ChartsCommunicator
- type ChartsService
- func (cs *ChartsService) Create(chart *Chart, spaceId int) (*Chart, error)
- func (cs *ChartsService) Delete(chartId, spaceId int) error
- func (cs *ChartsService) List(spaceId int) ([]*Chart, error)
- func (cs *ChartsService) Retrieve(chartId, spaceId int) (*Chart, error)
- func (cs *ChartsService) Update(existingChart *Chart, spaceId int) (*Chart, error)
- type Client
- func (c *Client) AlertsService() AlertsCommunicator
- func (c *Client) AnnotationsService() AnnotationsCommunicator
- func (c *Client) ApiTokensService() ApiTokensCommunicator
- func (c *Client) ChartsService() ChartsCommunicator
- func (c *Client) DefaultPaginationParameters(length int) *PaginationParameters
- func (c *Client) Do(req *http.Request, respData interface{}) (*http.Response, error)
- func (c *Client) JobsService() JobsCommunicator
- func (c *Client) MeasurementsService() MeasurementsCommunicator
- func (c *Client) MetricsService() MetricsCommunicator
- func (c *Client) NewRequest(method, path string, body interface{}) (*http.Request, error)
- func (c *Client) ServicesService() ServicesCommunicator
- func (c *Client) SnapshotsService() SnapshotsCommunicator
- func (c *Client) SpacesService() SpacesCommunicator
- type ClientOption
- type ErrorResponse
- type Job
- type JobsCommunicator
- type JobsService
- type LegacyClient
- type ListAnnotationsResponse
- type ListServicesResponse
- type ListSpacesResponse
- type Measurement
- type MeasurementSet
- func (s *MeasurementSet) Add(key string, delta int64)
- func (s *MeasurementSet) AddInt(key string, delta int)
- func (s *MeasurementSet) GetAggregator(key string) *SynchronizedAggregator
- func (s *MeasurementSet) GetCounter(key string) *SynchronizedCounter
- func (s *MeasurementSet) Incr(key string)
- func (s *MeasurementSet) Merge(report *MeasurementSetReport)
- func (s *MeasurementSet) Reset() *MeasurementSetReport
- func (s *MeasurementSet) UpdateAggregator(key string, other Aggregator)
- func (s *MeasurementSet) UpdateAggregatorValue(key string, val float64)
- type MeasurementSetReport
- type MeasurementsBatch
- type MeasurementsCommunicator
- type MeasurementsService
- type Metric
- type MetricAttributes
- type MetricUpdatePayload
- type MetricsCommunicator
- type MetricsResponse
- type MetricsService
- func (ms *MetricsService) Create(m *Metric) (*Metric, error)
- func (ms *MetricsService) Delete(name string) error
- func (ms *MetricsService) List() (*MetricsResponse, error)
- func (ms *MetricsService) Retrieve(name string) (*Metric, error)
- func (ms *MetricsService) Update(originalName string, m *Metric) error
- type MockMeasurementsService
- type MultiReporter
- type PaginationParameters
- type QueryInfo
- type Reporter
- type RetrieveAnnotationsRequest
- type RetrieveSpaceResponse
- type Service
- type ServiceAccessor
- type ServicesCommunicator
- type ServicesService
- type SimpleClient
- type Snapshot
- type SnapshotChart
- type SnapshotsCommunicator
- type SnapshotsService
- type Space
- type SpacesCommunicator
- type SpacesService
- func (s *SpacesService) Create(name string) (*Space, error)
- func (s *SpacesService) Delete(id int) error
- func (s *SpacesService) List(rp *PaginationParameters) ([]*Space, error)
- func (s *SpacesService) Retrieve(id int) (*RetrieveSpaceResponse, error)
- func (s *SpacesService) Update(id int, name string) error
- type Stream
- type SynchronizedAggregator
- type SynchronizedCounter
- type Tag
- type TaggedMeasurementSet
- func (s *TaggedMeasurementSet) Add(key string, delta int64)
- func (s *TaggedMeasurementSet) AddInt(key string, delta int)
- func (s *TaggedMeasurementSet) GetAggregator(key string) *SynchronizedAggregator
- func (s *TaggedMeasurementSet) GetCounter(key string) *SynchronizedCounter
- func (s *TaggedMeasurementSet) Incr(key string)
- func (s *TaggedMeasurementSet) Merge(report *MeasurementSetReport)
- func (s *TaggedMeasurementSet) SetTags(tags map[string]interface{})
- func (s *TaggedMeasurementSet) Tags() map[string]interface{}
- func (s *TaggedMeasurementSet) UpdateAggregator(key string, other Aggregator)
- func (s *TaggedMeasurementSet) UpdateAggregatorValue(key string, val float64)
- type Threshold
Constants ¶
const ( // MeasurementPostMaxBatchSize defines the max number of Measurements to send to the API at once MeasurementPostMaxBatchSize = 1000 // DefaultPersistenceErrorLimit sets the number of errors that will be allowed before persistence shuts down DefaultPersistenceErrorLimit = 5 )
const (
// AggregationKey is the key in the Measurement attributes used to tell the AppOptics system to aggregate values
AggregationKey = "aggregate"
)
const MetricTagSeparator = "\x00"
MetricTagSeparator is used by MetricWithTags as a separator when serializing the metric name and tags as a key for aggregation with measurements matching the same metric name and tags.
Users can build these strings internally if desired, using a format like below, substituting MetricTagSeparator for the "|" pipes: - "metric_name" - "metric_name|tag_1_key|tag_1_value" - "metric_name|tag_1_key|tag_1_value|tag_2_key|tag_2_value" ...
Variables ¶
var (
DefaultSink = NewMeasurementSet()
)
DefaultSink is a convenience instance of MeasurementSet that can be used to centrally aggregate measurements for an entire process.
var ( // ErrBadStatus is returned if the AppOptics API returns a non-200 error code. ErrBadStatus = errors.New("Received non-OK status from AppOptics POST") )
Functions ¶
func ContextWithMeasurementSet ¶
ContextWithMeasurementSet wraps the specified context with a MeasurementSet. XXX TODO: add convenience methods to read that MeasurementSet and manipulate Counters/Aggregators on it.
func MetricWithTags ¶
func RecordRuntimeMetrics ¶
func RecordRuntimeMetrics(m *MeasurementSet)
Types ¶
type Aggregator ¶
An Aggregator uses the "summary fields" measurement feature in AppOptics to aggregate multiple values into a single measurement, storing a count/sum/min/max/last that can be periodically sent as a single aggregate measurement. It can be either updated by passing sequential values to UpdateValue or by passing an Aggregator to Update, e.g. s.Update(Aggregator{Sum:100,Count:10,Min:5,Max:15})
func (*Aggregator) Update ¶
func (g *Aggregator) Update(other Aggregator)
Update merges another Aggregator into this Aggregator, merging sum/count/min/max/last accordingly. It can be used to facilitate efficient input of many data points into an Aggregator in one call, and it can also be used to merge two different Aggregators (for example, workers can each maintain their own and periodically merge them).
func (*Aggregator) UpdateValue ¶
func (g *Aggregator) UpdateValue(val float64)
UpdateValue sets the most recently observed value for this Aggregator, updating sum/count/min/max/last accordingly.
type Alert ¶
type Alert struct { ID int `json:"id,omitempty"` Name string `json:"name,omitempty"` Description string `json:"description,omitempty"` Active *bool `json:"active,omitempty"` RearmSeconds int `json:"rearm_seconds,omitempty"` Conditions []*AlertCondition `json:"conditions,omitempty"` Attributes map[string]interface{} `json:"attributes,omitempty"` Services []*Service `json:"services,omitempty"` CreatedAt int `json:"created_at,omitempty"` UpdatedAt int `json:"updated_at,omitempty"` }
Alert defines a policy for sending alarms to services when conditions are met
type AlertCondition ¶
type AlertCondition struct { ID int `json:"id,omitempty"` Type string `json:"type,omitempty"` MetricName string `json:"metric_name,omitempty"` Threshold float64 `json:"threshold"` SummaryFunction string `json:"summary_function,omitempty"` Duration int `json:"duration,omitempty"` DetectReset bool `json:"detect_reset,omitempty"` Tags []*Tag `json:"tags,omitempty"` }
type AlertRequest ¶
type AlertRequest struct { ID int `json:"id,omitempty"` Name string `json:"name,omitempty"` Description string `json:"description,omitempty"` Active *bool `json:"active,omitempty"` RearmSeconds int `json:"rearm_seconds,omitempty"` Conditions []*AlertCondition `json:"conditions,omitempty"` Attributes map[string]interface{} `json:"attributes,omitempty"` Services []int `json:"services,omitempty"` // correspond to IDs of Service objects CreatedAt int `json:"created_at,omitempty"` UpdatedAt int `json:"updated_at,omitempty"` }
AlertRequest is identical to Alert except for the fact that Services is a []int in AlertRequest
type AlertStatus ¶
type AlertsCommunicator ¶
type AlertsCommunicator interface { List() (*AlertsListResponse, error) Retrieve(int) (*Alert, error) Create(*AlertRequest) (*Alert, error) Update(*AlertRequest) error AssociateToService(int, int) error DisassociateFromService(alertId, serviceId int) error Delete(int) error Status(int) (*AlertStatus, error) }
type AlertsListResponse ¶
type AlertsService ¶
type AlertsService struct {
// contains filtered or unexported fields
}
func NewAlertsService ¶
func NewAlertsService(c *Client) *AlertsService
func (*AlertsService) AssociateToService ¶
func (as *AlertsService) AssociateToService(alertId, serviceId int) error
AssociateToService updates the Alert to allow assign it to the Service identified
func (*AlertsService) Create ¶
func (as *AlertsService) Create(a *AlertRequest) (*Alert, error)
Create creates the Alert
func (*AlertsService) Delete ¶
func (as *AlertsService) Delete(id int) error
Delete deletes the Alert
func (*AlertsService) DisassociateFromService ¶
func (as *AlertsService) DisassociateFromService(alertId, serviceId int) error
DisassociateFromService updates the Alert to remove the Service identified
func (*AlertsService) List ¶
func (as *AlertsService) List() (*AlertsListResponse, error)
List retrieves all Alerts
func (*AlertsService) Retrieve ¶
func (as *AlertsService) Retrieve(id int) (*Alert, error)
Retrieve returns the Alert identified by the parameter
func (*AlertsService) Status ¶
func (as *AlertsService) Status(id int) (*AlertStatus, error)
Status returns the Alert's status
func (*AlertsService) Update ¶
func (as *AlertsService) Update(a *AlertRequest) error
Update updates the Alert
type AnnotationEvent ¶
type AnnotationEvent struct { ID int `json:"id"` Title string `json:"title"` Source string `json:"source,omitempty"` Description string `json:"description,omitempty"` Links []AnnotationLink `json:"links,omitempty"` StartTime int64 `json:"start_time,omitempty"` EndTime int64 `json:"end_time,omitempty"` }
AnnotationEvent is the main data structure for the Annotations API
type AnnotationLink ¶
type AnnotationLink struct { Rel string `json:"rel"` Href string `json:"href"` Label string `json:"label,omitempty"` }
AnnotationLink represents the Link metadata for on the AnnotationEvent
type AnnotationStream ¶
type AnnotationStream struct { Name string `json:"name"` DisplayName string `json:"display_name,omitempty"` Events []map[string][]AnnotationEvent `json:"events,omitempty"` // keys are Source names }
AnnotationStream is a group of AnnotationEvents with a common name, representing a timeseries of occurrences of similar events
type AnnotationsCommunicator ¶
type AnnotationsCommunicator interface { List(*string) (*ListAnnotationsResponse, error) Retrieve(*RetrieveAnnotationsRequest) (*AnnotationStream, error) RetrieveEvent(string, int) (*AnnotationEvent, error) Create(*AnnotationEvent, string) (*AnnotationEvent, error) UpdateStream(string, string) error UpdateEvent(string, int, *AnnotationLink) (*AnnotationLink, error) Delete(string) error }
AnnotationsCommunicator provides an interface to the Annotations API from AppOptics
type AnnotationsService ¶
type AnnotationsService struct {
// contains filtered or unexported fields
}
func NewAnnotationsService ¶
func NewAnnotationsService(c *Client) *AnnotationsService
func (*AnnotationsService) Create ¶
func (as *AnnotationsService) Create(event *AnnotationEvent, streamName string) (*AnnotationEvent, error)
Create makes an AnnotationEvent on the stream with the given name
func (*AnnotationsService) Delete ¶
func (as *AnnotationsService) Delete(streamName string) error
Delete deletes the annotation stream matching the provided name
func (*AnnotationsService) List ¶
func (as *AnnotationsService) List(streamNameSearch *string) (*ListAnnotationsResponse, error)
List retrieves paginated AnnotationEvents for all streams with name LIKE argument string
func (*AnnotationsService) Retrieve ¶
func (as *AnnotationsService) Retrieve(retReq *RetrieveAnnotationsRequest) (*AnnotationStream, error)
Retrieve fetches all AnnotationEvents matching the provided sources
func (*AnnotationsService) RetrieveEvent ¶
func (as *AnnotationsService) RetrieveEvent(streamName string, id int) (*AnnotationEvent, error)
RetrieveEvent returns a single event identified by an integer ID from a given stream
func (*AnnotationsService) UpdateEvent ¶
func (as *AnnotationsService) UpdateEvent(streamName string, id int, link *AnnotationLink) (*AnnotationLink, error)
UpdateEvent adds a link to an annotation Event
func (*AnnotationsService) UpdateStream ¶
func (as *AnnotationsService) UpdateStream(streamName, displayName string) error
UpdateStream updates the display name of the stream
type ApiTokensCommunicator ¶
type ApiTokensResponse ¶
type ApiTokensService ¶
type ApiTokensService struct {
// contains filtered or unexported fields
}
func NewApiTokensService ¶
func NewApiTokensService(c *Client) *ApiTokensService
func (*ApiTokensService) Create ¶
func (ts *ApiTokensService) Create(at *ApiToken) (*ApiToken, error)
Create creates the ApiToken
func (*ApiTokensService) Delete ¶
func (ts *ApiTokensService) Delete(id int) error
Delete deletes the ApiToken
func (*ApiTokensService) List ¶
func (ts *ApiTokensService) List() (*ApiTokensResponse, error)
List retrieves all ApiTokens
func (*ApiTokensService) Retrieve ¶
func (ts *ApiTokensService) Retrieve(name string) (*ApiTokensResponse, error)
Retrieve returns the ApiToken identified by the parameter
type BatchPersister ¶
type BatchPersister struct {
// contains filtered or unexported fields
}
BatchPersister implements persistence to AppOptics and enforces error limits
func NewBatchPersister ¶
func NewBatchPersister(mc MeasurementsCommunicator, sendStats bool) *BatchPersister
NewBatchPersister sets up a new instance of batched persistence capabilities using the provided MeasurementsCommunicator
func (*BatchPersister) BatchAndPersistMeasurementsForever ¶
func (bp *BatchPersister) BatchAndPersistMeasurementsForever()
BatchAndPersistMeasurementsForever continually packages up Measurements from the channel returned by MeasurementSink() and persists them to AppOptics.
func (*BatchPersister) MaximumPushInterval ¶
func (bp *BatchPersister) MaximumPushInterval() int
MaxiumumPushIntervalMilliseconds returns the number of milliseconds the system will wait before pushing any accumulated Measurements to AppOptics
func (*BatchPersister) MeasurementsErrorChannel ¶
func (bp *BatchPersister) MeasurementsErrorChannel() chan<- error
MeasurementsErrorChannel gives calling code write-only access to the Measurements error channel
func (*BatchPersister) MeasurementsSink ¶
func (bp *BatchPersister) MeasurementsSink() chan<- []Measurement
MeasurementsSink gives calling code write-only access to the Measurements prep channel
func (*BatchPersister) MeasurementsStopBatchingChannel ¶
func (bp *BatchPersister) MeasurementsStopBatchingChannel() chan<- struct{}
MeasurementsStopBatchingChannel gives calling code write-only access to the Measurements batching control channel
func (*BatchPersister) SetMaximumPushInterval ¶
func (bp *BatchPersister) SetMaximumPushInterval(ms int)
SetMaximumPushInterval sets the number of milliseconds the system will wait before pushing any accumulated Measurements to AppOptics
type Chart ¶
type Chart struct { ID int `json:"id,omitempty"` Name string `json:"name,omitempty"` Type string `json:"type,omitempty"` Streams []Stream `json:"streams,omitempty"` Min float64 `json:"min,omitempty"` Max float64 `json:"max,omitempty"` Label string `json:"label,omitempty"` RelatedSpace int `json:"related_space,omitempty"` Thresholds []Threshold `json:"threshold,omitempty"` }
type ChartsCommunicator ¶
type ChartsService ¶
type ChartsService struct {
// contains filtered or unexported fields
}
func NewChartsService ¶
func NewChartsService(c *Client) *ChartsService
func (*ChartsService) Create ¶
func (cs *ChartsService) Create(chart *Chart, spaceId int) (*Chart, error)
Create creates the Chart in the Space
func (*ChartsService) Delete ¶
func (cs *ChartsService) Delete(chartId, spaceId int) error
Delete deletes the Chart from the Space
func (*ChartsService) List ¶
func (cs *ChartsService) List(spaceId int) ([]*Chart, error)
List retrieves the Charts for the provided Space ID
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client implements ServiceAccessor
func NewClient ¶
NewClient returns a new AppOptics API client. Optional arguments UserAgentClientOption and BaseURLClientOption can be provided.
func (*Client) AlertsService ¶
func (c *Client) AlertsService() AlertsCommunicator
AlertsService represents the subset of the API that deals with Alerts
func (*Client) AnnotationsService ¶
func (c *Client) AnnotationsService() AnnotationsCommunicator
AnnotationsService represents the subset of the API that deals with Annotations
func (*Client) ApiTokensService ¶
func (c *Client) ApiTokensService() ApiTokensCommunicator
func (*Client) ChartsService ¶
func (c *Client) ChartsService() ChartsCommunicator
ChartsService represents the subset of the API that deals with Charts
func (*Client) DefaultPaginationParameters ¶
func (c *Client) DefaultPaginationParameters(length int) *PaginationParameters
DefaultPaginationParameters provides a *PaginationParameters with minimum required fields
func (*Client) Do ¶
Do performs the HTTP request on the wire, taking an optional second parameter for containing a response
func (*Client) JobsService ¶
func (c *Client) JobsService() JobsCommunicator
JobsService represents the subset of the API that deals with Jobs
func (*Client) MeasurementsService ¶
func (c *Client) MeasurementsService() MeasurementsCommunicator
MeasurementsService represents the subset of the API that deals with Measurements
func (*Client) MetricsService ¶
func (c *Client) MetricsService() MetricsCommunicator
MetricsService represents the subset of the API that deals with Metrics
func (*Client) NewRequest ¶
NewRequest standardizes the request being sent
func (*Client) ServicesService ¶
func (c *Client) ServicesService() ServicesCommunicator
ServicesService represents the subset of the API that deals with Services
func (*Client) SnapshotsService ¶
func (c *Client) SnapshotsService() SnapshotsCommunicator
SnapshotsService represents the subset of the API that deals with Snapshots
func (*Client) SpacesService ¶
func (c *Client) SpacesService() SpacesCommunicator
SpacesService represents the subset of the API that deals with Spaces
type ClientOption ¶
ClientOption provides functional option-setting behavior
func BaseURLClientOption ¶
func BaseURLClientOption(urlString string) ClientOption
BaseURLClientOption is a config function allowing setting of the base URL the API is on
func SetDebugMode ¶
func SetDebugMode() ClientOption
SetDebugMode sets the debugMode struct member to true
func SetHTTPClient ¶
func SetHTTPClient(client *http.Client) ClientOption
SetHTTPClient allows the user to provide a custom http.Client configuration
func UserAgentClientOption ¶
func UserAgentClientOption(userAgentString string) ClientOption
UserAgentClientOption is a config function allowing setting of the User-Agent header in requests
type ErrorResponse ¶
type ErrorResponse struct { Errors interface{} `json:"errors"` Status string `json:"status"` Response *http.Response }
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 httpClient
type Job ¶
type Job struct { ID int `json:"id"` State string `json:"state"` Progress float64 `json:"progress,omitempty"` Output string `json:"output,omitempty"` Errors map[string][]string `json:"errors,omitempty"` }
Job is the representation of a task happening in the AppOptics cloud
type JobsCommunicator ¶
type JobsService ¶
type JobsService struct {
// contains filtered or unexported fields
}
func NewJobsService ¶
func NewJobsService(c *Client) *JobsService
type LegacyClient ¶
type LegacyClient interface {
Post(batch *MeasurementsBatch) error
}
func NewLegacyClient ¶
func NewLegacyClient(url, token string) LegacyClient
type ListAnnotationsResponse ¶
type ListAnnotationsResponse struct { AnnotationStreams []*AnnotationStream `json:"annotations"` Query QueryInfo `json:"query"` }
type ListServicesResponse ¶
type ListSpacesResponse ¶
type ListSpacesResponse struct { Query map[string]int `json:"query"` Spaces []*Space `json:"spaces"` }
ListSpacesResponse represents the returned data payload from Spaces API's List command (/spaces)
type Measurement ¶
type Measurement struct { Name string `json:"name"` Tags map[string]string `json:"tags,omitempty"` Value interface{} `json:"value,omitempty"` Time int64 `json:"time,omitempty"` Count interface{} `json:"count,omitempty"` Sum interface{} `json:"sum,omitempty"` Min interface{} `json:"min,omitempty"` Max interface{} `json:"max,omitempty"` Last interface{} `json:"last,omitempty"` Attributes map[string]interface{} `json:"attributes,omitempty"` }
Measurement wraps the corresponding API construct: https://docs.appoptics.com/api/#measurements Each Measurement represents a single timeseries value for an associated Metric. If AppOptics receives a Measurement with a Name field that doesn't correspond to an existing Metric, a new Metric will be created.
func NewMeasurement ¶
func NewMeasurement(name string) Measurement
NewMeasurement returns a Measurement with the given name and an empty attributes map
type MeasurementSet ¶
type MeasurementSet struct {
// contains filtered or unexported fields
}
MeasurementSet represents a map of SynchronizedCounters and SynchronizedAggregators. All functions of MeasurementSet are safe for concurrent use.
func NewMeasurementSet ¶
func NewMeasurementSet() *MeasurementSet
NewMeasurementSet returns a new empty MeasurementSet
func (*MeasurementSet) Add ¶
func (s *MeasurementSet) Add(key string, delta int64)
Add is a convenience function to get the specified Counter and call Add on it. See Counter.Add.
func (*MeasurementSet) AddInt ¶
func (s *MeasurementSet) AddInt(key string, delta int)
AddInt is a convenience function to get the specified Counter and call AddInt on it. See Counter.AddInt.
func (*MeasurementSet) GetAggregator ¶
func (s *MeasurementSet) GetAggregator(key string) *SynchronizedAggregator
GetAggregator returns a SynchronizedAggregator assigned to the specified key, creating a new one if necessary.
func (*MeasurementSet) GetCounter ¶
func (s *MeasurementSet) GetCounter(key string) *SynchronizedCounter
GetCounter returns a SynchronizedCounter assigned to the specified key, creating a new one if necessary.
func (*MeasurementSet) Incr ¶
func (s *MeasurementSet) Incr(key string)
Incr is a convenience function to get the specified Counter and call Incr on it. See Counter.Incr.
func (*MeasurementSet) Merge ¶
func (s *MeasurementSet) Merge(report *MeasurementSetReport)
Merge takes a MeasurementSetReport and merges all of it Counters and Aggregators into this MeasurementSet. This in turn calls Counter.Add for each Counter in the report, and Aggregator.Update for each Aggregator in the report. Any keys that do not exist in this MeasurementSet will be created.
func (*MeasurementSet) Reset ¶
func (s *MeasurementSet) Reset() *MeasurementSetReport
Reset generates a MeasurementSetReport with a copy of the state of each of the non-zero Counters and Aggregators in this MeasurementSet. Counters with a value of 0 and Aggregators with a count of 0 are omitted. All Counters and Aggregators are reset to the zero/nil state but are never removed from this MeasurementSet, so they can continue be used indefinitely.
func (*MeasurementSet) UpdateAggregator ¶
func (s *MeasurementSet) UpdateAggregator(key string, other Aggregator)
UpdateAggregator is a convenience to get the specified Aggregator and call Update on it. See Aggregator.Update.
func (*MeasurementSet) UpdateAggregatorValue ¶
func (s *MeasurementSet) UpdateAggregatorValue(key string, val float64)
UpdateAggregatorValue is a convenience to get the specified Aggregator and call UpdateValue on it. See Aggregator.UpdateValue.
type MeasurementSetReport ¶
type MeasurementSetReport struct { Counts map[string]int64 Aggregators map[string]Aggregator }
func NewMeasurementSetReport ¶
func NewMeasurementSetReport() *MeasurementSetReport
type MeasurementsBatch ¶
type MeasurementsBatch struct { // Measurements is the collection of timeseries entries being sent to the server Measurements []Measurement `json:"measurements,omitempty"` // Period is a slice of time measured in seconds, used in service-side aggregation Period int64 `json:"period,omitempty"` // Time is a Unix epoch timestamp used to align a group of Measurements on a time boundary Time int64 `json:"time"` // Tags are key-value identifiers that will be applied to all Measurements in the batch Tags *map[string]string `json:"tags,omitempty"` }
MeasurementsBatch is a collection of Measurements persisted to the API at the same time. It can optionally have tags that are applied to all contained Measurements.
func NewMeasurementsBatch ¶
func NewMeasurementsBatch(m []Measurement, tags *map[string]string) *MeasurementsBatch
type MeasurementsCommunicator ¶
type MeasurementsCommunicator interface {
Create(*MeasurementsBatch) (*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 NewMeasurementsService ¶
func NewMeasurementsService(c *Client) *MeasurementsService
func (*MeasurementsService) Create ¶
func (ms *MeasurementsService) Create(batch *MeasurementsBatch) (*http.Response, error)
Create persists the given MeasurementCollection to AppOptics
type Metric ¶
type Metric struct { Name string `json:"name"` Description string `json:"description,omitempty"` Type string `json:"type"` Period int `json:"period,omitempty"` DisplayName string `json:"display_name,omitempty"` Composite string `json:"composite,omitempty"` Attributes MetricAttributes `json:"attributes,omitempty"` }
Metric is an AppOptics Metric
type MetricAttributes ¶
type MetricAttributes struct { Color string `json:"color,omitempty"` DisplayMax interface{} `json:"display_max,omitempty"` DisplayMin interface{} `json:"display_min,omitempty"` DisplayUnitsLong string `json:"display_units_long,omitempty"` DisplayUnitsShort string `json:"display_units_short,omitempty"` DisplayStacked bool `json:"display_stacked,omitempty"` CreatedByUA string `json:"created_by_ua,omitempty"` GapDetection bool `json:"gap_detection,omitempty"` Aggregate bool `json:"aggregate,omitempty"` SummarizeFunction string `json:"summarize_function,omitempty"` }
MetricAttributes are key/value pairs of metadata about the Metric
type MetricUpdatePayload ¶
type MetricUpdatePayload struct { Names []string `json:"names"` Attributes MetricAttributes `json:"attributes"` }
MetricUpdatePayload will apply the state represented by Attributes to the Metrics identified by Names
type MetricsCommunicator ¶
type MetricsResponse ¶
type MetricsService ¶
type MetricsService struct {
// contains filtered or unexported fields
}
func NewMetricsService ¶
func NewMetricsService(c *Client) *MetricsService
func (*MetricsService) Create ¶
func (ms *MetricsService) Create(m *Metric) (*Metric, error)
Create creates the Metric in the organization identified by the AppOptics token
func (*MetricsService) Delete ¶
func (ms *MetricsService) Delete(name string) error
Delete deletes the Metric matching the name argument
func (*MetricsService) List ¶
func (ms *MetricsService) List() (*MetricsResponse, error)
List lists the Metrics in the organization identified by the AppOptics token
type MockMeasurementsService ¶
type MockMeasurementsService struct {
OnCreate func(batch *MeasurementsBatch) (*http.Response, error)
}
func (*MockMeasurementsService) Create ¶
func (m *MockMeasurementsService) Create(batch *MeasurementsBatch) (*http.Response, error)
type MultiReporter ¶
type MultiReporter struct {
// contains filtered or unexported fields
}
func NewMultiReporter ¶
func NewMultiReporter(m *MeasurementSet, reporters []*Reporter) *MultiReporter
func (*MultiReporter) Start ¶
func (m *MultiReporter) Start()
type PaginationParameters ¶
PaginationParameters holds pagination values https://docs.appoptics.com/api/?shell#request-parameters
func (*PaginationParameters) AddToRequest ¶
func (rp *PaginationParameters) AddToRequest(req *http.Request)
AddToRequest mutates the provided http.Request with the PaginationParameters values Note that only valid values for Sort are "asc" and "desc" but the client does not enforce this.
type QueryInfo ¶
type QueryInfo struct { Found int `json:"found,omitempty"` Length int `json:"length,omitempty"` Offset int `json:"offset,omitempty"` Total int `json:"total,omitempty"` }
QueryInfo holds pagination information coming from list actions
type Reporter ¶
type Reporter struct {
// contains filtered or unexported fields
}
Reporter provides a way to persist data from a set collection of Aggregators and Counters at a regular interval
func NewReporter ¶
func NewReporter(measurementSet *MeasurementSet, communicator MeasurementsCommunicator, prefix string) *Reporter
NewReporter returns a reporter for a given MeasurementSet, providing a way to sync metric information to AppOptics for a collection of running metrics.
type RetrieveSpaceResponse ¶
RetrieveSpaceResponse represents the returned data payload from Spaces API's Retrieve command (/spaces/:id)
type ServiceAccessor ¶
type ServiceAccessor interface { AlertsService() AlertsCommunicator AnnotationsService() AnnotationsCommunicator ApiTokensService() ApiTokensCommunicator ChartsService() ChartsCommunicator JobsService() JobsCommunicator MeasurementsService() MeasurementsCommunicator MetricsService() MetricsCommunicator ServicesService() ServicesCommunicator SnapshotsService() SnapshotsCommunicator SpacesService() SpacesCommunicator }
ServiceAccessor defines an interface for talking to via domain-specific service constructs
type ServicesCommunicator ¶
type ServicesService ¶
type ServicesService struct {
// contains filtered or unexported fields
}
func NewServiceService ¶
func NewServiceService(c *Client) *ServicesService
func (*ServicesService) Create ¶
func (ss *ServicesService) Create(s *Service) (*Service, error)
Create creates the Service
func (*ServicesService) Delete ¶
func (ss *ServicesService) Delete(id int) error
Delete deletes the Service
func (*ServicesService) List ¶
func (ss *ServicesService) List() (*ListServicesResponse, error)
List retrieves all Services
func (*ServicesService) Retrieve ¶
func (ss *ServicesService) Retrieve(id int) (*Service, error)
Retrieve returns the Service identified by the parameter
func (*ServicesService) Update ¶
func (ss *ServicesService) Update(s *Service) error
Update updates the Service
type SimpleClient ¶
func (*SimpleClient) Post ¶
func (c *SimpleClient) Post(batch *MeasurementsBatch) error
Used for the collector's internal metrics
type Snapshot ¶
type Snapshot struct { Href string `json:"href,omitempty"` JobHref string `json:"job_href,omitempty"` ImageHref string `json:"image_href,omitempty"` Duration int `json:"duration,omitempty"` EndTime time.Time `json:"end_time,omitempty"` CreatedAt time.Time `json:"created_at,omitempty"` UpdatedAt time.Time `json:"updated_at,omitempty"` Subject map[string]SnapshotChart `json:"subject"` }
Snapshot represents a portrait of a Chart at a specific point in time
type SnapshotChart ¶
type SnapshotChart struct { ID int `json:"id"` Sources []string `json:"sources"` Type string `json:"type"` }
SnapshotChart contains the metadata for the chart requested in the Snapshot
type SnapshotsCommunicator ¶
type SnapshotsService ¶
type SnapshotsService struct {
// contains filtered or unexported fields
}
func NewSnapshotsService ¶
func NewSnapshotsService(c *Client) *SnapshotsService
type Space ¶
type Space struct { // ID is the unique identifier of the Space ID int `json:"id,omitempty"` // Name is the name of the Space Name string `json:"name,omitempty"` }
Space represents a single AppOptics Space
type SpacesCommunicator ¶
type SpacesCommunicator interface { Create(string) (*Space, error) List(*PaginationParameters) ([]*Space, error) Retrieve(int) (*RetrieveSpaceResponse, error) Update(int, string) error Delete(int) error }
SpacesCommunicator defines the interface for the Spaces API
type SpacesService ¶
type SpacesService struct {
// contains filtered or unexported fields
}
func NewSpacesService ¶
func NewSpacesService(c *Client) *SpacesService
func (*SpacesService) Create ¶
func (s *SpacesService) Create(name string) (*Space, error)
Create creates the Space with the given name
func (*SpacesService) Delete ¶
func (s *SpacesService) Delete(id int) error
Delete implements the Spaces API's Delete command
func (*SpacesService) List ¶
func (s *SpacesService) List(rp *PaginationParameters) ([]*Space, error)
List implements the Spaces API's List command
func (*SpacesService) Retrieve ¶
func (s *SpacesService) Retrieve(id int) (*RetrieveSpaceResponse, error)
Retrieve implements the Spaces API's Retrieve command
type Stream ¶
type Stream struct { ID int `json:"id,omitempty"` Name string `json:"name,omitempty"` Metric string `json:"metric,omitempty"` Composite string `json:"composite,omitempty"` Type string `json:"type,omitempty"` Tags []Tag `json:"tags,omitempty"` GroupFunction string `json:"group_function,omitempty"` // valid: average, sum, min, max GroupBy string `json:"group_by,omitempty"` SummaryFunction string `json:"summary_function,omitempty"` // valid: average, sum, min, max, count DownsampleFunction string `json:"downsample_function,omitempty"` // valid: average, min, max, sum, count Color string `json:"color,omitempty"` UnitsShort string `json:"units_short,omitempty"` UnitsLong string `json:"units_long,omitempty"` TransformFunction string `json:"transform_function,omitempty"` Period int `json:"period,omitempty"` Min int `json:"min,omitempty"` Max int `json:"max,omitempty"` }
type SynchronizedAggregator ¶
type SynchronizedAggregator struct { Aggregator // contains filtered or unexported fields }
SynchronizedAggregator augments an Aggregator with a mutex to allow concurrent access from multiple goroutines.
func (*SynchronizedAggregator) Reset ¶
func (g *SynchronizedAggregator) Reset() Aggregator
Reset returns a copy the current Aggregator state and resets it back to its zero state.
func (*SynchronizedAggregator) Update ¶
func (g *SynchronizedAggregator) Update(other Aggregator)
Update is a concurrent-safe wrapper around Aggregator.Update
func (*SynchronizedAggregator) UpdateValue ¶
func (g *SynchronizedAggregator) UpdateValue(val float64)
UpdateValue is a concurrent-safe wrapper around Aggregator.UpdateValue
type SynchronizedCounter ¶
type SynchronizedCounter int64
SynchronizedCounter wraps an int64 with functions to concurrently add/increment and to periodically query & reset the sum.
func NewCounter ¶
func NewCounter() *SynchronizedCounter
NewCounter returns a new SynchronizedCounter initialized to 0.
func (*SynchronizedCounter) Add ¶
func (c *SynchronizedCounter) Add(delta int64)
Add adds the specified delta to the counter.
func (*SynchronizedCounter) AddInt ¶
func (c *SynchronizedCounter) AddInt(delta int)
AddInt is a convenience function to add delta to the counter, where delta is an int.
func (*SynchronizedCounter) Reset ¶
func (c *SynchronizedCounter) Reset() int64
Reset returns the current value and resets the counter to zero
type Tag ¶
type Tag struct { Name string `json:"name,omitempty"` Values []string `json:"values,omitempty"` Grouped bool `json:"grouped,omitempty"` Dynamic bool `json:"dynamic,omitempty"` }
Tag represents an AppOptics Tag, used in Measurements, Charts, etc
type TaggedMeasurementSet ¶
type TaggedMeasurementSet struct { *MeasurementSet // contains filtered or unexported fields }
func (*TaggedMeasurementSet) Add ¶
func (s *TaggedMeasurementSet) Add(key string, delta int64)
Add is a convenience function to get the specified Counter and call Add on it. See Counter.Add.
func (*TaggedMeasurementSet) AddInt ¶
func (s *TaggedMeasurementSet) AddInt(key string, delta int)
AddInt is a convenience function to get the specified Counter and call AddInt on it. See Counter.AddInt.
func (*TaggedMeasurementSet) GetAggregator ¶
func (s *TaggedMeasurementSet) GetAggregator(key string) *SynchronizedAggregator
GetAggregator returns a SynchronizedAggregator assigned to the specified key with tags, creating a new one if necessary.
func (*TaggedMeasurementSet) GetCounter ¶
func (s *TaggedMeasurementSet) GetCounter(key string) *SynchronizedCounter
GetCounter returns a SynchronizedCounter assigned to the specified key with tags, creating a new one if necessary.
func (*TaggedMeasurementSet) Incr ¶
func (s *TaggedMeasurementSet) Incr(key string)
Incr is a convenience function to get the specified Counter and call Incr on it. See Counter.Incr.
func (*TaggedMeasurementSet) Merge ¶
func (s *TaggedMeasurementSet) Merge(report *MeasurementSetReport)
Merge takes a MeasurementSetReport and merges all of it Counters and Aggregators into this MeasurementSet. This in turn calls Counter.Add for each Counter in the report, and Aggregator.Update for each Aggregator in the report. Any keys that do not exist in this MeasurementSet will be created.
func (*TaggedMeasurementSet) SetTags ¶
func (s *TaggedMeasurementSet) SetTags(tags map[string]interface{})
SetTags sets the value of the tags map
func (*TaggedMeasurementSet) Tags ¶
func (s *TaggedMeasurementSet) Tags() map[string]interface{}
Tags returns the tags map
func (*TaggedMeasurementSet) UpdateAggregator ¶
func (s *TaggedMeasurementSet) UpdateAggregator(key string, other Aggregator)
UpdateAggregator is a convenience to get the specified Aggregator and call Update on it. See Aggregator.Update.
func (*TaggedMeasurementSet) UpdateAggregatorValue ¶
func (s *TaggedMeasurementSet) UpdateAggregatorValue(key string, val float64)
UpdateAggregatorValue is a convenience to get the specified Aggregator and call UpdateValue on it. See Aggregator.UpdateValue.
Source Files
¶
- aggregator.go
- alerts.go
- annotations.go
- api_token.go
- charts.go
- client.go
- counter.go
- errors.go
- jobs.go
- legacy_client.go
- measurement_set.go
- measurement_set_report.go
- measurements.go
- measurements_batching.go
- metrics.go
- mock_measurements_service.go
- multi_reporter.go
- reporter.go
- request_parameters.go
- runtime.go
- services.go
- snapshots.go
- spaces.go
- tagged_measurement_set.go
- tags.go