Class DefaultInstrumentationLogger
java.lang.Object
com.atlassian.jira.instrumentation.DefaultInstrumentationLogger
- All Implemented Interfaces:
InitializingComponent,InstrumentationLogger
@ParametersAreNonnullByDefault
public class DefaultInstrumentationLogger
extends Object
implements InstrumentationLogger, InitializingComponent
Logs the instrumentation data that we have collected to various collection mechanisms.
- Since:
- v7.1
-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionDefaultInstrumentationLogger(JiraProperties jiraProperties, FeatureManager featureManager, com.atlassian.event.api.EventPublisher eventPublisher) -
Method Summary
Modifier and TypeMethodDescriptionvoidCalled after all the beans are constructed and the ApplicationContext is fully populated.protected voidcleanMdc()voidClear all the data collected in the memory buffer.protected StringgetJsonString(Optional<String> spanId, Optional<String> parentSpanId, LogEntry entry, Optional<Long> requestTime, Optional<Long> startNanoTime) Generates the JSON string object that we can log.Fetch the current list of statistics stored in memory.protected booleanvoidpluginFrameworkShuttingDown(com.atlassian.plugin.event.events.PluginFrameworkShuttingDownEvent pluginFrameworkShuttingDownEvent) voidsave(RequestData requestData, List<? extends Statistics> requestStats, Optional<Long> requestTime) Saves request data to the queue above.voidsave(RequestData requestData, List<? extends Statistics> requestStats, Optional<Long> requestTime, Exception exception) Saves request data to the queue above and generates a stacktrace that it inserts in the log.voidsave(String traceId, String path, List<? extends Statistics> requestStats, Optional<Long> requestTime) Saves request data to the queue above.
-
Field Details
-
REQUEST_EXECUTION_TIME
- See Also:
-
JIRA_INSTRUMENTATION_LAAS_PROPERTY
- See Also:
-
SPAN_ID
- See Also:
-
PARENT_SPAN_ID
- See Also:
-
-
Constructor Details
-
DefaultInstrumentationLogger
public DefaultInstrumentationLogger(JiraProperties jiraProperties, FeatureManager featureManager, com.atlassian.event.api.EventPublisher eventPublisher)
-
-
Method Details
-
afterInstantiation
Description copied from interface:InitializingComponentCalled after all the beans are constructed and the ApplicationContext is fully populated. Order of execution is order of bean creation, driven by InitializingComponentProcessor.- Specified by:
afterInstantiationin interfaceInitializingComponent- Throws:
Exception
-
pluginFrameworkShuttingDown
@EventListener public void pluginFrameworkShuttingDown(com.atlassian.plugin.event.events.PluginFrameworkShuttingDownEvent pluginFrameworkShuttingDownEvent) -
save
public void save(String traceId, String path, List<? extends Statistics> requestStats, Optional<Long> requestTime) Description copied from interface:InstrumentationLoggerSaves request data to the queue above. The queue will store the last 100 requests by default. As new requests are received the oldest are removed.- Specified by:
savein interfaceInstrumentationLogger- Parameters:
traceId- The ID for this request.path- the path of the URL.requestStats- The list of cache statistics.requestTime- The time in nanoseconds that the request took to complete.
-
save
public void save(RequestData requestData, List<? extends Statistics> requestStats, Optional<Long> requestTime) Description copied from interface:InstrumentationLoggerSaves request data to the queue above. The queue will store the last 100 requests by default. As new requests are received the oldest are removed.- Specified by:
savein interfaceInstrumentationLogger- Parameters:
requestData- data associated with the request.requestStats- The list of cache statistics.requestTime- The time of the request in nanoseconds. If zero, we did not collect any time.
-
save
public void save(RequestData requestData, List<? extends Statistics> requestStats, Optional<Long> requestTime, @Nullable Exception exception) Description copied from interface:InstrumentationLoggerSaves request data to the queue above and generates a stacktrace that it inserts in the log. The queue will store the last 100 requests by default. As new requests are received the oldest are removed.- Specified by:
savein interfaceInstrumentationLogger- Parameters:
requestData- data associated with the request.requestStats- The list of cache statistics.requestTime- The time of the request in nanoseconds. If zero, we did not collect any time.exception- An exception to be included with the log. This can be used if you require a stack trace to be recorded.
-
getJsonString
protected String getJsonString(Optional<String> spanId, Optional<String> parentSpanId, LogEntry entry, Optional<Long> requestTime, Optional<Long> startNanoTime) Generates the JSON string object that we can log.- Parameters:
spanId- The Zipkin spanId (if there is one, null otherwiseparentSpanId- The Zipkin parent spanId (if there is on, null otherwise).entry- TheLogEntrydatarequestTime- AnOptionalthat may contain the total request time in nanoseconds if applicable.- Returns:
- The JSON object as a string.
-
cleanMdc
protected void cleanMdc() -
getLogEntriesFromBuffer
Description copied from interface:InstrumentationLoggerFetch the current list of statistics stored in memory.- Specified by:
getLogEntriesFromBufferin interfaceInstrumentationLogger- Returns:
- A copy of the current list.
-
clearMemoryBuffer
public void clearMemoryBuffer()Description copied from interface:InstrumentationLoggerClear all the data collected in the memory buffer.- Specified by:
clearMemoryBufferin interfaceInstrumentationLogger
-
isEnabled
protected boolean isEnabled()
-