Documentation
¶
Overview ¶
Package mockdatadog provides an in-process Datadog API mock for testing.
Index ¶
- func NewClient(ts *httptest.Server) *datadog.Client
- func Usage(addr string) string
- type Dataset
- type MonitorBuilder
- type MonitorEventRecord
- type SLOBuilder
- func (b *SLOBuilder) AsViolated() *SLOBuilder
- func (b *SLOBuilder) Build() (datadog.SLOData, SLOHistoryRecord)
- func (b *SLOBuilder) WithBudget(bud float64) *SLOBuilder
- func (b *SLOBuilder) WithCurrent(c float64) *SLOBuilder
- func (b *SLOBuilder) WithTarget(t float64) *SLOBuilder
- func (b *SLOBuilder) WithType(t string) *SLOBuilder
- type SLOEventRecord
- type SLOHistoryRecord
- type Server
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Dataset ¶
type Dataset struct {
Monitors []datadog.Monitor
MonitorEvents []MonitorEventRecord
SLOs []datadog.SLOData
SLOHistory map[string]SLOHistoryRecord // keyed by SLO ID
SLOEvents []SLOEventRecord
}
Dataset holds all mock Datadog data served by the Server.
func LoadFromSLOCSV ¶
LoadFromSLOCSV loads SLO data from the --save-raw-data CSV format. CSV format: slo_id,app,name,type,target,current,budget,violated,event_count
func RealisticDataset ¶
func RealisticDataset() *Dataset
RealisticDataset returns a richer dataset with ~10 monitors and ~20 SLOs anchored to the current time.
func SmallDataset ¶
func SmallDataset() *Dataset
SmallDataset returns a small deterministic dataset with a handful of monitors and SLOs anchored to the current time so events fall within any recent default date range.
type MonitorBuilder ¶
type MonitorBuilder struct {
// contains filtered or unexported fields
}
MonitorBuilder provides a fluent API for constructing test monitors.
func NewMonitor ¶
func NewMonitor(id int64, name string) *MonitorBuilder
NewMonitor starts building a new monitor.
func (*MonitorBuilder) AsAlerted ¶
func (b *MonitorBuilder) AsAlerted() *MonitorBuilder
func (*MonitorBuilder) Build ¶
func (b *MonitorBuilder) Build() datadog.Monitor
Build returns the constructed datadog.Monitor.
func (*MonitorBuilder) WithState ¶
func (b *MonitorBuilder) WithState(s string) *MonitorBuilder
func (*MonitorBuilder) WithTags ¶
func (b *MonitorBuilder) WithTags(tags ...string) *MonitorBuilder
func (*MonitorBuilder) WithType ¶
func (b *MonitorBuilder) WithType(t string) *MonitorBuilder
type MonitorEventRecord ¶
type MonitorEventRecord struct {
ID string
MonitorID int64
Title string
Status string
Timestamp time.Time
Tags []string
}
MonitorEventRecord is the server-side representation of a monitor alert event.
type SLOBuilder ¶
type SLOBuilder struct {
// contains filtered or unexported fields
}
SLOBuilder provides a fluent API for constructing test SLOs.
func (*SLOBuilder) AsViolated ¶
func (b *SLOBuilder) AsViolated() *SLOBuilder
AsViolated marks the SLO as below its target.
func (*SLOBuilder) Build ¶
func (b *SLOBuilder) Build() (datadog.SLOData, SLOHistoryRecord)
Build returns the SLOData and SLOHistoryRecord for the Dataset.
func (*SLOBuilder) WithBudget ¶
func (b *SLOBuilder) WithBudget(bud float64) *SLOBuilder
func (*SLOBuilder) WithCurrent ¶
func (b *SLOBuilder) WithCurrent(c float64) *SLOBuilder
func (*SLOBuilder) WithTarget ¶
func (b *SLOBuilder) WithTarget(t float64) *SLOBuilder
func (*SLOBuilder) WithType ¶
func (b *SLOBuilder) WithType(t string) *SLOBuilder
type SLOEventRecord ¶
type SLOEventRecord struct {
ID string
SLOID string
Title string
Timestamp time.Time
Tags []string
}
SLOEventRecord is the server-side representation of an SLO violation event.
type SLOHistoryRecord ¶
SLOHistoryRecord stores SLI/budget values for a single SLO.
type Server ¶
type Server struct {
Dataset *Dataset
// contains filtered or unexported fields
}
Server is a mock Datadog API server backed by a Dataset.
func (*Server) ListenAndServe ¶
ListenAndServe starts the server on the given address (e.g., ":8083").