Skip to content

random choose host from provided hosts-list#31

Open
mavlyutov wants to merge 1 commit into
logstash-plugins:mainfrom
mavlyutov:master
Open

random choose host from provided hosts-list#31
mavlyutov wants to merge 1 commit into
logstash-plugins:mainfrom
mavlyutov:master

Conversation

@mavlyutov

Copy link
Copy Markdown

supercedes #21

Comment thread lib/logstash/outputs/graphite.rb Outdated
config :resend_on_failure, :validate => :boolean, :default => false

# Number of attempts to be made resending metrics before abandoning
config :resend_attempts, :validate => :number, :default => 3

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This resend-attempts feature seems out of scope for the proposed change (add multiple hosts, choose at random). Can you move it to a separate PR?

@logger.warn("Connection refused to graphite server, sleeping...", :host => @host, :port => @port)
sleep(@reconnect_interval)
retry
address, _, port = host.rpartition(":")

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This won't work for ipv6 addresses that omit a port, such as ::1 which we may assume means address ::1 default port 2003. In this case, the address would become "::" and port "1"

Comment thread lib/logstash/outputs/graphite.rb Outdated
retry
address, _, port = host.rpartition(":")
@logger.debug? && @logger.debug("Trying to send metrics to", :address => address, :port => port)
socket(address, port).puts(message)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Am I misreading the code, maybe? It looks like this creates a new connection for every event which is a regression from the previous implementation which reused existing connection.

Comment thread lib/logstash/outputs/graphite.rb Outdated
@logger.debug? && @logger.debug("Trying to send metrics to", :address => address, :port => port)
socket(address, port).puts(message)
rescue Exception => e
@logger.debug? && @logger.debug("Suffering from", :e => e.message)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Suffering is probably not the right word. Also, catching Exception isn't the right thing, you probably want StandardError, if the case is that you want a general catch-all. Exception will catch things like SyntaxError or NoMemoryError that you probably dont' want to be catching here.

@jordansissel

Copy link
Copy Markdown
Contributor

@mavlyutov

Copy link
Copy Markdown
Author

thank you for feedback @jordansissel!
I tried to fix all you comments take a look please

@mavlyutov

Copy link
Copy Markdown
Author

@jordansissel ping

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants