Classes in this File | Line Coverage | Branch Coverage | Complexity | ||||
MonitorUtil |
|
| 4.666666666666667;4,667 |
1 | 0 | /** |
2 | * 2011, Digitalis Informatica. All rights reserved. Distribuicao e Gestao de Informatica, Lda. Estrada de Paco de Arcos | |
3 | * num.9 - Piso -1 2780-666 Paco de Arcos Telefone: (351) 21 4408990 Fax: (351) 21 4408999 http://www.digitalis.pt | |
4 | */ | |
5 | ||
6 | package pt.digitalis.dif.utils.monitor; | |
7 | ||
8 | import pt.digitalis.dif.startup.DIFGeneralConfigurationParameters; | |
9 | import pt.digitalis.dif.startup.DIFStartupConfiguration; | |
10 | ||
11 | import com.newrelic.api.agent.NewRelic; | |
12 | ||
13 | /** | |
14 | * Serves as an abstraction to the monitoring agent in use. Presently New Relic. <br/> | |
15 | * All these calls will only be triggers when in developer or testing mode ({@link DIFStartupConfiguration}). * | |
16 | * | |
17 | * @see "http://http://newrelic.com/" | |
18 | * @author Pedro Viegas <a href="mailto:pviegas@digitalis.pt">pviegas@digitalis.pt</a><br/> | |
19 | * @created 17 de Ago de 2012 | |
20 | */ | |
21 | 0 | public class MonitorUtil { |
22 | ||
23 | /** | |
24 | * Adds a parameter to the current process for the monitoring agent | |
25 | * | |
26 | * @param key | |
27 | * the parameter key name | |
28 | * @param value | |
29 | * the parameter value | |
30 | */ | |
31 | static public void addParameter(String key, String value) | |
32 | { | |
33 | 0 | if (DIFStartupConfiguration.getDeveloperMode() || DIFStartupConfiguration.getTestingMode() |
34 | 0 | || DIFGeneralConfigurationParameters.getInstance().getMonitorizationEnabled()) |
35 | 0 | NewRelic.addCustomParameter(key, value); |
36 | 0 | } |
37 | ||
38 | /** | |
39 | * @return the JavaScript contribution for the page footer | |
40 | */ | |
41 | static public String getBrowserTimingFooter() | |
42 | { | |
43 | 0 | if (DIFStartupConfiguration.getDeveloperMode() || DIFStartupConfiguration.getTestingMode() |
44 | 0 | || DIFGeneralConfigurationParameters.getInstance().getMonitorizationEnabled()) |
45 | 0 | return NewRelic.getBrowserTimingFooter(); |
46 | else | |
47 | 0 | return ""; |
48 | } | |
49 | ||
50 | /** | |
51 | * @return the JavaScript contribution for the page header | |
52 | */ | |
53 | static public String getBrowserTimingHeader() | |
54 | { | |
55 | 0 | if (DIFStartupConfiguration.getDeveloperMode() || DIFStartupConfiguration.getTestingMode() |
56 | 0 | || DIFGeneralConfigurationParameters.getInstance().getMonitorizationEnabled()) |
57 | 0 | return NewRelic.getBrowserTimingHeader(); |
58 | else | |
59 | 0 | return ""; |
60 | } | |
61 | } |