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

Introduces basic logging back #4617

Closed
wants to merge 1 commit into from

Conversation

purbon
Copy link
Contributor

@purbon purbon commented Feb 2, 2016

Introduce basic logging, including basic access logging. This PR introduces basic access and error logging, booths serve the purpose of knowing:

  • When something goes wrong, why it's going wrong (aka exception and error handling).
  • Know usage of resources, including status code monitoring.

Fixes #4575

@purbon
Copy link
Contributor Author

purbon commented Feb 2, 2016

@ph your thoughts are more than welcome as always 😸


module LogStash::Api
class BaseApp < ::Sinatra::Application

attr_reader :factory

::Cabin::Channel.class_eval { alias :write :publish }
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Feels odd doing it this way. Can we add a mixin or extension to Cabin?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We could, but does it makes sense to change the way cabin works because of Sinatra?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What @jordansissel is suggesting is to create a module adding the compatibility layer required by Sinatra instead of using class_eval.

Something like

::Cabin::Channel.extend(Cabin::SinatraLoggerCompatibility)

The module can live inside logstash in the util directory, this is a bit cleaner and we don't need to push this change upstream.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh! got it, will do it that way then. I agree is a clear solution

@ph
Copy link
Contributor

ph commented Feb 2, 2016

I have been trying to test this PR, but I can seen to get the webserver started? It should answer on the default sinatra port of 4567 correct?

@purbon
Copy link
Contributor Author

purbon commented Feb 3, 2016

@ph sorry to tell you there is no default sinatra port per se, this is answering now to the default rackup port (aka 9292) .... we should definitely decide to which port do we want to make this listen to? do we have an issue for this?

@suyograo suyograo assigned jsvd and unassigned ph Feb 3, 2016

module LogStash::Api
class BaseApp < ::Sinatra::Application

attr_reader :factory

::Cabin::Channel.class_eval do
include ::Cabin::Mixins::SinatraLogger
end
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You don't need to do class_eval in that case.

You can do something like this

jruby-1.7.23 :001 > class Hello;end
 => nil
jruby-1.7.23 :002 > module Ola; def write;puts "ninja";end;end
 => nil
jruby-1.7.23 :003 > Hello.send(:include, Ola)
 => Hello
jruby-1.7.23 :004 > Ola.write
jruby-1.7.23 :006 > Hello.new.write
ninja
 => nil

Or we can do this if you require the exiting file before, the new functionality will be mixed in.

# in the helper
require "cabin/namespace"
class Cabin::Channel 
 def write(data, &block)
   self.publish(data, &block)
 end
end

Not sure if we have a preferred way

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi, I see this two methods as being very similar to what I did, isn't? what are the pros and cons of both for you? by using class_eval and include it make the definition very explicit, something less obscure than your option 1.

I do really see option 2 as doing the same as with the class eval, only thing is there is no module that we're actually including, just adding a new method and per se not using the same mechanism as other cabin extensions.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK, valid point, I think its okay

@purbon
Copy link
Contributor Author

purbon commented Feb 4, 2016

@ph @jsvd can you folks validate this PR so we can move forward? looks not that hard to actually review, isn't?

@ph
Copy link
Contributor

ph commented Feb 4, 2016

@purbon once its rebased with the new branch I will test it. Thanks.

@jsvd
Copy link
Member

jsvd commented Feb 4, 2016

same, code looks ok, will test manually after rebase

@purbon
Copy link
Contributor Author

purbon commented Feb 5, 2016

Closing this in benefit of #4635 that points to the new_metrics (rebuild branch with up to date master) branch.

@purbon purbon closed this Feb 5, 2016
@purbon purbon deleted the feature/basic_logging branch May 10, 2016 14:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants