GithubHelp home page GithubHelp logo

nuxt-prometheus's Issues

feature request: allow Nuxt Bridge

Can you please add nuxt 2.16+ with bridge enabled into module constraints? When Nitro enabled, current version is working as expected, unlike @artmizu/analytics-nuxt-2

Invariant Violation: Failed to Patch the 'fetch' Module: Already Patched

I encountered an Invariant Violation when attempting to patch the fetch module while using the this module. The error message indicates that the module has already been patched.

It seems like there's a conflict or a repeated attempt to patch the fetch module within the interceptors setup. This issue appeared after updating to the latest version of the nuxt-prometheus module.

Error Message

Invariant Violation
Failed to patch the 'fetch' module: already patched.

prevent access from the internet?

hi,
maybe i am doing it wrong but could it be that /metrics is exposed to the internet? if so, is there a way to prevent that? i thought about a nuxt middleware but it seems that the metrics endpoint is intercepted way earlier, before getting to nuxt and therefore ignoring the middleware.

did i miss a setting?

Uninstall Problem

I installed the module, then I realized that we did not need it. I then uninstalled the package. So now when I run 'npm run dev', I then get this message popping up several times every 15 seconds or so ' WARN [Vue Router warn]: No match found for location with path "/metrics". I have deleted the .nuxt folder, the pnpm-lock file, and the node_modules folder. I have removed the reference in the modules list in nuxt.config file. Then I ran pnpm install and npm run dev. And I still get this warning message.

Bug: calculation of request time sum

Found invalid calculation of total requests time in your calculateTime

export function calculateTime(data: AnalyticsModuleState) {

Ruined test cases are the second and last.

Test cases
{
      input: [
        { start: 1, end: 10 },
        { start: 5, end: 7 },
        { start: 15, end: 30 },
      ],
      res: 24,
    },
    {
      input: [
        { start: 100, end: 101 },
        { start: 100, end: 105 },
        { start: 95, end: 102 },
      ],
      // 5 from function
      res: 10,
    },
    {
      input: [
        { start: 53, end: 55 },
        { start: 58, end: 78 },
        { start: 90, end: 95 },
      ],
      res: 27,
    },
    {
      input: [
        { start: 45, end: 75 },
        { start: 65, end: 75 },
        { start: 85, end: 90 },
      ],
      res: 35,
    },
    {
      input: [
        { start: 50, end: 75 },
        { start: 35, end: 55 },
        { start: 10, end: 15 },
        { start: 55, end: 60 },
      ],
      // 25 from function
      res: 45,
    },

In the last test not sorted input, it possible if Object.values return different ordered array in different js realizations

Some improvements

Thanks for cool module I was always thinking of exporting metrics for promotheus!

A quick review I found some issues:

  • configKey seems is wrong analytics while should probably be promotheus in module definition and for runtime config (
    configKey: 'analytics',
    )
  • Exposed routes (/metrics, /health) can potentially conflict with user provided routes. Specially metrics. It would be nice to prefix them probably with /_promotheus (or at least _) by default and provide options to customize or disable each
  • Avoid restructuring event object - it currently uses a deprecated method without node. prefix . And directly return response (
    res.end(await register.metrics())
    )
  • Perf: We could probably directly render promethus metrics response and reduce bundle size in https://github.com/artmizu/nuxt-prometheus/blob/main/src/runtime/registry.ts.

Unable to detect request time when using ofetch or composables derive from it

Due to this issue in ofetch package @artmizu/nuxt-prometheus cannot detect network requests which take place through useFetch or $fetch, because they both use ofetch inside. So on the /metrics page, you don't see any request time related to ofetch.

I've already tried:

  1. Used different Nuxt hooks, for redefinition of global fetch. I'd try to do it before ofetch actually did it, but ofetch always did it first
  2. Tried different lifehacks around nuxt context to pass request information through functions and so on. In the end, it produced memory leaks or just didn't work.
  3. Try to reverse engineering ofetch to figure out the way how to overcome the issue, but for now don't see any outer way to modify its behavior, all variable is hidden inside closures, and so on

Maybe someone has an idea of how to overcome the issue? Or we'll just wait for updates from ofetch

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.