railslove / rack-tracker

Tracking made easy: Don’t fool around with adding tracking and analytics partials to your app and concentrate on the things that matter.
https://www.railslove.com/open-source
MIT License
647 stars 121 forks source link

Use local variables in rack middleware to prevent instance state changes #151

Closed bumi closed 4 years ago

bumi commented 4 years ago

see: https://github.com/railslove/rack-tracker/pull/150

bumi commented 4 years ago

@kspe @kangguru what do you think? can we merge this? I think such a fix should be released asap!

kspe commented 4 years ago

I'm only unsure about @handlers variable which is still there.

bumi commented 4 years ago

@DonSchado handlers should not have request state, do they?

@DonSchado @kangguru can we either merge this one or #150 and release a new patch version?

DonSchado commented 4 years ago

because I'm not completely sure and don't have the time to investigate this further, maybe then we merge #150 because @kspe already know's that it works. :) ack?

bumi commented 4 years ago

then let's merge both. those instance variables for sure should not be there. And then we got the dup also in - not sure what that does to memory consumption, but we will see.

kspe commented 4 years ago

not sure what that does to memory consumption, but we will see.

After deploying this change to prod we did not see any significant increase in memory usage (which was a bit surprising given this happens on each request). It might be this object is very lightweight and is garbage collected quite efficiently but I haven't done a detailed analysis of it.

bumi commented 4 years ago

ok, that's good to hear! thanks for that. @DonSchado ok? do you want to go ahead with both PRs and release a new patch? <3

DonSchado commented 4 years ago

new version released