Documentation ¶
Overview ¶
Package transport provides an interface and implementation for transporting data to the Elastic APM server.
Index ¶
- type HTTPError
- type HTTPTransport
- func (t *HTTPTransport) SendProfile(ctx context.Context, metadataReader io.Reader, profileReaders ...io.Reader) error
- func (t *HTTPTransport) SendStream(ctx context.Context, r io.Reader) error
- func (t *HTTPTransport) SetAPIKey(apiKey string)
- func (t *HTTPTransport) SetSecretToken(secretToken string)
- func (t *HTTPTransport) SetServerURL(u ...*url.URL)
- func (t *HTTPTransport) SetUserAgent(ua string)
- func (t *HTTPTransport) WatchConfig(ctx context.Context, args apmconfig.WatchParams) <-chan apmconfig.Change
- type Transport
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type HTTPTransport ¶
type HTTPTransport struct { // Client exposes the http.Client used by the HTTPTransport for // sending requests to the APM Server. 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() (*HTTPTransport, error)
NewHTTPTransport returns a new HTTPTransport which can be used for streaming data to the APM Server. The returned HTTPTransport will be initialized using the following environment variables:
- ELASTIC_APM_SERVER_URLS: a comma-separated list of APM Server URLs. The transport will use this list of URLs for sending requests, switching to the next URL in the list upon error. The list will be shuffled first. If no URLs are specified, then the transport will use the default URL "http://localhost:8200".
- ELASTIC_APM_SERVER_TIMEOUT: timeout for requests to the APM Server. If not specified, defaults to 30 seconds.
- ELASTIC_APM_SECRET_TOKEN: used to authenticate the agent.
- ELASTIC_APM_SERVER_CERT: path to a PEM-encoded certificate that must match the APM Server-supplied certificate. This can be used to pin a self signed certificate. If this is set, then ELASTIC_APM_VERIFY_SERVER_CERT is ignored.
- ELASTIC_APM_VERIFY_SERVER_CERT: if set to "false", the transport will not verify the APM Server's TLS certificate. Only relevant when using HTTPS. By default, the transport will verify server certificates.
func (*HTTPTransport) SendProfile ¶
func (t *HTTPTransport) SendProfile( ctx context.Context, metadataReader io.Reader, profileReaders ...io.Reader, ) error
SendProfile sends a symbolised pprof profile, encoded as protobuf, and gzip-compressed.
NOTE this is an experimental API, and may be removed in a future minor version, without being considered a breaking change.
func (*HTTPTransport) SendStream ¶
SendStream sends the stream over HTTP. If SendStream returns an error and the transport is configured with more than one APM Server URL, then the following request will be sent to the next URL in the list.
func (*HTTPTransport) SetAPIKey ¶
func (t *HTTPTransport) SetAPIKey(apiKey string)
SetAPIKey sets the Authorization header with the given API Key.
This overrides the value specified via the ELASTIC_APM_SECRET_TOKEN or ELASTIC_APM_API_KEY environment variables, if either are set.
func (*HTTPTransport) SetSecretToken ¶
func (t *HTTPTransport) SetSecretToken(secretToken string)
SetSecretToken sets the Authorization header with the given secret token.
This overrides the value specified via the ELASTIC_APM_SECRET_TOKEN or ELASTIC_APM_API_KEY environment variables, if either are set.
func (*HTTPTransport) SetServerURL ¶
func (t *HTTPTransport) SetServerURL(u ...*url.URL)
SetServerURL sets the APM Server URL (or URLs) for sending requests. At least one URL must be specified, or the method will panic. The list will be randomly shuffled.
func (*HTTPTransport) SetUserAgent ¶
func (t *HTTPTransport) SetUserAgent(ua string)
SetUserAgent sets the User-Agent header that will be sent with each request.
func (*HTTPTransport) WatchConfig ¶
func (t *HTTPTransport) WatchConfig(ctx context.Context, args apmconfig.WatchParams) <-chan apmconfig.Change
WatchConfig polls the APM Server for agent config changes, sending them over the returned channel.
type Transport ¶
type Transport interface { // SendStream sends a data stream to the server, returning when the // stream has been closed (Read returns io.EOF) or the HTTP request // terminates. SendStream(context.Context, io.Reader) error }
Transport provides an interface for sending streams of encoded model entities to the Elastic APM server, and for querying config. 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 ¶
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 result 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. |