forked from JetBrains/phpstorm-stubs
-
Notifications
You must be signed in to change notification settings - Fork 0
/
newrelic.php
358 lines (340 loc) · 16.2 KB
/
newrelic.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
<?php
/**
* Add a custom parameter to the current web transaction with the specified value.
*
* For example, you can add a customer's full name from your customer database. This parameter is shown in any
* transaction trace that results from this transaction.
*
* If the value given is a float with a value of NaN, Infinity, denorm or negative zero, the behavior of this function is
* undefined. For other floating point values, New Relic may discard 1 or more bits of precision (ULPs) from the given
* value.
*
* This function will return true if the parameter was added successfully.
*
* Warning: If you are using your custom parameters/attributes in Insights, avoid using any of Insights' reserved words
* for naming them.
*
* @link https://docs.newrelic.com/docs/agents/php-agent/configuration/php-agent-api#api-custom-param
*
* @param string $key
* @param boolean|float|integer|string $value
*
* @return boolean
*/
function newrelic_add_custom_parameter($key, $value) {}
/**
* Add user-defined functions or methods to the list to be instrumented . API equivalent of the
* newrelic.transaction_tracer.custom setting.
*
* Internal PHP functions cannot have custom tracing. functionName can be formatted either as "functionName"
* for procedural functions, or as "ClassName::method" for methods. Both static and instance methods will be
* instrumented if the method syntax is used.
*
* This function will return true if the tracer was added successfully.
*
* @link https://docs.newrelic.com/docs/agents/php-agent/configuration/php-agent-api#api-custom-tracer
*
* @param string $functionName
*
* @return boolean
*/
function newrelic_add_custom_tracer($functionName) {}
/**
* Mark current transaction as a background job or a web transaction.
*
* If the flag argument is set to true or omitted, the current transaction is marked as a background job. If flag is set
* to false, then the transaction is marked as a web transaction.
*
* @link https://docs.newrelic.com/docs/agents/php-agent/configuration/php-agent-api#api-bg
*
* @param boolean $flag [optional]
*
* @return void
*/
function newrelic_background_job($flag = true) {}
/**
* Enables the capturing of URL parameters for displaying in transaction traces. This will override the
* newrelic.capture_params setting.
*
* Note: Until version 2.1.3 of the PHP agent, this function was called newrelic_enable_params. Although this alias
* still exists, it is deprecated and will be removed in the future.
*
* @link https://docs.newrelic.com/docs/agents/php-agent/configuration/php-agent-api#api-capture-params
*
* @param boolean $enable [optional]
*
* @return void
*/
function newrelic_capture_params($enable = true) {}
/**
* Adds a custom metric with the specified name and value.
*
* Values saved are assumed to be milliseconds, so "4" will be stored as ".004" in our system. Your custom metrics can
* then be used in custom dashboards and custom views in the New Relic user interface. Name your custom metrics with
* a Custom/ prefix (for example, Custom/MyMetric). This will make them easily usable in custom dashboards. If the value
* is NaN, Infinity, denorm or negative zero, the behavior of this function is undefined. New Relic may discard 1 or
* more bits of precision (ULPs) from the given value.
*
* This function will return true if the metric was added successfully.
*
* Warning: Avoid creating too many unique custom metric names. New Relic limits the total number of custom metrics you
* can use (not the total you can report for each of these custom metrics). Exceeding more than 2000 unique custom
* metric names can cause automatic clamps that will affect other data.
*
* @link https://docs.newrelic.com/docs/agents/php-agent/configuration/php-agent-api#api-custom-metric
*
* @param string $metricName
* @param float $value
*
* @return boolean
*/
function newrelic_custom_metric($metricName, $value) {}
/**
* Prevents the output filter from attempting to insert the JavaScript for page load timing (sometimes referred to as
* real user monitoring or RUM) for this current transaction.
*
* This function will always return true.
*
* @link https://docs.newrelic.com/docs/agents/php-agent/configuration/php-agent-api#api-rum-disable
*
* @return true
*/
function newrelic_disable_autorum() {}
/**
* @deprecated use newrelic_capture_params() instead
*/
function newrelic_enable_params() {}
/**
* Stop recording the web transaction immediately.
*
* Usually used when a page is done with all computation and is about to stream data (file download, audio or video
* streaming, etc.) and you don't want the time taken to stream to be counted as part of the transaction. This is
* especially relevant when the time taken to complete the operation is completely outside the bounds of your
* application. For example, a user on a very slow connection may take a very long time to download even small files,
* and you wouldn't want that download time to skew the real transaction time.
*
* @link https://docs.newrelic.com/docs/agents/php-agent/configuration/php-agent-api#api-eot
*
* @return void
*/
function newrelic_end_of_transaction() {}
/**
* Causes the current transaction to end immediately.
*
* Despite being similar in name to newrelic_end_of_transaction above, this call serves a very different purpose.
* newrelic_end_of_transaction simply marks the end time of the transaction but takes no other action. The transaction
* is still only sent to the daemon when the PHP engine determines that the script is done executing and is shutting
* down. This function on the other hand, causes the current transaction to end immediately, and will ship all of the
* metrics gathered thus far to the daemon unless the ignore parameter is set to true. In effect this call simulates
* what would happen when PHP terminates the current transaction. This is most commonly used in command line scripts
* that do some form of job queue processing. You would use this call at the end of processing a single job task, and
* begin a new transaction (see below) when a new task is pulled off the queue.
* Normally, when you end a transaction you want the metrics that have been gathered thus far to be recorded. However,
* there are times when you may want to end a transaction without doing so. In this case use the second form of the
* function and set ignore to true.
*
* This function will return true if the transaction was successfully ended and data was sent to the New Relic daemon.
*
* @link https://docs.newrelic.com/docs/agents/php-agent/configuration/php-agent-api#api-end-txn
*
* @param boolean $ignore [optional]
*
* @return boolean
*/
function newrelic_end_transaction($ignore = false) {}
/**
* Returns the JavaScript string to inject at the very end of the HTML output for page load timing (sometimes referred
* to as real user monitoring or RUM).
*
* If includeTags omitted or set to true, the returned JavaScript string will be enclosed in a <script> tag.
*
* @link https://docs.newrelic.com/docs/agents/php-agent/configuration/php-agent-api#api-rum-footer
*
* @param bool $includeTags [optional]
*
* @return string
*/
function newrelic_get_browser_timing_footer ($includeTags = true) {}
/**
* Returns the JavaScript string to inject as part of the header for page load timing (sometimes referred to as real
* user monitoring or RUM).
*
* If includeTags are omitted or set to true, the returned JavaScript string will be enclosed in a <script> tag.
*
* @link https://docs.newrelic.com/docs/agents/php-agent/configuration/php-agent-api#api-rum-header
*
* @param bool $includeTags
*
* @return string
*/
function newrelic_get_browser_timing_header($includeTags = true) {}
/**
* Do not generate Apdex metrics for this transaction.
*
* This is useful when you have either very short or very long transactions (such as file downloads) that can skew your
* Apdex score.
*
* @link https://docs.newrelic.com/docs/agents/php-agent/configuration/php-agent-api#api-ignore-apdex
*
* @return void
*/
function newrelic_ignore_apdex() {}
/**
* Do not generate metrics for this transaction.
*
* This is useful when you have transactions that are particularly slow for known reasons and you do not want them
* always being reported as the transaction trace or skewing your site averages.
*
* @link https://docs.newrelic.com/docs/agents/php-agent/configuration/php-agent-api#api-ignore-transaction
*
* @return void
*/
function newrelic_ignore_transaction() {}
/**
* Sets the name of the transaction to the specified name.
*
* This can be useful if you have implemented your own dispatching scheme and want to name transactions according to
* their purpose rather than their URL.
*
* This function will return true if the transaction name was successfully changed. If false is returned, please check
* the agent log for more information.
*
* Call this function as early as possible. It will have no effect, for example, if called after the JavaScript footer
* for page load timing (sometimes referred to as real user monitoring or RUM) has been sent.
* Avoid creating too many unique transaction names. This will make your graphs less useful, and you may run into limits
* we set on the number of unique transaction names per account. It also can slow down the performance of your
* application.
*
* Example: Naming transactions
* You have /product/123 and /product/234. If you generate a separate transaction name for each, then New Relic will
* store separate information for these two transaction names.
* Instead, store the transaction as /product/*, or use something significant about the code itself to name the
* transaction, such as /Product/view. The total number of unique transaction names should be less than 1000. Exceeding
* that is not recommended.
*
* @link https://docs.newrelic.com/docs/agents/php-agent/configuration/php-agent-api#api-name-wt
*
* @param string $name
*
* @return boolean
*/
function newrelic_name_transaction($name) {}
/**
* Report an error at this line of code, with a complete stack trace.
*
* The first form of the call was added in agent version 2.6 and should be used for reporting exceptions. Only the
* exception for the last call is retained during the course of a transaction.
*
* Agent version 4.3 enhanced this form to use the exception class as the category for grouping within the New Relic APM
* user interface. The exception parameter must be a valid PHP Exception class, and the stack frame recorded in that
* class will be the one reported, rather than the stack at the time this function was called. When using this form,
* if the error message is empty, a standard message in the same format as created by Exception::__toString() will be
* automatically generated.
*
* function newrelic_notice_error(string $message, Exception $exception)
*
* With the second form of the call, only the message is used. This set of parameters allows newrelic_notice_error to be
* set as an error handler with the internal PHP function set_error_handler(). With the second form of the call, only
* the message is used.
*
* function newrelic_notice_error(integer $unused1, string $message, $unused2, $unused3, $unused4)
*
* @link https://docs.newrelic.com/docs/agents/php-agent/configuration/php-agent-api#api-notice-error
*
* @param string|integer $messageOrUnused [optional]
* @param Exception|string $exceptionOrMessage [optional]
* @param string $unused2 [optional]
* @param integer $unused3 [optional]
* @param mixed $unused4 [optional]
*
* @return void
*/
function newrelic_notice_error($messageOrUnused = null, $exceptionOrMessage = null, $unused2 = null, $unused3 = null, $unused4 = null) {}
/**
* Records a New Relic Insights custom event.
*
* For more information, see Inserting custom events with the PHP agent. The attributes parameter is expected to be an
* associative array: the keys should be the attribute names (which may be up to 255 characters in length), and the
* values should be scalar values: arrays and objects are not supported.
*
* This API call was introduced in version 4.18 of the agent.
*
* @link https://docs.newrelic.com/docs/agents/php-agent/configuration/php-agent-api#api-record-custom-event
*
* @param string $name
* @param array $attributes
*
* @return void
*/
function newrelic_record_custom_event($name, array $attributes) {}
/**
* Sets the name of the application to name.
*
* The string uses the same format as newrelic.appname and can set multiple application names by separating each with a
* semi-colon (;). However, be aware of the restriction on the application name ordering as described for that setting.
* The first application name is the primary name. You can also specify up to two extra application names. (However, the
* same application name can only ever be used once as a primary name.) Call this function as early as possible. It will
* have no effect if called after the JavaScript footer for page load timing (sometimes referred to as real user
* monitoring or RUM) has been sent.
*
* If you use multiple licenses, you can also specify a license key along with the application name. An application can
* appear in more than one account and the license key controls which account you are changing the name in. If you do
* not wish to change the license and wish to use the third variant, simply set the license key to the empty string
* ("").
*
* The xmit flag is new in PHP agent version 3.1. Usually, when you change an application name, the agent simply
* discards the current transaction and does not send any of the accumulated metrics to the daemon. However, if you want
* to record the metric and transaction data up to the point at which you called this function, you can specify a value
* of true for this argument to make the agent send the transaction to the daemon. This has a very slight performance
* impact as it takes a few milliseconds for the agent to dump its data. By default this parameter is false.
*
* Consider setting the application name in a file loaded by PHP's auto_prepend_file INI setting. This function returns
* true if it succeeded or false otherwise.
*
* This function will return true if the application name was successfully changed.
*
* @link https://docs.newrelic.com/docs/agents/php-agent/configuration/php-agent-api#api-set-appname
*
* @param string $name
* @param string $license [optional] defaults to ini_get('newrelic.license')
* @param boolean $xmit [optional]
*
* @return boolean
*/
function newrelic_set_appname($name, $license = null, $xmit = false) {}
/**
* Sets user attributes (custom parameters).
*
* As of release 4.4, calling newrelic_set_user_attributes("a", "b", "c"); is equivalent to calling:
* newrelic_add_custom_parameter("user", "a"); newrelic_add_custom_parameter("account", "b");
* newrelic_add_custom_parameter("product", "c"); Previously, the three parameter strings were added to collected
* browser traces. All three parameters are required, but may be empty strings. * This function will return true if the attributes were added successfully.
*
* @link https://docs.newrelic.com/docs/agents/php-agent/configuration/php-agent-api#api-set-user-attributes
*
* @param string $user
* @param string $account
* @param string $product
*
* @return boolean
*/
function newrelic_set_user_attributes($user, $account, $product) {}
/**
* If you have ended a transaction before your script terminates (perhaps due to it just having finished a task in a job
* queue manager) and you want to start a new transaction, use this call.
*
* This will perform the same operations that
* occur when the script was first started. Of the two arguments, only the application name is mandatory. However, if
* you are processing tasks for multiple accounts, you may also provide a license for the associated account. The
* license set for this API call will supersede all per-directory and global default licenses configured in INI files.
*
* This function will return true if the transaction was successfully started.
*
* @link https://docs.newrelic.com/docs/agents/php-agent/configuration/php-agent-api#api-start-txn
*
* @param string $appName
* @param string $license [optional] defaults to ini_get('newrelic.license')
*
* @return boolean
*/
function newrelic_start_transaction($appName, $license = null) {}