# @autometrics/autometrics

> Easily add metrics to your system -- and actually understand them using automatically customized Prometheus queries

Latest version **1.0.1** (published 2024-02-28) · MIT license · 0 weekly downloads

## Install

```sh
npm install @autometrics/autometrics
pnpm add @autometrics/autometrics
yarn add @autometrics/autometrics
bun add @autometrics/autometrics
```

## Health

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

Positive: has types; esm support; no vulnerabilities.

Warnings: low downloads.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.1 |
| Published | 2024-02-28 |
| First published | 2023-02-20 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Node | >=16.0.0 |
| Dependencies | 2 |
| Unpacked size | 143.7 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 145 |
| Author | Fiberplane |
| Maintainers | oscarvz, arendjr, fiberplane-admin, bretterplane, keturiosakys |

## Links

- npm: https://www.npmjs.com/package/@autometrics/autometrics
- Repository: https://github.com/autometrics-dev/autometrics-ts
- Homepage: https://github.com/autometrics-dev/autometrics-ts#readme
- Issues: https://github.com/autometrics-dev/autometrics-ts/issues
- npm.io page: https://npm.io/package/@autometrics/autometrics

## Dependencies (2)

- [@opentelemetry/api](https://npm.io/package/@opentelemetry/api.md) 1.7.0
- [@opentelemetry/sdk-metrics](https://npm.io/package/@opentelemetry/sdk-metrics.md) 1.18.0

## Recent versions

- 1.0.1 (latest) — 2024-02-28
- 0.7.2-beta.0 (beta) — 2023-10-03
- 1.0.0 — 2023-12-05
- 0.7.0 — 2023-09-28
- 0.7.0-beta11 — 2023-09-26
- 0.7.0-beta10 — 2023-09-07
- 0.7.0-beta9 — 2023-09-07
- 0.7.0-beta8 — 2023-09-07
- 0.7.0-beta7 — 2023-09-07
- 0.7.0-beta6 — 2023-09-07
- 0.7.0-beta5 — 2023-09-06
- 0.7.0-beta4 — 2023-09-06
- 0.7.0-beta3 — 2023-09-04
- 0.7.0-beta2 — 2023-08-15
- 0.7.0-beta — 2023-08-03
- … 9 more at https://npm.io/package/@autometrics/autometrics/versions

## README

# `@autometrics/autometrics` 📈✨

This is the official TypeScript implementation for https://autometrics.dev/.

## Documentation

Full documentation for the `@autometrics/autometrics` library can be found here:
https://github.com/autometrics-dev/autometrics-ts

## Recipe: Server-side example with Prometheus

### Installation

```shell
# npm
npm install @autometrics/autometrics @autometrics/exporter-prometheus

# yarn
yarn add @autometrics/autometrics @autometrics/exporter-prometheus

# pnpm
pnpm add @autometrics/autometrics @autometrics/exporter-prometheus
```

### Usage

1. Anywhere in your source code:

```typescript
import { autometrics } from "@autometrics/autometrics";
import { init } from "@autometrics/exporter-prometheus";

init(); // starts the webserver with the `/metrics` endpoint on port 9464

async function createUserRaw(payload: User) {
  // ...
}

const createUser = autometrics(createUserRaw);
//    ^ instrumented function
```

## Recipe: Client-side example with the OpenTelemetry Collector

### Installation

```shell
# npm
npm install @autometrics/autometrics @autometrics/exporter-otlp-http

# yarn
yarn add @autometrics/autometrics @autometrics/exporter-otlp-http

# pnpm
pnpm add @autometrics/autometrics @autometrics/exporter-otlp-http
```

### Usage

1. Anywhere in your source code:

```typescript
import { autometrics } from "@autometrics/autometrics";
import { init } from "@autometrics/exporter-otlp-http";

init({ url: "https://<your-otel-collector>" });

async function createUserRaw(payload: User) {
  // ...
}

const createUser = autometrics(createUserRaw);
//    ^ instrumented function
```

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