---
title: Instrumenting .NET Serverless Applications Using the Datadog Forwarder
description: Datadog, the leading service for cloud-scale monitoring.
breadcrumbs: >-
  Docs > Serverless > Serverless Monitoring Guides > Instrumenting .NET
  Serverless Applications Using the Datadog Forwarder
---

# Instrumenting .NET Serverless Applications Using the Datadog Forwarder

## Overview{% #overview %}

{% alert level="danger" %}
If you are a new user of Datadog Serverless, follow the [instructions to instrument your Lambda functions using the Datadog Lambda Extension](https://docs.datadoghq.com/serverless/installation/dotnet) 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.
{% /alert %}

## Prerequisites{% #prerequisites %}

The [Datadog Forwarder Lambda function](https://docs.datadoghq.com/serverless/forwarder) is required to ingest AWS Lambda enhanced metrics, custom metrics, and logs.

## Enable X-Ray tracing{% #enable-x-ray-tracing %}

1. Enable [AWS X-Ray active tracing](https://docs.aws.amazon.com/xray/latest/devguide/xray-services-lambda.html) for your Lambda function.
1. Install the [AWS X-Ray SDK for .NET](https://docs.aws.amazon.com/xray/latest/devguide/xray-sdk-dotnet.html).

## Subscribe the Datadog Forwarder to log groups{% #subscribe-the-datadog-forwarder-to-log-groups %}

[Subscribe](https://docs.datadoghq.com/logs/guide/send-aws-services-logs-with-the-datadog-lambda-function/) the Datadog Forwarder Lambda function to each of your function's log groups to send metrics, traces, and logs to Datadog.

## What's next?{% #whats-next %}

- You can now view metrics, logs, and traces on the [Serverless Homepage](https://app.datadoghq.com/functions).
- See the sample code to monitor custom business logic.
- See the [troubleshooting guide](https://docs.datadoghq.com/serverless/guide/troubleshoot_serverless_monitoring/) if you have trouble collecting the telemetry.

## Monitor custom business logic{% #monitor-custom-business-logic %}

If you would like to submit a [custom metric](https://docs.datadoghq.com/serverless/custom_metrics) using the Datadog Forwarder, see the sample code below:

```csharp
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));
```
