Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Informix Db: Parameterized Sql Trace via configuration #52

Merged
merged 9 commits into from
Jul 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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);
debnathbikram marked this conversation as resolved.
Show resolved Hide resolved
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