fix: dont call method on unitialized logger#50
Conversation
43b7409 to
62d0158
Compare
|
Hey @aglover-zendesk About the |
|
hey @remeh thanks for the reply. your point is valid, changing the behavior such that an exception can be raised feels like a breaking change. I will remove the if you think there's value in (optionally) raising an exception after retries are exhausted, let me know and i'd be happy to implement that as a separate PR. |
62d0158 to
9fee0db
Compare
|
@aglover-zendesk thanks for having adapted your PR, I'll merge it immediately in the main branch and will create a new release shipping it 👍 |
What does this PR do?
Fixes an issue where the
errormethod is called on a nil@loggerinstance variable. Seefluent-plugin-datadog/lib/fluent/plugin/out_datadog.rb
Line 144 in 49f8e4e
The
@loggerinstance variable is only set in theDatadogClientclass and its subclasses, but it is never initialized in the parentFluent::DatadogOutputclass. Instead, I believe the output plugin should be using thelogmethod of the PluginLoggerMixin. At least this would match the example from the docs.Note that I tried to write tests for this, but (a) was unable to mock a failed method call in test-unit and (b) was unable to access the instance of the Fluent log object to assert anything. Let me know if I'm missing something, happy to take another swing at a unit test if this is doable.
Motivation
Any exception coming from the
writemethod is lost. Right now it is very difficult to debug failures from the plugin. The only error message I'm getting isundefined method 'error' for nil:NilClass. This has come up in previous issues like #41 as wellAdditional Notes
Anything else we should know when reviewing?
I appreciate your work on this Gem ❤️