# apollo-metrics

> [![Build Status](https://travis-ci.org/dotellie/apollo-metrics.svg?branch=develop)](https://travis-ci.org/dotellie/apollo-metrics) [![npm](https://img.shields.io/npm/v/apollo-metrics)](https://www.npmjs.com/package/apollo-metrics)

Latest version **1.0.1** (published 2019-12-07) · MIT license · 0 weekly downloads

## Install

```sh
npm install apollo-metrics
pnpm add apollo-metrics
yarn add apollo-metrics
bun add apollo-metrics
```

## Health

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

Positive: has types; esm support; no vulnerabilities; high quality score.

Warnings: low downloads.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.1 |
| Published | 2019-12-07 |
| First published | 2019-12-07 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Dependencies | 2 |
| Unpacked size | 14.6 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 37 |
| Author | dotellie |
| Maintainers | dotellie |

## Links

- npm: https://www.npmjs.com/package/apollo-metrics
- Repository: https://github.com/dotellie/apollo-metrics
- Homepage: https://github.com/dotellie/apollo-metrics#readme
- Issues: https://github.com/dotellie/apollo-metrics/issues
- npm.io page: https://npm.io/package/apollo-metrics

## Dependencies (2)

- [apollo-tracing](https://npm.io/package/apollo-tracing.md) ^0.8.8
- [apollo-server-plugin-base](https://npm.io/package/apollo-server-plugin-base.md) ^0.6.8

## Recent versions

- 1.0.1 (latest) — 2019-12-07
- 1.0.0 — 2019-12-07

## README

# Apollo Server Metrics

[![Build Status](https://travis-ci.org/dotellie/apollo-metrics.svg?branch=develop)](https://travis-ci.org/dotellie/apollo-metrics)
[![npm](https://img.shields.io/npm/v/apollo-metrics)](https://www.npmjs.com/package/apollo-metrics)

Export Apollo server request information to Prometheus through
[prom-client](https://github.com/siimon/prom-client).

## Usage

```typescript
import { ApolloServer } from "apollo-server-express";
import express from "express";
import { register } from "prom-client";
import createMetricsPlugin from "apollo-metrics";

async function start(): Promise<void> {
  try {
    const app = express();

    app.get("/metrics", (_, res) => res.send(register.metrics());
    const apolloMetricsPlugin = createMetricsPlugin(register);

    const server = new ApolloServer({
      plugins: [apolloMetricsPlugin],
      // IMPORTANT: tracing needs to be enabled to get resolver and request timings!
      tracing: true
    });
    server.applyMiddleware({ app, path: "/" });

    app.listen(5000, () => console.log(`🚀 Service started`));
  } catch (error) {
    console.error("Failed to start!", error);
  }
}

start();
```

## License

MIT

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