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] Add feature flags to Rails integration #448

Closed
wants to merge 5 commits into from

Conversation

pawelchcki
Copy link
Contributor

@pawelchcki pawelchcki commented Jun 8, 2018

Put aspects of Rails integration behind feature flags, allowing finetuning of provided tracing data depending on specific user needs.

Key Description Default
flags Flags used in rails instrumentation. { instrument_action_view_rendering: true, instrument_action_controller_processing: true, instrument_active_support_caching: true, use_rack_integration: true, use_active_record_integration: true}

@pawelchcki pawelchcki self-assigned this Jun 8, 2018
@pawelchcki pawelchcki added integrations Involves tracing integrations feature Involves a product feature do-not-merge/WIP Not ready for merge labels Jun 8, 2018
@pawelchcki pawelchcki added this to the 0.12.1 milestone Jun 8, 2018
@pawelchcki pawelchcki removed the do-not-merge/WIP Not ready for merge label Jun 8, 2018
@pawelchcki pawelchcki assigned delner and unassigned pawelchcki Jun 8, 2018
@pawelchcki pawelchcki requested a review from delner June 8, 2018 17:57
@delner
Copy link
Contributor

delner commented Jun 8, 2018

Thinking about the scenario where a user only wants to turn off a single feature, would that mean they then have to list every other feature except the one they don't want?

If that's the case, I'd suggest making the features option into a Hash, so a user could do something like c.use :rails, features: { instantiation: false }, for more concise usability.

Also I might suggest renaming features to flags because there might come a time where we want some generic option that isn't exactly a feature. Once we commit to adding this name to the API, we won't be able to change it easily. Just something to think about.

@pawelchcki
Copy link
Contributor Author

pawelchcki commented Jun 11, 2018

Thanks for looking at this @delner.
Thats true, that when user want's to enable only a single feature it has to lists all other feature. This is something I thought could be addressed in separate PRs by introducing API's like disabled_feature and maybe even enabled_features.

For now since hashes are not merged in Options having the shorthand of { flag: false} would disable all other flags unless we would check it like so

enable if !configuration[:flags].has_key?(flag) || configuration[:flags][flag]

@pawelchcki
Copy link
Contributor Author

pawelchcki commented Jun 11, 2018

Ok I've extended the setter functionality a bit, to allow setters that can merge values with default. It should now allow for shorter way to set and disable the flags

Instead of extending setter, I've opted for option that doesn't require extending APIs

@pawelchcki pawelchcki force-pushed the feature/add_rails_feature_flags branch from e6c89b9 to 08fcdc6 Compare June 11, 2018 15:10
@pawelchcki pawelchcki requested a review from palazzem June 11, 2018 15:26
@pawelchcki
Copy link
Contributor Author

pawelchcki commented Jun 11, 2018

Since we are introducing new API to allow more granularity when configuring integrations. Would you mind taking a second look @palazzem?

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.

These changes look fine to me. Let's ask @palazzem to see what he thinks about adding this kind of option to the API.

@palazzem
Copy link
Contributor

@delner @pawelchcki I think it's great providing a fine-grain control on what integrations are enabled, considering we can keep reasonable defaults (so everything on by default). Two things I'm not sure are:

  1. I think the naming is a bit weird because we have a lot of instrument_* that is a duplication. What if we call the field instrument (or similar) instead of flags and we remove the same prefix?
  2. I'm saying (1) because I think the naming should be the same, so instead of use_active_record_integration, I would say instrument_active_record (the name could be changed after the first bullet point). I think it's better to enforce consistency around names so that it's easier to understand what's going on, and there is no difference from the users perspective if you're instrumenting active_record or using the active_record instrumentation.
  3. I think rack integration must not be disabled in any case. It could lead to huge issues especially if other frameworks are used. Disabling rack while you have grape, will lead to missing traces. I think this is the only integration that must never be disabled.

@delner
Copy link
Contributor

delner commented Jun 11, 2018

@palazzem I see, so options that are much more specific in name and purpose? I think that could make sense. Originally, I had suggested renaming it to flags in case we wanted to reuse this option as a general purpose "miscellaneous" options holder, but if we don't want or need something general purpose like that, I can see how instrument is better (because its more specific.)

action_view_rendering: true,
action_controller_processing: true,
active_support_caching: true,
active_record: true
Copy link
Contributor

Choose a reason for hiding this comment

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

Just a thought, albeit requiring no change at all: this active_record line is mean to enable/disable "sub-integrations" that the Rails meta-integration activates.

For what it's worth, I had started on changes to address exactly this kind of configuration setting in my configuration overhaul, which ultimately was meant to produce a new configuration API that resembles this prototype. The purpose of this is eerily similar to that.

@delner
Copy link
Contributor

delner commented Jun 11, 2018

@palazzem @pawelchcki Just wanted to get your opinion on this: how would you feel about bumping this to 0.13.0 (next week's release)? Or 0.14.0?

My suggestion for doing so is that 1) this isn't really a bug fix in itself as it is a new feature, and 2) it would grant us an opportunity to reconcile the API changes in this PR with my already-written API changes suggested in this Gist and implemented in this branch. By reconciling these, we could avoid mutating the API too frequently and isolate the API changes to a single release (0.12.x --> 0.13.0)

@palazzem
Copy link
Contributor

@delner agree. Let's bump the change to 0.13 if it's not required to address a specific issue.

@delner
Copy link
Contributor

delner commented Jun 11, 2018

Okay. BTW, the aforementioned changes can be found in #450 and #451 .

@pawelchcki Could you check those out, tell me what you think? They don't yet implement this specific change, but it would be easy to implement (see my sample code in #450 for an idea of what the API might look like). If you like what you see there, then we could rebase these changes on #451 and make it a part of that.

@delner delner modified the milestones: 0.12.1, 0.13.0 Jun 11, 2018
@delner delner removed this from the 0.13.0 milestone Jun 15, 2018
@delner delner assigned pawelchcki and unassigned delner Jul 11, 2018
@pawelchcki pawelchcki closed this Oct 3, 2018
@GustavoCaso GustavoCaso deleted the feature/add_rails_feature_flags branch October 11, 2023 11:35
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.

3 participants