Class: Banzai::Filter::InlineAlertMetricsFilter

Inherits:
InlineEmbedsFilter
  • Object
show all
Includes:
Gitlab::Routing
Defined in:
lib/banzai/filter/inline_alert_metrics_filter.rb

Overview

HTML filter that inserts a placeholder element for each reference to an alert dashboard.

Instance Method Summary collapse

Methods included from Gitlab::Routing

add_helpers, includes_helpers, redirect_legacy_paths, url_helpers

Methods inherited from InlineEmbedsFilter

#call, #create_element, #element_to_embed, #embed_params, #gitlab_domain

Instance Method Details

Regular expression matching alert dashboard urls


19
20
21
# File 'lib/banzai/filter/inline_alert_metrics_filter.rb', line 19

def link_pattern
  ::Gitlab::Metrics::Dashboard::Url.alert_regex
end

#xpath_searchObject

Search params for selecting alert metrics links. A few simple checks is enough to boost performance without the cost of doing a full regex match.


12
13
14
15
16
# File 'lib/banzai/filter/inline_alert_metrics_filter.rb', line 12

def xpath_search
  "descendant-or-self::a[contains(@href,'metrics_dashboard') and \
    contains(@href,'prometheus/alerts') and \
    starts-with(@href, '#{gitlab_domain}')]"
end