Remove ExceptionLogger refs from instrumentation (#883)

This commit is contained in:
Trask Stalnaker 2020-08-03 19:04:27 -07:00 committed by GitHub
parent 166bfb07cf
commit dce9d6db47
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 14 additions and 7 deletions

View File

@ -18,7 +18,6 @@ package io.opentelemetry.auto.bootstrap.instrumentation.jdbc;
import static io.opentelemetry.auto.bootstrap.instrumentation.jdbc.DBInfo.DEFAULT; import static io.opentelemetry.auto.bootstrap.instrumentation.jdbc.DBInfo.DEFAULT;
import io.opentelemetry.auto.bootstrap.ExceptionLogger;
import java.io.UnsupportedEncodingException; import java.io.UnsupportedEncodingException;
import java.net.URI; import java.net.URI;
import java.net.URLDecoder; import java.net.URLDecoder;
@ -29,6 +28,8 @@ import java.util.Map;
import java.util.Properties; import java.util.Properties;
import java.util.regex.Matcher; import java.util.regex.Matcher;
import java.util.regex.Pattern; import java.util.regex.Pattern;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/** /**
* Structured as an enum instead of a class hierarchy to allow iterating through the parsers * Structured as an enum instead of a class hierarchy to allow iterating through the parsers
@ -742,6 +743,8 @@ public enum JDBCConnectionUrlParser {
} }
}; };
private static final Logger log = LoggerFactory.getLogger(JDBCConnectionUrlParser.class);
private static final Map<String, JDBCConnectionUrlParser> typeParsers = new HashMap<>(); private static final Map<String, JDBCConnectionUrlParser> typeParsers = new HashMap<>();
static { static {
@ -791,7 +794,7 @@ public enum JDBCConnectionUrlParser {
} }
return withUrl(GENERIC_URL_LIKE.doParse(jdbcUrl, parsedProps), type); return withUrl(GENERIC_URL_LIKE.doParse(jdbcUrl, parsedProps), type);
} catch (final Exception e) { } catch (final Exception e) {
ExceptionLogger.LOGGER.debug("Error parsing URL", e); log.debug("Error parsing URL", e);
return parsedProps.build(); return parsedProps.build();
} }
} }
@ -870,7 +873,7 @@ public enum JDBCConnectionUrlParser {
try { try {
builder.port(Integer.parseInt(portNumber)); builder.port(Integer.parseInt(portNumber));
} catch (final NumberFormatException e) { } catch (final NumberFormatException e) {
ExceptionLogger.LOGGER.debug("Error parsing portnumber property: " + portNumber, e); log.debug("Error parsing portnumber property: " + portNumber, e);
} }
} }
@ -879,7 +882,7 @@ public enum JDBCConnectionUrlParser {
try { try {
builder.port(Integer.parseInt(portNumber)); builder.port(Integer.parseInt(portNumber));
} catch (final NumberFormatException e) { } catch (final NumberFormatException e) {
ExceptionLogger.LOGGER.debug("Error parsing portNumber property: " + portNumber, e); log.debug("Error parsing portNumber property: " + portNumber, e);
} }
} }
} }

View File

@ -16,14 +16,18 @@
package io.opentelemetry.auto.instrumentation.jdbc; package io.opentelemetry.auto.instrumentation.jdbc;
import io.opentelemetry.auto.bootstrap.ExceptionLogger;
import io.opentelemetry.auto.config.Config; import io.opentelemetry.auto.config.Config;
import io.opentelemetry.auto.instrumentation.jdbc.normalizer.SqlNormalizer; import io.opentelemetry.auto.instrumentation.jdbc.normalizer.SqlNormalizer;
import java.lang.reflect.Field; import java.lang.reflect.Field;
import java.sql.Connection; import java.sql.Connection;
import java.sql.Statement; import java.sql.Statement;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
public abstract class JDBCUtils { public abstract class JDBCUtils {
private static final Logger log = LoggerFactory.getLogger(JDBCUtils.class);
private static Field c3poField = null; private static Field c3poField = null;
/** /**
@ -67,7 +71,7 @@ public abstract class JDBCUtils {
} }
} catch (final Throwable e) { } catch (final Throwable e) {
// Had some problem getting the connection. // Had some problem getting the connection.
ExceptionLogger.LOGGER.debug("Could not get connection for StatementAdvice", e); log.debug("Could not get connection for StatementAdvice", e);
return null; return null;
} }
return connection; return connection;
@ -81,7 +85,7 @@ public abstract class JDBCUtils {
try { try {
return SqlNormalizer.normalize(sql); return SqlNormalizer.normalize(sql);
} catch (Exception e) { } catch (Exception e) {
ExceptionLogger.LOGGER.debug("Could not normalize sql", e); log.debug("Could not normalize sql", e);
return null; return null;
} }
} }