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

@opentelemetry/instrumentation-redis-4

Package Overview
Dependencies
Maintainers
3
Versions
30
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@opentelemetry/instrumentation-redis-4

OpenTelemetry instrumentation for `redis` v4 database client for Redis

  • 0.44.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
2M
decreased by-16.07%
Maintainers
3
Weekly downloads
 
Created

What is @opentelemetry/instrumentation-redis-4?

@opentelemetry/instrumentation-redis-4 is an OpenTelemetry instrumentation package for Redis version 4.x. It allows you to automatically collect and report telemetry data from your Redis operations, which can be used for monitoring, tracing, and performance analysis.

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

Automatic Tracing

This feature allows you to automatically trace Redis operations. The code sample demonstrates how to set up the OpenTelemetry NodeTracerProvider and register the Redis instrumentation. Once set up, Redis operations like `set` and `get` will be automatically traced.

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

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

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

const redis = require('redis');
const client = redis.createClient();

client.on('error', (err) => console.error('Redis Client Error', err));
client.connect();

client.set('key', 'value');
client.get('key', (err, reply) => {
  console.log(reply); // 'value'
});

Custom Span Attributes

This feature allows you to add custom attributes to spans. The code sample demonstrates how to set up a response hook that adds the length of the Redis response as a custom attribute to the span.

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

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

registerInstrumentations({
  instrumentations: [
    new RedisInstrumentation({
      responseHook: (span, response) => {
        span.setAttribute('redis.response_length', response.length);
      },
    }),
  ],
});

const redis = require('redis');
const client = redis.createClient();

client.on('error', (err) => console.error('Redis Client Error', err));
client.connect();

client.set('key', 'value');
client.get('key', (err, reply) => {
  console.log(reply); // 'value'
});

Other packages similar to @opentelemetry/instrumentation-redis-4

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