Skip to content

Commit

Permalink
Handle EOF When Parsing Payloads (#117)
Browse files Browse the repository at this point in the history
Closes #116
  • Loading branch information
kolanos authored Jun 6, 2022
1 parent 01dc845 commit db53188
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 14 deletions.
8 changes: 4 additions & 4 deletions telemetry/batch.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,10 @@ func (b *Batch) AddInvocation(requestId string, start time.Time) {
func (b *Batch) AddTelemetry(requestId string, telemetry []byte) *Invocation {
inv, ok := b.invocations[requestId]
if ok {
inv.Telemetry = append(inv.Telemetry, telemetry)
if b.eldest.Equal(epochStart) {
b.eldest = inv.Start
}
traceId, err := ExtractTraceID(telemetry)
if err != nil {
util.Debugln(err)
Expand All @@ -49,10 +53,6 @@ func (b *Batch) AddTelemetry(requestId string, telemetry []byte) *Invocation {
if traceId != "" {
inv.TraceId = traceId
}
inv.Telemetry = append(inv.Telemetry, telemetry)
if b.eldest.Equal(epochStart) {
b.eldest = inv.Start
}
return inv
}
return nil
Expand Down
23 changes: 14 additions & 9 deletions telemetry/payload.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,25 +14,25 @@ import (
func parsePayload(data []byte) (metadata, uncompressedData map[string]json.RawMessage, err error) {
var arr [4]json.RawMessage

if err = json.Unmarshal(data, &arr); nil != err {
if err = json.Unmarshal(data, &arr); err != nil {
err = fmt.Errorf("unable to unmarshal payload data array: %v", err)
return
}

var dataJSON []byte
compressed := strings.Trim(string(arr[3]), `"`)

if dataJSON, err = decodeUncompress(compressed); nil != err {
if dataJSON, err = decodeUncompress(compressed); err != nil {
err = fmt.Errorf("unable to uncompress payload: %v", err)
return
}

if err = json.Unmarshal(dataJSON, &uncompressedData); nil != err {
if err = json.Unmarshal(dataJSON, &uncompressedData); err != nil {
err = fmt.Errorf("unable to unmarshal uncompressed payload: %v", err)
return
}

if err = json.Unmarshal(arr[2], &metadata); nil != err {
if err = json.Unmarshal(arr[2], &metadata); err != nil {
err = fmt.Errorf("unable to unmarshal payload metadata: %v", err)
return
}
Expand All @@ -42,13 +42,13 @@ func parsePayload(data []byte) (metadata, uncompressedData map[string]json.RawMe

func decodeUncompress(input string) ([]byte, error) {
decoded, err := base64.StdEncoding.DecodeString(input)
if nil != err {
if err != nil {
return nil, err
}

buf := bytes.NewBuffer(decoded)
gz, err := gzip.NewReader(buf)
if nil != err {
if err != nil {
return nil, err
}

Expand All @@ -59,13 +59,18 @@ func decodeUncompress(input string) ([]byte, error) {
return out.Bytes(), nil
}

// ExtracTraceID extracts the trace ID within a payload, if present
// ExtractTraceID extracts the trace ID within a payload, if present
func ExtractTraceID(data []byte) (string, error) {
if !bytes.Contains(data, []byte("NR_LAMBDA_MONITORING")) {
decoded, err := base64.StdEncoding.DecodeString(string(data))
if err != nil {
return "", err
}

if !bytes.Contains(decoded, []byte("NR_LAMBDA_MONITORING")) {
return "", nil
}

_, segments, err := parsePayload(data)
_, segments, err := parsePayload(decoded)
if err != nil {
return "", err
}
Expand Down
9 changes: 9 additions & 0 deletions telemetry/payload_test.go
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
package telemetry

import (
"encoding/base64"
"testing"

"github.com/stretchr/testify/assert"
)

func TestParsePayload(t *testing.T) {
payload := []byte("[1, \"NR_LAMBDA_MONITORING\", {\"arn\": \"AWS_LAMBDA_FUNCTION_ARN\", \"protocol_version\": 16, \"function_version\": \"15\", \"execution_environment\": \"AWS_Lambda_python3.6\", \"agent_version\": \"4.2.0.100\", \"metadata_version\": 2, \"agent_language\": \"python\"}, \"H4sIAHpLdWIC/6VXaXPiSA/+Ky5/mtkk2O27Z995q8x93wGS7BbVthvb4Au7TYCp/PftNiRDskl2tjaVEJClllrS80j84ENMUt9eOogg/hv3EOVBcM0BVdahKOqGXJI1RTKMC5FCRWohenj4wUcoxNSOHx6IF0fCfNJoCYOcJDkRygeCM/6a4zM7Tgol/okagWtOuvhV/vyTCn8e1CQkqfpZgojt4fRdc7nw/vdXIBpAhAo9kZ3JowgFB0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tuSLfueMsaKJZROcPIF1prveq1WoorPBuEOjt1L1NO0ltNu3fB81ZP92R8XAixvHoNm1MdurdQQ4mVmfaGlIW9YBRu1L20s4LVwMMKvK2l3e3TfVqfFXe3s7Xt1qihuv7MiUwVB+ajjYI1eGifDsiyH9soMZV37AnZj6f7gyy3TfrR0lzG735otIchkar3UjKvXXrOMy0iR1d4bZ511DGoagventvOgmhvwBtqI3LXTUDeBzAnjuS1tqueWVu+p2jP3ND55iKq6OxhUZbM3f7bB6Fg4Fzexw3gXkI74b7lVUWDp7RWxz691rH/P6ddYABVBvIq5UhyrK1csBLhlcoyPDzB/ZKS/70F1o8LBCCEAAA\"]")

metadata, data, err := parsePayload(payload)
assert.NotNil(t, metadata)
assert.NotNil(t, data)
Expand All @@ -16,6 +18,7 @@ func TestParsePayload(t *testing.T) {

func TestParsePayloadBlank(t *testing.T) {
payload := []byte("")

metadata, data, err := parsePayload(payload)
assert.Nil(t, metadata)
assert.Nil(t, data)
Expand All @@ -24,6 +27,7 @@ func TestParsePayloadBlank(t *testing.T) {

func TestParsePayloadInvalidMetaData(t *testing.T) {
payload := []byte("[1, \"NR_LAMBDA_MONITORING\", \"foobar\", null]")

metadata, data, err := parsePayload(payload)
assert.Nil(t, metadata)
assert.Nil(t, data)
Expand All @@ -32,6 +36,7 @@ func TestParsePayloadInvalidMetaData(t *testing.T) {

func TestParsePayloadInvalidCompressedData(t *testing.T) {
payload := []byte("[1, \"NR_LAMBDA_MONITORING\", {\"arn\": \"AWS_LAMBDA_FUNCTION_ARN\", \"protocol_version\": 16, \"function_version\": \"15\", \"execution_environment\": \"AWS_Lambda_python3.6\", \"agent_version\": \"4.2.0.100\", \"metadata_version\": 2, \"agent_language\": \"python\"}, \"foobar\"]")

metadata, data, err := parsePayload(payload)
assert.Nil(t, metadata)
assert.Nil(t, data)
Expand All @@ -40,6 +45,7 @@ func TestParsePayloadInvalidCompressedData(t *testing.T) {

func TestParsePayloadInvalidData(t *testing.T) {
payload := []byte("[1, \"NR_LAMBDA_MONITORING\", {\"arn\": \"AWS_LAMBDA_FUNCTION_ARN\", \"protocol_version\": 16, \"function_version\": \"15\", \"execution_environment\": \"AWS_Lambda_python3.6\", \"agent_version\": \"4.2.0.100\", \"metadata_version\": 2, \"agent_language\": \"python\"}, \"H4sIAK6pdWIC/0vLz09KLAIAlR/2ngYAAAA=\"]")

metadata, data, err := parsePayload(payload)
assert.Nil(t, metadata)
assert.Nil(t, data)
Expand All @@ -48,6 +54,7 @@ func TestParsePayloadInvalidData(t *testing.T) {

func TestExtractTraceIDAnalyticEvent(t *testing.T) {
payload := []byte("[1, \"NR_LAMBDA_MONITORING\", {\"arn\": \"AWS_LAMBDA_FUNCTION_ARN\", \"protocol_version\": 16, \"function_version\": \"15\", \"execution_environment\": \"AWS_Lambda_python3.6\", \"agent_version\": \"4.2.0.100\", \"metadata_version\": 2, \"agent_language\": \"python\"}, \"H4sIAHpLdWIC/6VXaXPiSA/+Ky5/mtkk2O27Z995q8x93wGS7BbVthvb4Au7TYCp/PftNiRDskl2tjaVEJClllrS80j84ENMUt9eOogg/hv3EOVBcM0BVdahKOqGXJI1RTKMC5FCRWohenj4wUcoxNSOHx6IF0fCfNJoCYOcJDkRygeCM/6a4zM7Tgol/okagWtOuvhV/vyTCn8e1CQkqfpZgojt4fRdc7nw/vdXIBpAhAo9kZ3JowgFB0Lvhnc4Im9u+INPcYbTXeyny8w/svOBSH+oXaGeLTOMIyo1nk4XZeYWynAFBUElziPCLKj2s7yap4j4MTORShLQJSjphqopiioDCd+IKtP9qSOWaLSaYRgykCUoK6pOn7u577CLSooj6gACDYOVKGLMsvCcnzm2pimKMmSzk4R6Hp3eLJch8qPl8psfOXjPLJI4ZUEaosjiTFI/Tn1yYGGXoG4wWYbCJMDMJUlzTAXED3FGqJRpsYIbsq6rCmRpITFBwdQvong3epIiG7c+vAA5nKp4ET0r6I+nUzG2OfVcot3oxcURjdqUWT0/yFOfSYWTLEviKMMlDyMHp1nJjiNCa9bFkUs8F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F1o8LBCCEAAA\"]")
payload = []byte(base64.StdEncoding.EncodeToString(payload))

traceId, err := ExtractTraceID(payload)

Expand All @@ -57,6 +64,7 @@ func TestExtractTraceIDAnalyticEvent(t *testing.T) {

func TestExtractTraceIDSpanEvent(t *testing.T) {
payload := []byte("[1, \"NR_LAMBDA_MONITORING\", {\"arn\": \"AWS_LAMBDA_FUNCTION_ARN\", \"protocol_version\": 16, \"function_version\": \"15\", \"execution_environment\": \"AWS_Lambda_python3.6\", \"agent_version\": \"4.2.0.100\", \"metadata_version\": 2, \"agent_language\": \"python\"}, \"H4sIAPundWIC/6VWa3PiuBL9Ky5/mllS2PJbs3dulQnv9ytAkt2iZFvYBr+QZQJMzX+/kiEZMq/aW1uVAG611K3TfU77ixhjSkJ37SGKxE/Cc1JE0Z0AdNWEsmxaalU1NMWybkwaM+ml6fn5i5igGLN94vhEgzSRlrNWRxoVNCuoVDtRnIt3gpi7aVY6iV/ZJnAnKDd/2t9/M+O3g9qUZvUwzxB1A0x+ul0to//4CWQLyFBjJ/IzRbfIaRqv8QEn9Lv7fRFLa77OMU6YmR0qEpxjckhDss7DM48HFFn+erklDWOcUxRn3Kyrlg50Q9VM02T76OmS3X0ZrsHP5Yl+ETdpyu0OIuLXS0aYkJT8i4Te8vEKgmiYck+5KsuWrsksLV1WNWBCA76GqroRyvMyiSKMaJjknxYoKnCDL4pvXuxuOfLLS/Ccmd0vQo8/WjqESIEY6cCAuufxtYRUKUFJjlyeQes3nllKKFuzZJlfJyNhSkJ64hdhOcu6wWvLMI0wP4GSAnM0f0Ta1FRFU/kaQS7u/DLcTVbDazMtsTP/ZpWaRXL5sV7HKEzW60/4FYnXKt64X1DipSzLSfC+YKlVA4w8TPIqcl2c8fuJFB+pFNA4ukNZFoVuWRrpyC2V4/fWOPpz/1muwrswZphLL9jJrj9Rlvh3f0h/lOuWWHbA+5BBmpcBo9RFEX/4xLH9mWfBWsf2eSsy90F6DqMISXpVFj4MkBsmNM2DP4VOQnEkMIMwmgk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gB2xkJiAmKPXzHf2Bqik/H+spRdE8LDWm1EhFVSAbGjowLUVRjPJl4EYHfhaJpZStf5HI128DZX0ZKBfsRKY57u7Cfo4on+8udphN+BAzQgoEuwwBgeu7wF6W6MdPPFQzjLDwl8gGdzU7/SXyuZdgRsI7IUyE/8SpV0T4vzeO/ECfpEXirRnxd+83qeWuF8JOu7zQ/vx0o3Qri8Y7oZzg7wtzlbMbPVxfgP5VwzBYIbCqGmTqz6RJA0BjymtZigUU/f9qoiuauHsEcxmQoG5PpBk817fOU6tWQLjop7PZFk8b3aWmPvrTPGqjRcLmD6B9ZWkO6vV6LG3wYRSZXeI/kF7WWMyHT1F7MSQHOh3P5DSdPJDW7KA/ntRo5vTmnTFT0QBYjYp2VA5BvBlhcK/uB0V/39Yr00pt/7DcPhiZHm+fakzAUHNse8Yo1ser2sOEovClhVqVoeXO7GI5P1h0f2w3z4rhtwbL1X17HFudbiurDbad8zg3Zm5SwV37saVNY9lcDY7BfBbDcAW60JjW+noO8DSCA3+ibI1Du2Lvhr1zuPBj70zkzdnaQ6tr2Idjvkzi0ch7OE/bwD7Fj+PjxqlJp8AarE7DJ6Nnf/7MO8ACugvUzcaSVdXZeOAN4Q2Kcvz6wD9Zyb/+D6zpn+elDQAA\"]")
payload = []byte(base64.StdEncoding.EncodeToString(payload))

traceId, err := ExtractTraceID(payload)

Expand All @@ -66,6 +74,7 @@ func TestExtractTraceIDSpanEvent(t *testing.T) {

func TestExtractTraceIDInvalid(t *testing.T) {
payload := []byte("[1, \"NR_LAMBDA_MONITORING\", {\"arn\": \"AWS_LAMBDA_FUNCTION_ARN\", \"protocol_version\": 16, \"function_version\": \"15\", \"execution_environment\": \"AWS_Lambda_python3.6\", \"agent_version\": \"4.2.0.100\", \"metadata_version\": 2, \"agent_language\": \"python\"}, \"H4sIAK6pdWIC/0vLz09KLAIAlR/2ngYAAAA=\"]")
payload = []byte(base64.StdEncoding.EncodeToString(payload))

traceId, err := ExtractTraceID(payload)

Expand Down
2 changes: 1 addition & 1 deletion util/extension.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@ package util

const (
Name = "newrelic-lambda-extension"
Version = "2.3.0"
Version = "2.3.1"
Id = Name + ":" + Version
)

0 comments on commit db53188

Please sign in to comment.