-
Notifications
You must be signed in to change notification settings - Fork 58
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Tail.rb self.new_observing initialization issue #76
Comments
@bdanziger - I don't understand either. The tests in In module FileWatch
class Tail
extend Forwardable
def_delegators :@target, :tail, :logger=, :subscribe, :sincedb_record_uid, :sincedb_write, :quit, :close_file
attr_writer :target
def self.new_observing(opts = {})
new.tap do |instance|
instance.target = ObservingTail.new(opts)
end
end
def initialize(opts = {})
@target = YieldingTail.new(opts)
end
end
end the Tail class is a delegator that delegates to either YieldingTail or ObservingTail depending on whether one invokes it with For me, it is a bug that, when using |
Interesting. I am using Logstash and my logstash config file is using the "file" plugin. I traced the code and logstash is calling the new_observing method in tail.rb. I see my opts. Then, it runs the new.tap line and it calls initialize in tail.rb. I print out opts and it is empty. Then it calls YieldingTail.new(opts) with an empty opts. I can show you two stack traces. VERY VERBOSE. MY PRINT STATEMENTS SO IT IS CLEARER. The first stacktrace shows it not passing the args. The second shows it working properly, where I change the new.tap to new(opts).tap. I can send a standard stacktrace if necessary. Thanks Below is the trace with the code as is. YieldingTail is called with no opts. The only way I can fix this without changing code is I now have to set SINCEDB_DIR or HOME environment variable in pipeline.rb and about to call register BELOW is with the code new(opts).tap that I changed. |
@bdanziger - I see now. The problem is when the redundant YieldingTail is created with empty opts. None of the Logstash team have noticed this bug before - we must all have HOME set. As I said before the real problem is creating a YieldingTail object and then immediately throwing it away. Please accept my apologies, I will fix this. In the meantime can you set HOME to a valid path. I will need to release a new version of the file input. |
Yes, I didn't know enough about the code to know whether the throw away call to YieldingTail was the issue or if for some unknown reason it needed to be called and it wasn't passing the opts, which caused me to have an issue. Either way, this triggers the issue. I can keep HOME or SINCEDB_DIR set to something to prevent. Thank you, but no apology needed. I am just trying to help. |
No need to apologise. Your help is gladly accepted. It threw me that you On Tue, 16 Feb 2016 20:33 Bruce Danziger notifications@github.com wrote:
|
I guess I don't understand something. I was going to report it under Logstash, but I thought the issue was with the filewatch plugin? Tail.rb is part of filewatch, so that is where I logged the issue. I thought the bug should be reported with the plugin, unless I am really missing something here. |
It's no biggie. As the problem manifests in LS, people usually report it On Tue, 16 Feb 2016 20:51 Bruce Danziger notifications@github.com wrote:
|
Unless I do not understand what is happening in tail.rb I believe there is a bug when creating a new Tail object when using self.new_observing from file.rb. For the new.tap code in tail.rb below, it is creating a new Tail object and calls the initialization method that is in this file. If I understand the code correctly, it will be overriding the instance.target from (YieldingTail) but regardless, the initialization from the tap.new does not pass in the opts arguments. So, initialization receives no opts args. Then, YieldingTail.new(opts) passes in no opts args. Then in turn tail_base.rb initialization receives no opts args.
You might ask, why is this an issue if YieldingTail just gets overwritten.
I set my sincedb_path config for file.rb
In tail_base.rb, since it receives no opts, it never sees my sincedb_path config value. I am now forced to set HOME or SINCEDB_DIR environment variables because it is not seeing that I passed in a sincedb_path option in the opts.
This is the code that causes this :
when using :
new.tap do | instance |
instance.target = ObservingTail.new(opts)
end
Below, I show a simple fix :
new(opts).tap should be used instead of new.tap
so, it would be
new(opts).tap do | instance |
instance.target = ObservingTail.new(opts)
end
This code now properly passes in my opts, and I never need to set ENV HOME or SINCEDB_DIR since I am already setting it as a file config parameter.
The text was updated successfully, but these errors were encountered: