DaveAKing / guava-libraries

Automatically exported from code.google.com/p/guava-libraries
Apache License 2.0
0 stars 0 forks source link

Feature Request: add logging to ServiceManager.stopAsync #1405

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
When services are started in the ServiceManager, we get useful logs such as:

Starting ServiceA [NEW]
Started ConcurrentOpenTree ServiceA in 7 ms.

Unfortunately, ServiceManager is completely silent when stopping services, 
which makes it hard to debug problems (or identify services that take too long 
to stop). I'd argue for similar logs while stopping services, if only for 
consistency with startAsync.

Original issue reported on code.google.com by diwa...@maginatics.com on 9 May 2013 at 11:22

GoogleCodeExporter commented 9 years ago
Trivial patch that just adds a simple log:

--- guava/src/com/google/common/util/concurrent/ServiceManager.java
+++ guava/src/com/google/common/util/concurrent/ServiceManager.java
@@ -302,6 +302,9 @@ public final class ServiceManager {
    */
   public ServiceManager stopAsync() {
     for (Service service : services.keySet()) {
+      if (!(service instanceof NoOpService)) {
+        logger.log(Level.FINE, "Stopping {0}.", service);
+      }
       service.stop();
     }
     return this;

Ideally I'd also want a timer (similar to when starting services) so we get 
separate messages for 'Stopping' and 'Stopped in X ms'. This would involve 
changing the ServiceListener though. I'm happy to submit a patch if there's 
enough interest.

Original comment by diwa...@maginatics.com on 10 May 2013 at 9:51

GoogleCodeExporter commented 9 years ago

Original comment by kevinb@google.com on 20 Nov 2013 at 10:21

GoogleCodeExporter commented 9 years ago
Logging was added for when services become TERMINATED or FAILED but there are 
still no timers for service shutdown.

what is your usecase for shutdown timers?  would you want to include failed 
services in that set of timings?

Original comment by lu...@google.com on 22 Jan 2014 at 4:33

GoogleCodeExporter commented 9 years ago
Use case for timers is to surface services that take unexpectedly long to shut 
down. Timing for failed services is probably not that useful, but doesn't hurt 
if it simplifies the patch.

Broader use case for logs is consistency with startup and to simply observe 
that services are indeed being shut down properly -- this is useful for 
debugging.

Original comment by diwakerg...@gmail.com on 22 Jan 2014 at 5:15

GoogleCodeExporter commented 9 years ago
This issue has been migrated to GitHub.

It can be found at https://github.com/google/guava/issues/<issue id>

Original comment by cgdecker@google.com on 1 Nov 2014 at 4:12

GoogleCodeExporter commented 9 years ago

Original comment by cgdecker@google.com on 1 Nov 2014 at 4:17

GoogleCodeExporter commented 9 years ago

Original comment by cgdecker@google.com on 3 Nov 2014 at 9:08