Class MdcCopyingAsyncTaskExecutor

java.lang.Object
com.netflix.spinnaker.kork.web.context.MdcCopyingAsyncTaskExecutor
All Implemented Interfaces:
Executor, org.springframework.core.task.AsyncTaskExecutor, org.springframework.core.task.TaskExecutor

public class MdcCopyingAsyncTaskExecutor extends Object implements org.springframework.core.task.AsyncTaskExecutor
Copy the MDC before executing tasks. This supports async controller methods (e.g. that return StreamingResponseBody) passing X-SPINNAKER-* headers to downstream requests, and including the MDC from the calling thread in log messages.

The typical pattern is:

AuthenticatedRequestFilter: copies X-SPINNAKER-* incoming request headers into the MDC SpinnakerRequestInterceptor: copies X-SPINNAKER-* from the MDC into outgoing request headers

MdcCopyingAsyncTaskExecutor makes it so SpinnakerRequestInterceptor has something to copy for async methods. It also makes it so log messages include X-SPINNAKER-*, specifically X-SPINNAKER-REQUEST-ID and X-SPINNAKER-REQUEST-ID to faciliate troubleshooting.

  • Constructor Details

    • MdcCopyingAsyncTaskExecutor

      public MdcCopyingAsyncTaskExecutor(org.springframework.core.task.AsyncTaskExecutor asyncTaskExecutor)
  • Method Details

    • execute

      public void execute(Runnable task)
      Specified by:
      execute in interface Executor
      Specified by:
      execute in interface org.springframework.core.task.TaskExecutor
    • execute

      public void execute(Runnable task, long startTimeout)
      Specified by:
      execute in interface org.springframework.core.task.AsyncTaskExecutor
    • submit

      public Future<?> submit(Runnable task)
      Specified by:
      submit in interface org.springframework.core.task.AsyncTaskExecutor
    • submit

      public <T> Future<T> submit(Callable<T> task)
      Specified by:
      submit in interface org.springframework.core.task.AsyncTaskExecutor