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
4 changes: 4 additions & 0 deletions CHANGELOG.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,10 @@ https://github.com/elastic/apm-aws-lambda/compare/v1.4.0...main[View commits]
===== Bug fixes
- Log a warning, instead of failing a Lambda function, if auth retrieval from AWS Secrets Manager fails. Reporting APM data will not work, but the Lambda function invocations will proceed. {lambda-pull}401[401]

[float]
===== Features
- Use User-Agent header with Lambda extension version and propagate info from apm agents {lambda-pull}404[404]

[float]
[[lambda-1.4.0]]
=== 1.4.0 - 2023/05/03
Expand Down
1 change: 1 addition & 0 deletions accumulator/apmdata.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,5 @@ package accumulator
type APMData struct {
Data []byte
ContentEncoding string
AgentInfo string
}
3 changes: 3 additions & 0 deletions apmproxy/apmserver.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ import (
"time"

"github.com/elastic/apm-aws-lambda/accumulator"
"github.com/elastic/apm-aws-lambda/version"
"go.uber.org/zap"
)

Expand Down Expand Up @@ -130,6 +131,7 @@ func (c *Client) PostToApmServer(ctx context.Context, apmData accumulator.APMDat

endpointURI := "intake/v2/events"
encoding := apmData.ContentEncoding
agentInfo := apmData.AgentInfo

var r io.Reader
if apmData.ContentEncoding != "" {
Expand Down Expand Up @@ -160,6 +162,7 @@ func (c *Client) PostToApmServer(ctx context.Context, apmData accumulator.APMDat
}
req.Header.Add("Content-Encoding", encoding)
req.Header.Add("Content-Type", "application/x-ndjson")
req.Header.Set("User-Agent", version.UserAgent+" "+agentInfo)
if c.ServerAPIKey != "" {
req.Header.Add("Authorization", "ApiKey "+c.ServerAPIKey)
} else if c.ServerSecretToken != "" {
Expand Down
4 changes: 4 additions & 0 deletions apmproxy/receiver.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ import (
"time"

"github.com/elastic/apm-aws-lambda/accumulator"
"github.com/elastic/apm-aws-lambda/version"
)

const txnRegistrationContentType = "application/vnd.elastic.apm.transaction+ndjson"
Expand Down Expand Up @@ -105,6 +106,8 @@ func (c *Client) handleInfoRequest() (func(w http.ResponseWriter, r *http.Reques
r.URL.Host = parsedApmServerURL.Host
r.URL.Scheme = parsedApmServerURL.Scheme
r.Header.Set("X-Forwarded-Host", r.Header.Get("Host"))
reqAgent := r.UserAgent()
r.Header.Set("User-Agent", version.UserAgent+" "+reqAgent)
r.Host = parsedApmServerURL.Host

// Override authorization header sent by the APM agents
Expand Down Expand Up @@ -136,6 +139,7 @@ func (c *Client) handleIntakeV2Events() func(w http.ResponseWriter, r *http.Requ
agentData := accumulator.APMData{
Data: rawBytes,
ContentEncoding: r.Header.Get("Content-Encoding"),
AgentInfo: r.UserAgent(),
}

if len(agentData.Data) != 0 {
Expand Down
5 changes: 5 additions & 0 deletions extension/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import (
"net/http"
"time"

"github.com/elastic/apm-aws-lambda/version"
"go.uber.org/zap"
)

Expand Down Expand Up @@ -106,6 +107,7 @@ func (e *Client) Register(ctx context.Context, filename string) (*RegisterRespon
return nil, fmt.Errorf("failed to create register request: %w", err)
}
httpReq.Header.Set(extensionNameHeader, filename)
httpReq.Header.Set("User-Agent", version.UserAgent)
httpRes, err := e.httpClient.Do(httpReq)
if err != nil {
return nil, fmt.Errorf("extension register request failed: %w", err)
Expand Down Expand Up @@ -134,6 +136,7 @@ func (e *Client) NextEvent(ctx context.Context) (*NextEventResponse, error) {
return nil, fmt.Errorf("failed to create next event request: %w", err)
}
httpReq.Header.Set(extensionIdentiferHeader, e.ExtensionID)
httpReq.Header.Set("User-Agent", version.UserAgent)
httpRes, err := e.httpClient.Do(httpReq)
if err != nil {
return nil, fmt.Errorf("next event request failed: %w", err)
Expand Down Expand Up @@ -161,6 +164,7 @@ func (e *Client) InitError(ctx context.Context, errorType string) (*StatusRespon
}
httpReq.Header.Set(extensionIdentiferHeader, e.ExtensionID)
httpReq.Header.Set(extensionErrorType, errorType)
httpReq.Header.Set("User-Agent", version.UserAgent)
httpRes, err := e.httpClient.Do(httpReq)
if err != nil {
return nil, fmt.Errorf("initialization error request failed: %w", err)
Expand Down Expand Up @@ -188,6 +192,7 @@ func (e *Client) ExitError(ctx context.Context, errorType string) (*StatusRespon
}
httpReq.Header.Set(extensionIdentiferHeader, e.ExtensionID)
httpReq.Header.Set(extensionErrorType, errorType)
httpReq.Header.Set("User-Agent", version.UserAgent)
httpRes, err := e.httpClient.Do(httpReq)
if err != nil {
return nil, fmt.Errorf("exit error request failed: %w", err)
Expand Down
3 changes: 3 additions & 0 deletions logsapi/subscribe.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ import (
"io"
"net"
"net/http"

"github.com/elastic/apm-aws-lambda/version"
)

// SubscribeRequest is the request body that is sent to Logs API on subscribe
Expand Down Expand Up @@ -131,6 +133,7 @@ func (lc *Client) sendRequest(url string, data []byte, extensionID string) (*htt

req.Header.Set("Content-Type", "application/json")
req.Header.Set("Lambda-Extension-Identifier", extensionID)
req.Header.Set("User-Agent", version.UserAgent)

resp, err := lc.httpClient.Do(req)
if err != nil {
Expand Down
5 changes: 3 additions & 2 deletions extension/version.go → version/version.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,9 @@
// specific language governing permissions and limitations
// under the License.

package extension
package version

const (
Version = "1.4.0"
Version = "1.4.0"
UserAgent = "apm-aws-lambda/" + Version
)