GithubHelp home page GithubHelp logo

Comments (6)

sv2 avatar sv2 commented on May 12, 2024

Hi ! Could you kindly elaborate more on your scenarios ? I'd like to get a better sense of what kind of options to put in place to enable configurable tracking of endpoints ... for example, may consider introducing option to enable/disable tracking of all endpoints that are not in swagger, or explicitly specify an array of endpoints to track in options ... any details on your specific needs will help !

from swagger-stats.

jimmyjiji avatar jimmyjiji commented on May 12, 2024

Thanks for getting back to me!
I was thinking about having the option to enable/disable tracking of all endpoints that are not in swagger. The reason being is that I have two endpoints for example which are routed the same way. I have route 1 which would be:

/iwanttotrack/issue1

and route 2 which I also want to track which would be

/iwanttotrack/issue2.

Currently, both hits to these endpoints show up in swagger-stats as:

/iwanttotrack/:issue.

I was hoping there would be an option to separate it out specifically as I wanted to track which of the two issues issue1 or issue2 would be hit more often.

from swagger-stats.

sv2 avatar sv2 commented on May 12, 2024

Thanks! Could you give me a sample how /iwanttotrack/issue1 is defined in your swagger spec ?

from swagger-stats.

jimmyjiji avatar jimmyjiji commented on May 12, 2024

As of now it's a very simple definition

  "paths": {
    "/iwanttotrack/issue1": {
      "get": {
        "summary": "issue",
        "description": "This operation will get the issue",
        "responses": {
          "200": {
            "description": "The path is retrieved successfully."
          },
          "304": {
            "description": "The path is redirected successfully"
          }
        }
      }
    }
  },
    "/iwanttotrack/issue2": {
      "get": {
        "summary": "issue",
        "description": "This operation will get the issue",
        "responses": {
          "200": {
            "description": "The path is retrieved successfully."
          },
          "304": {
            "description": "The path is redirected successfully"
          }
        }
      }
  }

Nothing else to it.

from swagger-stats.

sv2 avatar sv2 commented on May 12, 2024

now you can specify option swaggerOnly={true|false}. When set to true, swagger-stats will only track API requests defined in swagger spec. Default is false. See example in auttest app:

app.use(swStats.getMiddleware({
    name: 'swagger-stats-authtest',
    version: '0.95.0',
    hostname: "hostname",
    ip: "127.0.0.1",
    swaggerSpec:swaggerSpec,
    swaggerOnly: true,
    uriPath: '/swagger-stats',
    durationBuckets: [10, 25, 50, 100, 200],
    requestSizeBuckets: [10, 25, 50, 100, 200],
    responseSizeBuckets: [10, 25, 50, 100, 200],
    apdexThreshold: 100,
    onResponseFinish: function(req,res,rrr){
        debug('onResponseFinish: %s', JSON.stringify(rrr));
    },
    authentication: true,
    sessionMaxAge: maxAge,
    onAuthenticate: function(req,username,password){
        // simple check for username and password
        if(username==='swagger-stats') {
            return ((username === 'swagger-stats') && (password === 'swagger-stats'));
        } else if(username==='swagger-promise'){
            return new Promise(function(resolve) {
                setTimeout(function(){
                    resolve((username === 'swagger-promise') && (password === 'swagger-promise'));
                }, 1000);
            });
        }
        return false;
    }
}));

from swagger-stats.

briankinney avatar briankinney commented on May 12, 2024

I don't believe this is solving the problem that the author of this issue described. However I also think that this tool should not do what he wants for reasons related to #34.

from swagger-stats.

Related Issues (20)

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.