Interface SqlClientAttributesGetter<REQUEST,RESPONSE>
- All Superinterfaces:
DbClientAttributesGetter<REQUEST,,RESPONSE> io.opentelemetry.instrumentation.api.semconv.network.NetworkAttributesGetter<REQUEST,,RESPONSE> io.opentelemetry.instrumentation.api.semconv.network.ServerAttributesGetter<REQUEST>
Instrumentation authors will create implementations of this interface for their specific
library/framework. It will be used by the SqlClientAttributesExtractor to obtain the
various SQL database client attributes in a type-generic way.
If an attribute is not available in this library, it is appropriate to return null
from the attribute methods, but implement as many as possible for best compliance with the
OpenTelemetry specification.
-
Method Summary
Modifier and TypeMethodDescriptiondefault StringgetDbCollectionName(REQUEST request) SQL instrumentations must not override or call this method.default StringgetDbOperationName(REQUEST request) SQL instrumentations must not override or call this method.default StringgetDbQuerySummary(REQUEST request) SQL instrumentations must not override or call this method.default StringgetDbQueryText(REQUEST request) SQL instrumentations must not override or call this method.getRawQueryTexts(REQUEST request) Get the raw SQL query texts.default Collection<String> getRawQueryTextsForOldSemconv(REQUEST request) Deprecated.This method supports old database semantic conventions and will be removed in 3.0.getSqlDialect(REQUEST request) Returns the SQL dialect used by the database.default booleanisParameterizedQuery(REQUEST request, int queryIndex) Returns whether the query atqueryIndexingetRawQueryTexts(Object)is parameterized.Methods inherited from interface io.opentelemetry.instrumentation.api.incubator.semconv.db.DbClientAttributesGetter
getConnectionString, getDbName, getDbNamespace, getDbOperation, getDbOperationBatchSize, getDbQueryParameters, getDbSystem, getDbSystemName, getErrorType, getUserMethods inherited from interface io.opentelemetry.instrumentation.api.semconv.network.NetworkAttributesGetter
getNetworkLocalAddress, getNetworkLocalInetSocketAddress, getNetworkLocalPort, getNetworkPeerAddress, getNetworkPeerInetSocketAddress, getNetworkPeerPort, getNetworkProtocolName, getNetworkProtocolVersion, getNetworkTransport, getNetworkTypeMethods inherited from interface io.opentelemetry.instrumentation.api.semconv.network.ServerAttributesGetter
getServerAddress, getServerPort
-
Method Details
-
getDbOperationName
SQL instrumentations must not override or call this method.Provide raw query text through
getRawQueryTexts(REQUEST)instead. When the database system does not support query text with multiple operations in non-batch operations, enableSqlClientAttributesExtractorBuilder.setSingleOperationAndCollection(boolean)andSqlClientAttributesExtractorwill derivedb.operation.namefromdb.query.text.- Specified by:
getDbOperationNamein interfaceDbClientAttributesGetter<REQUEST,RESPONSE> - Throws:
UnsupportedOperationException- always
-
getDbQueryText
SQL instrumentations must not override or call this method.Provide raw query text through
getRawQueryTexts(REQUEST)instead.SqlClientAttributesExtractorwill derivedb.query.textfrom the raw query text.- Specified by:
getDbQueryTextin interfaceDbClientAttributesGetter<REQUEST,RESPONSE> - Throws:
UnsupportedOperationException- always
-
getDbQuerySummary
SQL instrumentations must not override or call this method.Provide raw query text through
getRawQueryTexts(REQUEST)instead.SqlClientAttributesExtractorwill derivedb.query.summaryfrom the raw query text.- Specified by:
getDbQuerySummaryin interfaceDbClientAttributesGetter<REQUEST,RESPONSE> - Throws:
UnsupportedOperationException- always
-
getDbCollectionName
SQL instrumentations must not override or call this method.Provide raw query text through
getRawQueryTexts(REQUEST)instead. When the database system does not support query text with multiple collections in non-batch operations, enableSqlClientAttributesExtractorBuilder.setSingleOperationAndCollection(boolean)andSqlClientAttributesExtractorwill derivedb.collection.namefromdb.query.text. Do not enable that option when the database system supports query text with multiple collections in non-batch operations.- Specified by:
getDbCollectionNamein interfaceDbClientAttributesGetter<REQUEST,RESPONSE> - Throws:
UnsupportedOperationException- always
-
getSqlDialect
Returns the SQL dialect used by the database. -
getRawQueryTexts
Get the raw SQL query texts. The values returned by this method are later sanitized by theSqlClientAttributesExtractorbefore being set as span attribute.If
requestis not a batch query, then this method should return a collection with a single element. -
getRawQueryTextsForOldSemconv
Deprecated.This method supports old database semantic conventions and will be removed in 3.0.Returns the raw SQL query texts used to derive old semantic convention attributes and span names.By default, this returns
getRawQueryTexts(Object). Instrumentations may override this method when preserving old semantic convention telemetry requires a different query representation. -
isParameterizedQuery
Returns whether the query atqueryIndexingetRawQueryTexts(Object)is parameterized. Prepared statements are always considered parameterized even if no parameters are bound. By using a parameterized query the user is giving a strong signal that any sensitive data will be passed as parameter values, and so the query does not need to be sanitized. See sanitization of db.query.text.The
queryIndexis zero-based and follows the iteration order ofgetRawQueryTexts(Object). This supports batch operations where individual entries may have different parameterization.
-