# Migrate .Net OpenTelemetry APM

Complete these tasks to properly integrate OpenTelemetry APM in .Net:

- [Install](https://docs.kloudfuse.com/platform/4.0.2/data-collection/agents/otel/migrate-dotnet/#install)
- [Set Up Instrumentation](https://docs.kloudfuse.com/platform/4.0.2/data-collection/agents/otel/migrate-dotnet/#set-up)
- [Instrumentation Libraries](https://docs.kloudfuse.com/platform/4.0.2/data-collection/agents/otel/migrate-dotnet/#libraries)
- [Examples](https://docs.kloudfuse.com/platform/4.0.2/data-collection/agents/otel/migrate-dotnet/#examples)

## Install

Run these install commands to install .Net packages:

```console
dotnet add package OpenTelemetry.Extensions.Hosting
dotnet add package OpenTelemetry.Instrumentation.AspNetCore
dotnet add package OpenTelemetry.Exporter.Console
```

Copied!

## Set Up Instrumentation

To set up the instrumentation and use the APIs for manual instrumentation, follow these steps from the see OpenTelemetry’s documentation of [Manual Instrumentation Setup](https://opentelemetry.io/docs/languages/net/instrumentation/#manual-instrumentation-setup):

1. [Initialize the SDK](https://opentelemetry.io/docs/languages/net/instrumentation/#initialize-the-sdk)
2. [Initialize tracing](https://opentelemetry.io/docs/languages/net/instrumentation/#initialize-tracing)
3. [Create activities](https://opentelemetry.io/docs/languages/net/instrumentation/#create-activities)

For creating spans using the OpenTelemetry JS API, use the following OpenTelemetry documentation: [Initialize Tracing](https://opentelemetry.io/docs/languages/js/instrumentation/#initialize-tracing).

To use auto-instrumentation instead of manually creating spans for your functions, explore the [Instrumentation Libraries](https://docs.kloudfuse.com/platform/4.0.2/data-collection/agents/otel/migrate-dotnet/#libraries).

## Instrumentation Libraries

OpenTelemetry .Net can automatically instrument and support apps.

We recommend that you review the OpenTelemetry instruction on [Using instrumentation libraries](https://opentelemetry.io/docs/languages/net/libraries/) to automatically instrument standard .Net packages.

Also, review the available OpenTelemetry [Registry for .Net](https://opentelemetry.io/ecosystem/registry/?language=dotnet) and [OpenTelemetry .NET](https://github.com/open-telemetry/opentelemetry-dotnet) on GitHub.

## Examples

You can use a set of fully-functional, working examples of OpenTelemetry for .Net from [OpenTelemetry .Net Examples](https://github.com/open-telemetry/opentelemetry-dotnet/tree/main/examples). You can run them locally.
