forked from Netflix/Hystrix
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
example webapp showing how to use hystrix-request-servlet and hystrix…
…-metrics-event-stream
- Loading branch information
1 parent
e5af4cc
commit 67440a4
Showing
6 changed files
with
158 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
apply plugin: 'java' | ||
apply plugin: 'war' | ||
apply plugin: 'eclipse-wtp' | ||
|
||
dependencies { | ||
compile project(':hystrix-core') | ||
compile project(':hystrix-examples') | ||
compile project(':hystrix-contrib:hystrix-request-servlet') | ||
compile project(':hystrix-contrib:hystrix-metrics-event-stream') | ||
} |
6 changes: 6 additions & 0 deletions
6
hystrix-examples-webapp/src/main/webapp/WEB-INF/classes/log4j.properties
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
log4j.rootLogger=INFO, FILE | ||
log4j.appender.FILE=org.apache.log4j.ConsoleAppender | ||
log4j.appender.FILE.layout=org.apache.log4j.PatternLayout | ||
log4j.appender.FILE.layout.ConversionPattern=%d{yyyy-MM-dd HH:mm:ss} %p %C:%L [%C{1}] [%M]: %m%n | ||
|
||
log4j.appender.FILE.httpclient=ERROR |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xmlns="http://java.sun.com/xml/ns/javaee" xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" | ||
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" | ||
version="2.5"> | ||
|
||
<filter> | ||
<display-name>HystrixRequestContextServletFilter</display-name> | ||
<filter-name>HystrixRequestContextServletFilter</filter-name> | ||
<filter-class>com.netflix.hystrix.contrib.requestservlet.HystrixRequestContextServletFilter</filter-class> | ||
</filter> | ||
<filter-mapping> | ||
<filter-name>HystrixRequestContextServletFilter</filter-name> | ||
<url-pattern>/*</url-pattern> | ||
</filter-mapping> | ||
|
||
<filter> | ||
<display-name>HystrixRequestLogViaResponseHeaderServletFilter</display-name> | ||
<filter-name>HystrixRequestLogViaResponseHeaderServletFilter</filter-name> | ||
<filter-class>com.netflix.hystrix.contrib.requestservlet.HystrixRequestLogViaResponseHeaderServletFilter</filter-class> | ||
</filter> | ||
<filter-mapping> | ||
<filter-name>HystrixRequestLogViaResponseHeaderServletFilter</filter-name> | ||
<url-pattern>/*</url-pattern> | ||
</filter-mapping> | ||
|
||
<servlet> | ||
<description></description> | ||
<display-name>HystrixMetricsStreamServlet</display-name> | ||
<servlet-name>HystrixMetricsStreamServlet</servlet-name> | ||
<servlet-class>com.netflix.hystrix.contrib.metrics.eventstream.HystrixMetricsStreamServlet</servlet-class> | ||
</servlet> | ||
|
||
<servlet-mapping> | ||
<servlet-name>HystrixMetricsStreamServlet</servlet-name> | ||
<url-pattern>/hystrix.stream</url-pattern> | ||
</servlet-mapping> | ||
|
||
</web-app> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
<%@ page language="java" contentType="text/html; charset=ISO-8859-1" | ||
pageEncoding="ISO-8859-1"%> | ||
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> | ||
<html> | ||
<head> | ||
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"> | ||
<title>HystrixCommandDemo Execution and HystrixRequestLog [hystrix-examples-webapp]</title> | ||
</head> | ||
<body> | ||
<div style="width:800px;margin:0 auto;"> | ||
|
||
<center><h2>HystrixCommandDemo Execution and HystrixRequestLog<br>[hystrix-examples-webapp]</h2></center> | ||
<center><img width="264" height="233" src="https://raw.github.com/wiki/Netflix/Hystrix/images/hystrix-logo.png"></center> | ||
<p> | ||
The following is the output of <i>HystrixRequestLog.getCurrentRequest().getExecutedCommandsAsString()</i> after simulating the execution of several commands. | ||
</p> | ||
<p> | ||
The simulation code is in com.netflix.hystrix.examples.demo.HystrixCommandDemo. | ||
</p> | ||
<%@ page import="com.netflix.hystrix.examples.demo.HystrixCommandDemo, com.netflix.hystrix.HystrixRequestLog" %> | ||
<% | ||
new HystrixCommandDemo().executeSimulatedUserRequestForOrderConfirmationAndCreditCardPayment(); | ||
%> | ||
<hr> | ||
<b><%= HystrixRequestLog.getCurrentRequest().getExecutedCommandsAsString() %></b> | ||
<hr> | ||
<p> | ||
This request log is also part of the HTTP response header with key name "X-HystrixLog". | ||
</p> | ||
<p> | ||
You can view the realtime stream at <a href="./hystrix.stream">./hystrix.stream</a>. | ||
</p> | ||
<p> | ||
To see the realtime stream change over time execute the following (with correct hostname, port etc) to keep accessing the webapp while watching the stream and you will see the metrics change: | ||
</p> | ||
<pre> | ||
while true ; do curl "http://localhost:8080/hystrix-examples-webapp"; done | ||
</pre> | ||
<p> | ||
The configuration of Hystrix for this functionality is done in web.xml as follows: | ||
</p> | ||
<pre> | ||
<filter> | ||
<display-name>HystrixRequestContextServletFilter</display-name> | ||
<filter-name>HystrixRequestContextServletFilter</filter-name> | ||
<filter-class>com.netflix.hystrix.contrib.requestservlet.HystrixRequestContextServletFilter</filter-class> | ||
</filter> | ||
<filter-mapping> | ||
<filter-name>HystrixRequestContextServletFilter</filter-name> | ||
<url-pattern>/*</url-pattern> | ||
</filter-mapping> | ||
|
||
<filter> | ||
<display-name>HystrixRequestLogViaResponseHeaderServletFilter</display-name> | ||
<filter-name>HystrixRequestLogViaResponseHeaderServletFilter</filter-name> | ||
<filter-class>com.netflix.hystrix.contrib.requestservlet.HystrixRequestLogViaResponseHeaderServletFilter</filter-class> | ||
</filter> | ||
<filter-mapping> | ||
<filter-name>HystrixRequestLogViaResponseHeaderServletFilter</filter-name> | ||
<url-pattern>/*</url-pattern> | ||
</filter-mapping> | ||
|
||
<servlet> | ||
<description></description> | ||
<display-name>HystrixMetricsStreamServlet</display-name> | ||
<servlet-name>HystrixMetricsStreamServlet</servlet-name> | ||
<servlet-class>com.netflix.hystrix.contrib.metrics.eventstream.HystrixMetricsStreamServlet</servlet-class> | ||
</servlet> | ||
|
||
<servlet-mapping> | ||
<servlet-name>HystrixMetricsStreamServlet</servlet-name> | ||
<url-pattern>/hystrix.stream</url-pattern> | ||
</servlet-mapping> | ||
</pre> | ||
|
||
</div> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters