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 🙏

© 2024 – Pkg Stats / Ryan Hefner

instrumentation-arnavmq

v1.0.2

Published

OpenTelemetry automatic instrumentation for the `arnavmq` package

Downloads

3,257

Readme

Instrumentation Arnavmq

An OpenTelemetry automatic instrumentation implementation, providing tracing for the arnavmq package on nodejs.

Compatibility

Compatible with arnavmq v0.16.0 and later, as the package relies on the hooks api introduced there.

Installation

In order to use this tracing library, you will also need to install the opentelemetry nodjes tracing package (https://github.com/open-telemetry/opentelemetry-js/tree/main/packages/opentelemetry-sdk-trace-node), and of course, the arnavmq package itself.

# the instrumented package
npm install --save arnavmq
# install opentelemetry nodejs tracing
npm install --save @opentelemetry/api @opentelemetry/sdk-trace-node
# Install the package itself
npm install --save instrumentation-arnavmq

Usage

const { NodeTracerProvider } = require('@opentelemetry/sdk-trace-node');
const { registerInstrumentations } = require('@opentelemetry/instrumentation');
const { ArnavmqInstrumentation } = require('instrumentation-arnavmq');

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

registerInstrumentations({
  instrumentations: [
    new ArnavmqInstrumentation(
      // You can add your own custom attributes to the span by registering a hook. Each hook is invoked with the relevant span and info about the operation. See the types for the info properties for each hook.
      {
        // called from the producer before producing a message.
        produceHook: (span, info) => {},
        // called from the consumer upon receiving a message, before invoking the "consume callback" on the message. The info includes various details about the message.
        consumeHook: (span, info) => {},
        // called from the consumer after finished processing an RPC request, before producing a reply. Called with info about both the request message and the reply message.
        rpcResponseHook: (span, info) => {},
      },
    ),
  ],
});

In order for the instrumentation to be collected you will also need to setup nodejs instrumentation as per the opentelemetry official guide: https://opentelemetry.io/docs/languages/js/getting-started/nodejs/#setup

Also see the example.

Spans

This implementation attempts to follow the OpenTelemetry Semantic Conventions 1.24.0 for Messaging Spans specification when applicable, and the spans have the attributes specified there for the most part.

The created spans and their relations are described as follows, with the span types and hierarchy:

Regular Produce-Consume

Since normally there is only a single published message, the create and publish spans will have the exact same length.

Normally this would mean there should be only a single publish span with now create, but in case of publication failure and retry, there would be multiple publish spans under the create span.

All the attributes are on the parent create span, with the chile publish spans only holding the custom messaging.rabbitmq.message.retry_number attribute in addition to the messaging.operation attribute.

 PUBLISH (root, producer)
|---------|
            RECEIVE (consumer)
           |---------|

On Disconnect, Retry Produce

When configured to retry publication when disconnected from the server, Will not create a new span, but instead add events for the error and retry start when they occur.

The number of total publish retries until the produce succeeds is added to the sapn on the messaging.rabbitmq.message.reconnect_retry_number attribute, with each retry event having it set to the current retry.

 PUBLISH (root, producer)
|----(error, retry event)----(error, retry event)----(reconnected)--|
                                                                      RECEIVE (consumer)
                                                                     |---------|

RPC

On RPC requests, the publish span is not closed until a response is received from the consumer.

A custom "messaging.rabbitmq.message.rpc": true attribute is added to the span.

 PUBLISH (root, producer, ends when replied)
|-----------------------------|
            RECEIVE (consumer)
           |---------|
                       PUBLISH (consumer, reply)
                      |-------|