Skip to content

Commit

Permalink
add driver class label
Browse files Browse the repository at this point in the history
  • Loading branch information
Adam-Shedivy authored and ThePrez committed Apr 2, 2023
1 parent 93ab6bb commit 3e8ef83
Showing 1 changed file with 9 additions and 9 deletions.
18 changes: 9 additions & 9 deletions src/main/java/com/ibm/jesseg/prometheus/SQLMetricPopulator.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ public class SQLMetricPopulator {
private final String m_sql;
private volatile long m_numCollections = 0;


private final long m_interval;

private PreparedStatement m_statement = null;
Expand All @@ -37,9 +36,9 @@ public class SQLMetricPopulator {
private final Config m_config;
private ConnectionManager m_connMan;

public SQLMetricPopulator(AppLogger _logger, CollectorRegistry _registry, Config _config,
ConnectionManager _connMan,
long _interval,
public SQLMetricPopulator(AppLogger _logger, CollectorRegistry _registry, Config _config,
ConnectionManager _connMan,
long _interval,
boolean _isMultiRow,
String _sql, boolean _includeHostname, String _gaugePrefix)
throws IOException, SQLException {
Expand Down Expand Up @@ -96,7 +95,7 @@ private Gauge getGauge(String _gaugeName, final String _help) {
Gauge ret = Gauge.build()
.name(_gaugeName)
.help(_help)
.labelNames("hostname")
.labelNames("hostname", "driver_class")
.register();
m_gauges.put(_gaugeName, ret);
return ret;
Expand All @@ -119,10 +118,10 @@ private String getGaugeName(String _columnName, String _rowName) {

private void gatherData() throws SQLException {
synchronized (m_requestLock) {
if (!m_isMultiRow && 0 == m_gauges.size()) {
if (!m_isMultiRow && 0 == m_gauges.size()) {
return;
}
m_logger.println_verbose("gathering metrics..."+m_sql);
m_logger.println_verbose("gathering metrics..." + m_sql);
try {
ResultSet rs = getStatement().executeQuery();
ResultSetMetaData meta = rs.getMetaData();
Expand Down Expand Up @@ -152,9 +151,10 @@ private void gatherData() throws SQLException {
}
}
double value = rs.getDouble(i);
gauge.labels(m_config.getHostNameForDisplay().replaceAll("\\..*", "")).set(value);
gauge.labels(m_config.getHostNameForDisplay().replaceAll("\\..*", ""), m_config.getDriverClass())
.set(value);
}
if(!m_isMultiRow) {
if (!m_isMultiRow) {
break;
}
}
Expand Down

0 comments on commit 3e8ef83

Please sign in to comment.