• /
  • EnglishEspañol日本語한국어Português
  • EntrarComeçar agora

Approaches to .NET serverless AWS Lambda performance monitoring

Unified visibility into the most detailed behaviors of your .NET Lambda functions is essential so you can understand what's going on in your serverless applications. This information enables you to troubleshoot and optimize your functions so they can work faster and deliver consistent results.

You can choose from two instrumentation approaches to get visibility into your .NET Lambda functions:

Use the tips below to help you decide which approach is best for you.

Feature comparison

The following table outlines the different requirements and capabilities of each approach:

New Relic .NET agent

AWS Distro for OpenTelemetry

Requires code changes

No

Yes

Needs tool for sending data

Yes

No

New Relic UI experience

Serverless

OpenTelemetry

Distributed tracing

Yes

Partial

Metrics

No

Yes

Transaction traces

Yes

N/A

Transaction events

Yes

Partial

Error events/spans

Yes

Yes

Span events or spans

Yes

Yes

SQL traces

Yes

N/A

Thread profiling

No

N/A

Vulnerability Management

No

N/A

External calls

Yes

Partial

Custom instrumentation using XML

No

No

Custom instrumentation using API

Yes (Agent)

Yes (OpenTelemetry)

Custom metrics

No

Yes

Custom events

Yes

N/A

Custom spans

Yes

Yes

Custom errors

Yes

No

Custom attributes

Yes

Yes

Logs

Yes

Yes

Legacy Cross application tracing

No

No

Info

Logs-in-context will be captured by the Lambda extension or CloudWatch, not by in-agent log forwarding.

New Relic .NET agent

Starting in agent version 10.26.0, the New Relic .NET agent supports instrumenting AWS Lambda functions. In most cases, the .NET agent will automatically instrument your AWS Lambda function. The benefit of using the agent is that in most cases, no code changes are required to monitor your lambda function.

In a Lambda function, the agent will switch into a "serverless mode" that will disable sending data directly to New Relic, as well as disable some other features. To send data to New Relic, you must either use the New Relic Lambda Extension (included in our .NET agent layer) or CloudWatch.

Since the agent automatically instruments most lambda functions, you can use the agent NuGet package to monitor your lambda functions. You need to manually configure environment variables for your chosen deployment method (see our installation guide). This still requires that you set up either the New Relic Lambda Extension or CloudWatch integration to send your data to New Relic.

Automatic instrumentation is available for the following AWS Lambda function types (as of agent version 10.29.0):

  • Amazon.Lambda.AspNetCoreServer.APIGatewayProxyFunction
  • Amazon.Lambda.AspNetCoreServer.APIGatewayHttpApiV2ProxyFunction
  • Amazon.Lambda.AspNetCoreServer.ApplicationLoadBalancerFunction

Limitations:

  • Generic lambda Methods are not instrumented automatically. If your lambda method is a generic method, such as Task<TResponse> MyMethod<TRequest, TResponse>(TRequest, ILambdaContext), the .NET agent is currently not able to instrument that method.
  • The Lambda Annotations Framework is currently not supported.
  • ApiGatewayV2 events are missing some context required for distributed tracing.
  • Outbound distributed tracing for different AWS SDK calls (such as SQS) are not supported.
  • If your Lambda function handler does not include an ILambdaContext parameter, the .NET agent will not be able to gather all of the expected information about your Lambda function.
  • .NET Lambda functions built with the Native AOT deployment method are not supported.

Importante

Serverless Framework Plugin Support for .NET Lambda functions begins in v5.3.0 of the serverless plugin. If you are running a version of the serverless plugin prior to v5.3.0, upgrading to v5.3.0 or later will automatically instrument your .NET Lambda functions. You can use the exclude statement in your serverless.yml to exclude functions from automatic instrumentation.

AWS Distro for OpenTelemetry (ADOT) Lambda Support For .NET

The OpenTelemetry Lambda instrumentation for .NET provides extension and tracing APIs you can use to instrument your Lambda function. ADOT is available as a layer to make it easier to install. The ADOT Lambda layer provides a reduced version of the AWS Distro for OpenTelemetry Collector, which can export OpenTelemetry data to New Relic. Instead of the Serverless UI experience, this approach will use the OpenTelemetry UI.

This method requires some initial manual configuration depending on your deployment method.

For installation details, see Trace your .NET Lambda functions with New Relic and OpenTelemetry.

Copyright © 2024 New Relic Inc.

This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.