Class Db
- java.lang.Object
-
- co.elastic.apm.agent.impl.context.Db
-
- All Implemented Interfaces:
Recyclable
public class Db extends java.lang.Object implements Recyclable
An object containing contextual data for database spans
-
-
Constructor Summary
Constructors Constructor Description Db()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidcopyFrom(Db other)longgetAffectedRowsCount()java.lang.StringgetDbLink()DB Link for connections between 2 databasesjava.lang.StringgetInstance()Database instance namejava.lang.StringgetStatement()A database statement (e.g.java.nio.CharBuffergetStatementBuffer()Returns the associated pooledCharBufferto record the DB statement.java.lang.StringgetType()Database type.java.lang.StringgetUser()Username for accessing databasebooleanhasContent()voidresetState()resets pooled object state so it can be reusedDbwithAffectedRowsCount(long count)Sets the number of affected rows by statement executionDbwithDbLink(java.lang.String dbLink)DB Link for connections between 2 databasesDbwithInstance(java.lang.String instance)Database instance nameDbwithStatement(java.lang.String statement)A database statement (e.g.java.nio.CharBufferwithStatementBuffer()Gets a pooledCharBufferto record the DB statement and associates it with this instance.DbwithType(java.lang.String type)Database type.DbwithUser(java.lang.String user)Username for accessing database
-
-
-
Method Detail
-
getInstance
@Nullable public java.lang.String getInstance()
Database instance name
-
withInstance
public Db withInstance(@Nullable java.lang.String instance)
Database instance name
-
getStatement
@Nullable public java.lang.String getStatement()
A database statement (e.g. query) for the given database type
-
withStatement
public Db withStatement(@Nullable java.lang.String statement)
A database statement (e.g. query) for the given database type
-
withStatementBuffer
public java.nio.CharBuffer withStatementBuffer()
Gets a pooledCharBufferto record the DB statement and associates it with this instance.Note: you may not hold a reference to the returned
CharBufferas it will be reused.Note: This method is not thread safe
- Returns:
- a
CharBufferto record the DB statement
-
getStatementBuffer
@Nullable public java.nio.CharBuffer getStatementBuffer()
Returns the associated pooledCharBufferto record the DB statement.Note: returns
nullunlesswithStatementBuffer()has previously been called- Returns:
- a
CharBufferto record the DB statement, ornull
-
getType
@Nullable public java.lang.String getType()
Database type. For any SQL database, "sql". For others, the lower-case database category, e.g. "cassandra", "hbase", or "redis"
-
withType
public Db withType(@Nullable java.lang.String type)
Database type. For any SQL database, "sql". For others, the lower-case database category, e.g. "cassandra", "hbase", or "redis"
-
getUser
@Nullable public java.lang.String getUser()
Username for accessing database
-
withUser
public Db withUser(@Nullable java.lang.String user)
Username for accessing database
-
getDbLink
@Nullable public java.lang.String getDbLink()
DB Link for connections between 2 databases
-
withDbLink
public Db withDbLink(@Nullable java.lang.String dbLink)
DB Link for connections between 2 databases
-
getAffectedRowsCount
public long getAffectedRowsCount()
- Returns:
- number of affected rows by statement execution. A negative value might indicate feature is not supported by db/driver.
-
withAffectedRowsCount
public Db withAffectedRowsCount(long count)
Sets the number of affected rows by statement execution- Parameters:
count- number of affected rows- Returns:
- this
-
resetState
public void resetState()
Description copied from interface:Recyclableresets pooled object state so it can be reused- Specified by:
resetStatein interfaceRecyclable
-
hasContent
public boolean hasContent()
-
copyFrom
public void copyFrom(Db other)
-
-