mirror of
https://github.com/clusterio/clusterio.git
synced 2026-11-25 08:23:13 +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;
|
let master;
|
||||||
|
|
||||||
|
|
||||||
const slaveMappingGauge = new libPrometheus.Gauge(
|
void new libPrometheus.Gauge(
|
||||||
"clusterio_master_slave_mapping",
|
"clusterio_master_slave_mapping",
|
||||||
"Mapping of Slave ID to name",
|
"Mapping of Slave ID to name",
|
||||||
{
|
{
|
||||||
labels: ["slave_id", "slave_name"],
|
labels: ["slave_id", "slave_name"],
|
||||||
callback: function() {
|
callback: function(gauge) {
|
||||||
slaveMappingGauge.clear();
|
gauge.clear();
|
||||||
if (!master || !master.slaves) {
|
if (!master || !master.slaves) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
for (let [id, slave] of master.slaves) {
|
for (let [id, slave] of master.slaves) {
|
||||||
slaveMappingGauge.labels({
|
gauge.labels({
|
||||||
slave_id: String(id),
|
slave_id: String(id),
|
||||||
slave_name: slave.name,
|
slave_name: slave.name,
|
||||||
}).set(1);
|
}).set(1);
|
||||||
@@ -63,18 +63,18 @@ const slaveMappingGauge = new libPrometheus.Gauge(
|
|||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
const instanceMappingGauge = new libPrometheus.Gauge(
|
void new libPrometheus.Gauge(
|
||||||
"clusterio_master_instance_mapping",
|
"clusterio_master_instance_mapping",
|
||||||
"Mapping of Instance ID to name and slave",
|
"Mapping of Instance ID to name and slave",
|
||||||
{
|
{
|
||||||
labels: ["instance_id", "instance_name", "slave_id"],
|
labels: ["instance_id", "instance_name", "slave_id"],
|
||||||
callback: function() {
|
callback: function(gauge) {
|
||||||
instanceMappingGauge.clear();
|
gauge.clear();
|
||||||
if (!master || !master.instances) {
|
if (!master || !master.instances) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
for (let [id, instance] of master.instances) {
|
for (let [id, instance] of master.instances) {
|
||||||
instanceMappingGauge.labels({
|
gauge.labels({
|
||||||
instance_id: String(id),
|
instance_id: String(id),
|
||||||
instance_name: String(instance.config.get("instance.name")),
|
instance_name: String(instance.config.get("instance.name")),
|
||||||
slave_id: String(instance.config.get("instance.assigned_slave")),
|
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",
|
"clusterio_master_websocket_active_connections",
|
||||||
"How many WebSocket connections are currently open to the master server",
|
"How many WebSocket connections are currently open to the master server",
|
||||||
{ callback: function(gauge) { gauge.set(master.wsServer.activeConnectors.size); }}
|
{ callback: function(gauge) { gauge.set(master.wsServer.activeConnectors.size); }}
|
||||||
);
|
);
|
||||||
void wsActiveConnectionsGauge;
|
|
||||||
|
|
||||||
const wsActiveSlavesGauge = new libPrometheus.Gauge(
|
void new libPrometheus.Gauge(
|
||||||
"clusterio_master_active_slaves",
|
"clusterio_master_active_slaves",
|
||||||
"How many slaves are currently connected to the master",
|
"How many slaves are currently connected to the master",
|
||||||
{ callback: function(gauge) { gauge.set(master.wsServer.slaveConnections.size); }}
|
{ 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",
|
"clusterio_master_connected_clients_count", "How many clients are currently connected to this master server",
|
||||||
{
|
{
|
||||||
labels: ["type"], callback: async function(gauge) {
|
labels: ["type"], callback: async function(gauge) {
|
||||||
@@ -107,7 +105,6 @@ const masterConnectedClientsCount = new libPrometheus.Gauge(
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
void masterConnectedClientsCount;
|
|
||||||
|
|
||||||
|
|
||||||
async function handleBootstrapCommand(args, masterConfig) {
|
async function handleBootstrapCommand(args, masterConfig) {
|
||||||
|
|||||||
Reference in new issue
Block a user