From 7ca4eb26d5528ac3b5cf35d18ffef95e67026261 Mon Sep 17 00:00:00 2001 From: Philip Tellis Date: Thu, 12 Feb 2015 12:00:40 -0500 Subject: [PATCH] Merge pull request #50 from castle-it/master Optional parameter to await completion in bandwidth plugin before sending beacon Conflicts: doc/api/BW.html --- doc/api/BW.html | 7 +++++++ doc/howtos/howto-3.html | 8 ++++++-- doc/howtos/howto-6.html | 17 +++++++++++++++++ plugins/bw.js | 23 +++++++++++++++++++---- 4 files changed, 49 insertions(+), 6 deletions(-) diff --git a/doc/api/BW.html b/doc/api/BW.html index 7887cadb6..a01a2bcee 100644 --- a/doc/api/BW.html +++ b/doc/api/BW.html @@ -75,6 +75,13 @@

Configuration

set test_https to true, boomerang will run the test instead of skipping. +
block_beacon
+
+[optional] +By default, the bandwidth plugin will not block boomerang from sending a beacon, so the results +will not be included in the broadcast with default settings. If you set block_beacon to +true, boomerang will wait for the results of the test before sending the beacon. +
diff --git a/doc/howtos/howto-3.html b/doc/howtos/howto-3.html index 94a533f6f..c7dfec406 100644 --- a/doc/howtos/howto-3.html +++ b/doc/howtos/howto-3.html @@ -28,7 +28,10 @@

Boomerang Howto #3:
Measure a user's bandwidth/latency along with page lo

Simply adding boomerang to a page and calling the init() method is sufficient to start the bandwidth -test and beacon its results back to the server. This is the code you'd use: +test. If you want the beacon results to include the results of the bandwidth test, setting block_beacon +to true will force boomerang to wait for the test to complete before sending the beacon. If you do not +turn on the block_beacon feature, you will only receive bandwidth results if they were cached in a +cookie by a previous test run.

 <script src="boomerang.js" type="text/javascript"></script>
@@ -36,7 +39,8 @@ 

Boomerang Howto #3:
Measure a user's bandwidth/latency along with page lo BOOMR.init({ beacon_url: "http://yoursite.com/path/to/beacon.php", BW: { - base_url: "http://base_url/to/bandwidth/images/" + base_url: "http://base_url/to/bandwidth/images/", + block_beacon: true } }); </script> diff --git a/doc/howtos/howto-6.html b/doc/howtos/howto-6.html index 2d154239f..4c27aab67 100644 --- a/doc/howtos/howto-6.html +++ b/doc/howtos/howto-6.html @@ -210,6 +210,23 @@

Bandwidth plugin

value along with the timeout value above. +
test_https
+
+[optional] +By default, boomerang will skip the bandwidth test over an HTTPS connection. Establishing +an SSL connection takes time, which could skew the bandwidth results. If all your traffic +is sent over SSL, then running the test over SSL probably gets you what you want. If you +set test_https to true, boomerang will run the test instead of skipping. +
+ +
block_beacon
+
+[optional] +By default, the bandwidth plugin will not block boomerang from sending a beacon, so the results +will not be included in the broadcast with default settings. If you set block_beacon to +true, boomerang will wait for the results of the test before sending the beacon. +
+

All optional

diff --git a/plugins/bw.js b/plugins/bw.js index 97904db4c..1aa060bae 100644 --- a/plugins/bw.js +++ b/plugins/bw.js @@ -50,6 +50,7 @@ impl = { nruns: 5, latency_runs: 10, user_ip: "", + block_beacon: false, test_https: false, cookie_exp: 7*86400, cookie: "BA", @@ -406,7 +407,10 @@ impl = { } this.complete = true; - //BOOMR.sendBeacon(); + + if (this.block_beacon === true) + BOOMR.sendBeacon(); + this.running = false; }, @@ -475,7 +479,7 @@ BOOMR.plugins.BW = { } BOOMR.utils.pluginConfig(impl, config, "BW", - ["base_url", "timeout", "nruns", "cookie", "cookie_exp", "test_https"]); + ["base_url", "timeout", "nruns", "cookie", "cookie_exp", "test_https", "block_beacon"]); if(config && config.user_ip) { impl.user_ip = config.user_ip; @@ -522,7 +526,10 @@ BOOMR.plugins.BW = { BOOMR.info("HTTPS detected, skipping bandwidth test", "bw"); impl.complete = true; - //BOOMR.sendBeacon(); + + if (impl.block_beacon === true) + BOOMR.sendBeacon(); + return this; } @@ -545,7 +552,15 @@ BOOMR.plugins.BW = { } }, - is_complete: function() { return true; } + is_complete: function() { + if (impl.block_beacon === true) + { + return impl.complete; + } + else { + return true; + } + } }; }());