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

double tracking #50

Open
JohnAD opened this Issue Feb 10, 2019 · 4 comments

Comments

Projects
None yet
2 participants
@JohnAD
Copy link
Contributor

JohnAD commented Feb 10, 2019

I've not been able to hunt down the exact reason, but it appears that I'm getting "double" entries for every web query. Even using command-line wget on a specific page, it showing two entries in the tracking table and two calls into the library: one "extremely short" one. Usually with a speed of 0.04s or less. And one entry that is more representative of the actual time to download the page. This might be a quirk of Flask, but it is inflating the numbers.

Any ideas what might be causing this? Is the same procedure being called before and after the request?

@ashcrow

This comment has been minimized.

Copy link
Owner

ashcrow commented Feb 11, 2019

Off the top of my head no, but I'll take a quick gander and see if anything jumps out at me. Thanks for reporting it!

@ashcrow ashcrow self-assigned this Feb 11, 2019

@ashcrow ashcrow added the bug label Feb 11, 2019

@ashcrow

This comment has been minimized.

Copy link
Owner

ashcrow commented Feb 11, 2019

Before I look, do you mind providing the flask version and the backends you've configured?

@JohnAD

This comment has been minimized.

Copy link
Contributor Author

JohnAD commented Feb 14, 2019

I'm using mongoengine for storage (which I wrote for this repo, so it could easily be a bug of mine.)

Flask==0.12.1
flask-mongoengine==0.9.3
Flask-Track-Usage==2.0.0
mongoengine==0.13.0
pymongo==3.4.0

I've been observing it for a while on my various docker sites. An additional observation:

When ever an URL is "corrected" internally by Flask, instead of double-counting the visit, one count is applied to the original query and one count to the internal fix. For example, if a page is at "http://example.com/test/" and wget grabs "http://example.com/test", then one count is given to "http://example.com/test" and then one to "http://example.com/test/". No redirect is occurring, this is something internal to Flask.

It's almost like the wrapper is being applied prior to and after the view function.

Speaking of, I'm running with

app.config['TRACK_USAGE_USE_FREEGEOIP'] = False
app.config['TRACK_USAGE_INCLUDE_OR_EXCLUDE_VIEWS'] = 'exclude'
traffic_storage = MongoEngineStorage(hooks=[sumUrl, psTrackUsage])
t = TrackUsage(app, [traffic_storage])

"psTrackUsage" is a class I wrote. Removing it doesn't fix the problem.

If nothing jumps out, I'll start digging into this.

@ashcrow

This comment has been minimized.

Copy link
Owner

ashcrow commented Feb 15, 2019

I haven't been able to reproduce the issue with other storage backends. I tried Firefox and wget, same version of Flask and Flask-Track-Usage. I also upped to the latest release of Flask and couldn't reproduce it.

Did you try dropping sumUrl as well? While I don't have a specific reason to think it may be the culprit that was not something I was able to test with the SQLStorage with SQLite. That plus the use of mongoengine_document stood out to me, but I couldn't identify anything that was specifically out of place.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment