HubSpot / BuckyClient

Collect performance data from the client

Home Page:http://github.hubspot.com/bucky

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Question regarding documentation on sendPagePerformance

haimich opened this issue · comments

Hi,

today I managed to get Bucky working with a StatsD and Graphite backend. The setup was quite easy, the only thing that was a bit counterintuitive was the fact that there's no BuckyServer module to connect to a Graphite server directly but you have to use StatsD as an intermediate service. The documentation says

Next, you'll want to install statsd (...)

which I interpreted as "you can use StatsD but it's also possible to connect to Graphite directly".

In BuckyClient I tried out the example code to track Backbone history event changes from your documentation. I noticed that no performance data were sent when navigating between pages so I debugged the Bucky code and found out that it had to do with the variable sentPerformanceData being true all the time. I understand that it's set to true after the window.performance information have been sent to the backend once. This raised the question why would you call the function Bucky.sendPagePerformance() manually when it won't send any data after the initial page load?. The Backbone history events don't trigger a page reload when you're using a hash navigation so no new performance information are available through the window object. Am I'm getting it wrong?

The page performance data comes from window.performance.timing, which is set by the browser on page load. It doesn't change unless the page is reloaded, there isn't much point in sending the same data again. The function exists to allow you to trigger the send if you elect to not include the data- attribute which causes it to be sent automatically.

You can, however, increment a counter or timer based on backbone navigation:

Backbone.history.on('route', function(router, route) {
  Bucky.count('route.' + route);
});

As far as statsd is concerned, it wouldn't be particularly difficult to write a direct graphite connector. The problem is that without something like statsd to do the aggregation, timing data and counters are not going to work the way you'd expect. We could fold statsd behavior into bucky itself (someone could write a module to do that). Thanks for letting us know about how the docs are unclear.