public class DefaultInstrumentationListenerManager extends Object implements InstrumentationListenerManager
Constructor and Description |
---|
DefaultInstrumentationListenerManager(InstrumentationLogger instrumentationLogger,
com.atlassian.vcache.internal.VCacheLifecycleManager vCacheLifecycleManager,
JiraVCacheRequestContextSupplier contextSupplier,
com.atlassian.cache.CacheManager cacheManager) |
Modifier and Type | Method and Description |
---|---|
void |
addRequestListener(com.atlassian.instrumentation.caches.RequestListener listener)
Add a listener
|
void |
applyToAllListeners(java.util.function.Consumer<com.atlassian.instrumentation.caches.RequestListener> apply)
Apply function to each listener.
|
static void |
endContext()
End of the context where we are not timing the execution.
|
static void |
endContext(Optional<Long> requestTime)
Called at the end of the request to flush to the currently selected persistence mechanism.
|
Optional<String> |
getCurrentPath() |
Optional<String> |
getCurrentTraceId() |
Optional<RequestData> |
getRequestData() |
void |
processOnEndListeners(RequestData requestData,
Optional<Long> requestTime)
Runs all the registered RequestListeners at the end of the
Request processing.
|
void |
processOnStartListeners()
Run all the listeners at request start up.
|
void |
removeRequestListener(com.atlassian.instrumentation.caches.RequestListener listener)
Remove a listener.
|
static void |
startContext(String path)
Called at the beginning of a request to handle the setup.
|
static void |
startContext(String path,
String traceId,
String spanId,
String parentSpanId,
String queryString,
Long startNanoTime)
Called at the beginning of a request to handle the setup.
|
public DefaultInstrumentationListenerManager(InstrumentationLogger instrumentationLogger, com.atlassian.vcache.internal.VCacheLifecycleManager vCacheLifecycleManager, JiraVCacheRequestContextSupplier contextSupplier, com.atlassian.cache.CacheManager cacheManager)
public void processOnStartListeners()
processOnStartListeners
in interface InstrumentationListenerManager
public void processOnEndListeners(RequestData requestData, Optional<Long> requestTime)
InstrumentationListenerManager
processOnEndListeners
in interface InstrumentationListenerManager
requestData
- The request pathrequestTime
- An @{link Optional} that may contain the request time.@NotNull public void addRequestListener(@Nonnull com.atlassian.instrumentation.caches.RequestListener listener)
InstrumentationListenerManager
addRequestListener
in interface InstrumentationListenerManager
listener
- The listener to add.@NotNull public void removeRequestListener(@Nonnull com.atlassian.instrumentation.caches.RequestListener listener)
InstrumentationListenerManager
removeRequestListener
in interface InstrumentationListenerManager
listener
- The listener to remove.public static void startContext(@Nonnull String path)
path
- An identifier for the request. This will be the path for HttpRequests and the thread name for
threads.public static void startContext(@Nonnull String path, @Nullable String traceId, @Nullable String spanId, @Nullable String parentSpanId, @Nullable String queryString, @Nullable Long startNanoTime)
path
- An identifier for the request. This will be the path for HttpRequests and the thread name for
threads.traceId
- Pass in a traceId. If it is null, then we will generate our own.spanId
- If X_B3_SPAN_ID is set on the request, pass this throughparentSpanId
- If X_B3_PARENT_SPAN_ID is set on the request, pass it through.queryString
- query string that was provided for that request.startNanoTime
- The time that the request began in nanos.public static void endContext()
public static void endContext(Optional<Long> requestTime)
requestTime
- An Optional
that may contain the request timepublic void applyToAllListeners(java.util.function.Consumer<com.atlassian.instrumentation.caches.RequestListener> apply)
InstrumentationListenerManager
applyToAllListeners
in interface InstrumentationListenerManager
apply
- Run a function on each listener.@Nonnull public Optional<String> getCurrentPath()
getCurrentPath
in interface InstrumentationListenerManager
@Nonnull public Optional<String> getCurrentTraceId()
getCurrentTraceId
in interface InstrumentationListenerManager
@Nonnull public Optional<RequestData> getRequestData()
getRequestData
in interface InstrumentationListenerManager
Copyright © 2002-2022 Atlassian. All Rights Reserved.