🚀 Socket Launch Week Day 5:Introducing Repository Access Permissions and Custom Roles.Learn more
Sign In

@metis-data/sequelize-interceptor

Package Overview
Dependencies
Maintainers
1
Versions
24
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@metis-data/sequelize-interceptor

Intercept sequelize queries using OpenTelemetry and enrich spans

latest
Source
npmnpm
Version
2.3.1
Version published
Weekly downloads
7
-87.04%
Maintainers
1
Weekly downloads
 
Created
Source

@metis-data/sequelize-interceptor

Intercept sequelize queries using OpenTelemetry and enrich spans.

Usage

Create a Sequelize instrumentation object using getSequelizeInstrumentation function.

The Sequelize instance passed to this function will NOT be instrumented. It is only used for getting the execution plans from the database.

The rest are optional parameters. You can switch between Actual and Estimated plans collection using PlanType. Internal errors can be collected using the errorHandler function. Plan collection can be disabled using a flag.

import { PlanType } from '@metis-data/base-interceptor';
import { getSequelizeInstrumentation } from '@metis-data/sequelize-interceptor';

// Create the instrumentation object to use with Open Telemetry.
const sequelizeInstrumentation = getSequelizeInstrumentation(
  sequelize, // The sequelize instance, not instrumented.
  PlanType.ESTIMATED, // the type of plan to get, default to Estimated.
  console.error, // error handler, exception are still sent to metis' Sentry account.
  true, // Collect plans and add them to spans. default to true.
);

Add the instrumentation to your existing OpenTelemetry setup.

registerInstrumentations({
  ...
  instrumentations: [..., sequelizeInstrumentation],
});

Known Issues

CommonJS and ES Modules.

Currently this package can only be used in CommonJS modules, and it will not work with ES modules. The issue stems from the fact that we need to provide a Sequelize instance to the instrumentation. That means we need to import Sequelize, and that causes issues with the patching of Sequelize. To solve this issue we clear the required cache internally when instrument is called.

Typescript can be used, but it needs to target CommonJS.

FAQs

Package last updated on 16 Feb 2023

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