|
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
|
|
|
/** |
|
17
|
|
|
* This interactor does never assume that the NewRelic extension is installed. It will check |
|
18
|
|
|
* for the existence of each method EVERY time. This is a good interactor to use when you want |
|
19
|
|
|
* to enable and disable the NewRelic extension without rebuilding your container. |
|
20
|
|
|
* |
|
21
|
|
|
* @author Tobias Nyholm <[email protected]> |
|
22
|
|
|
*/ |
|
23
|
|
|
class AdaptiveInteractor implements NewRelicInteractorInterface |
|
24
|
|
|
{ |
|
25
|
|
|
private $interactor; |
|
26
|
|
|
|
|
27
|
|
|
public function __construct(NewRelicInteractorInterface $real, NewRelicInteractorInterface $fake) |
|
28
|
|
|
{ |
|
29
|
|
|
$this->interactor = \extension_loaded('newrelic') ? $real : $fake; |
|
30
|
|
|
} |
|
31
|
|
|
|
|
32
|
|
|
public function setApplicationName(string $name, string $license = null, bool $xmit = false): bool |
|
33
|
|
|
{ |
|
34
|
|
|
return $this->interactor->setApplicationName($name, $license, $xmit); |
|
35
|
|
|
} |
|
36
|
|
|
|
|
37
|
|
|
public function setTransactionName(string $name): bool |
|
38
|
|
|
{ |
|
39
|
|
|
return $this->interactor->setTransactionName($name); |
|
40
|
|
|
} |
|
41
|
|
|
|
|
42
|
|
|
public function ignoreTransaction(): void |
|
43
|
|
|
{ |
|
44
|
|
|
$this->interactor->ignoreTransaction(); |
|
45
|
|
|
} |
|
46
|
|
|
|
|
47
|
|
|
public function addCustomEvent(string $name, array $attributes): void |
|
48
|
|
|
{ |
|
49
|
|
|
$this->interactor->addCustomEvent($name, $attributes); |
|
50
|
|
|
} |
|
51
|
|
|
|
|
52
|
|
|
public function addCustomMetric(string $name, float $value): bool |
|
53
|
|
|
{ |
|
54
|
|
|
return $this->interactor->addCustomMetric($name, $value); |
|
55
|
|
|
} |
|
56
|
|
|
|
|
57
|
|
|
public function addCustomParameter(string $name, $value): bool |
|
58
|
|
|
{ |
|
59
|
|
|
return $this->interactor->addCustomParameter($name, $value); |
|
60
|
|
|
} |
|
61
|
|
|
|
|
62
|
|
|
public function getBrowserTimingHeader(bool $includeTags = true): string |
|
63
|
|
|
{ |
|
64
|
|
|
return $this->interactor->getBrowserTimingHeader($includeTags); |
|
65
|
|
|
} |
|
66
|
|
|
|
|
67
|
|
|
public function getBrowserTimingFooter(bool $includeTags = true): string |
|
68
|
|
|
{ |
|
69
|
|
|
return $this->interactor->getBrowserTimingFooter($includeTags); |
|
70
|
|
|
} |
|
71
|
|
|
|
|
72
|
|
|
public function disableAutoRUM(): bool |
|
73
|
|
|
{ |
|
74
|
|
|
return $this->interactor->disableAutoRUM(); |
|
75
|
|
|
} |
|
76
|
|
|
|
|
77
|
|
|
public function noticeThrowable(\Throwable $e, string $message = null): void |
|
78
|
|
|
{ |
|
79
|
|
|
$this->interactor->noticeThrowable($e, $message); |
|
80
|
|
|
} |
|
81
|
|
|
|
|
82
|
|
|
public function noticeError( |
|
83
|
|
|
int $errno, |
|
84
|
|
|
string $errstr, |
|
85
|
|
|
string $errfile = null, |
|
86
|
|
|
int $errline = null, |
|
87
|
|
|
string $errcontext = null |
|
88
|
|
|
): void { |
|
89
|
|
|
$this->interactor->noticeError($errno, $errstr, $errfile, $errline, $errcontext); |
|
90
|
|
|
} |
|
91
|
|
|
|
|
92
|
|
|
public function enableBackgroundJob(): void |
|
93
|
|
|
{ |
|
94
|
|
|
$this->interactor->enableBackgroundJob(); |
|
95
|
|
|
} |
|
96
|
|
|
|
|
97
|
|
|
public function disableBackgroundJob(): void |
|
98
|
|
|
{ |
|
99
|
|
|
$this->interactor->disableBackgroundJob(); |
|
100
|
|
|
} |
|
101
|
|
|
|
|
102
|
|
|
public function startTransaction(string $name = null, string $license = null): bool |
|
103
|
|
|
{ |
|
104
|
|
|
return $this->interactor->startTransaction($name, $license); |
|
105
|
|
|
} |
|
106
|
|
|
|
|
107
|
|
|
public function endTransaction(bool $ignore = false): bool |
|
108
|
|
|
{ |
|
109
|
|
|
return $this->interactor->endTransaction($ignore); |
|
110
|
|
|
} |
|
111
|
|
|
|
|
112
|
|
|
public function excludeFromApdex(): void |
|
113
|
|
|
{ |
|
114
|
|
|
$this->interactor->excludeFromApdex(); |
|
115
|
|
|
} |
|
116
|
|
|
|
|
117
|
|
|
public function addCustomTracer(string $name): bool |
|
118
|
|
|
{ |
|
119
|
|
|
return $this->interactor->addCustomTracer($name); |
|
120
|
|
|
} |
|
121
|
|
|
|
|
122
|
|
|
public function setCaptureParams(bool $enabled): void |
|
123
|
|
|
{ |
|
124
|
|
|
$this->interactor->setCaptureParams($enabled); |
|
125
|
|
|
} |
|
126
|
|
|
|
|
127
|
|
|
public function stopTransactionTiming(): void |
|
128
|
|
|
{ |
|
129
|
|
|
$this->interactor->stopTransactionTiming(); |
|
130
|
|
|
} |
|
131
|
|
|
|
|
132
|
|
|
public function recordDatastoreSegment(callable $func, array $parameters) |
|
133
|
|
|
{ |
|
134
|
|
|
return $this->interactor->recordDatastoreSegment($func, $parameters); |
|
135
|
|
|
} |
|
136
|
|
|
|
|
137
|
|
|
public function setUserAttributes(string $userValue, string $accountValue, string $productValue): bool |
|
138
|
|
|
{ |
|
139
|
|
|
return $this->interactor->setUserAttributes($userValue, $accountValue, $productValue); |
|
140
|
|
|
} |
|
141
|
|
|
} |
|
142
|
|
|
|