# @envelop/instrumentation

> This package contains utility functions and types to ease the use of instrumentation accross Envelop, Yoga, whatwg-node and Hive Gateway plugins.

Latest version **1.0.0** (published 2025-03-06) · MIT license · 0 weekly downloads

## Install

```sh
npm install @envelop/instrumentation
pnpm add @envelop/instrumentation
yarn add @envelop/instrumentation
bun add @envelop/instrumentation
```

## Health

**Score 45/100 (D)** — status: stable.

Positive: has types; esm support; no vulnerabilities.

Warnings: low downloads.

Negative: stale.

## Facts

| | |
|---|---|
| Version | 1.0.0 |
| Published | 2025-03-06 |
| First published | 2025-03-06 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Node | >=18.0.0 |
| Dependencies | 2 |
| Unpacked size | 14.6 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 827 |
| Author | Valentin Cocaud |
| Maintainers | dotansimha |

## Links

- npm: https://www.npmjs.com/package/@envelop/instrumentation
- Repository: https://github.com/n1ru4l/envelop
- Homepage: https://github.com/n1ru4l/envelop#readme
- Issues: https://github.com/n1ru4l/envelop/issues
- npm.io page: https://npm.io/package/@envelop/instrumentation

## Dependencies (2)

- [tslib](https://npm.io/package/tslib.md) ^2.5.0
- [@whatwg-node/promise-helpers](https://npm.io/package/@whatwg-node/promise-helpers.md) ^1.2.1

## Recent versions

- 1.0.0 (latest) — 2025-03-06
- 1.0.0-rc-20250306152642-f02839d206a88fa8ebab104fec74f8eca1874bc3 (rc) — 2025-03-06
- 1.0.0-alpha-20250306152310-8604b473d8a2cc9a1cc95d8d4bb0ddcfdc08a49a (alpha) — 2025-03-06
- 0.0.1-alpha-20250306143613-6c65ce45b6427a19190a3ccf4795017190b7d908 — 2025-03-06

## README

## `@envelop/instrumentation`

This package contains utility functions and types to ease the use of instrumentation accross
Envelop, Yoga, whatwg-node and Hive Gateway plugins.

> [!NOTE] Instrumentation are automatically composed together. This should only be used if the
> default ordering doesn't suit your needs (ie. instrumentation and hooks should be executed in
> different order)

## `composeInstrumentation(instrumentation: Instrumentation[]): Instrumentation`

This function composes all the instrumentation into one. The instrumentation will be called in the
same order as they are in the array (from top to bottom).

```ts
import { composeInstrumentation } from '@envelop/instrumentation'

// Extract instrumentation to compose from their plugins
const { instrumentation: instrumentation1, ...plugin1 } = usePlugin1()
const { instrumentation: instrumentation2, ...plugin2 } = usePlugin2()

const getEnveloped = envelop({
  plugins: [
    plugin1,
    plugin2,
    // Plugin instrumentation and plugin hooks will be executed in a different order
    { instrumentation: composeInstrumentation([instrumentation1, instrumentation2]) }
  ]
})
```

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