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

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

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

문제 신고

newrelic_add_custom_tracer(PHP 에이전트 API)

통사론

newrelic_add_custom_tracer(string $function_name)

에이전트가 사용자 지정 계측으로 계측할 함수 또는 방법을 지정합니다.

요구 사항

모든 에이전트 버전과 호환됩니다.

설명

에이전트가 사용자 지정 계측 을 대상으로 하는 기능 또는 방법을 지정합니다. 이는 newrelic.transaction_tracer.custom 설정에 해당하는 API입니다.

내부 PHP 함수에는 사용자 정의 추적을 적용할 수 없습니다.

매개변수

매개변수

설명

$function_name

필수의. 이름은 절차 함수의 경우 function_name 으로 형식을 지정하거나 메서드의 경우 "ClassName::method" 형식을 지정할 수 있습니다. 메서드 구문이 사용되는 경우 정적 메서드와 인스턴스 메서드가 모두 계측되며 클래스 이름은 정규화되어야 합니다. 클래스가 네임스페이스 내에 정의된 경우 전체 네임스페이스를 포함해야 합니다.

반환 값

추적 프로그램이 성공적으로 추가된 경우 true 을 반환합니다.

기능 계측

function example_function() {
if (extension_loaded('newrelic')) { // Ensure PHP agent is available
newrelic_add_custom_tracer("example_function");
}
}

클래스 내에서 메서드 계측

class ExampleClass {
function example_method() {
if (extension_loaded('newrelic')) { // Ensure PHP agent is available
newrelic_add_custom_tracer("ExampleClass::example_method");
}
}
}

네임스페이스 클래스 내에서 메서드 계측

namespace Foo\Bar;
class ExampleClass {
function example_method() {
if (extension_loaded('newrelic')) { // Ensure PHP agent is available
newrelic_add_custom_tracer("Foo\\Bar\\ExampleClass::example_method");
}
}
}

또는 PHP 5.5 이상에서는 ::class 구문을 대신 사용할 수 있습니다.

namespace Foo\Bar {
class ExampleClass {
function example_method() {
// ...
}
}
}
namespace {
use Foo\Bar;
if (extension_loaded('newrelic')) { // Ensure PHP agent is available
newrelic_add_custom_tracer(Bar::class . "::example_method");
}
}
Copyright © 2024 New Relic Inc.

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