mirror of
https://github.com/clusterio/clusterio.git
synced 2026-11-19 15:33:12 +09:00
Replace endpointHitCounter
Track summary statistic of total HTTP response durations using a middleware that applies for all requests instead of having every request needing to update the hit counter manually. Deprecates endpointHitCounter.
This commit is contained in:
1 parent
98dc0174d6
commit
5ad89f072f
7 files changed
+23
-24
No files matched your search
@@ -44,8 +44,6 @@ class MasterPlugin extends libPlugin.BaseMasterPlugin {
|
||||
}, 60e3).unref();
|
||||
|
||||
this.master.app.get("/api/player_auth/servers", (req, res) => {
|
||||
this.metrics.endpointHitCounter.labels(req.route.path).inc();
|
||||
|
||||
let servers = [];
|
||||
for (let instance of this.master.instances.values()) {
|
||||
if (instance.status === "running" && instance.config.get("player_auth.load_plugin")) {
|
||||
@@ -56,12 +54,10 @@ class MasterPlugin extends libPlugin.BaseMasterPlugin {
|
||||
});
|
||||
|
||||
this.master.app.post("/api/player_auth/player_code", express.json(), (req, res, next) => {
|
||||
this.metrics.endpointHitCounter.labels(req.route.path).inc();
|
||||
this.handlePlayerCode(req, res).catch(next);
|
||||
});
|
||||
|
||||
this.master.app.post("/api/player_auth/verify", express.json(), (req, res, next) => {
|
||||
this.metrics.endpointHitCounter.labels(req.route.path).inc();
|
||||
this.handleVerify(req, res).catch(next);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -86,7 +86,7 @@ class MasterPlugin extends libPlugin.BaseMasterPlugin {
|
||||
|
||||
this.subscribedControlLinks = new Set();
|
||||
|
||||
routes.addApiRoutes(this.master.app, this.items, this.metrics.endpointHitCounter);
|
||||
routes.addApiRoutes(this.master.app, this.items);
|
||||
}
|
||||
|
||||
updateStorage() {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
"use strict";
|
||||
function addApiRoutes(app, items, endpointHitCounter) {
|
||||
function addApiRoutes(app, items) {
|
||||
|
||||
/**
|
||||
* GET endpoint to read the masters current inventory of items.
|
||||
@@ -10,7 +10,6 @@ function addApiRoutes(app, items, endpointHitCounter) {
|
||||
* @returns {object[]} JSON [{name:"iron-plate", count:100},{name:"copper-plate",count:5}]
|
||||
*/
|
||||
app.get("/api/inventory", (req, res) => {
|
||||
endpointHitCounter.labels(req.route.path).inc();
|
||||
res.header("Access-Control-Allow-Origin", "*");
|
||||
res.header("Access-Control-Allow-Headers", "Origin, X-Requested-With, Content-Type, Accept");
|
||||
// Check it and send it
|
||||
@@ -31,7 +30,6 @@ function addApiRoutes(app, items, endpointHitCounter) {
|
||||
* @returns {object} JSON {"iron-plate":100, "copper-plate":5}
|
||||
*/
|
||||
app.get("/api/inventoryAsObject", (req, res) => {
|
||||
endpointHitCounter.labels(req.route.path).inc();
|
||||
res.header("Access-Control-Allow-Origin", "*");
|
||||
res.header("Access-Control-Allow-Headers", "Origin, X-Requested-With, Content-Type, Accept");
|
||||
// Check it and send it
|
||||
|
||||
Reference in new issue
Block a user