[Explore]: Change metrics base on ICM suggestions.
git-svn-id: https://svn.driver.research-infrastructures.eu/driver/dnet40/modules/uoa-services-portal/trunk@57441 d315682c-612b-4755-9ff5-7f18f6832af3
This commit is contained in:
parent
e6b5e916cd
commit
382a322100
|
@ -27,6 +27,8 @@ import {ngExpressEngine, RenderOptions} from '@nguniversal/express-engine';
|
|||
import {provideModuleMap} from '@nguniversal/module-map-ngfactory-loader';
|
||||
import {routes} from "./routes";
|
||||
import * as prom from "prom-client";
|
||||
import {REQUEST, RESPONSE} from "@nguniversal/express-engine/tokens";
|
||||
import {renderModuleFactory} from "@angular/platform-server";
|
||||
|
||||
/*
|
||||
// Our Universal express-engine (found @ https://github.com/angular/universal/tree/master/modules/express-engine)
|
||||
|
@ -41,30 +43,41 @@ app.engine('html', ngExpressEngine({
|
|||
|
||||
const register = new prom.Registry();
|
||||
|
||||
const counter = new prom.Counter({
|
||||
name: 'explore',
|
||||
help: 'Explore Counter',
|
||||
labelNames: ['route'],
|
||||
const responses = new prom.Counter({
|
||||
name: 'portal_http_responses_total',
|
||||
help: 'A counter for portal response codes for every existed or not existed pages.',
|
||||
labelNames: ['route', 'code'],
|
||||
registers: [register]
|
||||
});
|
||||
|
||||
const histogram = new prom.Histogram({
|
||||
name: 'exploreLatency',
|
||||
help: 'Explore Histogram',
|
||||
name: 'portal_http_request_duration_seconds',
|
||||
help: 'A Histogram for a portal. Providing information about page visits and load latency in seconds.',
|
||||
labelNames: ['route'],
|
||||
registers: [register],
|
||||
buckets: [0.5, 1, 2, 3, 4, 5]
|
||||
buckets: [0.1, 0.2, 0.5, 1, 2]
|
||||
});
|
||||
|
||||
app.engine('html', (_, options:RenderOptions, callback) => {
|
||||
let engine = ngExpressEngine({
|
||||
bootstrap: AppServerModuleNgFactory,
|
||||
providers: [
|
||||
{ provide: 'request', useFactory: () => options.req, deps: [] },
|
||||
provideModuleMap(LAZY_MODULE_MAP)
|
||||
app.engine('html', (_, options: any, callback) => {
|
||||
const opts = {
|
||||
document: template,
|
||||
url: options.req.url,
|
||||
extraProviders: [
|
||||
provideModuleMap(LAZY_MODULE_MAP),
|
||||
{
|
||||
provide: REQUEST,
|
||||
useValue: options.req
|
||||
},
|
||||
{
|
||||
provide: RESPONSE,
|
||||
useValue: options.req.res,
|
||||
},
|
||||
]
|
||||
});
|
||||
engine(_, options, callback);
|
||||
};
|
||||
|
||||
renderModuleFactory(AppServerModuleNgFactory, opts)
|
||||
.then(html => callback(null, html)
|
||||
);
|
||||
});
|
||||
|
||||
app.set('view engine', 'html');
|
||||
|
@ -88,13 +101,16 @@ app.get('/metrics', (req, res) => {
|
|||
app.get('*', (req, res) => {
|
||||
if (routes.indexOf(req.path) !== -1) {
|
||||
const end = histogram.startTimer({route: req.path});
|
||||
counter.inc({route: req.path});
|
||||
res.render('index', {req});
|
||||
res.on('finish', function () {
|
||||
responses.inc({route: req.path, code: res.statusCode});
|
||||
end();
|
||||
});
|
||||
} else {
|
||||
res.render('index', {req});
|
||||
res.on('finish', function () {
|
||||
responses.inc({route: '**', code: res.statusCode});
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
|
|
|
@ -35,7 +35,7 @@
|
|||
"piwikSiteId" : "6",
|
||||
"loginUrl" :"http://rudie.di.uoa.gr:8080/dnet-login/openid_connect_login",
|
||||
|
||||
"userInfoUrl" : "http://rudie.di.uoa.gr:8080/dnet-openaire-users-1.0.0-SNAPSHOT/api/users/getUserInfo?accessToken=",
|
||||
"userInfoUrl" : "http://scoobydoo.di.uoa.gr:8080/dnet-openaire-users-1.0.0-SNAPSHOT/api/users/getUserInfo?accessToken=",
|
||||
|
||||
"logoutUrl" :"https://aai.openaire.eu/proxy/saml2/idp/SingleLogoutService.php?ReturnTo=",
|
||||
|
||||
|
@ -45,7 +45,7 @@
|
|||
|
||||
"cacheUrl" :"http://scoobydoo.di.uoa.gr:3000/get?url=",
|
||||
|
||||
"adminToolsAPIURL" :"http://duffy.di.uoa.gr:8080/uoa-admin-tools/",
|
||||
"adminToolsAPIURL" :"http://mpagasas.di.uoa.gr:8080/uoa-admin-tools/",
|
||||
|
||||
"adminToolsCommunity" :"openaire",
|
||||
"datasourcesAPI": "https://beta.services.openaire.eu/openaire/ds/search/",
|
||||
|
|
Loading…
Reference in New Issue