Skip to content

Warn about possible misconfiguration #205

@tomas-bareikis

Description

@tomas-bareikis

Summary

I was setting up a NR integration for a Golang lambda function. There was a mistake done from my side. I have added a New Relic lambda layer to the lambda, but forgot to use github.com/newrelic/go-agent/v3/integrations/nrlambda package.

So, I had (A):

package main
import (
	"context"
	"fmt"
	"github.com/aws/aws-lambda-go/lambda"
)
func handler(ctx context.Context) {
	fmt.Println("Hello New Relic")
}
func main() {
	lambda.Start(handler)
}

Instead of (B):

package main
import (
	"context"
	"fmt"
	"github.com/newrelic/go-agent/v3/integrations/nrlambda"
	"github.com/newrelic/go-agent/v3/newrelic"
)
func handler(ctx context.Context) {
	fmt.Println("Hello New Relic")
}
func main() {
	app, err := newrelic.NewApplication(nrlambda.ConfigOption())
	if nil != err {
		fmt.Println("error creating app (invalid config):", err)
	}
	nrlambda.Start(handler, app)
}

The timeout for the lambda was set to 15 seconds. Option A was running for 14 seconds and 799.66ms. It finished successfully just before the timeout.

Lambda output was:

INIT_START Runtime Version: provided:al2.v34	Runtime Version ARN: arn:aws:lambda:eu-west-1::runtime:a38a7c2b20823ad5a2a1318d6dcec1bc0e12078c15888f062e9dc49b3d20d010
[NR_EXT] New Relic Lambda Extension starting up
[NR_EXT] Initializing version 2.3.11 of the New Relic Lambda Extension...
[NR_EXT] Fetching license key from secret id <redacted>
[NR_EXT] Starting log server.
LOGS	Name: newrelic-lambda-extension	State: Subscribed	Types: [Platform]
EXTENSION	Name: newrelic-lambda-extension	State: Ready	Events: [INVOKE, SHUTDOWN]
START RequestId: 65fc5476-7586-4452-8280-cc0ad3891d4c Version: $LATEST
Hello New Relic
END RequestId: 65fc5476-7586-4452-8280-cc0ad3891d4c
REPORT RequestId: 65fc5476-7586-4452-8280-cc0ad3891d4c	Duration: 14799.66 ms	Billed Duration: 15021 ms	Memory Size: 128 MB	Max Memory Used: 41 MB	Init Duration: 221.25 ms	
[NR_EXT] New Relic Extension shutting down after 2 events
[NR_EXT] Log server terminating: http: Server closed
[NR_EXT] Extension shutdown after 342737ms

I understand that the NR lambda extension was waiting for telemetry until the timeout - 200ms as defined here. However, there were no obvious hints of possible misconfiguration.

Desired Behavior

In case of lambda code in the example A, the New Relic lambda layer outputs a warning indicating that no telemetry data was received after waiting x ms.

Additional context

In case of misconfiguration like this, I spent a few hours investigating the weird behaviour of lambda getting stuck. A warning message hinting towards possible misconfiguration would be great.

  • AWS lambda runtime: provided.al2
  • AWS runtime arch: arm64
  • Go version: 1.22.2
  • New Relic lambda layer: arn:aws:lambda:eu-west-1:451483290750:layer:NewRelicLambdaExtensionARM64:20

Metadata

Metadata

Labels

enhancementNew feature or request

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions