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

Prepend instrumentation #565

Merged
merged 96 commits into from
Apr 5, 2021
Merged

Prepend instrumentation #565

merged 96 commits into from
Apr 5, 2021

Conversation

tannalynn
Copy link
Contributor

@tannalynn tannalynn commented Feb 5, 2021

Overview

The agent instruments many libraries using the method chaining (a.k.a. method aliasing) approach to monkey-patching. This is a form of monkey-patching was deprecated with Ruby's introduction of :prepend in Ruby version 2.0.0 as a means to insert additional functionality into a module's method lookup mechanism ahead of the library's original method implementation.

Prepend strategy will be the default choice in 7.0+. However, the prepend strategy may be reverted back to method chaining by adding the following (sidekiq example) configuration flag:

This PR collects all auto-instrumentation prepend implementation efforts and should be merged when all related work is completed and merged to this PR's branch. Each individual instrumentation issue should have its own PR against this branch.

instrumentation:
  sidekiq: chain

NOTE: The use case for this is for when an unknown gem is found to be conflicting. The user is able to revert to method-chaining to deal with the conflict until the agent can be updated to auto-detect and handle the conflict.

To disable instrumentation altogether:

instrumentation:
  sidekiq: disable

In some cases, we may know specific gems conflict with prepend. To facilitate, we offer an auto config option (which is the default) which will automatically degrade to chain in such cases.

The default setting in most cases is thus:

instrumentation:
  sidekiq: auto

It is possible to force using prepend strategy by specifying it in the config like so:

instrumentation:
  sidekiq: prepend

NOTE: The use case for this is for when a newer version of the conflicting gem is released and it's known to no longer conflict with prepend strategy.

If you find a conflict between Prepend and another gem in your application's Gemfile, we would highly appreciate opening an Issue or commenting on this one specific to this gem so that we are aware and potentially work with gem authors to eliminate conflicts.

Additional Context

We are switching to prepending by default and deprecating method-chaining as this is the most acceptable and dependable way to extend libraries with auto-instrumentation support outside of using the subscriber/notification hooks pattern that some gem authors already provide for observability purposes. However, this change is potentially a breaking change for some depending on other gems involved in an application's Gemfile makeup. To facilitate switching over to 7.0 release, the method chaining approach is only deprecated (not removed) and a configuration switch is provided to revert back to method-chaining for customers that are affected by prepend auto-instrumentation strategies.

Related Github Issue

Include a link to the related GitHub issue, if applicable

@github-actions
Copy link
Contributor

github-actions bot commented Feb 5, 2021

PR review checklist:

  • Perform code review
  • Add performance label
  • Perform appropriate level of performance testing
  • Confirm all checks passed
  • Add version label prior to acceptance

tannalynn and others added 14 commits April 2, 2021 11:30
due to jruby incompatibility with newer i18n
* default prepend to true

* add prepend for bunny

* fox for bunny prepend

* changed bunny prepend to module

* updated bunny testing for chain and prepend

* updated bunny

* update bunny instrumentation

* fix require_relative

* reset default for config not related to bunny

* added config check for bunny

* DRYed up bunny instrumentation

* fix leftover end

* fix missing args

* cleaned up and simplified

Co-authored-by: Michael Lang <[email protected]>
prepend implemented for memcache
* set up chain for sinatra

* update sinatra instrumentation

* added prepend file

* drying up prepend changes

* most tests passing

* got prepend working

* updated sinatra tests

* updated tested versions

* fix for sintra prepend build

* updated unit tests for sintra instrumentation

* updated deferred_instrumentation suite for sinatra

* WIP added padrino

* fix for padrino test app

* changes based on code review

* untangled includes/extends and simplify for better readability

* fixed weird unintialized constant error

* fix for unit test failures

Co-authored-by: Michael Lang <[email protected]>
@tannalynn tannalynn marked this pull request as ready for review April 5, 2021 17:23
Copy link
Contributor

@mwlang mwlang left a comment

Choose a reason for hiding this comment

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

Everything looks good!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Archived in project
3 participants