1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
declare(strict_types=1); |
4
|
|
|
|
5
|
|
|
/* |
6
|
|
|
* This file is part of Ekino New Relic bundle. |
7
|
|
|
* |
8
|
|
|
* (c) Ekino - Thomas Rabaix <[email protected]> |
9
|
|
|
* |
10
|
|
|
* For the full copyright and license information, please view the LICENSE |
11
|
|
|
* file that was distributed with this source code. |
12
|
|
|
*/ |
13
|
|
|
|
14
|
|
|
namespace Ekino\NewRelicBundle\NewRelic; |
15
|
|
|
|
16
|
|
|
class NewRelicInteractor implements NewRelicInteractorInterface |
17
|
|
|
{ |
18
|
|
|
public function setApplicationName(string $name, string $key = null, bool $xmit = false): bool |
19
|
|
|
{ |
20
|
|
|
return newrelic_set_appname($name, $key, $xmit); |
21
|
|
|
} |
22
|
|
|
|
23
|
|
|
public function setTransactionName(string $name): bool |
24
|
|
|
{ |
25
|
|
|
return newrelic_name_transaction($name); |
26
|
|
|
} |
27
|
|
|
|
28
|
|
|
public function ignoreTransaction(): void |
29
|
|
|
{ |
30
|
|
|
newrelic_ignore_transaction(); |
31
|
|
|
} |
32
|
|
|
|
33
|
|
|
public function addCustomEvent(string $name, array $attributes): void |
34
|
|
|
{ |
35
|
|
|
newrelic_record_custom_event((string) $name, $attributes); |
36
|
|
|
} |
37
|
|
|
|
38
|
|
|
public function addCustomMetric(string $name, float $value): bool |
39
|
|
|
{ |
40
|
|
|
return newrelic_custom_metric($name, $value); |
41
|
|
|
} |
42
|
|
|
|
43
|
|
|
public function addCustomParameter(string $name, $value): bool |
44
|
|
|
{ |
45
|
|
|
return newrelic_add_custom_parameter((string) $name, $value); |
46
|
|
|
} |
47
|
|
|
|
48
|
|
|
public function getBrowserTimingHeader(bool $includeTags = true): string |
49
|
|
|
{ |
50
|
|
|
return newrelic_get_browser_timing_header($includeTags); |
51
|
|
|
} |
52
|
|
|
|
53
|
|
|
public function getBrowserTimingFooter(bool $includeTags = true): string |
54
|
|
|
{ |
55
|
|
|
return newrelic_get_browser_timing_footer($includeTags); |
56
|
|
|
} |
57
|
|
|
|
58
|
|
|
public function disableAutoRUM(): bool |
59
|
|
|
{ |
60
|
|
|
return newrelic_disable_autorum(); |
61
|
|
|
} |
62
|
|
|
|
63
|
|
|
public function noticeError(int $errno, string $errstr, string $errfile = null, int $errline = null, string $errcontext = null): void |
64
|
|
|
{ |
65
|
|
|
newrelic_notice_error($errno, $errstr, $errfile, $errline, $errcontext); |
66
|
|
|
} |
67
|
|
|
|
68
|
|
|
public function noticeThrowable(\Throwable $e, string $message = null): void |
69
|
|
|
{ |
70
|
|
|
newrelic_notice_error($message ?: $e->getMessage(), $e); |
71
|
|
|
} |
72
|
|
|
|
73
|
|
|
public function enableBackgroundJob(): void |
74
|
|
|
{ |
75
|
|
|
newrelic_background_job(true); |
76
|
|
|
} |
77
|
|
|
|
78
|
|
|
public function disableBackgroundJob(): void |
79
|
|
|
{ |
80
|
|
|
newrelic_background_job(false); |
81
|
|
|
} |
82
|
|
|
|
83
|
|
|
public function endTransaction(bool $ignore = false): bool |
84
|
|
|
{ |
85
|
|
|
return newrelic_end_transaction($ignore); |
86
|
|
|
} |
87
|
|
|
|
88
|
|
|
public function startTransaction(string $name = null, string $license = null): bool |
89
|
|
|
{ |
90
|
|
|
if (null === $name) { |
91
|
|
|
$name = \ini_get('newrelic.appname'); |
92
|
|
|
} |
93
|
|
|
|
94
|
|
|
return newrelic_start_transaction($name, $license); |
95
|
|
|
} |
96
|
|
|
|
97
|
|
|
public function excludeFromApdex(): void |
98
|
|
|
{ |
99
|
|
|
newrelic_ignore_apdex(); |
100
|
|
|
} |
101
|
|
|
|
102
|
|
|
public function addCustomTracer(string $name): bool |
103
|
|
|
{ |
104
|
|
|
return newrelic_add_custom_tracer($name); |
105
|
|
|
} |
106
|
|
|
|
107
|
|
|
public function setCaptureParams(bool $enabled): void |
108
|
|
|
{ |
109
|
|
|
newrelic_capture_params($enabled); |
110
|
|
|
} |
111
|
|
|
|
112
|
|
|
public function stopTransactionTiming(): void |
113
|
|
|
{ |
114
|
|
|
newrelic_end_of_transaction(); |
115
|
|
|
} |
116
|
|
|
|
117
|
|
|
public function recordDatastoreSegment(callable $func, array $parameters) |
118
|
|
|
{ |
119
|
|
|
return newrelic_record_datastore_segment($func, $parameters); |
|
|
|
|
120
|
|
|
} |
121
|
|
|
|
122
|
|
|
public function setUserAttributes(string $userValue, string $accountValue, string $productValue): bool |
123
|
|
|
{ |
124
|
|
|
return newrelic_set_user_attributes($userValue, $accountValue, $productValue); |
125
|
|
|
} |
126
|
|
|
} |
127
|
|
|
|