10
10
use Magento \ApplicationPerformanceMonitor \Profiler \Metric ;
11
11
use Magento \ApplicationPerformanceMonitor \Profiler \OutputInterface ;
12
12
use Magento \Framework \App \DeploymentConfig ;
13
+ use Magento \NewRelicReporting \Model \NewRelicWrapper ;
13
14
14
15
/**
15
16
* Outputs the performance metrics and other information to New Relic
@@ -19,10 +20,7 @@ class NewRelicOutput implements OutputInterface
19
20
public const CONFIG_ENABLE_KEY = 'application/performance_monitor/newrelic_output_enable ' ;
20
21
public const CONFIG_VERBOSE_KEY = 'application/performance_monitor/newrelic_output_verbose ' ;
21
22
22
- /**
23
- * @param DeploymentConfig $deploymentConfig
24
- */
25
- public function __construct (private DeploymentConfig $ deploymentConfig )
23
+ public function __construct (private DeploymentConfig $ deploymentConfig , private NewRelicWrapper $ newRelicWrapper )
26
24
{
27
25
}
28
26
@@ -31,7 +29,7 @@ public function __construct(private DeploymentConfig $deploymentConfig)
31
29
*/
32
30
public function isEnabled (): bool
33
31
{
34
- if (!extension_loaded ( ' newrelic ' )) {
32
+ if (!$ this -> newRelicWrapper -> isExtensionInstalled ( )) {
35
33
return false ;
36
34
}
37
35
return match ($ this ->deploymentConfig ->get (static ::CONFIG_ENABLE_KEY )) {
@@ -49,14 +47,14 @@ public function doOutput(array $metrics, array $information)
49
47
return ;
50
48
}
51
49
foreach ($ information as $ key => $ value ) {
52
- newrelic_add_custom_parameter ($ key , $ value );
50
+ $ this -> newRelicWrapper -> addCustomParameter ($ key , $ value );
53
51
}
54
52
$ verbose = $ this ->isVerbose ();
55
53
foreach ($ metrics as $ metric ) {
56
54
if (!$ verbose && $ metric ->isVerbose ()) {
57
55
continue ;
58
56
}
59
- newrelic_add_custom_parameter ($ metric ->getName (), $ metric ->getValue ());
57
+ $ this -> newRelicWrapper -> addCustomParameter ($ metric ->getName (), $ metric ->getValue ());
60
58
}
61
59
}
62
60
0 commit comments