title: Something missing using micronaut filter
body: <p>I am attempting to implement a filter in a micronaut microservice, using the example code documented in Section 6.18 of the documentation:</p>
  
  <p><a href="https://docs.micronaut.io/latest/guide/index.html#filters" rel="nofollow noreferrer">https://docs.micronaut.io/latest/guide/index.html#filters</a></p>
  
  <p>I have a HelloWord service that is essentially the same as the service provided on the documentation, with a controller that goes to "/hello" (as documented). I am also using the same TraceService and trace filter that is provided in Section 6.18. I am compiling and running the server without problems.</p>
  
  <p>Unfortunately, the filter is not being engaged when I test the microservice.</p>
  
  <p>I am pretty sure that something is missing in my code, but as I said I am using the same code that is in the example:</p>
  
  <pre><code>TraceService Class
  
  import io.micronaut.http.HttpRequest;
  import io.reactivex.Flowable;
  import io.reactivex.schedulers.Schedulers;
  import org.slf4j.*;
  
  import javax.inject.Singleton;
  @Singleton
  public class TraceService {
  
      private static final Logger LOG = LoggerFactory.getLogger(TraceService.class);
  
      Flowable&lt;Boolean&gt; trace(HttpRequest&lt;?&gt; request) {
          System.out.println("TRACE ENGAGED!");
          return Flowable.fromCallable(() -&gt; { 
              if (LOG.isDebugEnabled()) {
                  LOG.debug("Tracing request: " + request.getUri());
              }
              // trace logic here, potentially performing I/O 
              return true;
          }).subscribeOn(Schedulers.io()); 
      }
  }
  
  
  Trace Filter    
  
  import io.micronaut.http.*;
  import io.micronaut.http.annotation.Filter;
  import io.micronaut.http.filter.*;
  import org.reactivestreams.Publisher;
  
  @Filter("/hello/**") 
  public class TraceFilter implements HttpServerFilter { 
      private final TraceService traceService;
  
      public TraceFilter(TraceService traceService) { 
          System.out.println("Filter created!");
          this.traceService = traceService;
      }
  
      @Override
      public Publisher&lt;MutableHttpResponse&lt;?&gt;&gt; doFilter(HttpRequest&lt;?&gt; request, ServerFilterChain chain) {
          System.out.println("Filter engaged!");
          return traceService.trace(request) 
                             .switchMap(aBoolean -&gt; chain.proceed(request)) 
                            .doOnNext(res -&gt; res.getHeaders().add("X-Trace-Enabled", "true")
                     );
      }
  }
  
  The Controller
  
  import io.micronaut.http.annotation.*;
  
  @Controller("/hello") 
  public class HelloController {
    @Get("/") 
    public String index() {
      return "Hello World"; 
    }
  }
  </code></pre>
  
  <p>Note that the controller uses code from Section 2.2 of the documentation:</p>
  
  <p><a href="https://docs.micronaut.io/latest/guide/index.html#creatingServer" rel="nofollow noreferrer">https://docs.micronaut.io/latest/guide/index.html#creatingServer</a></p>
  
  <p>I did a number of things to try and see what was happening with the filter, including putting little printouts in strategic parts of the Service and the filter. These printouts are not printing out, which tells me that the filter is not being created or used by Micronaut.</p>
  
  <p>Clearly I am missing somethning. I suspect that there is something I need to do in order to get the system to engage the filter. Unfortunately the documentation just tells how to make the filter, not how to use it in the microservice. Furthermore, there don't appear to be any complete code examples that tell how to make the request system utilize the filter (maybe there is an annotation I need to add to the controller???). </p>
  
  <p>Could someone tell me what I am missing? How do I get the filter to work? At the very least, could someone provide a complete example of how to create the filter and use it in an actual microservice?</p>