Package com.amazonaws.xray.sql
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 HikariCPstatic java.lang.String
DATABASE_VERSION
The version of the database product itself, like MySQL 8.0static java.lang.String
DEFAULT_DATABASE_NAME
The fallback name for subsegments representing SQL queries that failed to be named dynamicallystatic java.lang.String
DRIVER_VERSION
The version of the database driver library used for this databasestatic 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 onstatic java.lang.String
USER
The database username
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static Subsegment
forQuery(java.sql.Connection connection, @Nullable java.lang.String query)
Begins aSubsegment
populated with data provided by theConnection.getMetaData()
method.
-
-
-
Field Detail
-
URL
public static final java.lang.String URL
The URL of the database this query is made on- See Also:
- Constant Field Values
-
USER
public static final java.lang.String USER
The database username- See Also:
- Constant Field Values
-
DRIVER_VERSION
public static final java.lang.String DRIVER_VERSION
The version of the database driver library used for this database- See Also:
- Constant Field Values
-
DATABASE_TYPE
public static final java.lang.String DATABASE_TYPE
The type of SQL Database this query is done on, like MySQL or HikariCP- See Also:
- Constant Field Values
-
DATABASE_VERSION
public static final java.lang.String DATABASE_VERSION
The version of the database product itself, like MySQL 8.0- See Also:
- Constant Field Values
-
SANITIZED_QUERY
public static final java.lang.String SANITIZED_QUERY
The SQL query string used in this query. This is not recorded in subsegments by default due to security issues. SDK users may use this key orforQuery(java.sql.Connection, java.lang.String)
to manually record their queries if they wish. See https://github.com/aws/aws-xray-sdk-java/issues/28- See Also:
- Constant Field Values
-
DEFAULT_DATABASE_NAME
public static final java.lang.String DEFAULT_DATABASE_NAME
The fallback name for subsegments representing SQL queries that failed to be named dynamically- See Also:
- Constant Field Values
-
-
Method Detail
-
forQuery
public static Subsegment forQuery(java.sql.Connection connection, @Nullable java.lang.String query)
Begins aSubsegment
populated with data provided by theConnection.getMetaData()
method. Includes the SQL query string if it is non-null, omits it otherwise. Takes care to swallow any potentialSQLException
s and always start a subsegment for consistency.- Parameters:
connection
- the JDBC connection object used for the query thisSubsegment
represents.query
- the SQL query string used in this query, ornull
if it is not desirable to include in the subsegment, e.g. for security concerns.- Returns:
- the created
Subsegment
.
-
-