npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

opentelemetry-instrumentation-rhea

v1.1.0

Published

OpenTelemetry instrumentation for `rhea` AMQP 1.0 messaging client

Readme

opentelemetry-instrumentation-rhea

npm version npm downloads License

OpenTelemetry instrumentation for rhea (AMQP 1.0).

Why not amqplib instrumentation?

Existing OpenTelemetry instrumentation (@opentelemetry/instrumentation-amqplib) targets AMQP 0-9-1 (RabbitMQ via amqplib). This package focuses on AMQP 1.0, used by systems like Azure Service Bus, Azure Event Hubs, ActiveMQ Artemis, and Solace.

Install

npm install opentelemetry-instrumentation-rhea

Usage

Register the instrumentation before importing rhea. This is the standard OpenTelemetry pattern: the instrumentation must be registered before the target library is imported so it can hook into it.

// tracing.ts
import { NodeTracerProvider } from '@opentelemetry/sdk-trace-node';
import { registerInstrumentations } from '@opentelemetry/instrumentation';
import { RheaInstrumentation } from 'opentelemetry-instrumentation-rhea';

const provider = new NodeTracerProvider();
provider.register();

registerInstrumentations({
  instrumentations: [new RheaInstrumentation()],
});
// app.ts
import './tracing';
import rhea from 'rhea';

// Use rhea as usual - spans are created automatically

Example with Azure Service Bus

Since @azure/service-bus uses rhea internally, traces are created automatically:

import './tracing';
import { ServiceBusClient } from '@azure/service-bus';

const client = new ServiceBusClient(connectionString);
const sender = client.createSender('my-queue');

await sender.sendMessages({ body: 'hello' });
// -> traced automatically

Example with rhea directly

import './tracing';
import rhea from 'rhea';

const container = rhea.create_container();
const connection = container.connect({ host: 'localhost', port: 5672 });
const sender = connection.open_sender('my-queue');

sender.on('sendable', () => {
  sender.send({ body: 'hello' });
  // -> creates a "my-queue publish" span with context propagation
});

Configuration

| Option | Type | Default | Description | | --- | --- | --- | --- | | enabled | boolean | true | Enable/disable the instrumentation | | publishHook | (span, info) => void | - | Called before a publish span ends. Use to add custom attributes. | | consumeHook | (span, info) => void | - | Called when a message is consumed, before the user handler runs. | | consumeEndHook | (span, info) => void | - | Called when a consume span ends. | | useLinksForConsume | boolean | true | If true (default), consumer spans are new root traces with a link to the producer span. Set to false for parent-child behavior. |

Hook info objects

RheaPublishInfo: { msg, sender, connection }

RheaConsumeInfo: { msg, receiver, delivery, connection }

Semantic conventions

This package implements OpenTelemetry Messaging Semantic Conventions v1.29.0.

Note: Messaging semantic conventions are currently in Development status. When they are stabilized, this package will implement the OTEL_SEMCONV_STABILITY_OPT_IN migration path.

Span names

  • Publish: <destination> publish
  • Consume: <destination> process

Attributes

| Attribute | Value | | --- | --- | | messaging.system | amqp | | messaging.operation.name | publish or process | | messaging.operation.type | publish or process | | messaging.destination.name | Target/source address | | messaging.message.id | message.message_id (if present) | | messaging.message.conversation_id | message.correlation_id (if present) | | messaging.message.body.size | Payload size in bytes | | network.peer.address | Connection host | | network.peer.port | Connection port | | messaging.client.id | Container ID |

Context propagation

Trace context is propagated via AMQP 1.0 message.application_properties using the W3C Trace Context format (traceparent/tracestate).

Compatibility

This instrumentation hooks into rhea at runtime, so any library built on top of it is automatically instrumented:

  • rhea — direct usage
  • rhea-promise — the async/await wrapper around rhea
  • Azure SDK (@azure/event-hubs, @azure/service-bus) — which uses rhea-promise internally

Compatible with Azure Service Bus, Azure Event Hubs, ActiveMQ Artemis, Solace, and other AMQP 1.0-compliant brokers.

Note on Azure Service Bus internal spans

When used with Azure Service Bus, you may see additional spans for the $cbs AMQP link. This is the internal authentication mechanism used by the Azure SDK to exchange SAS tokens. These spans are legitimate AMQP operations instrumented by this package.

To filter them out in your application, use the publishHook and consumeHook:

new RheaInstrumentation({
  publishHook: (span, { sender }) => {
    if (sender.target?.address?.startsWith('$')) {
      span.setAttribute('messaging.azure.internal', true);
    }
  },
  consumeHook: (span, { receiver }) => {
    if (receiver.source?.address?.startsWith('$')) {
      span.setAttribute('messaging.azure.internal', true);
    }
  },
});

Supported versions

  • rhea: >=1.0.0 <4 (tested with v3.x)
  • Node.js: ^18.19.0 || >=20.6.0
  • @opentelemetry/api: ^1.0.0

Examples

See the examples/ folder for complete working examples.

License

Apache-2.0