Skip to content

Commit def51cd

Browse files
yashikakhuranaYashika Khurana
andauthored
feat(nimbus): improve feature monitoring card messaging and links (#16065)
Because - The metric-hub config and feature monitoring doc links in the Feature Monitoring card rendered empty, because the features view rebuilt its context without `EXTERNAL_URLS`. - When no dashboard is available, users had no way to see what feature monitoring actually looks like. - When a dashboard is available, there was no context explaining what it shows. This commit - Adds `EXTERNAL_URLS` to the features view context so the doc and metric-hub config links resolve. - Shows a short info line describing the dashboard when monitoring is available. - Adds an example dashboard link when monitoring is not available, so users can preview what they'll get after adding a featmon config. fixes #16064 Co-authored-by: Yashika Khurana <yashikakhurana@Yashikas-MBP.home.local>
1 parent 7d39c11 commit def51cd

5 files changed

Lines changed: 52 additions & 1 deletion

File tree

experimenter/experimenter/experiments/constants.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1247,6 +1247,7 @@ class FunnelTextColor(models.TextChoices):
12471247
"PREVIEW_LAUNCH_DOC": "https://experimenter.info/platform-guides/desktop/preview",
12481248
"FEATURE_MONITORING_DOC": "https://experimenter.info/feature-monitoring",
12491249
"METRIC_HUB_FEATMON_CONFIG": "https://github.com/mozilla/metric-hub/blob/main/featmon/firefox_desktop.toml",
1250+
"FEATURE_MONITORING_EXAMPLE": "https://yardstick.mozilla.org/d/dtfz7xv/nimbus-feature-monitoring?orgId=1&var-feature_slug=newtabSponsoredContent&var-application=firefox_desktop&var-metric=All",
12501251
}
12511252

12521253

experimenter/experimenter/nimbus_ui/constants.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -221,6 +221,12 @@ class NimbusUIConstants:
221221
NOTABLE_CHANGES_ABSENT_TEXT = "There are no notable changes in this experiment"
222222
FEATURE_MONITORING_CARD_TITLE = "Feature Monitoring"
223223
FEATURE_MONITORING_OPEN_DASHBOARD_TEXT = "Open in Grafana"
224+
FEATURE_MONITORING_DASHBOARD_INFO = (
225+
"This dashboard shows aggregate health and enrollment metrics for this "
226+
"feature across all live and completed rollouts."
227+
)
228+
FEATURE_MONITORING_EXAMPLE_TEXT = "Once configured, you'll get a dashboard like"
229+
FEATURE_MONITORING_EXAMPLE_LINK_TEXT = "this example"
224230

225231
FEATURE_PAGE_LINKS = {
226232
"feature_learn_more_url": "https://experimenter.info/getting-started/for-experiment-owners",

experimenter/experimenter/nimbus_ui/templates/nimbus_experiments/features.html

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,7 @@ <h5 class="fw-semibold mb-0 d-flex align-items-center">
7272
</a>
7373
</div>
7474
{% if selected_feature_config.has_metric_hub_monitoring %}
75+
<p class="text-muted small mb-2">{{ NimbusUIConstants.FEATURE_MONITORING_DASHBOARD_INFO }}</p>
7576
<div class="d-flex align-items-center gap-2 mb-3">
7677
<a href="{{ selected_feature_config.feature_monitoring_url }}"
7778
target="_blank"
@@ -97,6 +98,13 @@ <h5 class="fw-semibold mb-0 d-flex align-items-center">
9798
target="_blank"
9899
rel="noopener noreferrer">feature monitoring docs</a>
99100
for instructions.
101+
<hr class="my-2">
102+
<span class="small">
103+
{{ NimbusUIConstants.FEATURE_MONITORING_EXAMPLE_TEXT }}
104+
<a href="{{ EXTERNAL_URLS.FEATURE_MONITORING_EXAMPLE }}"
105+
target="_blank"
106+
rel="noopener noreferrer">{{ NimbusUIConstants.FEATURE_MONITORING_EXAMPLE_LINK_TEXT }}</a>.
107+
</span>
100108
</div>
101109
</div>
102110
{% endif %}

experimenter/experimenter/nimbus_ui/tests/test_views.py

Lines changed: 36 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
from django.core.files.uploadedfile import SimpleUploadedFile
99
from django.test import TestCase, override_settings
1010
from django.urls import reverse
11+
from django.utils.html import escape
1112
from parameterized import parameterized
1213
from PIL import Image
1314

@@ -16,7 +17,7 @@
1617
LanguageFactory,
1718
LocaleFactory,
1819
)
19-
from experimenter.experiments.constants import NimbusConstants
20+
from experimenter.experiments.constants import EXTERNAL_URLS, NimbusConstants
2021
from experimenter.experiments.models import (
2122
NimbusExperiment,
2223
NimbusExperimentBranchThroughExcluded,
@@ -5707,6 +5708,40 @@ def test_qa_runs_table_shows_experiments_with_testrail_urls_when_qa_status_not_s
57075708
self.assertNotIn(experiment_without_urls, qa_runs)
57085709
self.assertIn(experiment_with_status, qa_runs)
57095710

5711+
def _features_url_for(self, slug):
5712+
feature = self.feature_configs[slug]
5713+
url = reverse("nimbus-ui-features")
5714+
return f"{url}?application={feature.application}&feature_configs={feature.pk}"
5715+
5716+
@patch("experimenter.jetstream.client.get_featmon_slugs")
5717+
def test_monitoring_card_shows_dashboard_and_info_when_monitored(self, mock_slugs):
5718+
mock_slugs.return_value = frozenset({"feature-desktop"})
5719+
5720+
response = self.client.get(self._features_url_for("feature-desktop"))
5721+
5722+
self.assertEqual(response.status_code, 200)
5723+
content = response.content.decode()
5724+
self.assertIn("Open Grafana Dashboard", content)
5725+
self.assertIn(NimbusUIConstants.FEATURE_MONITORING_DASHBOARD_INFO, content)
5726+
self.assertIn(
5727+
escape(self.feature_configs["feature-desktop"].feature_monitoring_url),
5728+
content,
5729+
)
5730+
5731+
@patch("experimenter.jetstream.client.get_featmon_slugs")
5732+
def test_monitoring_card_shows_docs_and_example_when_not_monitored(self, mock_slugs):
5733+
mock_slugs.return_value = frozenset()
5734+
5735+
response = self.client.get(self._features_url_for("feature-desktop"))
5736+
5737+
self.assertEqual(response.status_code, 200)
5738+
content = response.content.decode()
5739+
self.assertIn("Grafana dashboard not available", content)
5740+
self.assertIn(EXTERNAL_URLS["FEATURE_MONITORING_DOC"], content)
5741+
self.assertIn(EXTERNAL_URLS["METRIC_HUB_FEATMON_CONFIG"], content)
5742+
self.assertIn(escape(EXTERNAL_URLS["FEATURE_MONITORING_EXAMPLE"]), content)
5743+
self.assertIn(escape(NimbusUIConstants.FEATURE_MONITORING_EXAMPLE_TEXT), content)
5744+
57105745

57115746
class TestTagsManageView(AuthTestCase):
57125747
def test_tags_manage_view_renders(self):

experimenter/experimenter/nimbus_ui/views.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1108,6 +1108,7 @@ def get_context_data(self, **kwargs):
11081108

11091109
context = {
11101110
"form": form,
1111+
"EXTERNAL_URLS": EXTERNAL_URLS,
11111112
"application": self.request.GET.get("application"),
11121113
"feature_configs": self.request.GET.get("feature_configs"),
11131114
"selected_feature_config": selected_feature_config,

0 commit comments

Comments
 (0)