ruby-on-rails - 如何在 Rails AMP 页面上禁用 newrelic_rpm

标签 ruby-on-rails newrelic amp-html

AMP 验证器说“标签‘script’是不允许的,特定形式除外。”。

现在我知道这个标签 'script' 是由 newrelic_rpm 自动创建的。

我的问题是如何在 AMP 页面上禁用 newrelic_rpm。

我的 AMP 页面的网址类似于 http://example.com/foo/bar.amp

所以我尝试了这样的设置 config/newrelic.yml:

common: &default_settings
  license_key: foobarfoobarfoobarfoobar

  app_name: Foobar

  rules.ignore_url_regexes: ["amp", ".*amp"]

development:
  <<: *default_settings
  app_name: FooBar (Development)

  developer_mode: true

但它不起作用。

我的项目环境:

  • rails (4.1.8)
  • ruby (2.2.3)
  • newrelic_rpm (3.14.0.305)

最佳答案

我也是这样。对@Awjecc 的回答进行微调

ApplicationController < ActionController::Base

  before_action :ignore_newrelic, :if => :amp_request?

   ...


  private

  def ignore_newrelic
    NewRelic::Agent.ignore_transaction
    NewRelic::Agent.ignore_apdex
    NewRelic::Agent.ignore_enduser
  end

  def amp_request?
    request.format.try(:amp?)
  end

end

关于ruby-on-rails - 如何在 Rails AMP 页面上禁用 newrelic_rpm,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36255448/

相关文章:

AMP 网站的纯 CSS 菜单

javascript - 如何处理 AMP 的 CORS

ruby-on-rails - 如何知道 I18n rails 的优先级

ruby-on-rails - 预期响应有成功状态代码 (2xx),但结果是 401

zend-server - Zend Server 与 newrelic

html - 将图像悬停在 AMP-Pinterest Pin It 按钮上

ruby-on-rails - 在图像上传程序的支持下,我可以在Rails 3.1应用程序中使用哪些所见即所得编辑器?

ruby-on-rails - 在Rails 3 View 中,如何检测显示字符串中的URL并将其格式化为指向该URL的链接?

privacy - NewRelic 和用户隐私政策

iis - 您能否绕过 IIS 请求的 "AuthenticateRequest"部分