Only set zero values on metrics if we're capturing logs

Only set zero values on metrics if we’re capturing logs

diff --git a/lib/mobystash/container.rb b/lib/mobystash/container.rb
index b7143ef..ebf4223 100644
--- a/lib/mobystash/container.rb
+++ b/lib/mobystash/container.rb
@@ -56,13 +56,6 @@ module Mobystash
 
       @name = (docker_data.info["Name"] || docker_data.info["Names"].first).sub(/\A\//, '')
 
-      if docker_data.info["Config"]["Tty"]
-        @config.log_entries_read_counter.increment({ container_name: @name, container_id: @id, stream: "tty" }, 0)
-      else
-        @config.log_entries_read_counter.increment({ container_name: @name, container_id: @id, stream: "stdout" }, 0)
-        @config.log_entries_read_counter.increment({ container_name: @name, container_id: @id, stream: "stderr" }, 0)
-      end
-
       @capture_logs = true
       @parse_syslog = false
 
@@ -83,6 +76,15 @@ module Mobystash
 
       super
 
+      if @capture_logs
+        if docker_data.info["Config"]["Tty"]
+          @config.log_entries_read_counter.increment({ container_name: @name, container_id: @id, stream: "tty" }, 0)
+        else
+          @config.log_entries_read_counter.increment({ container_name: @name, container_id: @id, stream: "stdout" }, 0)
+          @config.log_entries_read_counter.increment({ container_name: @name, container_id: @id, stream: "stderr" }, 0)
+        end
+      end
+
       @logger.debug(progname) do
         (["Created new container listener.  Instance variables:"] + %i{@name @capture_logs @parse_syslog @tags @last_log_time}.map do |iv|
           "#{iv}=#{instance_variable_get(iv).inspect}"

GitHub sha: 1aea9b83