Class DatabaseClientTracer<CONNECTION,STATEMENT,SANITIZEDSTATEMENT>
- java.lang.Object
-
- io.opentelemetry.instrumentation.api.tracer.BaseTracer
-
- io.opentelemetry.instrumentation.api.tracer.DatabaseClientTracer<CONNECTION,STATEMENT,SANITIZEDSTATEMENT>
-
- Type Parameters:
CONNECTION- type of the database connection.STATEMENT- type of the database statement being executed.SANITIZEDSTATEMENT- type of the database statement after sanitization.
public abstract class DatabaseClientTracer<CONNECTION,STATEMENT,SANITIZEDSTATEMENT> extends BaseTracer
Base class for implementing Tracers for database clients.
-
-
Field Summary
Fields Modifier and Type Field Description protected NetPeerAttributesnetPeerAttributes
-
Constructor Summary
Constructors Modifier Constructor Description protectedDatabaseClientTracer(io.opentelemetry.api.OpenTelemetry openTelemetry, NetPeerAttributes netPeerAttributes)protectedDatabaseClientTracer(NetPeerAttributes netPeerAttributes)
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description static StringconventionSpanName(@Nullable String dbName, @Nullable String operation, @Nullable String table)A helper method for constructing the span name formatting according to DB semantic conventions:<db.operation> <db.name><table>.static StringconventionSpanName(@Nullable String dbName, @Nullable String operation, @Nullable String table, String defaultValue)A helper method for constructing the span name formatting according to DB semantic conventions:<db.operation> <db.name><table>.protected @Nullable StringdbConnectionString(CONNECTION connection)protected StringdbName(CONNECTION connection)protected StringdbOperation(CONNECTION connection, STATEMENT statement, SANITIZEDSTATEMENT sanitizedStatement)protected StringdbStatement(CONNECTION connection, STATEMENT statement, SANITIZEDSTATEMENT sanitizedStatement)protected abstract StringdbSystem(CONNECTION connection)protected StringdbUser(CONNECTION connection)protected voidonConnection(io.opentelemetry.api.trace.SpanBuilder span, CONNECTION connection)This should be called when the connection is being used, not when it's created.protected voidonStatement(io.opentelemetry.api.trace.SpanBuilder span, CONNECTION connection, STATEMENT statement, SANITIZEDSTATEMENT sanitizedStatement)protected abstract @Nullable InetSocketAddresspeerAddress(CONNECTION connection)protected abstract SANITIZEDSTATEMENTsanitizeStatement(STATEMENT statement)protected voidsetNetSemanticConvention(io.opentelemetry.api.trace.SpanBuilder span, CONNECTION connection)booleanshouldStartSpan(io.opentelemetry.context.Context parentContext)protected StringspanName(CONNECTION connection, STATEMENT statement, SANITIZEDSTATEMENT sanitizedStatement)io.opentelemetry.context.ContextstartSpan(io.opentelemetry.context.Context parentContext, CONNECTION connection, STATEMENT statement)-
Methods inherited from class io.opentelemetry.instrumentation.api.tracer.BaseTracer
end, end, endExceptionally, endExceptionally, extract, getInstrumentationName, getVersion, inject, onException, shouldStartSpan, spanBuilder, startSpan, startSpan, startSpan, unwrapThrowable, withClientSpan, withConsumerSpan, withServerSpan
-
-
-
-
Field Detail
-
netPeerAttributes
protected final NetPeerAttributes netPeerAttributes
-
-
Constructor Detail
-
DatabaseClientTracer
protected DatabaseClientTracer(NetPeerAttributes netPeerAttributes)
-
DatabaseClientTracer
protected DatabaseClientTracer(io.opentelemetry.api.OpenTelemetry openTelemetry, NetPeerAttributes netPeerAttributes)
-
-
Method Detail
-
shouldStartSpan
public boolean shouldStartSpan(io.opentelemetry.context.Context parentContext)
-
startSpan
public io.opentelemetry.context.Context startSpan(io.opentelemetry.context.Context parentContext, CONNECTION connection, STATEMENT statement)
-
sanitizeStatement
protected abstract SANITIZEDSTATEMENT sanitizeStatement(STATEMENT statement)
-
spanName
protected String spanName(CONNECTION connection, STATEMENT statement, SANITIZEDSTATEMENT sanitizedStatement)
-
conventionSpanName
public static String conventionSpanName(@Nullable String dbName, @Nullable String operation, @Nullable String table)
A helper method for constructing the span name formatting according to DB semantic conventions:<db.operation> <db.name><table>.
-
conventionSpanName
public static String conventionSpanName(@Nullable String dbName, @Nullable String operation, @Nullable String table, String defaultValue)
A helper method for constructing the span name formatting according to DB semantic conventions:<db.operation> <db.name><table>. IfdbNameandoperationare not provided thendefaultValueis returned.
-
dbSystem
protected abstract String dbSystem(CONNECTION connection)
-
onConnection
protected void onConnection(io.opentelemetry.api.trace.SpanBuilder span, CONNECTION connection)This should be called when the connection is being used, not when it's created.
-
dbUser
protected String dbUser(CONNECTION connection)
-
dbName
protected String dbName(CONNECTION connection)
-
dbConnectionString
protected @Nullable String dbConnectionString(CONNECTION connection)
-
setNetSemanticConvention
protected void setNetSemanticConvention(io.opentelemetry.api.trace.SpanBuilder span, CONNECTION connection)
-
peerAddress
protected abstract @Nullable InetSocketAddress peerAddress(CONNECTION connection)
-
onStatement
protected void onStatement(io.opentelemetry.api.trace.SpanBuilder span, CONNECTION connection, STATEMENT statement, SANITIZEDSTATEMENT sanitizedStatement)
-
dbStatement
protected String dbStatement(CONNECTION connection, STATEMENT statement, SANITIZEDSTATEMENT sanitizedStatement)
-
dbOperation
protected String dbOperation(CONNECTION connection, STATEMENT statement, SANITIZEDSTATEMENT sanitizedStatement)
-
-