writer

package
v0.0.0-...-78c7f4a Latest Latest
Warning

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

Go to latest
Published: Aug 3, 2018 License: BSD-3-Clause Imports: 19 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewClient

func NewClient(conf *config.AgentConfig) *http.Client

NewClient returns a http.Client configured with the Agent options.

func SetExtraHeaders

func SetExtraHeaders(h http.Header, extras map[string]string)

SetExtraHeaders appends a header map to HTTP headers.

Types

type BasePayloadSender

type BasePayloadSender struct {
	// contains filtered or unexported fields
}

BasePayloadSender encodes structures and behaviours common to most PayloadSenders.

func NewBasePayloadSender

func NewBasePayloadSender(endpoint Endpoint) *BasePayloadSender

NewBasePayloadSender creates a new instance of a BasePayloadSender using the provided endpoint.

func (*BasePayloadSender) Monitor

func (s *BasePayloadSender) Monitor() <-chan interface{}

Monitor allows an external entity to monitor events of this sender by receiving Sender*Event structs.

func (*BasePayloadSender) Send

func (s *BasePayloadSender) Send(payload *Payload)

Send sends a single isolated payload through this sender.

func (*BasePayloadSender) Stop

func (s *BasePayloadSender) Stop()

Stop asks this sender to stop and waits until it correctly stops.

type BaseWriter

type BaseWriter struct {
	// contains filtered or unexported fields
}

BaseWriter encodes the base components and behaviour of a typical Writer.

func NewBaseWriter

func NewBaseWriter(conf *config.AgentConfig, path string, senderFactory func(Endpoint) PayloadSender) *BaseWriter

NewBaseWriter creates a new instance of a BaseWriter.

func (*BaseWriter) Start

func (w *BaseWriter) Start()

Start starts the necessary components of a BaseWriter.

func (*BaseWriter) Stop

func (w *BaseWriter) Stop()

Stop stops any the stoppable components of a BaseWriter.

type DatadogEndpoint

type DatadogEndpoint struct {
	// contains filtered or unexported fields
}

DatadogEndpoint sends payloads to Datadog API.

func NewDatadogEndpoint

func NewDatadogEndpoint(client *http.Client, url, path, apiKey string) *DatadogEndpoint

NewDatadogEndpoint returns an initialized DatadogEndpoint, from a provided http client and remote endpoint path.

func (*DatadogEndpoint) String

func (e *DatadogEndpoint) String() string

func (*DatadogEndpoint) Write

func (e *DatadogEndpoint) Write(payload *Payload) error

Write will send the serialized traces payload to the Datadog traces endpoint.

type Endpoint

type Endpoint interface {
	Write(payload *Payload) error
}

Endpoint is an interface where we send the data from the Agent.

type NullEndpoint

type NullEndpoint struct{}

NullEndpoint is a void endpoint dropping data.

func (*NullEndpoint) Write

func (ne *NullEndpoint) Write(payload *Payload) error

Write of NullEndpoint just drops the payload and log its size.

type Payload

type Payload struct {
	CreationDate time.Time
	Bytes        []byte
	Headers      map[string]string
}

Payload represents a data payload to be sent to some endpoint

func NewPayload

func NewPayload(bytes []byte, headers map[string]string) *Payload

NewPayload constructs a new payload object with the provided data and with CreationDate initialized to the current time.

type PayloadSender

type PayloadSender interface {
	Start()
	Run()
	Stop()
	Send(payload *Payload)

	Monitor() <-chan interface{}
	// contains filtered or unexported methods
}

PayloadSender represents an object capable of asynchronously sending payloads to some endpoint.

type QueuablePayloadSender

type QueuablePayloadSender struct {
	BasePayloadSender
	// contains filtered or unexported fields
}

QueuablePayloadSender is a specific implementation of a PayloadSender that will queue new payloads on error and retry sending them according to some configurable BackoffTimer.

func NewCustomQueuablePayloadSender

func NewCustomQueuablePayloadSender(endpoint Endpoint, conf writerconfig.QueuablePayloadSenderConf) *QueuablePayloadSender

NewCustomQueuablePayloadSender constructs a new QueuablePayloadSender with custom configuration to send payloads to the provided endpoint.

func NewQueuablePayloadSender

func NewQueuablePayloadSender(endpoint Endpoint) *QueuablePayloadSender

NewQueuablePayloadSender constructs a new QueuablePayloadSender with default configuration to send payloads to the provided endpoint.

func (*QueuablePayloadSender) NumQueuedPayloads

func (s *QueuablePayloadSender) NumQueuedPayloads() int

NumQueuedPayloads returns the number of payloads currently waiting in the queue for a retry

func (*QueuablePayloadSender) Run

func (s *QueuablePayloadSender) Run()

Run executes the QueuablePayloadSender main logic synchronously.

func (*QueuablePayloadSender) Start

func (s *QueuablePayloadSender) Start()

Start asynchronously starts this QueueablePayloadSender.

type RetriableError

type RetriableError struct {
	// contains filtered or unexported fields
}

RetriableError is an endpoint error that signifies that the associated operation can be retried at a later point.

func (*RetriableError) Error

func (re *RetriableError) Error() string

Error returns the error string.

type SampledTrace

type SampledTrace struct {
	Trace        *model.Trace
	Transactions []*model.Span
}

SampledTrace represents the result of a trace sample operation.

func (*SampledTrace) Empty

func (s *SampledTrace) Empty() bool

Empty returns true if this SampledTrace has no data.

type SendStats

type SendStats struct {
	SendTime time.Duration
}

SendStats represents basic stats related to the sending of a payload.

type SenderFailureEvent

type SenderFailureEvent struct {
	Payload   *Payload
	SendStats SendStats
	Error     error
}

SenderFailureEvent encodes information related to the failed sending of a payload without subsequent retry.

type SenderRetryEvent

type SenderRetryEvent struct {
	Payload    *Payload
	SendTime   time.Duration
	Error      error
	RetryDelay time.Duration
	RetryNum   int
}

SenderRetryEvent encodes information related to the failed sending of a payload that triggered an automatic retry.

type SenderSuccessEvent

type SenderSuccessEvent struct {
	Payload   *Payload
	SendStats SendStats
}

SenderSuccessEvent encodes information related to the successful sending of a payload.

type ServiceWriter

type ServiceWriter struct {
	InServices <-chan model.ServicesMetadata

	BaseWriter
	// contains filtered or unexported fields
}

ServiceWriter ingests service metadata and flush them to the API.

func NewServiceWriter

func NewServiceWriter(conf *config.AgentConfig, InServices <-chan model.ServicesMetadata) *ServiceWriter

NewServiceWriter returns a new writer for services.

func (*ServiceWriter) Run

func (w *ServiceWriter) Run()

Run runs the main loop of the writer goroutine. If buffers services read from input chan and flushes them when necessary.

func (*ServiceWriter) Start

func (w *ServiceWriter) Start()

Start starts the writer.

func (*ServiceWriter) Stop

func (w *ServiceWriter) Stop()

Stop stops the main Run loop.

type StatsWriter

type StatsWriter struct {
	BaseWriter

	// InStats is the stream of stat buckets to send out.
	InStats <-chan []model.StatsBucket
	// contains filtered or unexported fields
}

StatsWriter ingests stats buckets and flushes them to the API.

func NewStatsWriter

func NewStatsWriter(conf *config.AgentConfig, InStats <-chan []model.StatsBucket) *StatsWriter

NewStatsWriter returns a new writer for stats.

func (*StatsWriter) Run

func (w *StatsWriter) Run()

Run runs the event loop of the writer's main goroutine. It reads stat buckets from InStats, builds stat payloads and sends them out using the base writer.

func (*StatsWriter) Start

func (w *StatsWriter) Start()

Start starts the writer, awaiting stat buckets and flushing them.

func (*StatsWriter) Stop

func (w *StatsWriter) Stop()

Stop stops the writer

type TraceWriter

type TraceWriter struct {
	BaseWriter
	// contains filtered or unexported fields
}

TraceWriter ingests sampled traces and flushes them to the API.

func NewTraceWriter

func NewTraceWriter(conf *config.AgentConfig, in <-chan *SampledTrace) *TraceWriter

NewTraceWriter returns a new writer for traces.

func (*TraceWriter) Run

func (w *TraceWriter) Run()

Run runs the main loop of the writer goroutine. It sends traces to the payload constructor, flushing it periodically and collects stats which are also reported periodically.

func (*TraceWriter) Start

func (w *TraceWriter) Start()

Start starts the writer.

func (*TraceWriter) Stop

func (w *TraceWriter) Stop()

Stop stops the main Run loop.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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