Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
var Opsramptoken, OpsrampKey, OpsrampSecret, ApiEndPoint string
Functions ¶
This section is empty.
Types ¶
type DiscardSender ¶
type DiscardSender struct {
WriterSender
}
DiscardSender implements the Sender interface and drops all events.
func (*DiscardSender) Add ¶
func (d *DiscardSender) Add(ev *Event)
type Event ¶
type Event struct {
// APIKey, if set, overrides whatever is found in Config
//APIKey string
// Dataset, if set, overrides whatever is found in Config
Dataset string
// SampleRate, if set, overrides whatever is found in Config
SampleRate uint
// APIHost, if set, overrides whatever is found in Config
APIHost string
// Timestamp, if set, specifies the time for this event. If unset, defaults
// to Now()
Timestamp time.Time
// Metadata is a field for you to add in data that will be handed back to you
// on the Response object read off the Responses channel. It is not sent to
// Opsramp with the event.
Metadata interface{}
// Data contains the content of the event (all the fields and their values)
Data map[string]interface{}
APIToken string
APITenantId string
}
func (*Event) MarshalJSON ¶
Marshaling an Event for batching up to the Opsramp servers. Omits fields that aren't specific to this particular event, and allows for behavior like omitempty'ing a zero'ed out time.Time.
func (*Event) MarshalMsgpack ¶
type Logger ¶
type Logger interface {
// Printf accepts the same msg, args style as fmt.Printf().
Printf(msg string, args ...interface{})
}
type Metrics ¶
type Metrics interface {
//Register(name string, metricType string)
Gauge(string, interface{})
Increment(string)
Count(string, interface{})
}
Metrics is an interface that can be fulfilled by something like statsd
type MockSender ¶
type MockSender struct {
Started int
Stopped int
Flushed int
EventsCalled int
BlockOnResponses bool
sync.Mutex
// contains filtered or unexported fields
}
MockSender implements the Sender interface by retaining a slice of added events, for use in unit tests.
func (*MockSender) Add ¶
func (m *MockSender) Add(ev *Event)
func (*MockSender) Flush ¶
func (m *MockSender) Flush() error
func (*MockSender) SendResponse ¶
func (m *MockSender) SendResponse(r Response) bool
func (*MockSender) Start ¶
func (m *MockSender) Start() error
func (*MockSender) Stop ¶
func (m *MockSender) Stop() error
func (*MockSender) TxResponses ¶
func (m *MockSender) TxResponses() chan Response
type Opsramptraceproxy ¶
type Opsramptraceproxy struct {
// How many events to collect into a batch before sending. A
// batch could be sent before achieving this item limit if the
// BatchTimeout has elapsed since the last batch send. If set
// to zero, batches will only be sent upon reaching the
// BatchTimeout. It is an error for both this and
// the BatchTimeout to be zero.
// Default: 50 (from Config.MaxBatchSize)
MaxBatchSize uint
// How often to send batches. Events queue up into a batch until
// this time has elapsed or the batch item limit is reached
// (MaxBatchSize), then the batch is sent to Honeycomb API.
// If set to zero, batches will only be sent upon reaching the
// MaxBatchSize item limit. It is an error for both this and
// the MaxBatchSize to be zero.
// Default: 100 milliseconds (from Config.SendFrequency)
BatchTimeout time.Duration
// The start-to-finish timeout for HTTP requests sending event
// batches to the Honeycomb API. Transmission will retry once
// when receiving a timeout, so total time spent attempting to
// send events could be twice this value.
// Default: 60 seconds.
BatchSendTimeout time.Duration
// how many batches can be inflight simultaneously
MaxConcurrentBatches uint
// how many events to allow to pile up
// if not specified, then the work channel becomes blocking
// and attempting to add an event to the queue can fail
PendingWorkCapacity uint
// whether to block or drop events when the queue fills
BlockOnSend bool
// whether to block or drop responses when the queue fills
BlockOnResponse bool
UserAgentAddition string
// toggles compression when sending batches of events
DisableCompression bool
// Deprecated, synonymous with DisableCompression
DisableGzipCompression bool
// set true to send events with msgpack encoding
EnableMsgpackEncoding bool
// Transport defines the behavior of the lower layer transport details.
// It is used as the Transport value for the constructed HTTP client that
// sends batches of events.
// Default: http.DefaultTransport
Transport http.RoundTripper
Logger Logger
Metrics Metrics
UseTls bool
UseTlsInsecure bool
OpsrampKey string
OpsrampSecret string
ApiHost string
// contains filtered or unexported fields
}
func (*Opsramptraceproxy) Add ¶
func (h *Opsramptraceproxy) Add(ev *Event)
Add enqueues ev to be sent. If a Flush is in-progress, this will block until it completes. Similarly, if BlockOnSend is set and the pending work is more than the PendingWorkCapacity, this will block a Flush until more pending work can be enqueued.
func (*Opsramptraceproxy) Flush ¶
func (h *Opsramptraceproxy) Flush() (err error)
func (*Opsramptraceproxy) SendResponse ¶
func (h *Opsramptraceproxy) SendResponse(r Response) bool
func (*Opsramptraceproxy) Start ¶
func (h *Opsramptraceproxy) Start() error
func (*Opsramptraceproxy) Stop ¶
func (h *Opsramptraceproxy) Stop() error
func (*Opsramptraceproxy) TxResponses ¶
func (h *Opsramptraceproxy) TxResponses() chan Response
type Response ¶
type Response struct {
// Err contains any error returned by the httpClient on sending or an error
// indicating queue overflow
Err error
// StatusCode contains the HTTP Status Code returned by the Opsramp API
// server
StatusCode int
// Body is the body of the HTTP response from the Opsramp API server.
Body []byte
// Duration is a measurement of how long the HTTP request to send an event
// took to process. The actual time it takes libhoney to send an event may
// be longer due to any time the event spends waiting in the queue before
// being sent.
Duration time.Duration
// Metadata is whatever content you put in the Metadata field of the event for
// which this is the response. It is passed through unmodified.
Metadata interface{}
}
Response is a record of an event sent. It includes information about sending the event - how long it took, whether it succeeded, and so on. It also has a metadata field that is just a pass through - populate an Event's Metadata field and what you put there will be on the Response that corresponds to that Event. This allows you to track specific events.
func (*Response) MarshalMsgpack ¶
func (*Response) UnmarshalJSON ¶
func (*Response) UnmarshalMsgpack ¶
type Sender ¶
type Sender interface {
// Add queues up an event to be sent
Add(ev *Event)
// Start initializes any background processes necessary to send events
Start() error
// Stop flushes any pending queues and blocks until everything in flight has
// been sent. Once called, you cannot call Add unless Start has subsequently
// been called.
Stop() error
// Flush flushes any pending queues and blocks until everything in flight has
// been sent.
Flush() error
// Responses returns a channel that will contain a single Response for each
// Event added. Note that they may not be in the same order as they came in
TxResponses() chan Response
// SendResponse adds a Response to the Responses queue. It should be added
// for events handed to libhoney that are dropped before they even make it
// to the Transmission Sender (for example because of sampling) to maintain
// libhoney's guarantee that each event given to it will generate one event
// in the Responses channel.
SendResponse(Response) bool
}
Sender is responsible for handling events after Send() is called. Implementations of Add() must be safe for concurrent calls.
type WriterSender ¶
type WriterSender struct {
W io.Writer
BlockOnResponses bool
ResponseQueueSize uint
sync.Mutex
// contains filtered or unexported fields
}
WriterSender implements the Sender interface by marshalling events to JSON and writing to STDOUT, or to the writer W if one is specified.
func (*WriterSender) Add ¶
func (w *WriterSender) Add(ev *Event)
func (*WriterSender) Flush ¶
func (w *WriterSender) Flush() error
func (*WriterSender) SendResponse ¶
func (w *WriterSender) SendResponse(r Response) bool
func (*WriterSender) Start ¶
func (w *WriterSender) Start() error
func (*WriterSender) Stop ¶
func (w *WriterSender) Stop() error
func (*WriterSender) TxResponses ¶
func (w *WriterSender) TxResponses() chan Response