fix RPT spam, allow re-init of capture, change to spawn loop, fix setvar

- add readme too
This commit is contained in:
2023-04-18 17:14:04 -07:00
parent a209843caa
commit b7b9c89dc2
11 changed files with 3476 additions and 202 deletions

View File

@@ -31,7 +31,6 @@ try {
switch (_function) do {
case "deinitExtension": {
diag_log format ["RangerMetrics: deinitExtension: %1", _response];
// Our first call is deinitExtension. When we received a single "true" value, we can then run init processes for the extension connections.
if ((_response select 0) isEqualTo true) then {
"RangerMetrics" callExtension "initExtension";
@@ -46,6 +45,39 @@ switch (_function) do {
// Load settings
[_function, _response] call RangerMetrics_callback_fnc_loadSettings;
};
case "extensionReady": {
// deinitialize existing captures
if (!isNil "RangerMetrics_allMEH") then {
{
private _handle = missionNamespace getVariable _x;
if (isNil "_handle") then {continue};
private _EHName = (_x splitString "_") select 2;
removeMissionEventHandler [_EHName, _handle];
missionNamespace setVariable [_x, nil];
} forEach RangerMetrics_allMEH;
};
if (!isNil "RangerMetrics_allCBA") then {
{
private _handle = missionNamespace getVariable _x;
if (isNil "_handle") then {continue};
private _EHName = (_x splitString "_") select 2;
[_EHName, _handle] call CBA_fnc_removeEventHandler;
missionNamespace setVariable [_x, nil];
} forEach RangerMetrics_allCBA;
};
if (!isNil "RangerMetrics_allServerPoll") then {
{
private _handle = missionNamespace getVariable _x;
if (isNil "_handle") then {continue};
terminate _handle;
missionNamespace setVariable [_x, nil];
} forEach RangerMetrics_allServerPoll;
};
call RangerMetrics_fnc_initCapture;
};
default {
_response call RangerMetrics_fnc_log;
};

View File

@@ -16,10 +16,12 @@ if (_function isEqualTo "loadSettingsJSON") exitWith {
] call RangerMetrics_fnc_log;
if (isServer) then {
RangerMetrics_serverProfileName = profileName;
publicVariable "RangerMetrics_serverProfileName";
missionNamespace setVariable [
"RangerMetrics_serverProfileName",
profileName,
true
];
};
call RangerMetrics_fnc_initCapture;
};
switch (_data select 0) do {

View File

@@ -69,7 +69,7 @@
false;
} else {
missionNamespace setVariable [
("RangerMetrics" + "_CBAEH_" + _settingName),
("RangerMetrics" + "_CBAEH_" + _handleName),
_handle
];
true;
@@ -81,24 +81,24 @@
private _meh = allVariables missionNamespace select {
RangerMetrics_allMEH = allVariables missionNamespace select {
_x find (toLower "RangerMetrics_MEH_") == 0
};
private _cba = allVariables missionNamespace select {
RangerMetrics_allCBA = allVariables missionNamespace select {
_x find (toLower "RangerMetrics_CBAEH_") == 0
};
private _serverPoll = allVariables missionNamespace select {
RangerMetrics_allServerPoll = allVariables missionNamespace select {
_x find (toLower "RangerMetrics_serverPoll_") == 0
};
[format ["Mission event handlers: %1", _meh]] call RangerMetrics_fnc_log;
[format ["CBA event handlers: %1", _cba]] call RangerMetrics_fnc_log;
[format ["Server poll handles: %1", _serverPoll]] call RangerMetrics_fnc_log;
[format ["Mission event handlers: %1", RangerMetrics_allMEH]] call RangerMetrics_fnc_log;
[format ["CBA event handlers: %1", RangerMetrics_allCBA]] call RangerMetrics_fnc_log;
[format ["Server poll handles: %1", RangerMetrics_allServerPoll]] call RangerMetrics_fnc_log;
RangerMetrics_initialized = true;
RangerMetrics_run = true;
["RangerMetrics_run", true] remoteExecCall ["setVariable", 0];
missionNamespace setVariable ["RangerMetrics_initialized", true, true];
missionNamespace setVariable ["RangerMetrics_run", true, true];
// start sending

View File

@@ -1,4 +1,4 @@
params [["_text","Log text invalid"], ["_type","INFO"]];
params [["_text","Log text invalid"], ["_logType","DEBUG"]];
if (typeName _this != "ARRAY") exitWith {
diag_log format ["RangerMetrics: Invalid log params: %1", _this];
@@ -6,18 +6,19 @@ if (typeName _this != "ARRAY") exitWith {
if (typeName _text != "STRING") exitWith {
diag_log format ["RangerMetrics: Invalid log text: %1", _this];
};
if (typeName _type != "STRING") exitWith {
if (typeName _logType != "STRING") exitWith {
diag_log format ["RangerMetrics: Invalid log type: %1", _this];
};
if (_type isEqualTo "DEBUG") then {
if (!RangerMetrics_debug) exitWith {};
};
if (
_logType == "DEBUG" &&
!(missionNamespace getVariable ["RangerMetrics_debug", false])
) exitWith {};
private _textFormatted = format [
"[%1] %2: %3",
RangerMetrics_logPrefix,
_type,
_logType,
_text];
if(isServer) then {

View File

@@ -20,7 +20,7 @@ RangerMetrics_recordingSettings = createHashMap;
[format ["Instance name: %1", profileName]] call RangerMetrics_fnc_log;
[format ["CBA detected: %1", RangerMetrics_cbaPresent]] call RangerMetrics_fnc_log;
["Initializing v0.1"] call RangerMetrics_fnc_log;
["Initializing v0.0.2"] call RangerMetrics_fnc_log;
// Create listener - extension calls are async, so we need to listen for the response
addMissionEventHandler [

View File

@@ -21,7 +21,17 @@ if (_tagContext find "world" > -1) then {
_tags pushBack ["string", "world", toLower worldName];
};
if (_tagContext find "server" > -1) then {
_tags pushBack ["string", "connectedServer", RangerMetrics_serverProfileName];
private _serverProfile = missionNamespace getVariable [
"RangerMetrics_serverProfileName",
""
];
if (_serverProfile isNotEqualTo "") then {
_tags pushBack [
"string",
"connectedServer",
_serverProfile
];
};
};
private _outTags = _tags apply {

View File

@@ -12,16 +12,41 @@ if (_interval == 0) exitWith {
[_code] call CBA_fnc_execNextFrame;
};
private _handle = [{
params ["_args", "_idPFH"];
_args params ["_refName", "_code"];
[_code] call CBA_fnc_execNextFrame;
}, _interval, _this] call CBA_fnc_addPerFrameHandler;
// run a constant scheduled loop
private _runnerVar = "RangerMetrics" + "_serverPollRunner_" + _refName;
missionNamespace setVariable [_runnerVar, scriptNull];
private _spawnParams = [_refName, _code, _interval, _runnerVar];
private _handle = _spawnParams spawn {
params ["_refName", "_code", "_interval", "_runnerVar"];
while {true} do {
if (scriptDone (
missionNamespace getVariable _runnerVar
)) then {
private _handle = [] spawn _code;
missionNamespace setVariable [
_runnerVar,
_handle
];
};
// sleep _interval;
sleep 2;
};
};
missionNamespace setVariable [
"RangerMetrics" + "_serverPoll_" + _refName,
_handle
];
];
// USE PFH
// private _handle = [{
// params ["_args", "_idPFH"];
// _args params ["_refName", "_code"];
// [_code] call CBA_fnc_execNextFrame;
// }, _interval, _this] call CBA_fnc_addPerFrameHandler;
// missionNamespace setVariable [
// "RangerMetrics" + "_serverPoll_" + _refName,
// _handle
// ];

View File

@@ -5,116 +5,97 @@
"token": "XXXXXXXXXXXXXXXXXXXXXXXXXXXX_AUTH_TOKEN_XXXXXXXXXXXXXXXXXXXXXXXXXXX",
"org": "ORG_NAME"
},
"arma3": {
"refreshRateMs": 1000,
"debug": false
},
"timescaledb": {
"enabled": false,
"connectionUrl": "postgresql://user:pass@host.com:5432",
"databaseName": "ranger_metrics",
"description": "TimescaleDB is an open-source time-series database built on Postgres. The extension will connect to the maintenance database (postgres) first and create the database it will control with desired name, then shift connections to the newly created database to create the schema and conduct write operations."
},
"arma3": {
"refreshRateMs": 1000,
"debug": false
},
"recordingSettings": {
"serverPerformance": {
"name": "serverPerformance",
"enabled": true,
"serverOnly": false,
"intervalMs": 1000,
"bucket": "server_performance",
"measurement": "fps",
"description": "SERVER/HC POLL. Tracks average and minimum FPS. Polled on server (and HC) at specified interval."
},
"runningScripts": {
"name": "runningScripts",
"enabled": true,
"serverOnly": false,
"intervalMs": 1000,
"bucket": "server_performance",
"measurement": "running_scripts",
"description": "SERVER/HC POLL. Tracks the number of scripts running on the server (and HC). Polled on specified interval."
},
"entityCount": {
"name": "entityCount",
"enabled": true,
"serverOnly": false,
"intervalMs": 20000,
"bucket": "server_performance",
"measurement": "n/a",
"description": "SERVER/HC POLL. Tracks the number of entities on the server. Polled on server (and HC) at specified interval as well as on EntityCreated/EntityRespawned/EntityKilled events. Measurement is static, [entities_local, entities_remote, entities_global]."
},
"playerPerformance": {
"name": "playerPerformance",
"enabled": true,
"serverOnly": true,
"intervalMs": 3000,
"bucket": "player_performance",
"measurement": "network",
"description": "SERVER POLL. User network performance. Tracks average ping, average bandwidth, and desync. Polled by the server at specified interval. Not tracked from headless client."
},
"serverTime": {
"name": "serverTime",
"enabled": true,
"serverOnly": true,
"intervalMs": 10000,
"bucket": "mission_data",
"measurement": "server_time",
"description": "SERVER POLL. Tracks the server time. Always server-only. Runs at specified interval."
},
"weather": {
"name": "weather",
"enabled": true,
"serverOnly": true,
"intervalMs": 300000,
"bucket": "mission_data",
"measurement": "weather",
"description": "SERVER POLL. Tracks the weather on the server. Always server-only. Runs at specified interval."
},
"viewDistance": {
"name": "viewDistance",
"enabled": true,
"serverOnly": true,
"intervalMs": 300000,
"bucket": "mission_data",
"measurement": "view_distance",
"description": "SERVER POSTINIT, MPEnded. Tracks the view distance on the server. Always server-only. Runs at specified interval."
},
"runningMission": {
"name": "runningMission",
"enabled": true,
"serverOnly": true,
"intervalMs": 0,
"bucket": "mission_data",
"measurement": "running_mission",
"description": "SERVER POSTINIT, MPEnded. Tracks the name of the mission running on the server. Always server-only. Runs at the start (and tries at end) of the mission."
},
"playerStatus": {
"name": "playerStatus",
"enabled": true,
"serverOnly": true,
"intervalMs": 0,
"bucket": "player_data",
"measurement": "client_state",
"description": "EH. Tracks players' clientstateNumber, adminState, and profileName on connect/disconnect to server and to mission, as well as when these values change."
},
"playerIdentity": {
"name": "playerIdentity",
"enabled": true,
"serverOnly": true,
"intervalMs": 0,
"bucket": "player_data",
"measurement": "player_identity",
"description": "EH. Tracks players' identity on connect/disconnect to server and to mission, as well as when these values change."
},
"CBAEventHandlers": {
"milsimServerEfficiency": {
"name": "milsimServerEfficiency",
"serverPolls": [
{
"name": "serverPerformance",
"enabled": true,
"serverOnly": false,
"intervalMs": 1000,
"bucket": "server_performance",
"measurement": "fps",
"description": "SERVER/HC POLL. Tracks average and minimum FPS. Polled on server (and HC) at specified interval."
},
{
"name": "runningScripts",
"enabled": true,
"serverOnly": false,
"intervalMs": 1000,
"bucket": "server_performance",
"measurement": "running_scripts",
"description": "SERVER/HC POLL. Tracks the number of scripts running on the server (and HC). Polled on specified interval."
},
{
"name": "entityCount",
"enabled": true,
"serverOnly": false,
"intervalMs": 20000,
"bucket": "server_performance",
"measurement": "n/a",
"description": "SERVER/HC POLL. Tracks the number of entities on the server. Polled on server (and HC) at specified interval as well as on EntityCreated/EntityRespawned/EntityKilled events. Measurement is static, [entities_local, entities_remote, entities_global]."
},
{
"name": "playerPerformance",
"enabled": true,
"serverOnly": true,
"bucket": "server_performance",
"measurement": "milsim_server_efficiency",
"intervalMs": 1000,
"bucket": "player_performance",
"measurement": "network",
"description": "SERVER POLL. User network performance. Tracks average ping, average bandwidth, and desync. Polled by the server at specified interval. Not tracked from headless client."
},
{
"name": "serverTime",
"enabled": true,
"serverOnly": true,
"intervalMs": 10000,
"bucket": "mission_data",
"measurement": "server_time",
"description": "SERVER POLL. Tracks the server time. Always server-only. Runs at specified interval."
},
{
"name": "weather",
"enabled": true,
"serverOnly": true,
"intervalMs": 120000,
"bucket": "mission_data",
"measurement": "weather",
"description": "SERVER POLL. Tracks the weather on the server. Always server-only. Runs at specified interval."
},
{
"name": "viewDistance",
"enabled": true,
"serverOnly": true,
"intervalMs": 120000,
"bucket": "mission_data",
"measurement": "view_distance",
"description": "SERVER POSTINIT, MPEnded. Tracks the view distance on the server. Always server-only. Runs at specified interval."
},
{
"name": "runningMission",
"enabled": true,
"serverOnly": true,
"intervalMs": 0,
"bucket": "mission_data",
"measurement": "running_mission",
"description": "SERVER POSTINIT, MPEnded. Tracks the name of the mission running on the server. Always server-only. Runs at the start (and tries at end) of the mission."
}
],
"CBAEventHandlers": [
{
"name": "milsimServerEfficiency",
"enabled": true,
"description": "EVENTHANDLER. Tracks the efficiency of the server."
}
}
]
}
}