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 Details

  • Constructor Details

    • DefaultInstrumentationLogger

      public DefaultInstrumentationLogger(JiraProperties jiraProperties, FeatureManager featureManager, com.atlassian.event.api.EventPublisher eventPublisher)
  • Method Details

    • afterInstantiation

      public void afterInstantiation() throws Exception
      Description copied from interface: InitializingComponent
      Called 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:
      afterInstantiation in interface InitializingComponent
      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: InstrumentationLogger
      Saves 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:
      save in interface InstrumentationLogger
      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: InstrumentationLogger
      Saves 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:
      save in interface InstrumentationLogger
      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: InstrumentationLogger
      Saves 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:
      save in interface InstrumentationLogger
      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 otherwise
      parentSpanId - The Zipkin parent spanId (if there is on, null otherwise).
      entry - The LogEntry data
      requestTime - An Optional that may contain the total request time in nanoseconds if applicable.
      Returns:
      The JSON object as a string.
    • cleanMdc

      protected void cleanMdc()
    • getLogEntriesFromBuffer

      public List<LogEntry> getLogEntriesFromBuffer()
      Description copied from interface: InstrumentationLogger
      Fetch the current list of statistics stored in memory.
      Specified by:
      getLogEntriesFromBuffer in interface InstrumentationLogger
      Returns:
      A copy of the current list.
    • clearMemoryBuffer

      public void clearMemoryBuffer()
      Description copied from interface: InstrumentationLogger
      Clear all the data collected in the memory buffer.
      Specified by:
      clearMemoryBuffer in interface InstrumentationLogger
    • isEnabled

      protected boolean isEnabled()