Skip to content
This repository was archived by the owner on Mar 15, 2018. It is now read-only.

Commit

Permalink
Add pmx for metrics (#30)
Browse files Browse the repository at this point in the history
  • Loading branch information
Bouncey authored Sep 2, 2017
1 parent f7d5fbf commit b324fcf
Show file tree
Hide file tree
Showing 3 changed files with 91 additions and 0 deletions.
81 changes: 81 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
"helmet": "^3.6.1",
"morgan": "^1.8.2",
"node-svn-ultimate": "^1.0.4",
"pmx": "^1.2.0",
"pug": "^2.0.0-rc.2",
"request": "^2.81.0",
"rss-parser": "^2.9.0",
Expand Down
9 changes: 9 additions & 0 deletions server/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,15 @@ const express = require('express');
const bodyParser = require('body-parser');
const helmet = require('helmet');
const Rx = require('rx');
const pmx = require('pmx');

const app = express();
const probe = pmx.probe();

const reqPerHour = probe.meter({
name: 'Requests per hour',
samples: 60 * 60
});

const { findTheThings, getAllTitleFields } = require('../elastic');
const cors = require('./middleware/cors');
Expand All @@ -24,6 +32,7 @@ app.set('views', './views');
app.set('view engine', 'pug');

app.get('/search', cors, (req, res) => {
reqPerHour.mark();
const { q: query } = req.query;
Observable.fromPromise(findTheThings(query))
.subscribe(
Expand Down

0 comments on commit b324fcf

Please sign in to comment.