Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Hard to debug and refactor fluent-plugin-grafana-loki #1645

Closed
takanabe opened this issue Feb 6, 2020 · 3 comments · Fixed by #1646
Closed

Hard to debug and refactor fluent-plugin-grafana-loki #1645

takanabe opened this issue Feb 6, 2020 · 3 comments · Fixed by #1646
Labels
stale A stale issue or PR that will automatically be closed.

Comments

@takanabe
Copy link
Contributor

takanabe commented Feb 6, 2020

Describe the bug

https://github.com/grafana/loki/tree/master/fluentd/fluent-plugin-grafana-loki is not well maintained and hard to debug because,

  • the code creates many rubocop violations
  • the spec does not work

To Reproduce
Steps to reproduce the behavior:

  1. bin/setup
  2. bundle exec rake spec creates the following violation messages and errors
bundle exec rake spec
Running RuboCop...
.rubocop.yml: Metrics/LineLength has the wrong namespace - should be Layout
Inspecting 7 files
....C..

Offenses:

lib/fluent/plugin/out_loki.rb:72:7: C: Metrics/CyclomaticComplexity: Cyclomatic complexity for configure is too high. [7/6]
      def configure(conf) ...
      ^^^^^^^^^^^^^^^^^^^
lib/fluent/plugin/out_loki.rb:76:21: C: Style/ClassCheck: Prefer Object#is_a? over Object#kind_of?.
        unless @uri.kind_of?(URI::HTTP) or @uri.kind_of?(URI::HTTPS)
                    ^^^^^^^^
lib/fluent/plugin/out_loki.rb:76:41: C: Style/AndOr: Use || instead of or.
        unless @uri.kind_of?(URI::HTTP) or @uri.kind_of?(URI::HTTPS)
                                        ^^
lib/fluent/plugin/out_loki.rb:76:49: C: Style/ClassCheck: Prefer Object#is_a? over Object#kind_of?.
        unless @uri.kind_of?(URI::HTTP) or @uri.kind_of?(URI::HTTPS)
                                                ^^^^^^^^
lib/fluent/plugin/out_loki.rb:77:38: C: Style/StringLiterals: Prefer single-quoted strings when you don't need string interpolation or special symbols.
          raise Fluent::ConfigError, "url parameter must be valid HTTP"
                                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
lib/fluent/plugin/out_loki.rb:78:9: C: Layout/EmptyLineAfterGuardClause: Add empty line after guard clause.
        end
        ^^^

7 files inspected, 6 offenses detected

Even if we ignore the robocop by comment out Rakefile like

# frozen_string_literal: true

require 'bundler/gem_tasks'
require 'rspec/core/rake_task'
require 'rubocop/rake_task'

# comment out this line
#RuboCop::RakeTask.new(:spec)
RSpec::Core::RakeTask.new(:spec)

task default: :spec

bundle exec rake spec fails due to the following errors

bundle exec rake spec
/Users/takayuki-watanabe/.rbenv/versions/2.6.5/bin/ruby -I/Users/takayuki-watanabe/.rbenv/versions/2.6.5/lib/ruby/gems/2.6.0/gems/rspec-core-3.9.1/lib:/Users/takayuki-watanabe/.rbenv/versions/2.6.5/lib/ruby/gems/2.6.0/gems/rspec-support-3.9.2/lib /Users/takayuki-watanabe/.rbenv/versions/2.6.5/lib/ruby/gems/2.6.0/gems/rspec-core-3.9.1/exe/rspec --pattern spec/\*\*\{,/\*/\*\*\}/\*_spec.rb

An error occurred while loading spec_helper.
Failure/Error: require 'fluent/plugin/output'

NoMethodError:
  undefined method `windows?' for Fluent:Module
# ./lib/fluent/plugin/out_loki.rb:18:in `require'
# ./lib/fluent/plugin/out_loki.rb:18:in `<top (required)>'
# ./spec/spec_helper.rb:7:in `require'
# ./spec/spec_helper.rb:7:in `<top (required)>'
No examples found.
No examples found.


Finished in 0.00002 seconds (files took 0.80014 seconds to load)
0 examples, 0 failures, 1 error occurred outside of examples

Finished in 0.00002 seconds (files took 0.80014 seconds to load)
0 examples, 0 failures, 1 error occurred outside of examples


/Users/takayuki-watanabe/.rbenv/versions/2.6.5/bin/ruby -I/Users/takayuki-watanabe/.rbenv/versions/2.6.5/lib/ruby/gems/2.6.0/gems/rspec-core-3.9.1/lib:/Users/takayuki-watanabe/.rbenv/versions/2.6.5/lib/ruby/gems/2.6.0/gems/rspec-support-3.9.2/lib /Users/takayuki-watanabe/.rbenv/versions/2.6.5/lib/ruby/gems/2.6.0/gems/rspec-core-3.9.1/exe/rspec --pattern spec/\*\*\{,/\*/\*\*\}/\*_spec.rb failed

Expected behavior

  • bundle exec rake spec succeeds without violations and errors

Environment:

  • Infrastructure: MacOS Mojave(10.4.16)
  • Ruby and bundler version:
$ ruby -v
ruby 2.6.5p114 (2019-10-01 revision 67812) [x86_64-darwin18]
$ bundle -v
Bundler version 2.1.4

Comment

Are we sure that the docs written in the development section are correct? (https://github.com/grafana/loki/tree/master/fluentd/fluent-plugin-grafana-loki#development). If not I want to refactor this directory.

According to the Slack comment, this directory isn't well maintained. I'm not sure who could run spec with the current master code.

In addition, there are no Gemfile.lock and .ruby-version(ruby version info). It's hard to develop this plugin without documentation and testable specs.

@cyriltovena
Copy link
Contributor

Awesome please join #loki-dev on slack if you need help.

@takanabe
Copy link
Contributor Author

takanabe commented Feb 6, 2020

@cyriltovena

This issue is ongoing 💨 could you reopen this issue so I can put all the information here? I'm planning to fix broken specs and introduce CI. Otherwise, this plugin won't be maintained.

@stale
Copy link

stale bot commented Mar 8, 2020

This issue has been automatically marked as stale because it has not had any activity in the past 30 days. It will be closed in 7 days if no further activity occurs. Thank you for your contributions.

@stale stale bot added the stale A stale issue or PR that will automatically be closed. label Mar 8, 2020
@stale stale bot closed this as completed Mar 15, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
stale A stale issue or PR that will automatically be closed.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants