# opentelemetry-instrumentation-node-cache

> open telemetry instrumentation for the `node-cache`

Latest version **0.41.0** (published 2024-05-21) · Apache-2.0 license · 0 weekly downloads

## Install

```sh
npm install opentelemetry-instrumentation-node-cache
pnpm add opentelemetry-instrumentation-node-cache
yarn add opentelemetry-instrumentation-node-cache
bun add opentelemetry-instrumentation-node-cache
```

## Health

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

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

Warnings: low downloads; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.41.0 |
| Published | 2024-05-21 |
| First published | 2021-07-04 |
| Weekly downloads | 0 |
| License | Apache-2.0 |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 4 |
| Unpacked size | 62.8 KB |
| Known vulnerabilities | 0 (+1 in 1 direct dependencies) |
| Install scripts | no |
| GitHub stars | 168 |
| Author | Aspecto |
| Maintainers | aspecto-release-bot |
| Keywords | node-cache, opentelemetry |

## Links

- npm: https://www.npmjs.com/package/opentelemetry-instrumentation-node-cache
- Repository: https://github.com/aspecto-io/opentelemetry-ext-js
- Issues: https://github.com/aspecto-io/opentelemetry-ext-js/issues
- npm.io page: https://npm.io/package/opentelemetry-instrumentation-node-cache

## Dependencies (4)

- [@opentelemetry/core](https://npm.io/package/@opentelemetry/core.md) ^1.24.1
- [@opentelemetry/instrumentation](https://npm.io/package/@opentelemetry/instrumentation.md) ^0.51.1
- [@opentelemetry/contrib-test-utils](https://npm.io/package/@opentelemetry/contrib-test-utils.md) ^0.39.0
- [@opentelemetry/semantic-conventions](https://npm.io/package/@opentelemetry/semantic-conventions.md) ^1.24.1

## Alternatives

- [memory-cache](https://npm.io/package/memory-cache.md) — 795.0K weekly downloads
- [@httptoolkit/proxy-agent](https://npm.io/package/@httptoolkit/proxy-agent.md) — 11.2K weekly downloads
- [express-cache-controller](https://npm.io/package/express-cache-controller.md) — 5.3K weekly downloads
- [http-cache-middleware](https://npm.io/package/http-cache-middleware.md) — 4.5K weekly downloads
- [cache2](https://npm.io/package/cache2.md) — 1.5K weekly downloads

## Recent versions

- 0.41.0 (latest) — 2024-05-21
- 0.0.0-2024-05-16--12-47 (alpha) — 2024-05-16
- 0.40.0 — 2023-10-17
- 0.0.0-2023-10-17--13-06 — 2023-10-17
- 0.39.1 — 2023-07-27
- 0.35.1 — 2023-07-27
- 0.0.0-2023-07-26--14-48 — 2023-07-26
- 0.35.0 — 2023-03-01
- 0.34.0 — 2022-11-21
- 0.32.0 — 2022-10-18
- 0.0.0-2022-07-11--08-09 — 2022-07-11
- 0.29.0 — 2022-06-28
- 0.28.0 — 2022-06-02
- 0.27.1 — 2022-04-13
- 0.0.0-2022-04-13--14-32 — 2022-04-13
- … 20 more at https://npm.io/package/opentelemetry-instrumentation-node-cache/versions

## README

# OpenTelemetry node-cache Instrumentation for Node.js
[![NPM version](https://img.shields.io/npm/v/opentelemetry-instrumentation-node-cache.svg)](https://www.npmjs.com/package/opentelemetry-instrumentation-node-cache)

This module provides automatic instrumentation for [`node-cache`](https://www.npmjs.com/package/node-cache).  
> Supports versions **>=5.0.0** of node-cache

## Installation

```
npm install --save opentelemetry-instrumentation-node-cache
```

## Usage
For further automatic instrumentation instruction see the [@opentelemetry/instrumentation](https://github.com/open-telemetry/opentelemetry-js/tree/main/packages/opentelemetry-instrumentation) package.

```js
const { NodeTracerProvider } = require('@opentelemetry/sdk-trace-node');
const { registerInstrumentations } = require('@opentelemetry/instrumentation');
const { NodeCacheInstrumentation } = require('opentelemetry-instrumentation-node-cache');

registerInstrumentations({
  tracerProvider,
  instrumentations: [
    new NodeCacheInstrumentation({
      // see under for available configuration
    })
  ]
});
```

### node-cache Instrumentation Options

node-cache instrumentation has few options available to choose from. You can set the following:

| Option | Type  | Description |
| --- | --- | --- |
| `requestHook` | function | Hook for adding custom attributes before express start handling the request. Receives params: `span, { moduleVersion, operation, args }` |
| `responseHook` | function | Hook called before response is returned, which allows to add custom attributes to span.<br>Function receive params: `span, { operation, response }` |
| `requireParentSpan` | `boolean` | Set to true if you only want to trace operation which has parent spans |

See the [tests](./test/node-cache.spec.ts) for config usage example.


---

This extension (and many others) was developed by [Aspecto](https://www.aspecto.io/) with ❤️

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