Skip to content

Commit

Permalink
Fix value on first fetch for connpool prometheus metrics
Browse files Browse the repository at this point in the history
The initial value for metrics using 'p_update_connection_pool_update_*'
helpers were missing. This only affects to the first metrics fetch,
during the metric creation on the internal maps, subsequent fetches will
find the already created metric and updated the value properly. As
real counters are internal, this doesn't affect the correctness of the
value in subsequent fetches.
  • Loading branch information
JavierJF committed Aug 20, 2024
1 parent 04aa3e4 commit 50a95d4
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions lib/MySQL_HostGroups_Manager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3314,12 +3314,13 @@ void MySQL_HostGroups_Manager::p_update_connection_pool_update_counter(
counter_id->second->Increment(value - cur_val);
} else {
auto& new_counter = status.p_dyn_counter_array[idx];
m_map.insert(
const auto& new_counter_it = m_map.insert(
{
endpoint_id,
std::addressof(new_counter->Add(labels))
}
);
new_counter_it.first->second->Increment(value);
}
}

Expand All @@ -3332,12 +3333,13 @@ void MySQL_HostGroups_Manager::p_update_connection_pool_update_gauge(
counter_id->second->Set(value);
} else {
auto& new_counter = status.p_dyn_gauge_array[idx];
m_map.insert(
const auto& new_gauge_it = m_map.insert(
{
endpoint_id,
std::addressof(new_counter->Add(labels))
}
);
new_gauge_it.first->second->Set(value);
}
}

Expand Down

0 comments on commit 50a95d4

Please sign in to comment.