Extension_NewRelic_Page_View_Apm.php
10.3 KB
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
<?php
namespace W3TC;
if ( !defined( 'W3TC' ) )
die();
?>
<p>
Jump to:
<a href="admin.php?page=w3tc_general"><?php _e( 'Main Menu', 'w3-total-cache' ); ?></a> |
<a href="admin.php?page=w3tc_extensions"><?php _e( 'Extensions', 'w3-total-cache' ); ?></a>
</p>
<p>
NewRelic extension is currently <?php
if ( $config->is_extension_active_frontend( 'newrelic' ) )
echo '<span class="w3tc-enabled">enabled</span>';
else
echo '<span class="w3tc-disabled">disabled</span>';
?>.
<p>
<form action="admin.php?page=w3tc_monitoring" method="post">
<div class="metabox-holder">
<?php Util_Ui::postbox_header( __( 'Application Settings', 'w3-total-cache' ), '', 'application' ); ?>
<?php if ( $application_settings ): ?>
<table class="form-table">
<tr>
<th>
<label>Application ID:</label>
</th>
<td>
<?php esc_attr_e( $application_settings['application-id'] )?>
</td>
</tr>
<tr>
<th>
<label>Application name:</label>
</th>
<td>
<?php esc_attr_e( $application_settings['name'] )?>
</td>
</tr>
<tr>
<th>
<label for="alerts-enabled">Alerts enabled:</label>
</th>
<td>
<input name="alerts-enabled]" type="hidden" value="false" />
<input id="alerts-enabled" name="application[alerts_enabled]"
type="checkbox" value="1" <?php checked( $application_settings['alerts-enabled'], 'true' ) ?> <?php Util_Ui::sealing_disabled( 'newrelic' ) ?>/>
</td>
</tr>
<tr>
<th>
<label for="app-apdex-t">Application ApDex Threshold:</label>
</th>
<td>
<input id="app-apdex-t" name="application[app_apdex_t]" type="text"
value="<?php echo esc_attr( $application_settings['app-apdex-t'] )?>"
<?php Util_Ui::sealing_disabled( 'newrelic' ) ?> />
</td>
</tr>
<tr>
<th>
<label for="rum-apdex-t"><acronym title="Real User Monitoring">RUM</acronym> ApDex Threshold:</label>
</th>
<td>
<input id="rum-apdex-t" name="application[rum_apdex_t]" type="text"
value="<?php echo esc_attr( $application_settings['rum-apdex-t'] )?>"
<?php Util_Ui::sealing_disabled( 'newrelic' ) ?>/>
</td>
</tr>
<tr>
<th>
<label for="rum-enabled"><acronym title="Real User Monitoring">RUM</acronym> enabled:</label>
</th>
<td>
<input name="application[rum_enabled]" type="hidden" value="false"
<?php Util_Ui::sealing_disabled( 'newrelic' ) ?> />
<input id="rum-enabled" name="application[rum_enabled]"
type="checkbox" value="1"
<?php checked( $application_settings['rum-enabled'], 'true' ) ?>
<?php Util_Ui::sealing_disabled( 'newrelic' ) ?>/>
</td>
</tr>
</table>
<p class="submit">
<?php echo Util_Ui::nonce_field( 'w3tc' ); ?>
<input type="submit" name="w3tc_save_new_relic"
class="w3tc-button-save button-primary"
<?php Util_Ui::sealing_disabled( 'newrelic' ) ?>
value="Save New Relic settings" />
</p>
<?php elseif ( empty( $application_settings ) ): ?>
<p><span class="description"><?php echo sprintf( __( 'Application settings could not be retrieved. New Relic may not be properly configured, <a href="%s">review the settings</a>.', 'w3-total-cache' ), network_admin_url( 'admin.php?page=w3tc_general#monitoring' ) ) ?></span></p>
<?php else: ?>
<p><?php _e( 'Application settings are only visible when New Relic is enabled', 'w3-total-cache', 'w3-total-cache' ) ?></p>
<?php endif; ?>
<?php Util_Ui::postbox_footer(); ?>
</form>
<form action="admin.php?page=w3tc_monitoring" method="post">
<?php Util_Ui::postbox_header( __( 'Dashboard Settings', 'w3-total-cache' ), '', 'dashboard' ); ?>
<table class="form-table">
<tr>
<th>
<label for="newrelic_cache_time"><?php
_e( 'Cache time:', 'w3-total-cache' )
?></label></th>
<td><input id="newrelic_cache_time" name="extension__newrelic__cache_time"
type="text" value="<?php echo esc_attr( $config->get_integer( array( 'newrelic', 'cache_time', 5 ) ) ) ?>"
<?php Util_Ui::sealing_disabled( 'newrelic' ) ?> />
<p><span class="description">
<?php _e( 'How many minutes data retrieved from New Relic should be stored. Minimum is 1 minute.', 'w3-total-cache' ) ?>
</span>
</p>
</td>
</tr>
</table>
<?php Util_Ui::button_config_save( 'extension_newrelic_dashboard' ); ?>
<?php Util_Ui::postbox_footer(); ?>
<?php Util_Ui::postbox_header( __( 'Behavior Settings', 'w3-total-cache' ), '', 'behavior' ); ?>
<table class="form-table">
<tr>
<th colspan="2">
<?php
Util_Ui::checkbox( '',
Util_Ui::config_key_to_http_name( array( 'newrelic', 'accept.logged_roles' ) ),
$config->get_boolean( array( 'newrelic', 'accept.logged_roles' ) ),
$config->is_sealed( 'newrelic' ) );
_e( 'Use <acronym title="Real User Monitoring">RUM</acronym> only for following user roles', 'w3-total-cache' )
?></label><br />
<span class="description"><?php
_e( 'Select user roles that <acronym title="Real User Monitoring">RUM</acronym> should be enabled for:', 'w3-total-cache' )
?></span>
<div id="newrelic_accept_roles">
<?php $saved_roles = $config->get_array( array( 'newrelic', 'accept.roles' ) ); ?>
<input type="hidden" name="newrelic___accept__roles" value="" /><br />
<?php foreach ( get_editable_roles() as $role_name => $role_data ) : ?>
<input type="checkbox" name="newrelic___accept__roles[]" value="<?php echo $role_name ?>"
<?php checked( in_array( $role_name, $saved_roles ) ) ?>
id="role_<?php echo $role_name ?>"
<?php Util_Ui::sealing_disabled( 'newrelic' ) ?> />
<label for="role_<?php echo $role_name ?>"><?php echo $role_data['name'] ?></label>
<?php endforeach; ?>
</div>
</th>
</tr>
<tr>
<th>
<label for="newrelic_include_rum"><?php
_e( 'Include <acronym title="Real User Monitoring">RUM</acronym> in compressed or cached pages:', 'w3-total-cache' )
?></label>
</th>
<td>
<input name="extension__newrelic__include_rum" type="hidden" value="0"
<?php Util_Ui::sealing_disabled( 'newrelic' ) ?> />
<input id="newrelic_include_rum" name="extension__newrelic__include_rum"
type="checkbox" value="1"
<?php checked( $config->get_boolean( array( 'newrelic', 'include_rum' ) ) ) ?>
<?php Util_Ui::sealing_disabled( 'newrelic' ) ?> />
<p><span class="description">
<?php _e( 'This enables inclusion of <acronym title="Real User Monitoring">RUM</acronym> when using Page Cache together with Browser Cache gzip or when using Page Cache with Disc: Enhanced', 'w3-total-cache' )?>
</span>
</p>
</td>
</tr>
<tr>
<th>
<label for="newrelic_use_php_function"><?php
_e( 'Use <acronym title=\"Hypertext Preprocessor\">PHP</acronym> function to set application name:', 'w3-total-cache' )
?></label></th>
<td>
<?php if ( Util_Environment::is_wpmu() ): ?>
<input id="newrelic_use_php_function" name="extension__newrelic__use_php_function" type="checkbox" value="1" checked="checked" disabled="disabled" />
<p><span class="description">
<?php _e( 'This is required when using New Relic on a network install to set the proper names for sites.', 'w3-total-cache' ) ?></span></p>
<?php else: ?>
<input name="extension__newrelic__use_php_function" type="hidden" value="0" />
<input id="newrelic_use_php_function" name="extension__newrelic__use_php_function" type="checkbox" value="1" <?php checked( $config->get_boolean( array( 'newrelic', 'use_php_function' ) ) ) ?>/>
<p><span class="description">
<?php _e( 'Enable this to dynamically set proper application name. (See New Relic <a href="https://newrelic.com/docs/php/per-directory-settings">Per-directory settings</a> for other methods.', 'w3-total-cache' ) ?></span>
</p>
<?php endif ?>
</td>
</tr>
<tr>
<th>
<label for="newrelic_enable_xmit"><?php
_e( 'Enable XMIT:', 'w3-total-cache' )
?></label>
</th>
<td><input name="" type="hidden" value="0" />
<input id="newrelic_enable_xmit" name="extension__newrelic__enable_xmit" type="checkbox" value="1" <?php checked( $config->get_boolean( array( 'newrelic', 'enable_xmit' ) ) ) ?> <?php Util_Ui::sealing_disabled( 'newrelic' ) ?>/>
<p><span class="description"><?php _e( sprintf( 'Enable this if you want to record the metric and transaction data (until the name is changed using PHP function), specify a value of true for this argument to make the agent send the transaction to the daemon. There is a slight performance impact as it takes a few milliseconds for the agent to dump its data. <em>From %s</em>',
'<a href="https://newrelic.com/docs/php/the-php-api">New Relic PHP API doc</a>' )
, 'w3-total-cache' )?></span></p>
</td>
</tr>
</table>
<?php Util_Ui::button_config_save( 'extension_newrelic_behaviour' ); ?>
<?php Util_Ui::postbox_footer(); ?>
</form>
</div>
<?php if ( $view_metric ):?>
<table>
<?php foreach ( $metric_names as $metric ):?>
<tr>
<th style="text-align: right"><strong><?php echo $metric->name ?></strong></th>
<td><?php echo implode( ', ', $metric->fields ) ?></td>
</tr>
<?php endforeach; ?>
</table>
<?php endif; ?>