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