or run

npx @tessl/cli init
Log in

Version

Tile

Overview

Evals

Files

Files

docs

aws-lambda.mdbrowser-monitoring.mdcustom-attributes.mdcustom-instrumentation.mddistributed-tracing.mderror-handling.mdindex.mdllm-monitoring.mdmetrics-events.mdsegments-timing.mdtransaction-management.mdurl-naming-rules.mdutilities.md

aws-lambda.mddocs/

0

# AWS Lambda Support

1

2

Serverless monitoring capabilities for AWS Lambda functions with automatic cold start detection.

3

4

## Capabilities

5

6

### Set Lambda Handler

7

8

Wrap AWS Lambda handler function for serverless monitoring.

9

10

```javascript { .api }

11

/**

12

* Wrap AWS Lambda handler for serverless monitoring with automatic transaction management

13

* @param {Function} handler - Original Lambda handler function

14

* @returns {Function} Wrapped handler with New Relic instrumentation

15

*/

16

function setLambdaHandler(handler);

17

```

18

19

**Usage Examples:**

20

21

```javascript

22

const newrelic = require('newrelic');

23

24

// Basic Lambda handler wrapping

25

exports.handler = newrelic.setLambdaHandler((event, context, callback) => {

26

// Your Lambda function logic

27

const result = processEvent(event);

28

callback(null, result);

29

});

30

31

// Async Lambda handler

32

exports.handler = newrelic.setLambdaHandler(async (event, context) => {

33

// Async processing

34

const data = await fetchData(event.id);

35

const processed = await processData(data);

36

37

return {

38

statusCode: 200,

39

body: JSON.stringify(processed)

40

};

41

});

42

43

// Lambda handler with custom attributes

44

exports.handler = newrelic.setLambdaHandler(async (event, context) => {

45

// Add Lambda-specific attributes

46

newrelic.addCustomAttributes({

47

lambdaRequestId: context.awsRequestId,

48

functionName: context.functionName,

49

remainingTime: context.getRemainingTimeInMillis()

50

});

51

52

return processLambdaEvent(event);

53

});

54

```

55

56

## Lambda-Specific Features

57

58

The wrapped handler automatically:

59

- Creates transactions for each Lambda invocation

60

- Detects cold starts

61

- Captures Lambda context information

62

- Handles both callback and async/await patterns

63

- Reports invocation duration and memory usage

64

- Manages transaction lifecycle automatically

65

66

## Configuration

67

68

Lambda monitoring works best with:

69

- `NEW_RELIC_SERVERLESS_MODE_ENABLED=true`

70

- Appropriate Lambda layer or deployment package

71

- Sufficient memory allocation for the agent overhead