Class SqlSubsegments

java.lang.Object
com.amazonaws.xray.sql.SqlSubsegments

public final class SqlSubsegments
extends java.lang.Object
Class containing utility method to create fully-populated SQL subsegments. See https://docs.aws.amazon.com/xray/latest/devguide/xray-api-segmentdocuments.html#api-segmentdocuments-sql
  • Field Summary

    Fields 
    Modifier and Type Field Description
    static java.lang.String DATABASE_TYPE
    The type of SQL Database this query is done on, like MySQL or HikariCP
    static java.lang.String DATABASE_VERSION
    The version of the database product itself, like MySQL 8.0
    static java.lang.String DEFAULT_DATABASE_NAME
    The fallback name for subsegments representing SQL queries that failed to be named dynamically
    static java.lang.String DRIVER_VERSION
    The version of the database driver library used for this database
    static java.lang.String SANITIZED_QUERY
    The SQL query string used in this query.
    static java.lang.String URL
    The URL of the database this query is made on
    static java.lang.String USER
    The database username
  • Method Summary

    Modifier and Type Method Description
    static Subsegment forQuery​(java.sql.Connection connection, @Nullable java.lang.String query)
    Begins a Subsegment populated with data provided by the Connection.getMetaData() method.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

  • Method Details

    • forQuery

      public static Subsegment forQuery​(java.sql.Connection connection, @Nullable java.lang.String query)
      Begins a Subsegment populated with data provided by the Connection.getMetaData() method. Includes the SQL query string if it is non-null, omits it otherwise. Takes care to swallow any potential SQLExceptions and always start a subsegment for consistency.
      Parameters:
      connection - the JDBC connection object used for the query this Subsegment represents.
      query - the SQL query string used in this query, or null if it is not desirable to include in the subsegment, e.g. for security concerns.
      Returns:
      the created Subsegment.