Class QueryTrace
- java.lang.Object
-
- com.datastax.driver.core.QueryTrace
-
public class QueryTrace extends Object
The Cassandra trace for a query.A trace is generated by Cassandra when query tracing is enabled for the query. The trace itself is stored in Cassandra in the
sessionsandeventstable in thesystem_traceskeyspace and can be retrieve manually using the trace identifier (the one returned bygetTraceId()).This class provides facilities to fetch the traces from Cassandra. Please note that the writing of the trace is done asynchronously in Cassandra. So accessing the trace too soon after the query may result in the trace being incomplete.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classQueryTrace.EventA trace event.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description InetAddressgetCoordinator()Returns the coordinator host of the query.intgetDurationMicros()Returns the server-side duration of the query in microseconds.List<QueryTrace.Event>getEvents()Returns the events contained in this trace.Map<String,String>getParameters()Returns the parameters attached to this trace.StringgetRequestType()Returns the type of request.longgetStartedAt()Returns the server-side timestamp of the start of this query.UUIDgetTraceId()Returns the identifier of this trace.StringtoString()
-
-
-
Method Detail
-
getTraceId
public UUID getTraceId()
Returns the identifier of this trace.Note that contrary to the other methods in this class, this does not entail fetching query trace details from Cassandra.
- Returns:
- the identifier of this trace.
-
getRequestType
public String getRequestType()
Returns the type of request.- Returns:
- the type of request or
nullif the request type is not yet available. - Throws:
TraceRetrievalException- if the trace details cannot be retrieve from Cassandra successfully.
-
getDurationMicros
public int getDurationMicros()
Returns the server-side duration of the query in microseconds.- Returns:
- the (server side) duration of the query in microseconds. This method will return
Integer.MIN_VALUEif the duration is not yet available. - Throws:
TraceRetrievalException- if the trace details cannot be retrieve from Cassandra successfully.
-
getCoordinator
public InetAddress getCoordinator()
Returns the coordinator host of the query.- Returns:
- the coordinator host of the query or
nullif the coordinator is not yet available. - Throws:
TraceRetrievalException- if the trace details cannot be retrieve from Cassandra successfully.
-
getParameters
public Map<String,String> getParameters()
Returns the parameters attached to this trace.- Returns:
- the parameters attached to this trace. or
nullif the coordinator is not yet available. - Throws:
TraceRetrievalException- if the trace details cannot be retrieve from Cassandra successfully.
-
getStartedAt
public long getStartedAt()
Returns the server-side timestamp of the start of this query.- Returns:
- the server side timestamp of the start of this query or 0 if the start timestamp is not available.
- Throws:
TraceRetrievalException- if the trace details cannot be retrieve from Cassandra successfully.
-
getEvents
public List<QueryTrace.Event> getEvents()
Returns the events contained in this trace.Query tracing is asynchronous in Cassandra. Hence, it is possible for the list returned to be missing some events for some of the replica involved in the query if the query trace is requested just after the return of the query it is a trace of (the only guarantee being that the list will contain the events pertaining to the coordinator of the query).
- Returns:
- the events contained in this trace.
- Throws:
TraceRetrievalException- if the trace details cannot be retrieve from Cassandra successfully.
-
-