Class TracingSupport
- java.lang.Object
-
- graphql.execution.instrumentation.tracing.TracingSupport
-
- All Implemented Interfaces:
InstrumentationState
@PublicApi public class TracingSupport extends java.lang.Object implements InstrumentationState
This creates a map of tracing information as outlined in https://github.com/apollographql/apollo-tracingThis is a stateful object that should be instantiated and called via
Instrumentation
calls. It has been made a separate class so that you can compose this into existing instrumentation code.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static interface
TracingSupport.TracingContext
A simple object that you need to callTracingSupport.TracingContext.onEnd()
on
-
Field Summary
Fields Modifier and Type Field Description private java.util.concurrent.ConcurrentLinkedQueue<java.util.Map<java.lang.String,java.lang.Object>>
fieldData
private boolean
includeTrivialDataFetchers
private java.util.Map<java.lang.String,java.lang.Object>
parseMap
private long
startRequestNanos
private java.time.Instant
startRequestTime
private java.util.Map<java.lang.String,java.lang.Object>
validationMap
-
Constructor Summary
Constructors Constructor Description TracingSupport(boolean includeTrivialDataFetchers)
The timer starts as soon as you create this object
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description TracingSupport.TracingContext
beginField(DataFetchingEnvironment dataFetchingEnvironment, boolean trivialDataFetcher)
This should be called to start the trace of a field, withTracingSupport.TracingContext.onEnd()
being called to end the call.TracingSupport.TracingContext
beginParse()
This should be called to start the trace of query parsing, withTracingSupport.TracingContext.onEnd()
being called to end the call.TracingSupport.TracingContext
beginValidation()
This should be called to start the trace of query validation, withTracingSupport.TracingContext.onEnd()
being called to end the call.private java.lang.Object
copyMap(java.util.Map<java.lang.String,java.lang.Object> map)
private java.util.Map<java.lang.String,java.lang.Object>
executionData()
private java.lang.String
rfc3339(java.time.Instant time)
java.util.Map<java.lang.String,java.lang.Object>
snapshotTracingData()
This will snapshot this tracing and return a map of the resultsprivate TracingSupport.TracingContext
traceToMap(java.util.Map<java.lang.String,java.lang.Object> map)
-
-
-
Field Detail
-
startRequestTime
private final java.time.Instant startRequestTime
-
startRequestNanos
private final long startRequestNanos
-
fieldData
private final java.util.concurrent.ConcurrentLinkedQueue<java.util.Map<java.lang.String,java.lang.Object>> fieldData
-
parseMap
private final java.util.Map<java.lang.String,java.lang.Object> parseMap
-
validationMap
private final java.util.Map<java.lang.String,java.lang.Object> validationMap
-
includeTrivialDataFetchers
private final boolean includeTrivialDataFetchers
-
-
Method Detail
-
beginField
public TracingSupport.TracingContext beginField(DataFetchingEnvironment dataFetchingEnvironment, boolean trivialDataFetcher)
This should be called to start the trace of a field, withTracingSupport.TracingContext.onEnd()
being called to end the call.- Parameters:
dataFetchingEnvironment
- the data fetching that is occurringtrivialDataFetcher
- if the data fetcher is considered trivial- Returns:
- a context to call end on
-
beginParse
public TracingSupport.TracingContext beginParse()
This should be called to start the trace of query parsing, withTracingSupport.TracingContext.onEnd()
being called to end the call.- Returns:
- a context to call end on
-
beginValidation
public TracingSupport.TracingContext beginValidation()
This should be called to start the trace of query validation, withTracingSupport.TracingContext.onEnd()
being called to end the call.- Returns:
- a context to call end on
-
traceToMap
private TracingSupport.TracingContext traceToMap(java.util.Map<java.lang.String,java.lang.Object> map)
-
snapshotTracingData
public java.util.Map<java.lang.String,java.lang.Object> snapshotTracingData()
This will snapshot this tracing and return a map of the results- Returns:
- a snapshot of the tracing data
-
copyMap
private java.lang.Object copyMap(java.util.Map<java.lang.String,java.lang.Object> map)
-
executionData
private java.util.Map<java.lang.String,java.lang.Object> executionData()
-
rfc3339
private java.lang.String rfc3339(java.time.Instant time)
-
-