Documentation ¶
Index ¶
- func DefaultCertPool() *x509.CertPool
- func EnsureTlsConfig(c *Client)
- type Client
- func (c *Client) ComputeGracePeriod() time.Duration
- func (c *Client) FlushAPMData(ctx context.Context)
- func (c *Client) ForwardApmData(ctx context.Context) error
- func (c *Client) IsUnhealthy() bool
- func (c *Client) PostToApmServer(ctx context.Context, apmData accumulator.APMData) error
- func (c *Client) ResetFlush()
- func (c *Client) ShouldFlush() bool
- func (c *Client) Shutdown() error
- func (c *Client) StartReceiver() error
- func (c *Client) UpdateStatus(ctx context.Context, status Status)
- func (c *Client) WaitForFlush() <-chan struct{}
- type Option
- func WithAPIKey(key string) Option
- func WithAgentDataBufferSize(size int) Option
- func WithBatch(batch *accumulator.Batch) Option
- func WithDataForwarderTimeout(timeout time.Duration) Option
- func WithLogger(logger *zap.SugaredLogger) Option
- func WithReceiverAddress(addr string) Option
- func WithReceiverTimeout(timeout time.Duration) Option
- func WithRootCerts(certs string) Option
- func WithSecretToken(secret string) Option
- func WithSendStrategy(strategy SendStrategy) Option
- func WithURL(url string) Option
- func WithVerifyCerts(verify bool) Option
- type SendStrategy
- type Status
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func DefaultCertPool ¶ added in v1.3.0
func EnsureTlsConfig ¶ added in v1.3.0
func EnsureTlsConfig(c *Client)
Types ¶
type Client ¶
type Client struct { AgentDataChannel chan accumulator.APMData LambdaDataChannel chan []byte Status Status ReconnectionCount int ServerAPIKey string ServerSecretToken string // contains filtered or unexported fields }
Client is the client used to communicate with the apm server.
func (*Client) ComputeGracePeriod ¶
ComputeGracePeriod https://github.com/elastic/apm/blob/main/specs/agents/transport.md#transport-errors
func (*Client) FlushAPMData ¶
FlushAPMData reads all the apm data in the apm data channel and sends it to the APM server.
func (*Client) ForwardApmData ¶
ForwardApmData receives apm data as it comes in and posts it to the APM server. Stop checking for, and sending apm data when the function invocation has completed, signaled via a channel.
func (*Client) IsUnhealthy ¶ added in v1.2.0
IsUnhealthy returns true if the apmproxy is not healthy.
func (*Client) PostToApmServer ¶
PostToApmServer takes a chunk of APM agent data and posts it to the APM server.
The function compresses the APM agent data, if it's not already compressed. It sets the APM transport status to failing upon errors, as part of the backoff strategy.
func (*Client) ResetFlush ¶
func (c *Client) ResetFlush()
ResetFlush resets the client's "agent flushed" state, such that subsequent calls to WaitForFlush will block until another request is received from the agent indicating it has flushed.
func (*Client) ShouldFlush ¶
ShouldFlush returns true if the client should flush APM data after processing the event.
func (*Client) StartReceiver ¶
StartReceiver starts the server listening for APM agent data.
func (*Client) UpdateStatus ¶ added in v1.2.0
UpdateStatus takes a state of the APM server transport and updates the current state of the transport. For a change to a failing state, the grace period is calculated and a go routine is started that waits for that period to complete before changing the status to "pending". This would allow a subsequent send attempt to the APM server.
This function is public for use in tests.
func (*Client) WaitForFlush ¶
func (c *Client) WaitForFlush() <-chan struct{}
WaitForFlush returns a channel that is closed when the agent has signalled that the Lambda invocation has completed, and there is no more APM data coming.
type Option ¶
type Option func(*Client)
func WithAPIKey ¶
func WithAgentDataBufferSize ¶
WithAgentDataBufferSize sets the agent data buffer size.
func WithBatch ¶ added in v1.3.0
func WithBatch(batch *accumulator.Batch) Option
WithBatch configures a batch to be used for batching data before sending to APM Server.
func WithLogger ¶
func WithLogger(logger *zap.SugaredLogger) Option
WithLogger configures a custom zap logger to be used by the client.
func WithReceiverAddress ¶
WithReceiverAddress sets the receiver address.
func WithReceiverTimeout ¶
WithReceiverTimeout sets the timeout receiver.
func WithRootCerts ¶ added in v1.3.0
func WithSecretToken ¶
func WithSendStrategy ¶
func WithSendStrategy(strategy SendStrategy) Option
WithSendStrategy sets the sendstrategy.
func WithVerifyCerts ¶ added in v1.3.0
type SendStrategy ¶
type SendStrategy string
SendStrategy represents the type of sending strategy the extension uses
const ( // Background send strategy allows the extension to send remaining buffered // agent data on the next function invocation Background SendStrategy = "background" // SyncFlush send strategy indicates that the extension will synchronously // flush remaining buffered agent data when it receives a signal that the // function is complete SyncFlush SendStrategy = "syncflush" )
type Status ¶
type Status string
Constants for the state of the transport used in the backoff implementation.
const ( // The apmproxy started but no information can be // inferred on the status of the transport. // Either because the apmproxy just started and no // request was forwarded or because it recovered // from a failure. Started Status = "Started" // Last request completed successfully. Healthy Status = "Healthy" // Last request failed. Failing Status = "Failing" // The APM Server returned status 429 and the extension // was ratelimited. RateLimited Status = "RateLimited" // A failure on the client was observed. This does not // trigger any backoff mechanism. ClientFailing Status = "ClientFailing" )