@Override
	public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain)
			throws IOException, ServletException {
		if (!(request instanceof HttpServletRequest) || !(response instanceof HttpServletResponse)
				|| monitoringDisabled || !instanceEnabled) {
			// si ce n'est pas une requête http ou si le monitoring est désactivé, on fait suivre
			chain.doFilter(request, response);
			return;
		}
		final HttpServletRequest httpRequest = (HttpServletRequest) request;
		final HttpServletResponse httpResponse = (HttpServletResponse) response;

		if (httpRequest.getRequestURI().equals(getMonitoringUrl(httpRequest))) {
			doMonitoring(httpRequest, httpResponse);
			return;
		}
		if (!httpCounter.isDisplayed() || isRequestExcluded((HttpServletRequest) request)) {
			// si cette url est exclue ou si le counter http est désactivé, on ne monitore pas cette requête http
			chain.doFilter(request, response);
			return;
		}

		doFilter(chain, httpRequest, httpResponse);
	}
@Test
	public void testDoMonitoringWithRum() throws ServletException, IOException {
		try {
			setProperty(Parameter.RUM_ENABLED, Boolean.TRUE.toString());
			setUp();

			// simulate html page with RUM
			final HttpServletRequest requestForRum = createNiceMock(HttpServletRequest.class);
			expect(requestForRum.getHeader("accept")).andReturn("text/html");
			expect(requestForRum.getInputStream())
					.andReturn(createInputStreamForString("<html><body>test</body></html>"))
					.anyTimes();
			doFilter(requestForRum);

			// simulate call to monitoring?resource=boomerang.min.js
			monitoring(Collections.singletonMap(HttpParameter.RESOURCE, "boomerang.min.js"));
			monitoring(Collections.emptyMap());
			monitoring(Collections.singletonMap(HttpParameter.PART, HttpPart.RUM.getName()), false);

			// simulate call to monitoring?part=rum to register RUM data
			final Map<String, String> rumMap = new HashMap<>();
			rumMap.put(HttpParameter.PART.getName(), HttpPart.RUM.getName());
			rumMap.put("requestName", TEST_REQUEST + " GET");
			rumMap.put("serverTime", "100");
			rumMap.put("timeToFirstByte", "100");
			rumMap.put("domProcessing", "50");
			rumMap.put("pageRendering", "50");
			monitoring0(rumMap, false);

			// simulate call to monitoring for details of request with RUM data in html (period=jour : rumHits=0)
			final Map<HttpParameter, String> graphMap = new HashMap<>();
			graphMap.put(HttpParameter.PART, HttpPart.GRAPH.getName());
			final String requestId = new CounterRequest(TEST_REQUEST + " GET",
					Counter.HTTP_COUNTER_NAME).getId();
			graphMap.put(HttpParameter.GRAPH, requestId);
			monitoring(graphMap);

			// simulate call to monitoring for details of request with RUM data in html (period=tout  : rumHits>0)
			graphMap.put(HttpParameter.PERIOD, Period.TOUT.getCode());
			monitoring(graphMap);
			// simulate call to monitoring for details of request with RUM data in pdf
			graphMap.put(HttpParameter.FORMAT, "pdf");
			monitoring(graphMap);
		} finally {
			setProperty(Parameter.RUM_ENABLED, null);
		}
	}