Skip to content

Commit

Permalink
Merge pull request #52 from instana/informix_traceCheck
Browse files Browse the repository at this point in the history
Informix Db: Parameterized Sql Trace via configuration
  • Loading branch information
vivek-22 authored Jul 11, 2024
2 parents a8b8321 + 171638b commit 5c56f55
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 4 deletions.
2 changes: 1 addition & 1 deletion rdb/config/config-informix.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ instances:
#Time Frame for which you want to get the expensive query. Default value 900 Sec
db.sql.elapsed.timeframe: 900 # Values should be in Seconds
db.sequential.scan.count: 0

db.sql.trace.enabled: false #Default is false. Make it true only if `SqlTrace` is enabled for the DB.
### Uncomment the below section in case you are using Vault to retrieve the password.
#vault:
# connection_url: #Vault Address URL
Expand Down
2 changes: 1 addition & 1 deletion rdb/src/main/java/com/instana/dc/rdb/impl/Constants.java
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ public class Constants {
public static final String CACHE_WRITE_RATIO_SCRIPT = "cache_write_ratio.sh";
public static final String LOCK_WAITS_SCRIPT = "lock_waits.sh";
public static final String LRU_WRITES_SCRIPT = "lru_writes.sh";

public static final String DB_SQL_TRACE_ENABLED = "db.sql.trace.enabled";
private Constants() {
//Private constructor
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@
import static com.instana.dc.rdb.impl.Constants.CACHE_WRITE_RATIO_SCRIPT;
import static com.instana.dc.rdb.impl.Constants.LOCK_WAITS_SCRIPT;
import static com.instana.dc.rdb.impl.Constants.LRU_WRITES_SCRIPT;
import static com.instana.dc.rdb.impl.Constants.DB_SQL_TRACE_ENABLED;
import static com.instana.dc.rdb.impl.informix.InformixUtil.DB_HOST_AND_VERSION_SQL;


Expand All @@ -65,6 +66,8 @@ public class InformixDc extends AbstractDbDc {

private final MetricsCollector metricCollector;

private Boolean sqlTraceEnabled;

public InformixDc(Map<String, Object> properties, String dbSystem, String dbDriver) throws SQLException {
super(properties, dbSystem, dbDriver);
parseCustomAttributes(properties);
Expand Down Expand Up @@ -230,6 +233,7 @@ private void scheduleCustomPollRate(int pollInterval, IntervalType intervalType)
@SuppressWarnings("unchecked")
private void parseCustomAttributes(Map<String, Object> properties) {
Map<String, Object> customInput = (Map<String, Object>) properties.get("custom.input");
sqlTraceEnabled = (Boolean)customInput.getOrDefault(DB_SQL_TRACE_ENABLED, false);
int sequentialScanCount = (Integer)customInput.getOrDefault("db.sequential.scan.count", 0);
long elapsedTimeFrame = Long.parseLong((customInput.getOrDefault("db.sql.elapsed.timeframe", DEFAULT_ELAPSED_TIME)).toString());
StringBuilder databaseName = new StringBuilder(Constants.SINGLE_QUOTES + getDbName() + Constants.SINGLE_QUOTES);
Expand Down Expand Up @@ -289,11 +293,13 @@ private void getallMetrics() {

@SuppressWarnings("unchecked")
private void mediumPollingInterval() {
getRawMetric(DB_SQL_COUNT_NAME).setValue((Number) metricCollector.collectMetrics(DB_SQL_COUNT_NAME));
if(sqlTraceEnabled) {
getRawMetric(DB_SQL_COUNT_NAME).setValue((Number) metricCollector.collectMetrics(DB_SQL_COUNT_NAME));
getRawMetric(DB_SQL_ELAPSED_TIME_NAME).setValue((List<SimpleQueryResult>) metricCollector.collectMetrics(DB_SQL_ELAPSED_TIME_NAME));
}
getRawMetric(DB_SQL_RATE_NAME).setValue((Number) metricCollector.collectMetrics(DB_SQL_RATE_NAME));
getRawMetric(DB_TRANSACTION_COUNT_NAME).setValue((Number) metricCollector.collectMetrics(DB_TRANSACTION_COUNT_NAME));
getRawMetric(DB_TRANSACTION_RATE_NAME).setValue((Number) metricCollector.collectMetrics(DB_TRANSACTION_COUNT_NAME));
getRawMetric(DB_SQL_ELAPSED_TIME_NAME).setValue((List<SimpleQueryResult>) metricCollector.collectMetrics(DB_SQL_ELAPSED_TIME_NAME));
}

private void shortPollingInterval() {
Expand Down

0 comments on commit 5c56f55

Please sign in to comment.