Instrumenting .NET Applications

Instrumenting .NET Applications

Required setup

If not already configured:

After you have installed the AWS integration and the Datadog Forwarder, follow these steps to instrument your application to send metrics, logs, and traces to Datadog.

Configuration

Configure the function

  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 the log groups

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

  1. Install the Datadog Forwarder if you haven’t.
  2. Subscribe the Datadog Forwarder to your function’s log groups.

Unified service tagging

Although it’s optional, Datadog highly recommends tagging you serverless applications with the env, service, and version tags following the unified service tagging documentation.

Explore Datadog serverless monitoring

After you have configured your function following the steps above, you should be able to view metrics, logs and traces on the Serverless homepage.

Monitor custom business logic

If you would like to submit a custom metric, 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));

For more information on custom metric submission, see here.

Further Reading