-
Notifications
You must be signed in to change notification settings - Fork 184
Add metrics to the jdbc input operations #155
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
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -115,14 +115,16 @@ def jdbc_connect | |
@logger.error("Failed to connect to database. #{@jdbc_pool_timeout} second timeout exceeded. Tried #{@connection_retry_attempts} times.") | ||
raise e | ||
else | ||
@logger.error("Failed to connect to database. #{@jdbc_pool_timeout} second timeout exceeded. Trying again.") | ||
@logger.error("Failed to connect to database. #{@jdbc_pool_timeout} second timeout exceeded. Trying again.") | ||
@metric_errors.increment(:connection_retries) | ||
end | ||
rescue Sequel::Error => e | ||
if retry_attempts <= 0 | ||
@logger.error("Unable to connect to database. Tried #{@connection_retry_attempts} times", :error_message => e.message, ) | ||
raise e | ||
else | ||
@logger.error("Unable to connect to database. Trying again", :error_message => e.message) | ||
@metric_errors.increment(:connection_retries) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The |
||
end | ||
end | ||
sleep(@connection_retry_attempts_wait_time) | ||
|
@@ -159,6 +161,8 @@ def prepare_jdbc_connection | |
raise LogStash::ConfigurationError, "#{e}. #{message}" | ||
end | ||
@database = jdbc_connect() | ||
metric.increment(:connections) | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This seems to be only called at register time? so it will be always 1 ? |
||
@database.extension(:pagination) | ||
if @jdbc_default_timezone | ||
@database.extension(:named_timezones) | ||
|
@@ -201,8 +205,11 @@ def execute_statement(statement, parameters) | |
parameters = symbolized_params(parameters) | ||
query = @database[statement, parameters] | ||
sql_last_value = @use_column_value ? @sql_last_value : Time.now.utc | ||
metric.gauge(:sql_last_value, sql_last_value) | ||
|
||
@tracking_column_warning_sent = false | ||
@logger.debug? and @logger.debug("Executing JDBC query", :statement => statement, :parameters => parameters, :count => query.count) | ||
metric.gauge(:rows_in, query.count) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I propose just |
||
|
||
if @jdbc_paging_enabled | ||
query.each_page(@jdbc_page_size) do |paged_dataset| | ||
|
@@ -220,6 +227,7 @@ def execute_statement(statement, parameters) | |
success = true | ||
rescue Sequel::DatabaseConnectionError, Sequel::DatabaseError => e | ||
@logger.warn("Exception when executing JDBC query", :exception => e) | ||
@metric_errors.increment(:jdbc_query_errors) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think it would be better if we remove the mention of jdbc and maybe have |
||
else | ||
@sql_last_value = sql_last_value | ||
end | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am not sure about the usefulness of theses metrics?