Effective Rails Instrumentation

Effective Rails Instrumentation

298d330a34834dcc3717885d5391b445?s=128

Andre Luis Anastacio

November 18, 2017
Tweet

Transcript

  1. Effective Rails Instrumentation

  2. André Luís Anastácio Desenvolvedor Twitter / Github - ndrluis

  3. None
  4. Belo Horizonte

  5. None
  6. Use New Relic, Papertrail e Rollbar.

  7. Use New Relic, Papertrail e Rollbar. Duvidas?

  8. None
  9. None
  10. None
  11. Testar não é negociável

  12. Mensurar/Instrumentar não deveria ser negociável

  13. None
  14. Exemplo E-commerce

  15. class PaymentService def initialize(order) @order = order end def pay

    response = ExternalPaymentStuff.pay(order) if response.success? @order.pay! else fail SomePaymentError, response.error_message end end end
  16. ActiveSupport::TaggedLogging

  17. class PaymentService def initialize(order) @order = order end def pay

    logger.tagged(order_tag, client_tag) do response = ExternalPaymentStuff.pay(order) if response.success? order.pay! else logger.error(response.body) fail SomePaymentError, response.error_message end end end private attr_accessor :order def logger @logger ||= Rails.logger end def order_tag "ORDER ##{order.id}" end def client_tag "CLIENT ##{order.client_id}" end end
  18. Serviço de Terceiros Rollbar

  19. class PaymentService def initialize(order) @order = order end def pay

    response = ExternalPaymentStuff.pay(order) if response.success? order.pay! else Rollbar.error('PaymentError', response_body: response.body, order_id: order.id) fail SomePaymentError, response.error_message end end private attr_accessor :order end
  20. None
  21. None
  22. None
  23. None
  24. Como escolher entre TaggedLogging e Rollbar?

  25. Facilitar a reprodução do Erro

  26. BONUS STAGE

  27. BONUS STAGE Performance

  28. None
  29. None
  30. None
  31. None
  32. None
  33. None
  34. Obrigado!