npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

epip-typeorm-analyses

v0.0.36

Published

**EpipTypeormAnalyses** is a NestJS module that allows you to monitor and analyze the performance of your TypeORM queries by logging the average time and the number of executions for each query. The data is stored in Redis, and you can use tools like Graf

Downloads

238

Readme

EpipTypeormAnalyses

EpipTypeormAnalyses is a NestJS module that allows you to monitor and analyze the performance of your TypeORM queries by logging the average time and the number of executions for each query. The data is stored in Redis, and you can use tools like Grafana to visualize and report on the logged data.

Installation

To install the package, use the following npm command:

npm i epip-typeorm-analyses

Usage

To integrate the EpipTypeormAnalyses module into your NestJS application, you need to register it within your AppModule. The module requires two arguments to connect to your Redis instance: url and password. Here’s an example:

import { Module } from '@nestjs/common';
import { EpipTypeormAnalyses } from 'epip-typeorm-analyses';

@Module({
  imports: [
    // Other imports...
    EpipTypeormAnalyses.register({
      url: process.env.REDIS_URL,
      password: process.env.REDIS_PASS,
    }),
    // Other imports...
  ],
  // Other module metadata...
})
export class AppModule {}

In the above code:

  • url: The URL of your Redis instance. This is typically stored in the REDIS_URL environment variable.
  • password: The password for your Redis instance. This is typically stored in the REDIS_PASS environment variable.

Functionality

Once integrated, the EpipTypeormAnalyses module will log the average execution time and the number of executions for each TypeORM query to the specified Redis database.

Query Storage

Each query is hashed to create a unique identifier. This ensures that even if the same query is executed multiple times, it is consistently tracked using the same unique key in Redis. This unique hash is then used to store and update the performance metrics in Redis, ensuring that duplicate queries are correctly aggregated under the same entry.

Visualization and Reporting

You have two options to visualize and report the logged data:

  • Grafana Integration: You can use Grafana to create custom dashboards and reports based on the data logged by EpipTypeormAnalyses. Grafana’s powerful visualization tools allow you to monitor and analyze your application’s database performance effectively.

  • Pre-Built Reporting Tool: Alternatively, you can use a pre-built reporting tool developed by Mr. Mousavi, which is publicly available on GitLab. This tool provides various log visualization and reporting features out-of-the-box.

  1. Repository for the reporting tool: Analyse Backend(https://gitlab.com/bakhshabadi.javad/analyse-backend/)
  2. Repository by Mr. Mousavi: Mousavi’s GitLab Repo(https://gitlab.com/moein1378)

Alt Text

Conclusion

The EpipTypeormAnalyses module is a powerful tool for monitoring the performance of TypeORM queries in your NestJS application. By logging query metrics to Redis, it provides the foundation for detailed performance analysis and reporting using tools like Grafana or the pre-built reporting tool by Mr. Mousavi.

For more detailed instructions on how to use the reporting tool or to contribute to its development, please visit the linked repositories.