Documentation
¶
Index ¶
- type API
- type Config
- type LogWrapper
- type Logger
- type TrapCheck
- func (tc *TrapCheck) GetBrokerTLSConfig() (*tls.Config, error)
- func (tc *TrapCheck) GetCheckBundle() (apiclient.CheckBundle, error)
- func (tc *TrapCheck) IsNewCheckBundle() bool
- func (tc *TrapCheck) RefreshCheckBundle() (apiclient.CheckBundle, error)
- func (tc *TrapCheck) SendMetrics(ctx context.Context, metrics bytes.Buffer) (*TrapResult, error)
- func (tc *TrapCheck) TraceMetrics(trace string) (string, error)
- func (tc *TrapCheck) UpdateCheckTags(_ context.Context, tags []string) (*apiclient.CheckBundle, error)
- type TrapResult
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type API ¶
type API interface { // generic methods Get(requrl string) ([]byte, error) // broker methods FetchBroker(cid apiclient.CIDType) (*apiclient.Broker, error) FetchBrokers() (*[]apiclient.Broker, error) SearchBrokers(searchCriteria *apiclient.SearchQueryType, filterCriteria *apiclient.SearchFilterType) (*[]apiclient.Broker, error) // check bundle methods FetchCheckBundle(cid apiclient.CIDType) (*apiclient.CheckBundle, error) CreateCheckBundle(cfg *apiclient.CheckBundle) (*apiclient.CheckBundle, error) SearchCheckBundles(searchCriteria *apiclient.SearchQueryType, filterCriteria *apiclient.SearchFilterType) (*[]apiclient.CheckBundle, error) UpdateCheckBundle(cfg *apiclient.CheckBundle) (*apiclient.CheckBundle, error) }
type Config ¶
type Config struct { // Client is a valid circonus go-apiclient instance Client API // CheckConfig is a valid circonus go-apiclient.CheckBundle configuration // or nil for defaults CheckConfig *apiclient.CheckBundle // SubmitTLSConfig is a *tls.Config to use when submitting to the broker SubmitTLSConfig *tls.Config // Logger interface for logging Logger Logger // SubmissionURL explicit submission url (e.g. submitting to an agent, if tls used a SubmitTLSConfig is required) SubmissionURL string // SubmissionTimeout sets the timeout for submitting metrics to a broker SubmissionTimeout string // BrokerMaxResponseTime defines the timeout in which brokers must respond when selecting BrokerMaxResponseTime string // TraceMetrics path to write traced metrics to (must be writable by the user running app) TraceMetrics string // BrokerSelectTags defines a tag to use when selecting a broker to use (when creating a check) BrokerSelectTags apiclient.TagType // CheckSearchTags defines a tag to use when searching for a check CheckSearchTags apiclient.TagType // PublicCA indicates the broker is using a public cert (do not use custom TLS config) PublicCA bool }
type LogWrapper ¶
LogWrapper is a wrapper around Go's log.Logger.
func (*LogWrapper) Debugf ¶
func (lw *LogWrapper) Debugf(fmt string, v ...interface{})
func (*LogWrapper) Errorf ¶
func (lw *LogWrapper) Errorf(fmt string, v ...interface{})
func (*LogWrapper) Infof ¶
func (lw *LogWrapper) Infof(fmt string, v ...interface{})
func (*LogWrapper) Printf ¶
func (lw *LogWrapper) Printf(fmt string, v ...interface{})
func (*LogWrapper) Warnf ¶
func (lw *LogWrapper) Warnf(fmt string, v ...interface{})
type Logger ¶
type Logger interface { Printf(fmt string, v ...interface{}) Debugf(fmt string, v ...interface{}) Infof(fmt string, v ...interface{}) Warnf(fmt string, v ...interface{}) Errorf(fmt string, v ...interface{}) }
Logger is a generic logging interface.
type TrapCheck ¶
type TrapCheck struct { Log Logger // contains filtered or unexported fields }
func New ¶
New creates a new TrapCheck instance it will create a check if it is not able to find one based on the passed Check Config and Check Search Tag.
func NewFromCheckBundle ¶ added in v0.0.5
NewFromCheckBundle creates a new TrapCheck instance using the supplied check bundle.
func (*TrapCheck) GetBrokerTLSConfig ¶
GetBrokerTLSConfig returns the current tls config - can be used for pre-seeding multiple check creation without repeatedly calling the API for the same CA cert - returns tls config, error.
func (*TrapCheck) GetCheckBundle ¶
GetCheckBundle returns the trap check bundle currently in use - can be used for caching checks on disk and re-using the check quickly by passing the CID in via the check bundle config.
func (*TrapCheck) IsNewCheckBundle ¶ added in v0.0.7
IsNewCheckBundle returns true if the check bundle was created.
func (*TrapCheck) RefreshCheckBundle ¶ added in v0.0.9
RefreshCheckBundle will pull down a fresh copy from the API.
func (*TrapCheck) SendMetrics ¶
SendMetrics submits the metrics to the broker metrics must be valid JSON encoded data for the broker httptrap check returns trap results in a structure or an error.
func (*TrapCheck) TraceMetrics ¶
TraceMetrics allows changing the tracing of metric submissions dynamically, pass "" to disable tracing going forward. returns current setting or error. on error, the current setting will not be changed. Note: if going from no Logger to trace="-" the Logger will need to be set.
type TrapResult ¶
type TrapResult struct { CheckUUID string `json:"check_uuid"` Error string `json:"error,omitempty"` SubmitUUID string `json:"submit_uuid"` Filtered uint64 `json:"filtered,omitempty"` Stats uint64 `json:"stats"` SubmitDuration time.Duration `json:"submit_dur"` LastReqDuration time.Duration `json:"last_req_dur"` BytesSent int `json:"bytes_sent"` BytesSentGzip int `json:"bytes_sent_gz"` }