• EnglishEspañol日本語한국어Português
  • 로그인지금 시작하기

이 한글 문서는 사용자의 편의를 위해 기계 번역되었습니다.

영문본과 번역본이 일치하지 않는 경우 영문본이 우선합니다. 보다 자세한 내용은 이 페이지를 방문하시기 바랍니다.

문제 신고

금속 컨트롤러 계측

기본적으로 New Relic Ruby 에이전트는 ActionController::Metal 컨트롤러를 계측하지 않습니다. 이는 Metal 컨트롤러가 유효한 Rack 앱을 제공하는 데 필요한 최소한의 인터페이스만 제공한다는 철학과 일치합니다. 필요에 따라 금속 컨트롤러를 장식하는 것은 일반적으로 귀하에게 달려 있습니다. 이 문서에서는 이러한 컨트롤러 작업을 APM 트랜잭션 페이지 에 표시하는 방법과 Rails 3 앱 이상에 대해 ApplicationController 에서 상속된 작업과 함께 개요를 설명합니다.

레일즈 4.0 이상

Rails 4.0부터 New Relic의 컨트롤러 계측은 ActiveSupport::Notifications 을 사용합니다. ActionController::Instrumentation 모듈을 포함하면 컨트롤러 이벤트가 Metal 컨트롤러에서 시작됩니다. 이를 통해 New Relic은 이러한 작업을 계측할 수 있습니다.

class PlatinumController < ActionController::Metal
include ActionController::Rendering
def show
render :text => "Here is some text"
end
# Ensure ActiveSupport::Notifications events are fired
include ActionController::Instrumentation
# Uncomment the following line to include New Relic helper methods, such as newrelic_ignore or add_method_tracer
# include NewRelic::Agent::Instrumentation::ControllerInstrumentation
end

레일 3.0 - 3.2

방법 1

다음 방법은 기본 컨트롤러와 마찬가지로 모든 금속 컨트롤러 동작을 자동 계측합니다.

Metal Controller 클래스의 맨 아래에 NewRelic::Agent::Instrumentation::ControllerInstrumentationNewRelic::Agent::Instrumentation::Rails3::ActionController 을 포함합니다.

class SteelController < ActionController::Metal
include ActionController::Rendering
def show
render :text => "Here is some text"
end
include NewRelic::Agent::Instrumentation::ControllerInstrumentation
include NewRelic::Agent::Instrumentation::Rails3::ActionController
end

방법 2

다음 예에서는 Metal 컨트롤러의 특정 작업 방법만 추적하도록 선택할 수 있습니다.

각 메서드 계측에 대해 NewRelic::Agent::Instrumentation::ControllerInstrumentation 을 포함하고 add_transaction_tracer 을 호출합니다.

class SteelController < ActionController::Metal
include ActionController::Rendering
include NewRelic::Agent::Instrumentation::ControllerInstrumentation
def show
render :text => "Here is some text"
end
add_transaction_tracer :show
end

방법 3

마지막 예제는 Metal Controller 클래스뿐만 아니라 모든 클래스에서 작동하는 메서드의 추적을 추가하는 보다 일반적인 방법입니다.

각 메서드 계측에 대해 NewRelic::Agent::MethodTracer 을 포함하고 add_method_tracer 을 호출합니다.

class SteelController < ActionController::Metal
include ActionController::Rendering
include NewRelic::Agent::MethodTracer
def show
render :text => "Here is some text"
end
add_method_tracer :show
end

레일 2.3

Rails 2의 Rails::Rack::Metal 클래스를 사용하는 경우 다음과 같이 Metals에 대한 호출을 계측할 수 있습니다.

require 'newrelic_rpm'
class MyMetal < Rails::Rack::Metal
def self.call(env)
# ... your metal code ...
end
class << self
include NewRelic::Agent::Instrumentation::ControllerInstrumentation
add_transaction_tracer :call
end
end
Copyright © 2024 New Relic Inc.

This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.