-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathnew_relic_rpm.settings.inc
199 lines (171 loc) · 8.56 KB
/
new_relic_rpm.settings.inc
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
<?php
/**
* @file
* New Relic RPM Drupal setting form and callbacks.
*/
/**
* New Relic RPM settings form.
*/
function new_relic_rpm_settings($form, &$form_state) {
$form = array();
$form['new_relic_rpm_track_drush'] = array(
'#type' => 'select',
'#title' => t('Drush transactions'),
'#description' => t('How do you wish RPM to track drush commands?'),
'#options' => array(
'ignore' => t('Ignore completely'),
'bg' => t('Track as background tasks'),
'norm' => t('Track normally'),
),
'#default_value' => variable_get('new_relic_rpm_track_drush', 'norm'),
);
$form['new_relic_rpm_track_cron'] = array(
'#type' => 'select',
'#title' => t('Cron transactions'),
'#description' => t('How do you wish RPM to track cron tasks?'),
'#options' => array(
'ignore' => t('Ignore completely'),
'bg' => t('Track as background tasks'),
'norm' => t('Track normally'),
),
'#default_value' => variable_get('new_relic_rpm_track_cron', 'norm'),
);
$form['new_relic_rpm_module_deployment'] = array(
'#type' => 'select',
'#title' => t('Track module activation as deployment'),
'#description' => t('Turning this on will create a "deployment" on the New Relic RPM dashboard each time a module is enabled or disabled. This will help you track before and after statistics.'),
'#options' => array(
'1' => t('Enable'),
'0' => t('Disable'),
),
'#default_value' => variable_get('new_relic_rpm_module_deployment', 0),
);
$form['new_relic_rpm_add_manual_rum_instrumentation'] = array(
'#type' => 'checkbox',
'#title' => t('Manually add RUM instructions to header and footer'),
'#description' => t("When compress cached pages and cache pages for anonymous users is turned on, the New Relic Browser JavaScript is not inserted into the served pages for anonymous users. This is because Drupal's pages are compressed before they are stored in the cache (with gzip), so New Relic's PHP agent does not have a chance to parse any HTML, to add header and footer automatically. In this situation, manual instrumentation provides a better opportunity to capture data for anonymous users. See also @reference_url.", array('@reference_url' => 'https://docs.newrelic.com/docs/agents/php-agent/frameworks-libraries/drupal-specific-functionality#page-load-timing-rum')),
'#default_value' => variable_get('new_relic_rpm_add_manual_rum_instrumentation', FALSE),
);
$form['new_relic_rpm_ignore_urls'] = array(
'#type' => 'textarea',
'#wysiwyg' => FALSE,
'#title' => t('Ignore URLs'),
'#description' => t('Enter URLs you wish New Relic RPM to ignore. Enter one URL per line.'),
'#default_value' => variable_get('new_relic_rpm_ignore_urls', ''),
);
$form['new_relic_rpm_ignored_roles'] = array(
'#type' => 'select',
'#multiple' => TRUE,
'#title' => t('Ignored Roles'),
'#required' => FALSE,
'#options' => user_roles(),
'#description' => t('Select roles you wish New Relic RPM to ignore.'),
'#default_value' => variable_get('new_relic_rpm_ignored_roles', array()),
);
$form['new_relic_rpm_bg_urls'] = array(
'#type' => 'textarea',
'#wysiwyg' => FALSE,
'#title' => t('Background URLs'),
'#description' => t('Enter URLs you wish to have tracked as background tasks. Enter one URL per line.'),
'#default_value' => variable_get('new_relic_rpm_bg_urls', ''),
);
$form['new_relic_rpm_exclusive_urls'] = array(
'#type' => 'textarea',
'#wysiwyg' => FALSE,
'#title' => t('Exclusive URLs'),
'#description' => t('Enter URLs you wish to exclusively track. This is useful for debugging specific issues. **NOTE** Entering URLs here effectively marks all other URLs as ignored. Leave blank to disable.'),
'#default_value' => variable_get('new_relic_rpm_exclusive_urls', ''),
);
$form['new_relic_rpm_api_key'] = array(
'#type' => 'textfield',
'#title' => t('API Key'),
'#description' => t('Enter your New Relic API key if you wish to view reports and analysis within Drupal.'),
'#default_value' => variable_get('new_relic_rpm_api_key', ''),
);
$form['new_relic_rpm_watchdog_severities'] = array(
'#type' => 'select',
'#multiple' => TRUE,
'#title' => t('Forward watchdog messages'),
'#description' => t('Select which watchdog severities should be forwarded to New Relic API as errors.'),
'#options' => watchdog_severity_levels(),
'#default_value' => variable_get('new_relic_rpm_watchdog_severities', array()),
);
$form['new_relic_rpm_override_exception_handler'] = array(
'#type' => 'checkbox',
'#title' => t('Override exception handler'),
'#description' => t('Check to override default Drupal exception handler and to have exceptions passed to New Relic.'),
'#default_value' => variable_get('new_relic_rpm_override_exception_handler', FALSE),
);
$form['new_relic_rpm_use_menu_item_as_transaction'] = array(
'#type' => 'checkbox',
'#title' => t('Use the active menu item to name transactions'),
'#description' => t('If enabled the path of the active menu item on a request will be used as a transaction name in New Relic. This allows you to use fine granular key transaction tracking.'),
'#default_value' => variable_get('new_relic_rpm_use_menu_item_as_transaction', FALSE),
);
$form['new_relic_rpm_add_node_type_to_node_page_paths'] = array(
'#type' => 'checkbox',
'#title' => t('Put the node type in the paths for node pages'),
'#description' => t('If enabled the node type will be inserted into the path where the nid placeholder would be. This depends on using the menu item path for the name.'),
'#default_value' => variable_get('new_relic_rpm_add_node_type_to_node_page_paths', FALSE),
);
$form['new_relic_rpm_suppress_module_not_enabled_error_on_cli'] = array(
'#type' => 'checkbox',
'#title' => t('Suppress error message on CLI when New Relic extension is not present'),
'#description' => t('By default the module will show an error message when New Relic extension is not present. Suppress that message only when drupal invoked from command line interface, for example by drush.'),
'#default_value' => variable_get('new_relic_rpm_suppress_module_not_enabled_error_on_cli', FALSE),
);
$form['new_relic_rpm_suppress_module_not_enabled_error_always'] = array(
'#type' => 'checkbox',
'#title' => t('Always suppress error message when New Relic extension is not present'),
'#description' => t('By default the module will show an error message when New Relic extension is not present. Suppress that message always, for example on a local development environment.'),
'#default_value' => variable_get('new_relic_rpm_suppress_module_not_enabled_error_always', FALSE),
);
return system_settings_form($form);
}
/**
* Form callback for manually creating a deployment.
*/
function new_relic_rpm_deploy($form, &$form_state) {
$form = array();
$form['deploy_user'] = array(
'#type' => 'textfield',
'#title' => t('Deployer/Deployment Name'),
'#required' => TRUE,
'#description' => t('Enter the name for this deployment of your application. This will be the name shown in your list of deployments on the New Relic RPM website.'),
);
$form['deploy_description'] = array(
'#type' => 'textarea',
'#title' => t('Deployment Description'),
'#description' => t('Provide some notes and description regarding this deployment.'),
);
$form['deploy_changelog'] = array(
'#type' => 'textarea',
'#title' => t('Deployment Changelog'),
'#description' => t('Provide a specific changelog for this deployment.'),
);
$form['deploy_revision'] = array(
'#type' => 'textfield',
'#title' => t('Deployment Revision'),
'#description' => t('Add a revision number to this deployment.'),
);
$form['submit'] = array(
'#type' => 'submit',
'#value' => t('Create Deployment'),
);
return $form;
}
/**
* FormAPI submit callback for the manual deployment creation.
*/
function new_relic_rpm_deploy_submit($form, &$form_state) {
$deployments = _new_relic_rpm_deploy($form_state['values']['deploy_user'],
$form_state['values']['deploy_description'],
$form_state['values']['deploy_changelog'],
$form_state['values']['deploy_revision']);
if (strlen($deployments) > 20) {
drupal_set_message(t('New Relic RPM deployment created successfully'), 'status');
}
else {
drupal_set_message(t('New Relic RPM deployment failed to be created. Please ensure you have your account configured on the <a href="@settings">New Relic RPM Drupal admin page</a>.', array('@settings' => url('admin/config/development/new-relic-rpm'))), 'error');
}
}