# JavaScript OpenTelemetry APM

Complete these tasks to properly integrate OpenTelemetry APM in JavaScript:

- [Install](https://docs.kloudfuse.com/platform/3.5.0/agent-otel-migrate-javascript/#install)
- [Set Up Instrumentation](https://docs.kloudfuse.com/platform/3.5.0/agent-otel-migrate-javascript/#set-up)
- [Instrumentation Libraries](https://docs.kloudfuse.com/platform/3.5.0/agent-otel-migrate-javascript/#libraries)
- [Examples](https://docs.kloudfuse.com/platform/3.5.0/agent-otel-migrate-javascript/#examples)

## Install

Run these install commands to install JavaScript packages:

```console
npm install @opentelemetry/sdk-node \
  @opentelemetry/api \
  @opentelemetry/auto-instrumentations-node \
  @opentelemetry/sdk-metrics \
  @opentelemetry/sdk-trace-node
```

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/js/instrumentation/#manual-instrumentation-setup):

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

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/3.5.0/agent-otel-migrate-javascript/#libraries).

## Instrumentation Libraries

OpenTelemetry JavaScript can automatically instrument and support a number of libraries, frameworks, and application servers, as separate NPN packages. We recommend that you review the available OpenTelemetry [Registry for JavaScript](https://opentelemetry.io/ecosystem/registry/?language=js&component=instrumentation).

## Examples

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