Skip to content

Commit

Permalink
q level metric
Browse files Browse the repository at this point in the history
  • Loading branch information
lobis committed Aug 29, 2024
1 parent d7d0c7d commit 1b23755
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 6 deletions.
13 changes: 7 additions & 6 deletions src/mclient/femarray.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -314,26 +314,27 @@ int FemArray_SendDaq(FemArray* fa, unsigned int fem_beg, unsigned int fem_end, u
const auto number_of_events = feminos_daq_storage::StorageManager::Instance().GetNumberOfEntries();

auto& storageManager = feminos_daq_storage::StorageManager::Instance();
const auto queueUsagePercent = storageManager.GetQueueUsage() * 100.0;
const auto queueUsage = storageManager.GetQueueUsage();

time_t now_time = time(nullptr);
tm* now_tm = gmtime(&now_time);
char time_str[80];
strftime(time_str, 80, "[%Y-%m-%dT%H:%M:%SZ]", now_tm);

string q_fill_string;
if (queueUsagePercent > 5.0) {
if (queueUsage > 0.05) {
std::stringstream ss;
ss << std::fixed << std::setprecision(1) << queueUsagePercent;
ss << std::fixed << std::setprecision(1) << queueUsage * 100.0;
q_fill_string = " | ⚠\uFE0F Queue at " + ss.str() + "% Capacity ⚠\uFE0F";
}

cout << time_str << " | # Entries: " << number_of_events << " | 🏃 Speed: " << speed_events_per_second << " entry/s (" << daq_speed << " MB/s)" << q_fill_string << endl;

auto& prometheusManager = feminos_daq_prometheus::PrometheusManager::Instance();
auto& prometheus_manager = feminos_daq_prometheus::PrometheusManager::Instance();

prometheusManager.SetDaqSpeedMB(daq_speed);
prometheusManager.SetDaqSpeedEvents(speed_events_per_second);
prometheus_manager.SetDaqSpeedMB(daq_speed);
prometheus_manager.SetDaqSpeedEvents(speed_events_per_second);
prometheus_manager.SetFrameQueueFillLevel(queueUsage);

// Update the new time and size of received data
fa->daq_last_time = now;
Expand Down
30 changes: 30 additions & 0 deletions src/prometheus/prometheus.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,26 @@ feminos_daq_prometheus::PrometheusManager::PrometheusManager() {
{0.99, 0.02},
});

frame_queue_fill_level_now = &BuildGauge()
.Name("frame_queue_fill_level_now")
.Help("Frame queue fill level (0 empty, 1 full)")
.Register(*registry)
.Add({});

frame_queue_fill_level = &BuildSummary()
.Name("frame_queue_fill_level_now")
.Help("Frame queue fill level (0 empty, 1 full)")
.Register(*registry)
.Add({}, Summary::Quantiles{
{0.01, 0.02},
{0.1, 0.02},
{0.25, 0.02},
{0.5, 0.02},
{0.75, 0.02},
{0.9, 0.02},
{0.99, 0.02},
});

run_number = &BuildGauge()
.Name("run_number")
.Help("Run number")
Expand Down Expand Up @@ -208,6 +228,16 @@ void feminos_daq_prometheus::PrometheusManager::UpdateOutputRootFileSize() {
}
}

void feminos_daq_prometheus::PrometheusManager::SetFrameQueueFillLevel(double fill_level) {
if (frame_queue_fill_level_now) {
daq_speed_events_per_s_now->Set(fill_level);
}

if (frame_queue_fill_level) {
frame_queue_fill_level->Observe(fill_level);
}
}

double feminos_daq_prometheus::GetFreeDiskSpaceGigabytes(const std::string& path) {
std::error_code ec;
std::filesystem::space_info space = std::filesystem::space(path, ec);
Expand Down
4 changes: 4 additions & 0 deletions src/prometheus/prometheus.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@ class PrometheusManager {

PrometheusManager& operator=(const PrometheusManager&) = delete;

void SetFrameQueueFillLevel(double fill_level);

void SetDaqSpeedMB(double speed);

void SetDaqSpeedEvents(double speed);
Expand Down Expand Up @@ -66,11 +68,13 @@ class PrometheusManager {
Gauge* number_of_events = nullptr;
Gauge* daq_speed_mb_per_s_now = nullptr;
Gauge* daq_speed_events_per_s_now = nullptr;
Gauge* frame_queue_fill_level_now = nullptr;
Gauge* run_number = nullptr;
Gauge* number_of_signals_in_last_event = nullptr;
Summary* number_of_signals_in_event = nullptr;
Summary* daq_speed_mb_per_s = nullptr;
Summary* daq_speed_events_per_s = nullptr;
Summary* frame_queue_fill_level = nullptr;
Gauge* output_root_file_size = nullptr;
};
} // namespace feminos_daq_prometheus
Expand Down

0 comments on commit 1b23755

Please sign in to comment.