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

사용자의 편의를 위해 제공되는 기계 번역입니다.

In the event of any inconsistency between the English version and the translated version, the English versionwill take priority. Please visit this page for more information.

문제 신고

지연::작업 계측

Ruby 에이전트에는 Delayed::Job 라이브러리에 대한 내장 계측이 있습니다. 추가 계측이 필요하지 않습니다.

백그라운드 작업 보기

New Relic Ruby 에이전트의 gem 또는 플러그인이 Delayed::Job 작업자가 시작되기 전에 로드되는 한 모든 작업은 컨트롤러 작업과 동일한 세부 수준으로 모니터링됩니다. 작업 자체를 보려면 다음을 수행합니다.

  1. one.newrelic.com > All capabilities > APM & services > (select an app) > Monitor > Transactions

    으)로 이동합니다.

  2. APM

    Transactions

    페이지 에서

    Other transactions

    선택합니다.

사용자 정의 속성 추가

Delayed::Job 트랜잭션에 맞춤 속성을 추가하려면 수명 주기 후크를 통해 Delayed::Job 플러그인을 작성하고 실행된 각 작업의 트랜잭션에 이러한 속성을 추가할 수 있습니다.

  1. 다음 구조로 플러그인을 만듭니다.

    module NewRelicInstrumenter
    class DelayedJobPlugin < Delayed::Plugin
    callbacks do |lifecycle|
    lifecycle.around(:invoke_job) do |job, *args, &block|
    # Forward the call to the next callback in the callback chain
    ::NewRelic::Agent.add_custom_attributes(
    {
    # Any custom attributes go here -- from here you can access info
    # about the job like run_at, created_at, etc
    my_custom_attribute: "my_custom_attribute_value"
    }
    )
    block.call(job, *args)
    end
    end
    end
    end
  2. config/initializers/delayed_job.rb 파일의 초기화 프로그램에서 플러그인을 Delayed::Job 에 추가합니다.

    require "new_relic_instrumenter"
    Delayed::Worker.plugins << NewRelicInstrumenter::DelayedJobPlugin

문제점 해결

Ruby 에이전트는 계측을 올바르게 설정하기 위해 Delayed::Job 에서 실행 중임을 식별할 수 있어야 합니다. 이를 위해 스크립트 이름(Ruby의 $0 변수)을 검사하여 delayed_job 로 끝나는지 확인합니다.

delayed_job 작업자를 시작하는 데 사용하는 스크립트의 이름을 다른 이름으로 변경했거나 이름이 다른 사용자 지정 스크립트가 있는 경우 Delayed::Job 작업자를 시작할 때 NEW_RELIC_DISPATCHER 환경 변수를 delayed_job로 설정하여 Delayed::Job를 사용 중임을 에이전트에 명시적으로 알려야 합니다. 예를 들어:

bash
$
NEW_RELIC_DISPATCHER=delayed_job bundle exec ./script/my_custom_script

작업이 모니터링되지 않는 것으로 나타나면 작업자가 시작될 때 생성된 newrelic_agent.log 파일을 검토하세요. 에이전트가 Delayed 감지하고 서버와 통신하는지 여부를 나타내야 합니다. 로그를 찾을 수 없거나 작업이 표시되지 않는 이유를 여전히 확인할 수 없는 경우 support.newrelic.com 에서 지원을 받으십시오.

Copyright © 2024 New Relic Inc.

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