zalando / logbook

An extensible Java library for HTTP request and response logging
MIT License
1.83k stars 260 forks source link

Micronaut configuration #629

Closed marceloverdijk closed 4 years ago

marceloverdijk commented 4 years ago

Would you consider adding a logbook-micronaut-configuration module similar as logbook-spring-boot-starter? Or accepting a PR for this?

marceloverdijk commented 4 years ago

Probably not that easy as the http logging is tight to the servlet api, which Micronaut is not using. It is similar as https://github.com/zalando/logbook/issues/331.

whiskeysierra commented 4 years ago

What is micronaut using? Netty directly?

On Mon, 4 Nov 2019, 10:57 Marcel Overdijk, notifications@github.com wrote:

Probably not that easy as the http logging is tight to the servlet api, which Micronaut is not using. It is similar as #331 https://github.com/zalando/logbook/issues/331.

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/zalando/logbook/issues/629?email_source=notifications&email_token=AADI7HINTRYEZIOKD7ALI43QR7WXVA5CNFSM4JIQ6U7KYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEC6WUPI#issuecomment-549284413, or unsubscribe https://github.com/notifications/unsubscribe-auth/AADI7HLKGBGVGESWOJEV4UDQR7WXVANCNFSM4JIQ6U7A .

marceloverdijk commented 4 years ago

@whiskeysierra Under the hood yes, but not directly. But exposed in the framework they have their own classes like Micronaut's HttpRequest similar as Spring WebFlux has ServerRequest That's why I made the second comment that it might not be that easy.

whiskeysierra commented 4 years ago

If we could build a module for Netty than that could cover #331 as well

whiskeysierra commented 4 years ago

@marceloverdijk Do you happen to have experience with micronaut in terms of a customized netty setup by any chance?

marceloverdijk commented 4 years ago

@whiskeysierra unfortunately not, maybe good to reach out to @graemerocher or discuss it on https://gitter.im/micronautfw/questions

graemerocher commented 4 years ago

What is it you want to achieve?

whiskeysierra commented 4 years ago

I want to register a custom ChannelHandler which does http-specific traffic logging.

graemerocher commented 4 years ago

Seems currently we only allow injection of instances of ChannelOutboundHandler if your instance is a ChannelOutboundHandler then you can do:

@javax.inject.Singleton
class MyHandler implements ChannelOutboundHandler {
  // your impl
}

And it will be registered automatically

whiskeysierra commented 4 years ago

@graemerocher Can I control the position within the pipeline?

graemerocher commented 4 years ago

You can implemented Ordered but that doesn't seem to provide full control at the moment. Where does it need to go in the pipeline?

whiskeysierra commented 4 years ago

After the http codec. I need to observe Netty's HttpRequest and HttpResponse objects as messages in my handler.

graemerocher commented 4 years ago

Seems like we need a better API for that. Can you report an issue https://github.com/micronaut-projects/micronaut-core/issues

whiskeysierra commented 4 years ago

708 introduces support for Netty. Now it's up to Micronaut users to lobby for the change on Micronaut side to get the ability to register those handlers into Micronaut itself: https://github.com/micronaut-projects/micronaut-core/issues/2719

dstepanov commented 4 years ago

@whiskeysierra Is there a way to try netty support for logbook? 'https://oss.sonatype.org/content/repositories/snapshots' and 2.1.0-SNAPSHOT doesn't work.