Class OpenTelemetryDriver

java.lang.Object
io.opentelemetry.instrumentation.jdbc.OpenTelemetryDriver
All Implemented Interfaces:
Driver

public final class OpenTelemetryDriver extends Object implements Driver
JDBC driver for OpenTelemetry.
  • Constructor Details

    • OpenTelemetryDriver

      public OpenTelemetryDriver()
  • Method Details

    • register

      public static void register() throws SQLException
      Register the driver against DriverManager. This is done automatically when the class is loaded. Dropping the driver from DriverManager's list is possible using deregister() method.
      Throws:
      IllegalStateException - if the driver is already registered
      SQLException - if registering the driver fails
    • deregister

      public static void deregister() throws SQLException
      According to JDBC specification, this driver is registered against DriverManager when the class is loaded. To avoid leaks, this method allow unregistering the driver so that the class can be gc'ed if necessary.
      Throws:
      IllegalStateException - if the driver is not registered
      SQLException - if deregistering the driver fails
    • isRegistered

      public static boolean isRegistered()
      Returns true if the driver is registered against DriverManager.
    • addDriverCandidate

      public static void addDriverCandidate(Driver driver)
      Add driver candidate that wasn't registered against DriverManager. This is mainly useful when drivers are initialized at native image build time, and you don't want to postpone class initialization, for runtime initialization could make driver incompatible with other systems. Drivers registered with this method have higher priority over those registered against DriverManager.
      Parameters:
      driver - Driver that should be registered
    • removeDriverCandidate

      public static boolean removeDriverCandidate(Driver driver)
      Remove driver added via addDriverCandidate(Driver).
      Parameters:
      driver - Driver that should be unregistered
      Returns:
      true if the driver was unregistered
    • install

      public static void install(io.opentelemetry.api.OpenTelemetry openTelemetry)
      Installs the OpenTelemetry instance on the OpenTelemetryDriver. OpenTelemetry has to be set before the initialization of the database connection pool.
    • setOpenTelemetry

      public void setOpenTelemetry(io.opentelemetry.api.OpenTelemetry openTelemetry)
      Configures the OpenTelemetry. See install(OpenTelemetry) for simple installation option. OpenTelemetry has to be set before the initialization of the database connection pool.
    • connect

      @Nullable public Connection connect(String url, Properties info) throws SQLException
      Specified by:
      connect in interface Driver
      Throws:
      SQLException
    • acceptsURL

      public boolean acceptsURL(String url)
      Specified by:
      acceptsURL in interface Driver
    • getPropertyInfo

      public DriverPropertyInfo[] getPropertyInfo(String url, Properties info) throws SQLException
      Specified by:
      getPropertyInfo in interface Driver
      Throws:
      SQLException
    • getMajorVersion

      public int getMajorVersion()
      Specified by:
      getMajorVersion in interface Driver
    • getMinorVersion

      public int getMinorVersion()
      Specified by:
      getMinorVersion in interface Driver
    • jdbcCompliant

      public boolean jdbcCompliant()
      Returns false because not all delegated drivers are JDBC compliant.
      Specified by:
      jdbcCompliant in interface Driver
    • getParentLogger

      public Logger getParentLogger() throws SQLFeatureNotSupportedException
      Specified by:
      getParentLogger in interface Driver
      Throws:
      SQLFeatureNotSupportedException