transmission

package
v1.9.4 Latest Latest
Warning

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

Go to latest
Published: Mar 14, 2019 License: Apache-2.0 Imports: 17 Imported by: 27

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Version string

Version is the build version, set by libhoney

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
	// Honeycomb with the event.
	Metadata interface{}

	// Data contains the content of the event (all the fields and their values)
	Data map[string]interface{}
}

func (*Event) MarshalJSON

func (e *Event) MarshalJSON() ([]byte, error)

Marshaling an Event for batching up to the Honeycomb servers. Omits fields that aren't specific to this particular event, and allows for behavior like omitempty'ing a zero'ed out time.Time.

type Honeycomb

type Honeycomb struct {
	MaxBatchSize           uint          // how many events to collect into a batch before sending
	BatchTimeout           time.Duration // how often to send off batches
	MaxConcurrentBatches   uint          // how many batches can be inflight simultaneously
	PendingWorkCapacity    uint          // how many events to allow to pile up
	BlockOnSend            bool          // whether to block or drop events when the queue fills
	BlockOnResponse        bool          // whether to block or drop responses when the queue fills
	UserAgentAddition      string
	DisableGzipCompression bool // toggles gzip compression when sending batches of events

	Transport http.RoundTripper

	Logger  Logger
	Metrics Metrics
	// contains filtered or unexported fields
}

func (*Honeycomb) Add

func (h *Honeycomb) Add(ev *Event)

func (*Honeycomb) SendResponse

func (h *Honeycomb) SendResponse(r Response) bool

func (*Honeycomb) Start

func (h *Honeycomb) Start() error

func (*Honeycomb) Stop

func (h *Honeycomb) Stop() error

func (*Honeycomb) TxResponses

func (h *Honeycomb) TxResponses() chan Response

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 {
	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
	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) Events

func (m *MockSender) Events() []*Event

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 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 Honeycomb API
	// server
	StatusCode int

	// Body is the body of the HTTP response from the Honeycomb 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) UnmarshalJSON

func (r *Response) UnmarshalJSON(b []byte) error

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
	Stop() 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) 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

Jump to

Keyboard shortcuts

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