Instrumenting .NET Serverless Applications Using the Datadog Forwarder

Overview

If you are a new user of Datadog Serverless, follow the instructions to instrument your Lambda functions using the Datadog Lambda Extension instead. If you have already set up Datadog Serverless with the Datadog Forwarder before Lambda offered out-of-the-box functionality, use this guide to maintain your instance.

Prerequisites

The Datadog Forwarder Lambda function is required to ingest AWS Lambda enhanced metrics, custom metrics, and logs.

Enable X-Ray tracing

  1. Enable AWS X-Ray active tracing for your Lambda function.
  2. Install the AWS X-Ray SDK for .NET.

Subscribe the Datadog Forwarder to log groups

Subscribe the Datadog Forwarder Lambda function to each of your function’s log groups to send metrics, traces, and logs to Datadog.

What’s next?

Monitor custom business logic

If you would like to submit a custom metric using the Datadog Forwarder, see the sample code below:

var myMetric = new Dictionary<string, object>();
myMetric.Add("m", "coffee_house.order_value");
myMetric.Add("v", 12.45);
myMetric.Add("e", (int)(DateTime.UtcNow - new DateTime(1970, 1, 1)).TotalSeconds);
myMetric.Add("t", new string[] {"product:latte", "order:online"});
LambdaLogger.Log(JsonConvert.SerializeObject(myMetric));