transport

package
v0.5.2 Latest Latest
Warning

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

Go to latest
Published: Sep 20, 2018 License: Apache-2.0 Imports: 20 Imported by: 0

Documentation

Overview

Package transport provides an interface and implementation for transporting data to the Elastic APM server.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type HTTPError

type HTTPError struct {
	Op       string
	Response *http.Response
	Message  string
}

HTTPError is an error returned by HTTPTransport methods when requests fail.

func (*HTTPError) Error

func (e *HTTPError) Error() string

type HTTPTransport

type HTTPTransport struct {
	Client *http.Client
	// contains filtered or unexported fields
}

HTTPTransport is an implementation of Transport, sending payloads via a net/http client.

func NewHTTPTransport

func NewHTTPTransport(serverURL, secretToken string) (*HTTPTransport, error)

NewHTTPTransport returns a new HTTPTransport, which can be used for sending transactions and errors to the APM server at the specified URL, with the given secret token.

If the URL specified is the empty string, then NewHTTPTransport will use the value of the ELASTIC_APM_SERVER_URL environment variable, if defined; if the environment variable is also undefined, then the transport will use the default URL "http://localhost:8200". The URL must be the base server URL, excluding any transactions or errors path. e.g. "http://server.example:8200".

If the secret token specified is the empty string, then NewHTTPTransport will use the value of the ELASTIC_APM_SECRET_TOKEN environment variable, if defined; if the environment variable is also undefined, then requests will not be authenticated.

If ELASTIC_APM_VERIFY_SERVER_CERT is set to "false", then the transport will not verify the APM server's TLS certificate.

The Client field will be initialized with a new http.Client configured from ELASTIC_APM_* environment variables. The Client field may be modified or replaced, e.g. in order to specify TLS root CAs.

func (*HTTPTransport) SendErrors

func (t *HTTPTransport) SendErrors(ctx context.Context, p *model.ErrorsPayload) error

SendErrors sends the errors payload over HTTP.

func (*HTTPTransport) SendMetrics added in v0.5.0

func (t *HTTPTransport) SendMetrics(ctx context.Context, p *model.MetricsPayload) error

SendMetrics sends the metrics payload over HTTP.

func (*HTTPTransport) SendTransactions

func (t *HTTPTransport) SendTransactions(ctx context.Context, p *model.TransactionsPayload) error

SendTransactions sends the transactions payload over HTTP.

func (*HTTPTransport) SetUserAgent added in v0.5.0

func (t *HTTPTransport) SetUserAgent(ua string)

SetUserAgent sets the User-Agent header that will be sent with each request.

type Transport

type Transport interface {
	// SendErrors sends the errors payload to the server.
	SendErrors(context.Context, *model.ErrorsPayload) error

	// SendMetrics sends the metrics payload to the server.
	SendMetrics(context.Context, *model.MetricsPayload) error

	// SendTransactions sends the transactions payload to the server.
	SendTransactions(context.Context, *model.TransactionsPayload) error
}

Transport provides an interface for sending data to the Elastic APM server. Methods are not required to be safe for concurrent use.

var (
	// Default is the default Transport, using the
	// ELASTIC_APM_* environment variables.
	//
	// If ELASTIC_APM_SERVER_URL is set to an invalid
	// location, Default will be set to a transport
	// returning an error for every operation.
	Default Transport

	// Discard is a Transport on which all operations
	// succeed without doing anything.
	Discard = discardTransport{}
)

func InitDefault

func InitDefault() (Transport, error)

InitDefault (re-)initializes Default, the default transport, returning its new value along with the error that will be returned by the transport if the environment variable configuration is invalid. The Transport returned is always non-nil.

Directories

Path Synopsis
Package transporttest provides implementations of transport.Transport for testing purposes.
Package transporttest provides implementations of transport.Transport for testing purposes.

Jump to

Keyboard shortcuts

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