Skip to content
This repository has been archived by the owner on Sep 12, 2022. It is now read-only.

Commit

Permalink
Make metrics more robust against settings
Browse files Browse the repository at this point in the history
See local.py.dist 'SHOW_INSTANCE_METRICS' setting
  • Loading branch information
cdosborn committed Aug 12, 2015
1 parent 6b2fe13 commit 9b71d60
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 14 deletions.
3 changes: 3 additions & 0 deletions troposphere/settings/local.py.dist
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,9 @@ SERVER_URL = 'https://SERVERNAME'
ALLOWED_HOSTS = [SERVER_URL.replace("https://",""), "localhost"]


# Uncomment to include instance metrics,
# the version of atmosphere must include the metrics endpoint
# SHOW_INSTANCE_METRICS = True

# CAS
CAS_SERVER = 'https://cas.example.com'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,9 @@ define(function (require) {
<InstanceDetailsSection instance={instance}/>
<hr/>
{
show_instance_metrics ?
<InstanceMetricsSection instance={instance}/> : <div></div>
typeof show_instance_metrics != "undefined"
? <InstanceMetricsSection instance={instance}/>
: ""
}
</div>
<div className="col-md-3">
Expand Down
1 change: 0 additions & 1 deletion troposphere/templates/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,6 @@ <h4>Loading Atmosphere...</h4>

{% if show_instance_metrics %}
var show_instance_metrics = true;
var hyper_stats_url = "{{ hyper_stats_url }}";
{% else %}
var show_instance_metrics = false;
{% endif %}
Expand Down
15 changes: 4 additions & 11 deletions troposphere/views/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,14 +69,16 @@ def _handle_public_application_request(request, maintenance_records, disabled_lo


def _handle_authenticated_application_request(request, maintenance_records):
show_troposphere_only = hasattr(settings, "SHOW_TROPOSPHERE_ONLY") and settings.SHOW_TROPOSPHERE_ONLY is True
show_troposphere_only = getattr(settings, "SHOW_TROPOSPHERE_ONLY", False)
show_instance_metrics = getattr(settings, "SHOW_INSTANCE_METRICS", False)

template_params = {
'access_token': request.session.get('access_token'),
'emulator_token': request.session.get('emulator_token'),
'emulated_by': request.session.get('emulated_by'),
'records': maintenance_records,
'show_troposphere_only': show_troposphere_only
'show_troposphere_only': show_troposphere_only,
'show_instance_metrics': show_instance_metrics
}

template_params['THEME_HEADER_TEXT'] = settings.THEME_HEADER_TEXT
Expand All @@ -97,15 +99,6 @@ def _handle_authenticated_application_request(request, maintenance_records):
if hasattr(settings, "API_V2_ROOT"):
template_params['API_V2_ROOT'] = settings.API_V2_ROOT

template_params["show_instance_metrics"] = getattr(settings, "SHOW_INSTANCE_METRICS", False)

if settings.SHOW_INSTANCE_METRICS:
try:
template_params["hyper_stats_url"] = settings.HYPER_STATS_URL
except AttributeError:
logger.warn("SHOW_INSTANCE_METRICS disabled: requires HYPER_STATS_URL to be set")
template_params["show_instance_metrics"] = False

user_preferences, created = UserPreferences.objects.get_or_create(user=request.user)

# If beta flag in query params, set the session value to that
Expand Down

0 comments on commit 9b71d60

Please sign in to comment.