libhoney-go: github.com/honeycombio/libhoney-go/transmission Index | Files

package transmission

import "github.com/honeycombio/libhoney-go/transmission"

Index

Package Files

discard.go event.go logger.go metrics.go mock.go response.go sender.go transmission.go writer.go

Variables

var Version string

Version is the build version, set by libhoney

type DiscardSender Uses

type DiscardSender struct {
    WriterSender
}

DiscardSender implements the Sender interface and drops all events.

func (*DiscardSender) Add Uses

func (d *DiscardSender) Add(ev *Event)

type Event Uses

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 Uses

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.

func (*Event) MarshalMsgpack Uses

func (e *Event) MarshalMsgpack() (byts []byte, err error)

type Honeycomb Uses

type Honeycomb struct {
    // how many events to collect into a batch before sending
    MaxBatchSize uint

    // how often to send off batches
    BatchTimeout 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 http.RoundTripper

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

func (*Honeycomb) Add Uses

func (h *Honeycomb) 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 (*Honeycomb) Flush Uses

func (h *Honeycomb) Flush() (err error)

func (*Honeycomb) SendResponse Uses

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

func (*Honeycomb) Start Uses

func (h *Honeycomb) Start() error

func (*Honeycomb) Stop Uses

func (h *Honeycomb) Stop() error

func (*Honeycomb) TxResponses Uses

func (h *Honeycomb) TxResponses() chan Response

type Logger Uses

type Logger interface {
    // Printf accepts the same msg, args style as fmt.Printf().
    Printf(msg string, args ...interface{})
}

type Metrics Uses

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 Uses

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 Uses

func (m *MockSender) Add(ev *Event)

func (*MockSender) Events Uses

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

func (*MockSender) Flush Uses

func (m *MockSender) Flush() error

func (*MockSender) SendResponse Uses

func (m *MockSender) SendResponse(r Response) bool

func (*MockSender) Start Uses

func (m *MockSender) Start() error

func (*MockSender) Stop Uses

func (m *MockSender) Stop() error

func (*MockSender) TxResponses Uses

func (m *MockSender) TxResponses() chan Response

type Response Uses

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) MarshalMsgpack Uses

func (r *Response) MarshalMsgpack() ([]byte, error)

func (*Response) UnmarshalJSON Uses

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

func (*Response) UnmarshalMsgpack Uses

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

type Sender Uses

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 Uses

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 Uses

func (w *WriterSender) Add(ev *Event)

func (*WriterSender) Flush Uses

func (w *WriterSender) Flush() error

func (*WriterSender) SendResponse Uses

func (w *WriterSender) SendResponse(r Response) bool

func (*WriterSender) Start Uses

func (w *WriterSender) Start() error

func (*WriterSender) Stop Uses

func (w *WriterSender) Stop() error

func (*WriterSender) TxResponses Uses

func (w *WriterSender) TxResponses() chan Response

Package transmission imports 18 packages (graph) and is imported by 11 packages. Updated 2020-08-28. Refresh now. Tools for package owners.