diff --git a/common/lib/xmodule/xmodule/video_module/video_module.py b/common/lib/xmodule/xmodule/video_module/video_module.py index f12347fd4f3f7676d53a5fc4e78a5ae15e53b331..46272814a696c043c7bbac2f3ecd664a9ebb3a7f 100644 --- a/common/lib/xmodule/xmodule/video_module/video_module.py +++ b/common/lib/xmodule/xmodule/video_module/video_module.py @@ -235,12 +235,15 @@ class VideoModule(VideoFields, VideoTranscriptsMixin, VideoStudentViewHandlers, # CDN_VIDEO_URLS is only to be used here and will be deleted # TODO(ali@edx.org): Delete this after the CDN experiment has completed. + html_id = self.location.html_id() if getattr(settings, 'PERFORMANCE_GRAPHITE_URL', '') != '' and \ self.system.user_location == 'CN' and \ - getattr(settings, 'ENABLE_VIDEO_BEACON', False) and \ - self.edx_video_id in getattr(settings, 'CDN_VIDEO_URLS', {}).keys(): - cdn_urls = getattr(settings, 'CDN_VIDEO_URLS', {})[self.edx_video_id] - cdn_exp_group, sources[0] = random.choice(zip(range(len(cdn_urls)), cdn_urls)) + getattr(settings.FEATURES, 'ENABLE_VIDEO_BEACON', False) and \ + html_id in getattr(settings, 'CDN_VIDEO_URLS', {}).keys(): + cdn_urls = getattr(settings, 'CDN_VIDEO_URLS', {})[html_id] + cdn_exp_group, new_source = random.choice(zip(range(len(cdn_urls)), cdn_urls)) + if cdn_exp_group > 0: + sources[0] = new_source cdn_eval = True else: cdn_eval = False diff --git a/lms/envs/aws.py b/lms/envs/aws.py index f38b46fa5a9adef122dfb7b50a6e90104913dc0a..db43cf3c562eae0aad843078b24bb9ebfe2b11ad 100644 --- a/lms/envs/aws.py +++ b/lms/envs/aws.py @@ -554,3 +554,7 @@ FACEBOOK_APP_SECRET = AUTH_TOKENS.get("FACEBOOK_APP_SECRET") FACEBOOK_APP_ID = AUTH_TOKENS.get("FACEBOOK_APP_ID") XBLOCK_SETTINGS = ENV_TOKENS.get('XBLOCK_SETTINGS', {}) + +##### CDN EXPERIMENT/MONITORING FLAGS ##### +PERFORMANCE_GRAPHITE_URL = ENV_TOKENS.get('PERFORMANCE_GRAPHITE_URL', PERFORMANCE_GRAPHITE_URL) +CDN_VIDEO_URLS = ENV_TOKENS.get('CDN_VIDEO_URLS', CDN_VIDEO_URLS) diff --git a/lms/envs/common.py b/lms/envs/common.py index ddb04f24f525d6ce084f67395e04b18d86e83e63..a9a8025d4ab4b066c3bcce8eb4cacb26074c8c8d 100644 --- a/lms/envs/common.py +++ b/lms/envs/common.py @@ -348,6 +348,9 @@ FEATURES = { # log all information from cybersource callbacks 'LOG_POSTPAY_CALLBACKS': True, + + # enable beacons for video timing statistics + 'ENABLE_VIDEO_BEACON': False, } # Ignore static asset files on import which match this pattern @@ -2066,6 +2069,10 @@ SEARCH_ENGINE = None # Use the LMS specific result processor SEARCH_RESULT_PROCESSOR = "lms.lib.courseware_search.lms_result_processor.LmsSearchResultProcessor" +##### CDN EXPERIMENT/MONITORING FLAGS ##### +PERFORMANCE_GRAPHITE_URL = '' +CDN_VIDEO_URLS = {} + # The configuration for learner profiles PROFILE_CONFIGURATION = { # Default visibility level for accounts without a specified value diff --git a/lms/templates/video.html b/lms/templates/video.html index cc73172e9aa082fd05cc3786aaa0c995e41f7cf5..d14bdca0341b571e9f494aa0dee0efe6068ff261 100644 --- a/lms/templates/video.html +++ b/lms/templates/video.html @@ -164,7 +164,7 @@ $("#video_${id}").bind("html5:canplaythrough", null, function() { if (!beaconSent) { timeElapsed = Date.now() - cdnStartTime; - sendMetricToGraphite("loadtime_${cdn_exp_group}", timeElapsed); + sendMetricToGraphite("videocdnexp.${id}.${cdn_exp_group}.loadtime", timeElapsed); } beaconSent = true; });