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

@opentelemetry/instrumentation-redis

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-redis

OpenTelemetry instrumentation for `redis` v2 and v3 database client for Redis

  • 0.44.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
1.1M
increased by6.77%
Maintainers
3
Weekly downloads
 
Created

What is @opentelemetry/instrumentation-redis?

@opentelemetry/instrumentation-redis is an npm package that provides automatic tracing and monitoring for Redis operations using the OpenTelemetry framework. It helps developers gain insights into the performance and behavior of their Redis interactions by capturing and exporting telemetry data.

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

Automatic Tracing

This feature allows you to automatically trace Redis operations. By registering the RedisInstrumentation with the OpenTelemetry tracer provider, all Redis commands will be traced and telemetry data will be collected.

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

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

registerInstrumentations({
  instrumentations: [
    new RedisInstrumentation(),
  ],
  tracerProvider: provider,
});

Custom Span Attributes

This feature allows you to add custom attributes to the spans created for Redis operations. By using the responseHook option, you can capture additional information from the Redis response and add it to the span.

const { RedisInstrumentation } = require('@opentelemetry/instrumentation-redis');

const redisInstrumentation = new RedisInstrumentation({
  responseHook: (span, cmdName, cmdArgs, response) => {
    span.setAttribute('redis.response', response);
  },
});

Error Handling

This feature allows you to handle errors in Redis operations and record them in the span. By checking if the response is an instance of Error, you can set the span status to indicate an error occurred.

const { RedisInstrumentation } = require('@opentelemetry/instrumentation-redis');

const redisInstrumentation = new RedisInstrumentation({
  responseHook: (span, cmdName, cmdArgs, response) => {
    if (response instanceof Error) {
      span.setStatus({ code: 2, message: response.message });
    }
  },
});

Other packages similar to @opentelemetry/instrumentation-redis

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