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

Rails 6 support #814

Merged
merged 4 commits into from
Sep 24, 2019
Merged

Rails 6 support #814

merged 4 commits into from
Sep 24, 2019

Conversation

marcotc
Copy link
Member

@marcotc marcotc commented Sep 13, 2019

Add support for all Rails tracer features to Rails 6.

Compared to Rails 5, there are not new features in Rails 6 that require special instrumentation for enhanced visibility.

One example is support for multiple databases: the infrastructure was already present in its current form since Rails 5.

Also, a few notable changes to our testing infrastructure:

@marcotc marcotc added integrations Involves tracing integrations feature Involves a product feature labels Sep 13, 2019
@marcotc marcotc added this to the 0.28.0 milestone Sep 13, 2019
@marcotc marcotc requested a review from a team September 13, 2019 00:07
@marcotc marcotc self-assigned this Sep 13, 2019
def datadog_parse_args(view, template, layout_name, *args)
[template, layout_name]
end
end
Copy link
Member Author

Choose a reason for hiding this comment

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

After many iterations, I ended up with separate modules to encapsulate this branching logic between Rails v3.1-v5 and v6.

The reason I chose this approach in end was because:

  • It makes it clear to us which implementation is the latest, without explicit branching logic.
    • This allows for easier deprecation of older implementations in the future.
  • It avoids conditional branching at runtime, making such decision during our patching phase.

I did add a method call, so the overhead of this approach is not zero.

In the end, I valued how clearly Rails 6 and future versions will read over succinctness of changes (few lines touched), as my best judgement here is that this approach increases maintainability.

Regardless of my rationale, I'm very much open to suggestions.

@marcotc marcotc changed the base branch from master to 0.28-dev September 13, 2019 00:24
Copy link
Contributor

@delner delner left a comment

Choose a reason for hiding this comment

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

Going to give this a more thorough review later, but I like what I see so far! One minor comment related to tests on the first scan.

spec/ddtrace/contrib/rails/support/rails6.rb Outdated Show resolved Hide resolved
Copy link
Contributor

@delner delner left a comment

Choose a reason for hiding this comment

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

Looks pretty good! Just want to request some relatively small housekeeping tasks, but otherwise very pleased with this.

spec/ddtrace/contrib/active_record/multi_db_spec.rb Outdated Show resolved Hide resolved
require 'contrib/rails/apps/application'

module Rails6
class Application < RailsTrace::TestApplication
Copy link
Contributor

Choose a reason for hiding this comment

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

This Application class is defined as a full-blown constant (as opposed to some kind of stub) because of how we setup Minitest to test Rails yeah? I don't think there's anything else to do here, just wanted to clarify that's the case, which would mean this will go away when we finish migrating to RSpec.

Copy link
Member Author

Choose a reason for hiding this comment

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

This is correct!

@marcotc marcotc requested a review from delner September 20, 2019 19:24
Copy link
Contributor

@delner delner left a comment

Choose a reason for hiding this comment

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

Just one suggestion about naming, otherwise this is ready.

module Datadog
module Contrib
module ActionView
module Instrumentations
Copy link
Contributor

Choose a reason for hiding this comment

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

Nitpick but I think it should be Instrumentation singular.

@marcotc marcotc requested a review from delner September 23, 2019 21:58
Copy link
Contributor

@delner delner left a comment

Choose a reason for hiding this comment

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

Looks great, thanks @marcotc! 👍

@marcotc marcotc merged commit 398c89f into 0.28-dev Sep 24, 2019
@marcotc marcotc deleted the feature/rails6-support branch September 24, 2019 20:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature Involves a product feature integrations Involves tracing integrations
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants