Skip to content

Commit 1b7f677

Browse files
committed
read config only once
1 parent a685b20 commit 1b7f677

File tree

1 file changed

+4
-2
lines changed
  • dd-java-agent/instrumentation/jdbc/src/main/java/datadog/trace/instrumentation/jdbc

1 file changed

+4
-2
lines changed

dd-java-agent/instrumentation/jdbc/src/main/java/datadog/trace/instrumentation/jdbc/JDBCDecorator.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,8 @@ public class JDBCDecorator extends DatabaseClientDecorator<DBInfo> {
6060
DBM_PROPAGATION_MODE.equals(DBM_PROPAGATION_MODE_FULL);
6161
public static final boolean DBM_TRACE_PREPARED_STATEMENTS =
6262
Config.get().isDbmTracePreparedStatements();
63+
private static final boolean FETCH_DB_METADATA = Config.get().isDbMetadataFetchingEnabled();
64+
private static final boolean FETCH_DB_CLIENT_INFO = Config.get().isDbClientInfoFetchingEnabled();
6365

6466
private volatile boolean warnedAboutDBMPropagationMode = false; // to log a warning only once
6567

@@ -201,7 +203,7 @@ public String getDbService(final DBInfo dbInfo) {
201203
}
202204

203205
public static DBInfo parseDBInfoFromConnection(final Connection connection) {
204-
if (connection == null || !Config.get().isDbMetadataFetchingEnabled()) {
206+
if (connection == null || !FETCH_DB_METADATA) {
205207
// we can log here, but it risks to be too verbose
206208
return DBInfo.DEFAULT;
207209
}
@@ -211,7 +213,7 @@ public static DBInfo parseDBInfoFromConnection(final Connection connection) {
211213
final String url = metaData.getURL();
212214
if (url != null) {
213215
Properties clientInfo = null;
214-
if (Config.get().isDbClientInfoFetchingEnabled()) {
216+
if (FETCH_DB_CLIENT_INFO) {
215217
try {
216218
clientInfo = connection.getClientInfo();
217219
} catch (final Throwable ex) {

0 commit comments

Comments
 (0)