• /
  • Log in

PHP agent API

The PHP agent API allows you to extend the functionality of the PHP agent. The agent API is included by default with your installation, so no additional configuration is required to use the agent.

Among other things, you can use the API to customize your app name; collect errors; record custom attributes, custom events, and custom metrics; and enable or disable browser monitoring. For an introduction to this API, see Guide to PHP agent API.

Tip

Enclose these API calls in a conditional check for the PHP agent so that your code will work even if the agent is not present:

if (extension_loaded('newrelic')) {
newrelic_set_appname($name);
}
newrelic_accept_distributed_trace_headers

Accepts an array of distributed trace headers.

newrelic_accept_distributed_trace_payload (PHP agent API)

Accepts a distributed trace payload.

newrelic_accept_distributed_trace_payload_httpsafe (PHP agent API)

Accepts a distributed trace payload that includes an HTTPSafe (Base64 encoded) JSON string.

newrelic_add_custom_parameter (PHP agent API)

Attaches a custom attribute (key/value pair) to the current transaction and the current span (if enabled).

newrelic_add_custom_span_parameter (PHP agent API)

Attaches a custom attribute (key/value pair) to the current span.

newrelic_add_custom_tracer (PHP agent API)

Specify functions or methods for the agent to instrument with custom instrumentation.

newrelic_background_job (PHP agent API)

Manually specify that a transaction is a background job or a web transaction.

newrelic_capture_params (PHP agent API)

Enable or disable the capture of URL parameters.

newrelic_create_distributed_trace_payload (PHP agent API)

Creates a distributed trace payload.

newrelic_custom_metric (PHP agent API)

Add a custom metric (in milliseconds) to time a component of your app not captured by default.

newrelic_disable_autorum (PHP agent API)

Disable automatic injection of the browser monitoring snippet on particular pages.

newrelic_end_of_transaction (PHP agent API)

Stop timing the current transaction, but continue instrumenting it.

newrelic_end_transaction (PHP agent API)

Stop instrumenting the current transaction immediately.

newrelic_get_browser_timing_footer (PHP agent API)

Returns a browser monitoring snippet to inject at the end of the HTML output.

newrelic_get_browser_timing_header (PHP agent API)

Returns a browser monitoring snippet to inject in the head of your HTML output.

newrelic_get_linking_metadata

Returns a collection of metadata necessary for linking data to a trace or an entity.

newrelic_get_trace_metadata

Returns an associative array containing the identifiers of the current trace and the parent span.

newrelic_ignore_apdex (PHP agent API)

Ignore the current transaction when calculating Apdex.

newrelic_ignore_transaction (PHP agent API)

Do not instrument the current transaction.

newrelic_insert_distributed_trace_headers

Inserts W3C Trace Context headers and New Relic Distributed Tracing headers into an outbound array of headers.

newrelic_is_sampled

Returns a value indicating whether or not the current transaction is marked as sampled.

newrelic_name_transaction (PHP agent API)

Set custom name for current transaction.

newrelic_notice_error (PHP agent API)

Use these calls to collect errors that the PHP agent does not collect automatically and to set the callback for your own error and exception handler.

newrelic_record_custom_event (PHP agent API)

Record a custom event with the given name and attributes.

newrelic_record_datastore_segment (PHP agent API)

Records a datastore segment.

newrelic_set_appname (PHP agent API)

Sets the New Relic app name, which controls data rollup.

newrelic_set_user_attributes (PHP agent API)

Create user-related custom attributes. newrelic_add_custom_parameter is more flexible.

newrelic_start_transaction (PHP agent API)

Starts a new transaction, usually after manually ending a transaction.

Create issueEdit page
Copyright © 2021 New Relic Inc.