Syntax
newrelic_add_custom_tracer(string $function_name)
Specify functions or methods for the agent to instrument with custom instrumentation.
Requirements
Compatible with all agent versions.
Description
Specify functions or methods for the agent to target for custom instrumentation. This is the API equivalent of the newrelic.transaction_tracer.custom
setting.
You cannot apply custom tracing to internal PHP functions.
Parameters
Parameter | Description |
---|---|
string | Required. The name can be formatted either as |
Return values
Returns true
if the tracer was added successfully.
Examples
Instrument a function
function example_function() { if (extension_loaded('newrelic')) { // Ensure PHP agent is available newrelic_add_custom_tracer("example_function"); }}
Instrument a method within a class
class ExampleClass { function example_method() { if (extension_loaded('newrelic')) { // Ensure PHP agent is available newrelic_add_custom_tracer("ExampleClass::example_method"); } }}
Instrument a method within a namespaced class
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"); } }}
Alternatively, on PHP 5.5 or later, the ::class
syntax can be used instead:
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"); } }}
For more help
If you need more help, check out these support and learning resources:
- Suggest a change and learn how to contribute to our PHP agent open source repository.
- Browse the Explorers Hub to get help from the community and join in discussions.
- Find answers on our sites and learn how to use our support portal.
- Run New Relic Diagnostics, our troubleshooting tool for Linux, Windows, and macOS.
- Review New Relic's data security and licenses documentation.
その他のヘルプ
さらに支援が必要な場合は、これらのサポートと学習リソースを確認してください:
- Explorers Hubでは、コミュニティからのサポートを受けたり、ディスカッションに参加したりすることができます。
- 当社サイトで答えを見つけて、サポートポータルの使用方法を確認してください。
- Linux、Windows、およびmacOS向けトラブルシューティングツールであるNew Relic Diagnosticsを実行してください。
- New Relicのデータセキュリティとライセンスドキュメント をご確認ください。