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 4 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
1 change: 1 addition & 0 deletions rdb/config/config-informix.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +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: 0 # Value should be 0 if the SQL Trace is enabled and 1 when not eneabled.When not specified, SQL Trace is considered to be disabled.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it should be a boolean value.

Suggested change
db.sql.trace.enabled: 0 # Value should be 0 if the SQL Trace is enabled and 1 when not eneabled.When not specified, SQL Trace is considered to be disabled.
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:
Expand Down
13 changes: 10 additions & 3 deletions rdb/src/main/java/com/instana/dc/rdb/impl/informix/InformixDc.java
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,8 @@ public class InformixDc extends AbstractDbDc {

private final MetricsCollector metricCollector;

int sqlTraceEnabled;
debnathbikram marked this conversation as resolved.
Show resolved Hide resolved

public InformixDc(Map<String, Object> properties, String dbSystem, String dbDriver) throws SQLException {
super(properties, dbSystem, dbDriver);
parseCustomAttributes(properties);
Expand Down Expand Up @@ -128,7 +130,7 @@ private void registerMetricsMetadata() {
MetricsDataConfigRegister.subscribeMetricDataConfig(DB_SEQ_SCAN_TABLE_NAME,
new MetricDataConfig(sequentialScanTableQuery, MetricCollectionMode.SQL, Number.class));

//Metrics via onstat command
// Metrics via onstat command
debnathbikram marked this conversation as resolved.
Show resolved Hide resolved
MetricsDataConfigRegister.subscribeMetricDataConfig(DB_SQL_COUNT_NAME,
new MetricDataConfig(DB_SQL_COUNT_NAME, SQL_COUNT_SCRIPT, MetricCollectionMode.CMD, Number.class));
MetricsDataConfigRegister.subscribeMetricDataConfig(DB_SQL_RATE_NAME,
Expand Down Expand Up @@ -230,6 +232,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 = (Integer)customInput.getOrDefault("db.sql.trace.enabled", 0);
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 All @@ -240,6 +243,7 @@ private void parseCustomAttributes(Map<String, Object> properties) {
tableSpaceUtilizationQuery = String.format(InformixUtil.TABLESPACE_UTILIZATION_SQL, databaseName);
tableSpaceMaxQuery = String.format(InformixUtil.TABLESPACE_MAX_SQL, databaseName);
sqlElapsedTimeQuery = String.format(InformixUtil.SQL_ELAPSED_TIME_SQL, elapsedTimeFrame, databaseName);

}

private void setDbConnUrl() {
Expand Down Expand Up @@ -289,11 +293,14 @@ private void getallMetrics() {

@SuppressWarnings("unchecked")
private void mediumPollingInterval() {
getRawMetric(DB_SQL_COUNT_NAME).setValue((Number) metricCollector.collectMetrics(DB_SQL_COUNT_NAME));
if(sqlTraceEnabled==1) {
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