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

Add ActiveSupport::Notifications subscription error handling #395

Merged

Conversation

delner
Copy link
Contributor

@delner delner commented Apr 9, 2018

This pull request fixes two bugs:

  • Integrations implementing ActiveSupport::Notifications subscriptions whose block raises an error could raise exceptions breaking application flow. Error handling around the block traps and logs these errors now.
  • ensure_clean_context! wasn't working; fixes use of tracer.

Also adds support for call for 3.x ActiveSupport implementations and refactors the internals of Subscription a little (should improve extensibility.)

@delner delner added bug Involves a bug integrations Involves tracing integrations labels Apr 9, 2018
@delner delner added this to the 0.12.0 milestone Apr 9, 2018
@delner delner self-assigned this Apr 9, 2018
@delner delner requested a review from palazzem April 9, 2018 16:50
Copy link
Contributor

@palazzem palazzem left a comment

Choose a reason for hiding this comment

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

The approach is good, I think only a small change in the log output and we're good.

def run(span, name, id, payload)
run!(span, name, id, payload)
rescue StandardError => e
Datadog::Tracer.log.error("ActiveSupport::Notifications handler for '#{name}' failed: #{e.message}")
Copy link
Contributor

Choose a reason for hiding this comment

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

In a high throughput environment we may spam logs too much. Can you write using the debug mode so without any config change we're sure to not write our failures?

begin
callback.call(event, key, *args)
rescue StandardError => e
Datadog::Tracer.log.error(
Copy link
Contributor

Choose a reason for hiding this comment

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

I think the same applies here

@@ -98,7 +98,7 @@ def initialize(options = {})
@provider = options.fetch(:context_provider, Datadog::DefaultContextProvider.new)
@provider ||= Datadog::DefaultContextProvider.new # @provider should never be nil

@context_flush = Datadog::ContextFlush.new(options) if options[:partial_flush]
@context_flush = options[:partial_flush] ? Datadog::ContextFlush.new(options) : nil
Copy link
Contributor

Choose a reason for hiding this comment

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

👍

@delner delner merged commit 969e459 into 0.12-dev Apr 9, 2018
@delner delner deleted the bugfix/active_support_notifications_missing_error_handling branch May 8, 2018 19:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Involves a bug integrations Involves tracing integrations
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants