apmproxy

package
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: Aug 24, 2022 License: Apache-2.0 Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetUncompressedBytes

func GetUncompressedBytes(rawBytes []byte, encodingType string) ([]byte, error)

func ProcessMetadata

func ProcessMetadata(data AgentData) ([]byte, error)

ProcessMetadata return a byte array containing the Metadata marshaled in JSON In case we want to update the Metadata values, usage of https://github.com/tidwall/sjson is advised

Types

type AgentData

type AgentData struct {
	Data            []byte
	ContentEncoding string
}

type Client

type Client struct {
	DataChannel chan AgentData

	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 NewClient

func NewClient(opts ...Option) (*Client, error)

func (*Client) EnqueueAPMData

func (c *Client) EnqueueAPMData(agentData AgentData)

EnqueueAPMData adds a AgentData struct to the agent data channel, effectively queueing for a send to the APM server.

func (*Client) FlushAPMData

func (c *Client) FlushAPMData(ctx context.Context)

FlushAPMData reads all the apm data in the apm data channel and sends it to the APM server.

func (*Client) ForwardApmData

func (c *Client) ForwardApmData(ctx context.Context, metadataContainer *MetadataContainer) error

ForwardApmData receives agent data as it comes in and posts it to the APM server. Stop checking for, and sending agent data when the function invocation has completed, signaled via a channel.

func (*Client) PostToApmServer

func (c *Client) PostToApmServer(ctx context.Context, agentData AgentData) error

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) SetApmServerTransportState

func (c *Client) SetApmServerTransportState(ctx context.Context, status Status)

SetApmServerTransportState 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) ShouldFlush

func (c *Client) ShouldFlush() bool

ShouldFlush returns true if the client should flush APM data after processing the event.

func (*Client) Shutdown

func (c *Client) Shutdown() error

Shutdown shutdowns the apm receiver gracefully.

func (*Client) StartReceiver

func (c *Client) StartReceiver() error

StartHttpServer starts the server listening for APM agent data.

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 MetadataContainer

type MetadataContainer struct {
	Metadata []byte
}

type Option

type Option func(*Client)

func WithAPIKey

func WithAPIKey(key string) Option

func WithAgentDataBufferSize

func WithAgentDataBufferSize(size int) Option

WithAgentDataBufferSize sets the agent data buffer size.

func WithDataForwarderTimeout

func WithDataForwarderTimeout(timeout time.Duration) Option

func WithLogger

func WithLogger(logger *zap.SugaredLogger) Option

func WithReceiverAddress

func WithReceiverAddress(addr string) Option

WithReceiverAddress sets the receiver address.

func WithReceiverTimeout

func WithReceiverTimeout(timeout time.Duration) Option

WithReceiverTimeout sets the timeout receiver.

func WithSecretToken

func WithSecretToken(secret string) Option

func WithSendStrategy

func WithSendStrategy(strategy SendStrategy) Option

WithSendStrategy sets the sendstrategy.

func WithURL

func WithURL(url string) Option

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 (
	Failing Status = "Failing"
	Pending Status = "Pending"
	Healthy Status = "Healthy"
)

Jump to

Keyboard shortcuts

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