# Migrate Python OpenTelemetry APM

## Install API and SDK Packages

Run these install commands to install both packages:

```console
pip install opentelemetry-api
pip install opentelemetry-sdk
```

## Set Up Instrumentation

OpenTelemetry documentation for [Traces](https://opentelemetry.io/docs/languages/python/instrumentation/#traces) clearly describes the basic steps for initializing a tracer and creating spans.

While New Relic supports automatic instrumentation of functions through the `config` file using [Python agent configuration](https://docs.newrelic.com/docs/apm/agents/python-agent/configuration/python-agent-configuration/#txn-tracer-function), OpenTelemetry **does not** have such support. However, you can easily create function spans with minimal code using function [decorators](https://opentelemetry.io/docs/languages/python/instrumentation/#creating-spans-with-decorators).

## Instrumentation Libraries

We recommend that you review the available OpenTelemetry [instrumentation libraries](https://opentelemetry.io/docs/languages/python/libraries/) to automatically instrument standard Python packages.

See the [list and code](https://github.com/open-telemetry/opentelemetry-python-contrib/tree/main/instrumentation#readme) for available instrumentation libraries on GitHub.

## Examples

Common code scenarios and some example applications have been instrumented using OpenTelemetry, and shared in the OpenTelemetry documentation stack. See [Examples](https://opentelemetry-python.readthedocs.io/en/stable/examples/) and [Cookbook](https://opentelemetry.io/docs/languages/python/cookbook/).
