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
42
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@opentelemetry/instrumentation-ioredis

OpenTelemetry instrumentation for `ioredis` database redis client for Redis

  • 0.45.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
2M
decreased by-16.78%
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 18 Nov 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