mirror of
https://github.com/clusterio/clusterio.git
synced 2026-11-15 15:24:52 +09:00
Use anonymous master metrics
Convert the master metrics to void instead of storing them in a variable as they are completely self contained, and this makes it more clear that there are no use of references to the metrics.
This commit is contained in:
1 parent
61cd5bd76c
commit
dec5467538
1 file changed
+11
-14
+11
-14
@@ -43,18 +43,18 @@ const UserManager = require("./src/UserManager");
|
||||
let master;
|
||||
|
||||
|
||||
const slaveMappingGauge = new libPrometheus.Gauge(
|
||||
void new libPrometheus.Gauge(
|
||||
"clusterio_master_slave_mapping",
|
||||
"Mapping of Slave ID to name",
|
||||
{
|
||||
labels: ["slave_id", "slave_name"],
|
||||
callback: function() {
|
||||
slaveMappingGauge.clear();
|
||||
callback: function(gauge) {
|
||||
gauge.clear();
|
||||
if (!master || !master.slaves) {
|
||||
return;
|
||||
}
|
||||
for (let [id, slave] of master.slaves) {
|
||||
slaveMappingGauge.labels({
|
||||
gauge.labels({
|
||||
slave_id: String(id),
|
||||
slave_name: slave.name,
|
||||
}).set(1);
|
||||
@@ -63,18 +63,18 @@ const slaveMappingGauge = new libPrometheus.Gauge(
|
||||
}
|
||||
);
|
||||
|
||||
const instanceMappingGauge = new libPrometheus.Gauge(
|
||||
void new libPrometheus.Gauge(
|
||||
"clusterio_master_instance_mapping",
|
||||
"Mapping of Instance ID to name and slave",
|
||||
{
|
||||
labels: ["instance_id", "instance_name", "slave_id"],
|
||||
callback: function() {
|
||||
instanceMappingGauge.clear();
|
||||
callback: function(gauge) {
|
||||
gauge.clear();
|
||||
if (!master || !master.instances) {
|
||||
return;
|
||||
}
|
||||
for (let [id, instance] of master.instances) {
|
||||
instanceMappingGauge.labels({
|
||||
gauge.labels({
|
||||
instance_id: String(id),
|
||||
instance_name: String(instance.config.get("instance.name")),
|
||||
slave_id: String(instance.config.get("instance.assigned_slave")),
|
||||
@@ -84,21 +84,19 @@ const instanceMappingGauge = new libPrometheus.Gauge(
|
||||
}
|
||||
);
|
||||
|
||||
const wsActiveConnectionsGauge = new libPrometheus.Gauge(
|
||||
void new libPrometheus.Gauge(
|
||||
"clusterio_master_websocket_active_connections",
|
||||
"How many WebSocket connections are currently open to the master server",
|
||||
{ callback: function(gauge) { gauge.set(master.wsServer.activeConnectors.size); }}
|
||||
);
|
||||
void wsActiveConnectionsGauge;
|
||||
|
||||
const wsActiveSlavesGauge = new libPrometheus.Gauge(
|
||||
void new libPrometheus.Gauge(
|
||||
"clusterio_master_active_slaves",
|
||||
"How many slaves are currently connected to the master",
|
||||
{ callback: function(gauge) { gauge.set(master.wsServer.slaveConnections.size); }}
|
||||
);
|
||||
void wsActiveSlavesGauge;
|
||||
|
||||
const masterConnectedClientsCount = new libPrometheus.Gauge(
|
||||
void new libPrometheus.Gauge(
|
||||
"clusterio_master_connected_clients_count", "How many clients are currently connected to this master server",
|
||||
{
|
||||
labels: ["type"], callback: async function(gauge) {
|
||||
@@ -107,7 +105,6 @@ const masterConnectedClientsCount = new libPrometheus.Gauge(
|
||||
},
|
||||
},
|
||||
);
|
||||
void masterConnectedClientsCount;
|
||||
|
||||
|
||||
async function handleBootstrapCommand(args, masterConfig) {
|
||||
|
||||
Reference in new issue
Block a user