Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions apm-lambda-extension/CHANGELOG.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ https://github.com/elastic/apm-aws-lambda/compare/v1.0.2...main[View commits]
- Added support for Secret Manager {pull}208[208]
- Added support for Lambda platform metrics {pull}202[202]
- Migrated to AWS SDK for Go v2 {pull}232[232]
- Make buffer size for agent data configurable {pull}262[262]

[float]
==== Bug fixes
Expand Down
3 changes: 2 additions & 1 deletion apm-lambda-extension/apmproxy/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ const (
defaultDataReceiverTimeout time.Duration = 15 * time.Second
defaultDataForwarderTimeout time.Duration = 3 * time.Second
defaultReceiverAddr = ":8200"
defaultAgentBufferSize int = 100
)

// Client is the client used to communicate with the apm server.
Expand All @@ -54,7 +55,7 @@ func NewClient(opts ...Option) (*Client, error) {
bufferPool: sync.Pool{New: func() interface{} {
return &bytes.Buffer{}
}},
DataChannel: make(chan AgentData, 100),
DataChannel: make(chan AgentData, defaultAgentBufferSize),
client: &http.Client{
Transport: http.DefaultTransport.(*http.Transport).Clone(),
},
Expand Down
7 changes: 7 additions & 0 deletions apm-lambda-extension/apmproxy/option.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,3 +65,10 @@ func WithReceiverAddress(addr string) Option {
c.receiver.Addr = addr
}
}

// WithAgentDataBufferSize sets the agent data buffer size.
func WithAgentDataBufferSize(size int) Option {
return func(c *Client) {
c.DataChannel = make(chan AgentData, size)
}
}
9 changes: 9 additions & 0 deletions apm-lambda-extension/app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,15 @@ func New(opts ...configOption) (*App, error) {
apmOpts = append(apmOpts, apmproxy.WithReceiverAddress(fmt.Sprintf(":%s", port)))
}

if bufferSize := os.Getenv("ELASTIC_APM_LAMBDA_AGENT_DATA_BUFFER_SIZE"); bufferSize != "" {
size, err := strconv.Atoi(bufferSize)
if err != nil {
return nil, err
}

apmOpts = append(apmOpts, apmproxy.WithAgentDataBufferSize(size))
}

apmOpts = append(apmOpts, apmproxy.WithURL(os.Getenv("ELASTIC_APM_LAMBDA_APM_SERVER")))

ac, err := apmproxy.NewClient(apmOpts...)
Expand Down
5 changes: 4 additions & 1 deletion docs/monitoring-aws-lambda.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,9 @@ The following configuration options are particularly relevant for the {apm-lambd
=== `ELASTIC_APM_LAMBDA_APM_SERVER`
This required config option controls where the {apm-lambda-ext} will ship data. This should be the URL of the final APM Server destination for your telemetry.

=== `ELASTIC_APM_LAMBDA_AGENT_DATA_BUFFER_SIZE`
The size of the buffer that stores APM agent data to be forwarded to the APM server. The _default_ is `100`.

[[aws-lambda-config-authentication-keys]]
=== `ELASTIC_APM_SECRET_TOKEN` or `ELASTIC_APM_API_KEY`
One of these (or, alternatively, the corresponding settings for the AWS Secrets Manager IDs) needs to be set as the authentication method that the {apm-lambda-ext} uses when sending data to the URL configured via `ELASTIC_APM_LAMBDA_APM_SERVER`. Alternatively, you can store your APM Server credentials <<aws-lambda-secrets-manager, using the AWS Secrets Manager>> and use the <<aws-lambda-config-secrets-manager-options>> config options, instead. Sending data to the APM Server if none of these options is set is possible, but your APM agent must be allowed to send data to your APM server in https://www.elastic.co/guide/en/apm/guide/current/configuration-anonymous.html[anonymous mode].
Expand Down Expand Up @@ -121,4 +124,4 @@ That's it. With the first invocation (cold start) of your Lambda function you sh
[source, yml]
----
"Using the APM secret token retrieved from Secrets Manager."
----
----