Comments (6)
is it possible to let app to pick additional data from both request and response and add it to reports.
for ex, we have req.rid object in each request which holds our correlation ids.
so it may not be required to create and maintain a new id but just let app put one if it needs.
This can be done quite easily if you choose to add lodash in dependency stack, app may just provide key path(s) as string like 'userinfo.userid' or 'body.userinfo.userid'
app.use(swStats.getMiddleware({
pickFromReq: ['userinfo.userid', 'dummy.id'],
pickFromRes: ['body.userinfo.userid'],
}));
Additionally,
it would also be greate if it lets app to add any data, may be with a simple callback to extend rrr
.
A callback/hook might even be better as app can even pick its data from req or res or somewhere else and put in rrr directly.
if i can find some time, i will try to create pull request so you can check if it is ok or not.
from swagger-stats.
This sounds good, thank you ! couple of thoughts:
- we can use onResponseFinish callback to do exactly that - app can extend rrr before it gets stored in Elasticsearch
- Need to think about schema how additional attributes will be stored in Elasticsearch
from swagger-stats.
onResponseFinish
works perfectly !
i don't have much knowledge about how template works but even if the template is not updated, it should work but new custom fields won't be indexed right?
it tried overriding default schema and it seems working but i am not sure if i miss smt or not.
i will be creating a pull request just for your inspection.
btw, i am definetly lost in test folder :) need guidance so that i won't be ruining your coverage
from swagger-stats.
Also added more comments to #27 ...
even if the template is not updated, it should work but new custom fields won't be indexed right?
Not exactly. Elasticsearch will assign type and index custom field first time it appears. But then if next time custom field with the same name would have different type, it would cause indexing error. This is why it's best to define this in schema upfront - to avoid indexing errors.
btw, i am definetly lost in test folder :) need guidance so that i won't be ruining your coverage
Sure :) I'll try to add more detailed readme to /tests ... As a short description - there are several groups of tests focusing each on specific area:
- 000_baseline.js - test for basic functionality
- 010_swsapistats.js - test for swagger spec initialization
- 100_method.js - test for method-based statistics
- 200_apicore.js - test for api operation - based statistics
- 300_timeline.js - test for timeline - based statistics
- 400_auth.js - authentication tests
- 500_elastic.js - Elasticsearch-specific tests
- /ui - Tests for UI , using karma
Each of tests instantiates one of sample application (from /examples ) and then sends API requests to app and checks that swagger-stats returns correct stats. So these are more integration tests, as they validate everything end-to-end, rather then testing specific modules
from swagger-stats.
Any progress here?
from swagger-stats.
See V1 discussion: #135
from swagger-stats.
Related Issues (20)
- unit tests fail at [email protected] HOT 4
- How to make the data persist? HOT 1
- URL Normalization and 404 count consolidation by config option without requiring swagger apiSpec HOT 1
- how to customize metrics
- problem
- feat
- Hope to support a new feature
- DEBUG env is being overridden by `lib/swsElasticEmitter.js`
- 0.99.7 HOT 1
- where is the file "swagger.json" ? HOT 1
- Error on routes with wildcards
- Support prom-client 15
- Issue with Basic Auth when connecting the Endpoint to Grafana cloud HOT 2
- ReferenceError: that is not defined
- How to implement it in a production environment? HOT 1
- Error in tests when updating to 0.99.7
- Native Fastify plugin
- Issue in authentication in case of a multi-instance environment
- Issues with Requests to the root route (/)
- ReferenceError: that is not defined HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from swagger-stats.