# opentelemetry-instrumentation-amqplib

> open telemetry instrumentation for the `amqplib` package

Latest version **0.27.1** (published 2022-04-13) · Apache-2.0 license · 0 weekly downloads

> **Deprecated.** This package is deprecated.

## Install

```sh
npm install opentelemetry-instrumentation-amqplib
pnpm add opentelemetry-instrumentation-amqplib
yarn add opentelemetry-instrumentation-amqplib
bun add opentelemetry-instrumentation-amqplib
```

## Health

**Score 10/100 (F)** — status: deprecated.

Negative: deprecated.

## Facts

| | |
|---|---|
| Version | 0.27.1 |
| Published | 2022-04-13 |
| First published | 2021-03-09 |
| Weekly downloads | 0 |
| License | Apache-2.0 |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 2 |
| Unpacked size | 110.1 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Maintainers | aspecto-release-bot |
| Keywords | amqplib, opentelemetry, rabbitmq, AMQP 0-9-1 |

## Links

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

## Dependencies (2)

- [@opentelemetry/instrumentation](https://npm.io/package/@opentelemetry/instrumentation.md) ^0.27.0
- [@opentelemetry/semantic-conventions](https://npm.io/package/@opentelemetry/semantic-conventions.md) ^1.0.0

## Recent versions

- 0.27.1 (latest) — 2022-04-13
- 0.0.0-2022-04-13--14-32 (alpha) — 2022-04-13
- 0.4.1-aws-import-one-serivce.0 (canary) — 2021-04-28
- 0.2.2 (dev) — 2021-03-09
- 0.27.0 — 2021-12-27
- 0.0.0-2021-12-26--12-31 — 2021-12-26
- 0.0.0-2021-12-26--12-22 — 2021-12-26
- 0.0.0-2021-12-22--14-33 — 2021-12-22
- 0.0.0-2021-12-21--15-57 — 2021-12-21
- 0.0.0-2021-12-20--13-41 — 2021-12-20
- 0.0.0-2021-12-15--16-17 — 2021-12-15
- 0.0.0-2021-12-15--13-29 — 2021-12-15
- 0.0.0-2021-12-15--13-05 — 2021-12-15
- 0.0.0-2021-12-15--12-47 — 2021-12-15
- 0.26.1 — 2021-11-29
- … 34 more at https://npm.io/package/opentelemetry-instrumentation-amqplib/versions

## README

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

This module provides automatic instrumentation for [`amqplib`](https://github.com/squaremo/amqp.node).

## Installation

```
npm install --save opentelemetry-instrumentation-amqplib
```

## 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 { AmqplibInstrumentation } = require('opentelemetry-instrumentation-amqplib');

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

### amqplib Instrumentation Options

amqplib instrumentation has few options available to choose from. You can set the following:

| Options        | Type                                   | Description                                                                                     |
| -------------- | -------------------------------------- | ----------------------------------------------------------------------------------------------- |
| `publishHook` | `AmqplibPublishCustomAttributeFunction` | hook for adding custom attributes before publish message is sent |
| `consumeHook` | `AmqplibConsumerCustomAttributeFunction` | hook for adding custom attributes before consumer message is processed |
| `consumeEndHook` | `AmqplibConsumerEndCustomAttributeFunction` | hook for adding custom attributes after consumer message is acked to server |
| `moduleVersionAttributeName` | `string` | If passed, a span attribute will be added to all spans with key of the provided `moduleVersionAttributeName` and value of the patched module version |
| `consumeTimeoutMs` | `number` | default is 1 minute. read [description below](#InstrumentationTimeout)|
---

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

## Implementation Issues

### Instrumentation Timeout
The instrumentation is keeping track on open consumed messages which are not acked yet to support `ackAll`/`allUpTo` etc features.

Saving a reference, means the msg will not be garbage collected if user forget about it
and never ack the msg.
To insure we don't leak memory, the instrumentation has internal timeout **which is not
correlated to the server timeout if one is set**, and which will trigger ending the span when reached.
This timeout is by default set to 1 minute, and should be reviewed in each use case, for example if handling consumed messages is expected to take more than 1 minute.
If you want to disable this behavior, set `consumeTimeoutMs` to `null` or `0`.

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