# @amplication/plugin-observability-opentelemetry

> This plugin is created to add integrate opentelemetry to the amplication app

Latest version **2.0.8** (published 2024-02-26) · Apache-2.0 license · 0 weekly downloads

## Install

```sh
npm install @amplication/plugin-observability-opentelemetry
pnpm add @amplication/plugin-observability-opentelemetry
yarn add @amplication/plugin-observability-opentelemetry
bun add @amplication/plugin-observability-opentelemetry
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 2.0.8 |
| Published | 2024-02-26 |
| First published | 2023-09-08 |
| Weekly downloads | 0 |
| License | Apache-2.0 |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 83 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | Ashish Padhy |
| Maintainers | amplication-bot, mulygottlieb, levivannoort, overbit, barshimi, morhag, amitbarletz, yuvalhazaz |

## Links

- npm: https://www.npmjs.com/package/@amplication/plugin-observability-opentelemetry
- npm.io page: https://npm.io/package/@amplication/plugin-observability-opentelemetry

## Recent versions

- 2.0.8 (latest) — 2024-02-26
- 2.0.11-beta.pr-354.1e83d71 (beta) — 2024-03-12
- 2.0.11-beta.pr-354.31d30ce — 2024-03-12
- 2.0.10 — 2024-03-08
- 2.0.9 — 2024-03-08
- 2.0.7 — 2024-02-23
- 2.0.6 — 2024-02-19
- 2.0.5 — 2024-02-19
- 2.0.4 — 2023-12-28
- 2.0.2 — 2023-11-28
- 2.0.2-beta.pr-297.80f0b66 — 2023-11-28
- 2.0.1-beta.pr-295.e09faa7 — 2023-11-27
- 2.0.1-beta.pr-289.0d3954c — 2023-11-22
- 2.0.1 — 2023-11-01
- 2.0.0 — 2023-10-31
- … 1 more at https://npm.io/package/@amplication/plugin-observability-opentelemetry/versions

## README

# @amplication/plugin-observability-opentelemetry

[![NPM Downloads](https://img.shields.io/npm/dt/@amplication/plugin-observability-opentelemetry)](https://www.npmjs.com/package/@amplication/plugin-observability-opentelemetry)

This plugin helps in integrating Opentelemetry into your app generated by Amplication and sends the telemetry data to the [**Jaeger**](https://www.jaegertracing.io/docs/1.21/opentelemetry/) agent.

## Purpose

Provides a way to integrate opentelemetry into your app generated by Amplication by adding the required dependencies and configuration files. [**OpenTelemetry**](https://opentelemetry.io/) is a collection of tools, APIs, and SDKs used to instrument, generate, collect, and export telemetry data (metrics, logs, and traces) for analysis in order to understand your software's performance and behavior.
The implemented solution follow the jeager architecture with With OpenTelemetry Collector described here: https://www.jaegertracing.io/docs/1.54/architecture/#with-opentelemetry-collector

## Configuration

This plugin requires the following settings during plugin configuration:

- `serviceName` - The name of the service that will be used in the configuration file. It is optional and if not provided, the name of the app will be used.

- `OTEL_COLLECTOR_PORT_GRPC` - The port of the collector that will be used in the configuration file. Default value is `4317`.

- `OTEL_COLLECTOR_PORT_HTTP` - The port of the collector for http that will be used in the configuration file. Default value is `4316`.

- `JAEGER_AGENT_PORT` - The port of the jaeger agent that will be used in the configuration file. This exposes the jaeger agent UI to the port specified. Default value is `16686`

#### Example

```json
{
  "serviceName": "my-service",
  "OTEL_COLLECTOR_PORT_GRPC": "4317",
  "OTEL_COLLECTOR_PORT_HTTP": "4316",
  "JAEGER_AGENT_PORT": "16686"
}
```

## Working with the plugin

It can be used by adding the plugin in the `plugins` page of the app settings. The plugin can be added by providing the settings as shown in the [Configuration](#configuration) section.

Results in creating a `otel-config.yml` file in the root of the app. This file is used to configure the opentelemetry sdk. The file is created by using the [template](./src/static/otel-config.yml) file and replacing the placeholders with the values provided in the plugin configuration.

The plugin also adds the required dependencies in the `package.json` file and installs them.

This also creates the required environment variables in the `.env` file and a docker compose for setting up the jaeger agent and OpenTelemetry collector.

## Usage

Follow the steps below to use the created app. Make sure to have the prerequisites installed :- [Docker](https://docs.docker.com/get-docker/) and [Docker Compose](https://docs.docker.com/compose/install/).

#### Local development

1. Install the dependencies

```sh
npm install
```

2. Generate the prisma client

```sh
$ npm run prisma:generate
```

3.  Start the database, Jaeger agent and OpenTelemetry collector

```sh
$ npm run docker:dev
```

4. Start the app and see the traces in the Jaeger UI

```sh
# initialize the database
$ npm run db:init

# start the server component
$ npm run start
```

#### Production

```sh
# start the server component as a docker container
$ npm run compose:up
```

## Development

### `build`

Running `npm run build` will bundle your plugin with Webpack for production.

### `dev`

Running `npm run dev` will watch your plugin's source code and automatically bundle it with every change.

### `lint`

Running `npm run lint` will lint your plugin's source code. If run with `npm run lint:fix` it will also fix the linting errors.

### `prettier`

Running `npm run format:write` will format your plugin's source code.

---
_Source: https://npm.io/package/@amplication/plugin-observability-opentelemetry · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
