From cdc81c8894e42d6c4aeab1f6010b830d0a3bcd43 Mon Sep 17 00:00:00 2001 From: alawibaba <ali@edx.org> Date: Wed, 11 Mar 2015 11:23:55 -0400 Subject: [PATCH] Fixed ID bug in China CDN experiment, added default, changed graphite metric name, and exposed CDN monitoring ENVs. --- .../lib/xmodule/xmodule/video_module/video_module.py | 11 +++++++---- lms/envs/aws.py | 4 ++++ lms/envs/common.py | 7 +++++++ lms/templates/video.html | 2 +- 4 files changed, 19 insertions(+), 5 deletions(-) diff --git a/common/lib/xmodule/xmodule/video_module/video_module.py b/common/lib/xmodule/xmodule/video_module/video_module.py index f12347fd4f3..46272814a69 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 f38b46fa5a9..db43cf3c562 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 ddb04f24f52..a9a8025d4ab 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 cc73172e9aa..d14bdca0341 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; }); -- GitLab