Skip to content

Use Module#prepend where possible#890

Merged
mikker merged 13 commits intoelastic:nextfrom
mikker:prependageddon
Nov 23, 2020
Merged

Use Module#prepend where possible#890
mikker merged 13 commits intoelastic:nextfrom
mikker:prependageddon

Conversation

@mikker
Copy link
Contributor

@mikker mikker commented Nov 11, 2020

This leaves us with only the module based APIs still using class_eval, specifically delayed_job and sucker_punch. The problem being that at the time of hooking up the integration, the target modules have already been included and so prepending doesn't modify the including classes.

I propose we leave them as is for now and change them in a future version if we come up with a scheme or they introduce some sort of plugin api that could help us avoid class_eval.

This PR is a breaking change not because it removes any features but because it might interfere with other libraries still using class_eval and thereby possibly introduce the infinite loop when trying to look up stacktraces after an exception(#753 for example).

@mikker mikker changed the title Use Module#prepend in DynamoDB spy Nov 11, 2020
@ghost
Copy link

ghost commented Nov 11, 2020

💚 Build Succeeded

the below badges are clickable and redirect to their specific view in the CI or DOCS
Pipeline View Test View Changes Artifacts preview

Expand to view the summary

Build stats

  • Build Cause: [Pull request #890 updated]

  • Start Time: 2020-11-19T20:12:43.757+0000

  • Duration: 22 min 42 sec

Test stats 🧪

Test Results
Failed 0
Passed 66715
Skipped 129
Total 66844

Steps errors 3

Expand to view the steps failures

Shell Script

  • Took 6 min 40 sec . View more details on here
  • Description: [2020-11-19T20:16:46.951Z] + ./spec/scripts/spec.sh docker.elastic.co/observability-ci/jruby:9.2-13-

Shell Script

  • Took 5 min 6 sec . View more details on here
  • Description: [2020-11-19T20:17:16.349Z] + ./spec/scripts/spec.sh docker.elastic.co/observability-ci/jruby:9.2-13-

Shell Script

  • Took 5 min 55 sec . View more details on here
  • Description: [2020-11-19T20:17:25.758Z] + ./spec/scripts/spec.sh docker.elastic.co/observability-ci/jruby:9.1-7-j

@mikker mikker self-assigned this Nov 12, 2020
@mikker mikker marked this pull request as ready for review November 12, 2020 09:32
@mikker mikker requested a review from estolfo November 12, 2020 09:32
@mikker
Copy link
Contributor Author

mikker commented Nov 12, 2020

😅

klass.prepend(Module.new do
define_method(method) do |*args|
unless ElasticAPM.current_transaction
return super(*args)
end
ElasticAPM.with_span "#{name}", "#{type}" do
super(*args)
end
end
end)

@mikker mikker changed the base branch from master to next November 12, 2020 14:43
Copy link
Contributor

@estolfo estolfo left a comment

Choose a reason for hiding this comment

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

Looks good-- seems a lot more straightforward than I thought it would be.
You mentioned wanting to change the name of Spies, do you still want to? We could call them extensions, as they are each in a module Ext. Or integrations, as I think you suggested.

@mikker
Copy link
Contributor Author

mikker commented Nov 18, 2020

I sort of still do. We'd have to do it in 2 steps though as we'd be renaming some config options too. So step 1 is soft deprecation, then remove in major.

@estolfo
Copy link
Contributor

estolfo commented Nov 19, 2020

ok, I guess it's not urgent then and doesn't necessarily have to be part of this PR.

@mikker mikker merged commit 8808363 into elastic:next Nov 23, 2020
@mikker mikker deleted the prependageddon branch November 23, 2020 12:56
mikker pushed a commit that referenced this pull request Nov 26, 2020
mikker pushed a commit that referenced this pull request Dec 2, 2020
mikker pushed a commit that referenced this pull request Dec 22, 2020
mikker pushed a commit that referenced this pull request Jan 15, 2021
mikker pushed a commit that referenced this pull request Jan 29, 2021
estolfo pushed a commit that referenced this pull request Feb 9, 2021
mikker pushed a commit that referenced this pull request Mar 19, 2021
mikker pushed a commit that referenced this pull request Mar 26, 2021
mikker pushed a commit that referenced this pull request Mar 30, 2021
mikker pushed a commit that referenced this pull request Mar 30, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment