Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@opentelemetry/instrumentation-ioredis

Package Overview
Dependencies
Maintainers
3
Versions
41
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@opentelemetry/instrumentation-ioredis

OpenTelemetry ioredis automatic instrumentation package.

  • 0.40.0
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
2.4M
decreased by-3.41%
Maintainers
3
Weekly downloads
 
Created

What is @opentelemetry/instrumentation-ioredis?

@opentelemetry/instrumentation-ioredis is an npm package that provides automatic tracing and monitoring for applications using the ioredis library. It integrates with OpenTelemetry to collect and report metrics and traces for Redis operations, helping developers gain insights into the performance and behavior of their Redis interactions.

What are @opentelemetry/instrumentation-ioredis's main functionalities?

Automatic Tracing

This feature allows you to automatically trace Redis operations using the ioredis library. The code sample demonstrates how to set up the OpenTelemetry NodeTracerProvider and register the IORedisInstrumentation to start collecting traces for Redis commands.

const { NodeTracerProvider } = require('@opentelemetry/node');
const { registerInstrumentations } = require('@opentelemetry/instrumentation');
const { IORedisInstrumentation } = require('@opentelemetry/instrumentation-ioredis');

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

registerInstrumentations({
  instrumentations: [
    new IORedisInstrumentation(),
  ],
});

const Redis = require('ioredis');
const redis = new Redis();

redis.set('key', 'value');
redis.get('key', (err, result) => {
  console.log(result);
});

Custom Attributes

This feature allows you to add custom attributes to the spans created for Redis operations. The code sample shows how to use the responseHook option to add the Redis response as an attribute to the span.

const { IORedisInstrumentation } = require('@opentelemetry/instrumentation-ioredis');

const instrumentation = new IORedisInstrumentation({
  responseHook: (span, cmdName, args, response) => {
    span.setAttribute('redis.response', response);
  },
});

const { NodeTracerProvider } = require('@opentelemetry/node');
const { registerInstrumentations } = require('@opentelemetry/instrumentation');

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

registerInstrumentations({
  instrumentations: [instrumentation],
});

const Redis = require('ioredis');
const redis = new Redis();

redis.set('key', 'value');
redis.get('key', (err, result) => {
  console.log(result);
});

Other packages similar to @opentelemetry/instrumentation-ioredis

Keywords

FAQs

Package last updated on 25 Apr 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc