diff --git a/multi/multi__router_and_filter_zuul.html b/multi/multi__router_and_filter_zuul.html index 33e6581d3..03736ee09 100644 --- a/multi/multi__router_and_filter_zuul.html +++ b/multi/multi__router_and_filter_zuul.html @@ -437,7 +437,10 @@ type ZuulFallbackProvider and have the

9.13 Rewriting Location header

If Zuul is fronting a web application then there may be a need to re-write the Location header when the web application redirects through a http status code of 3XX, otherwise the browser will end up redirecting to the web application’s url instead of the Zuul url. +}

9.13 Zuul Timeouts

If you want to configure the socket timeouts and read timeouts for requests proxied through +Zuul there are two options based on your configuration.

If Zuul is using service discovery than you need to configure these timeouts via Ribbon properties, +ribbon.ReadTimeout and ribbon.SocketTimeout.

If you have configured Zuul routes by specifying URLs than you will need to use +zuul.host.connect-timeout-millis and zuul.host.socket-timeout-millis.

9.14 Rewriting Location header

If Zuul is fronting a web application then there may be a need to re-write the Location header when the web application redirects through a http status code of 3XX, otherwise the browser will end up redirecting to the web application’s url instead of the Zuul url. A LocationRewriteFilter Zuul filter can be configured to re-write the Location header to the Zuul’s url, it also adds back the stripped global and route specific prefixes. The filter can be added the following way via a Spring Configuration file:

import org.springframework.cloud.netflix.zuul.filters.post.LocationRewriteFilter;
 ...
 
@@ -448,7 +451,7 @@ A LocationRewriteFilter Zuul filter can  be configu
     public LocationRewriteFilter locationRewriteFilter() {
         return new LocationRewriteFilter();
     }
-}
[Warning]Warning

Use this filter with caution though, the filter acts on the Location header of ALL 3XX response codes which may not be appropriate in all scenarios, say if the user is redirecting to an external URL.

9.14 Zuul Developer Guide

For a general overview of how Zuul works, please see the Zuul Wiki.

9.14.1 The Zuul Servlet

Zuul is implemented as a Servlet. For the general cases, Zuul is embedded into the Spring Dispatch mechanism. This allows Spring MVC to be in control of the routing. In this case, Zuul is configured to buffer requests. If there is a need to go through Zuul without buffering requests (e.g. for large file uploads), the Servlet is also installed outside of the Spring Dispatcher. By default, this is located at /zuul. This path can be changed with the zuul.servlet-path property.

9.14.2 Zuul RequestContext

To pass information between filters, Zuul uses a RequestContext. Its data is held in a ThreadLocal specific to each request. Information about where to route requests, errors and the actual HttpServletRequest and HttpServletResponse are stored there. The RequestContext extends ConcurrentHashMap, so anything can be stored in the context. FilterConstants contains the keys that are used by the filters installed by Spring Cloud Netflix (more on these later).

9.14.3 @EnableZuulProxy vs. @EnableZuulServer

Spring Cloud Netflix installs a number of filters based on which annotation was used to enable Zuul. @EnableZuulProxy is a superset of @EnableZuulServer. In other words, @EnableZuulProxy contains all filters installed by @EnableZuulServer. The additional filters in the "proxy" enable routing functionality. If you want a "blank" Zuul, you should use @EnableZuulServer.

9.14.4 @EnableZuulServer Filters

Creates a SimpleRouteLocator that loads route definitions from Spring Boot configuration files.

The following filters are installed (as normal Spring Beans):

Pre filters:

  • ServletDetectionFilter: Detects if the request is through the Spring Dispatcher. Sets boolean with key FilterConstants.IS_DISPATCHER_SERVLET_REQUEST_KEY.
  • FormBodyWrapperFilter: Parses form data and reencodes it for downstream requests.
  • DebugFilter: if the debug request parameter is set, this filter sets RequestContext.setDebugRouting() and RequestContext.setDebugRequest() to true.

Route filters:

  • SendForwardFilter: This filter forwards requests using the Servlet RequestDispatcher. The forwarding location is stored in the RequestContext attribute FilterConstants.FORWARD_TO_KEY. This is useful for forwarding to endpoints in the current application.

Post filters:

  • SendResponseFilter: Writes responses from proxied requests to the current response.

Error filters:

  • SendErrorFilter: Forwards to /error (by default) if RequestContext.getThrowable() is not null. The default forwarding path (/error) can be changed by setting the error.path property.

9.14.5 @EnableZuulProxy Filters

Creates a DiscoveryClientRouteLocator that loads route definitions from a DiscoveryClient (like Eureka), as well as from properties. A route is created for each serviceId from the DiscoveryClient. As new services are added, the routes will be refreshed.

In addition to the filters described above, the following filters are installed (as normal Spring Beans):

Pre filters:

  • PreDecorationFilter: This filter determines where and how to route based on the supplied RouteLocator. It also sets various proxy-related headers for downstream requests.

Route filters:

  • RibbonRoutingFilter: This filter uses Ribbon, Hystrix and pluggable HTTP clients to send requests. Service ids are found in the RequestContext attribute FilterConstants.SERVICE_ID_KEY. This filter can use different HTTP clients. They are:

    • Apache HttpClient. This is the default client.
    • Squareup OkHttpClient v3. This is enabled by having the com.squareup.okhttp3:okhttp library on the classpath and setting ribbon.okhttp.enabled=true.
    • Netflix Ribbon HTTP client. This is enabled by setting ribbon.restclient.enabled=true. This client has limitations, such as it doesn’t support the PATCH method, but also has built-in retry.
  • SimpleHostRoutingFilter: This filter sends requests to predetermined URLs via an Apache HttpClient. URLs are found in RequestContext.getRouteHost().

9.14.6 Custom Zuul Filter examples

Most of the following "How to Write" examples below are included Sample Zuul Filters project. There are also examples of manipulating the request or response body in that repository.

9.14.7 How to Write a Pre Filter

Pre filters are used to set up data in the RequestContext for use in filters downstream. The main use case is to set information required for route filters.

public class QueryParamPreFilter extends ZuulFilter {
+}
[Warning]Warning

Use this filter with caution though, the filter acts on the Location header of ALL 3XX response codes which may not be appropriate in all scenarios, say if the user is redirecting to an external URL.

9.15 Zuul Developer Guide

For a general overview of how Zuul works, please see the Zuul Wiki.

9.15.1 The Zuul Servlet

Zuul is implemented as a Servlet. For the general cases, Zuul is embedded into the Spring Dispatch mechanism. This allows Spring MVC to be in control of the routing. In this case, Zuul is configured to buffer requests. If there is a need to go through Zuul without buffering requests (e.g. for large file uploads), the Servlet is also installed outside of the Spring Dispatcher. By default, this is located at /zuul. This path can be changed with the zuul.servlet-path property.

9.15.2 Zuul RequestContext

To pass information between filters, Zuul uses a RequestContext. Its data is held in a ThreadLocal specific to each request. Information about where to route requests, errors and the actual HttpServletRequest and HttpServletResponse are stored there. The RequestContext extends ConcurrentHashMap, so anything can be stored in the context. FilterConstants contains the keys that are used by the filters installed by Spring Cloud Netflix (more on these later).

9.15.3 @EnableZuulProxy vs. @EnableZuulServer

Spring Cloud Netflix installs a number of filters based on which annotation was used to enable Zuul. @EnableZuulProxy is a superset of @EnableZuulServer. In other words, @EnableZuulProxy contains all filters installed by @EnableZuulServer. The additional filters in the "proxy" enable routing functionality. If you want a "blank" Zuul, you should use @EnableZuulServer.

9.15.4 @EnableZuulServer Filters

Creates a SimpleRouteLocator that loads route definitions from Spring Boot configuration files.

The following filters are installed (as normal Spring Beans):

Pre filters:

  • ServletDetectionFilter: Detects if the request is through the Spring Dispatcher. Sets boolean with key FilterConstants.IS_DISPATCHER_SERVLET_REQUEST_KEY.
  • FormBodyWrapperFilter: Parses form data and reencodes it for downstream requests.
  • DebugFilter: if the debug request parameter is set, this filter sets RequestContext.setDebugRouting() and RequestContext.setDebugRequest() to true.

Route filters:

  • SendForwardFilter: This filter forwards requests using the Servlet RequestDispatcher. The forwarding location is stored in the RequestContext attribute FilterConstants.FORWARD_TO_KEY. This is useful for forwarding to endpoints in the current application.

Post filters:

  • SendResponseFilter: Writes responses from proxied requests to the current response.

Error filters:

  • SendErrorFilter: Forwards to /error (by default) if RequestContext.getThrowable() is not null. The default forwarding path (/error) can be changed by setting the error.path property.

9.15.5 @EnableZuulProxy Filters

Creates a DiscoveryClientRouteLocator that loads route definitions from a DiscoveryClient (like Eureka), as well as from properties. A route is created for each serviceId from the DiscoveryClient. As new services are added, the routes will be refreshed.

In addition to the filters described above, the following filters are installed (as normal Spring Beans):

Pre filters:

  • PreDecorationFilter: This filter determines where and how to route based on the supplied RouteLocator. It also sets various proxy-related headers for downstream requests.

Route filters:

  • RibbonRoutingFilter: This filter uses Ribbon, Hystrix and pluggable HTTP clients to send requests. Service ids are found in the RequestContext attribute FilterConstants.SERVICE_ID_KEY. This filter can use different HTTP clients. They are:

    • Apache HttpClient. This is the default client.
    • Squareup OkHttpClient v3. This is enabled by having the com.squareup.okhttp3:okhttp library on the classpath and setting ribbon.okhttp.enabled=true.
    • Netflix Ribbon HTTP client. This is enabled by setting ribbon.restclient.enabled=true. This client has limitations, such as it doesn’t support the PATCH method, but also has built-in retry.
  • SimpleHostRoutingFilter: This filter sends requests to predetermined URLs via an Apache HttpClient. URLs are found in RequestContext.getRouteHost().

9.15.6 Custom Zuul Filter examples

Most of the following "How to Write" examples below are included Sample Zuul Filters project. There are also examples of manipulating the request or response body in that repository.

9.15.7 How to Write a Pre Filter

Pre filters are used to set up data in the RequestContext for use in filters downstream. The main use case is to set information required for route filters.

public class QueryParamPreFilter extends ZuulFilter {
 	@Override
 	public int filterOrder() {
 		return PRE_DECORATION_FILTER_ORDER - 1; // run before PreDecoration
@@ -475,7 +478,7 @@ A LocationRewriteFilter Zuul filter can  be configu
     	}
         return null;
     }
-}

The filter above populates SERVICE_ID_KEY from the foo request parameter. In reality, it’s not a good idea to do that kind of direct mapping, but the service id should be looked up from the value of foo instead.

Now that SERVICE_ID_KEY is populated, PreDecorationFilter won’t run and RibbonRoutingFilter will. If you wanted to route to a full URL instead, call ctx.setRouteHost(url) instead.

To modify the path that routing filters will forward to, set the REQUEST_URI_KEY.

9.14.8 How to Write a Route Filter

Route filters are run after pre filters and are used to make requests to other services. Much of the work here is to translate request and response data to and from the client required model.

public class OkHttpRoutingFilter extends ZuulFilter {
+}

The filter above populates SERVICE_ID_KEY from the foo request parameter. In reality, it’s not a good idea to do that kind of direct mapping, but the service id should be looked up from the value of foo instead.

Now that SERVICE_ID_KEY is populated, PreDecorationFilter won’t run and RibbonRoutingFilter will. If you wanted to route to a full URL instead, call ctx.setRouteHost(url) instead.

To modify the path that routing filters will forward to, set the REQUEST_URI_KEY.

9.15.8 How to Write a Route Filter

Route filters are run after pre filters and are used to make requests to other services. Much of the work here is to translate request and response data to and from the client required model.

public class OkHttpRoutingFilter extends ZuulFilter {
 	@Autowired
 	private ProxyRequestHelper helper;
 
@@ -549,7 +552,7 @@ A LocationRewriteFilter Zuul filter can  be configu
 		context.setRouteHost(null); // prevent SimpleHostRoutingFilter from running
 		return null;
     }
-}

The above filter translates Servlet request information into OkHttp3 request information, executes an HTTP request, then translates OkHttp3 reponse information to the Servlet response. WARNING: this filter might have bugs and not function correctly.

9.14.9 How to Write a Post Filter

Post filters typically manipulate the response. In the filter below, we add a random UUID as the X-Foo header. Other manipulations, such as transforming the response body, are much more complex and compute-intensive.

public class AddResponseHeaderFilter extends ZuulFilter {
+}

The above filter translates Servlet request information into OkHttp3 request information, executes an HTTP request, then translates OkHttp3 reponse information to the Servlet response. WARNING: this filter might have bugs and not function correctly.

9.15.9 How to Write a Post Filter

Post filters typically manipulate the response. In the filter below, we add a random UUID as the X-Foo header. Other manipulations, such as transforming the response body, are much more complex and compute-intensive.

public class AddResponseHeaderFilter extends ZuulFilter {
 	@Override
 	public String filterType() {
 		return POST_TYPE;
@@ -572,7 +575,7 @@ A LocationRewriteFilter Zuul filter can  be configu
 		servletResponse.addHeader("X-Foo", UUID.randomUUID().toString());
 		return null;
 	}
-}

9.14.10 How Zuul Errors Work

If an exception is thrown during any portion of the Zuul filter lifecycle, the error filters are executed. The SendErrorFilter is only run if RequestContext.getThrowable() is not null. It then sets specific javax.servlet.error.* attributes in the request and forwards the request to the Spring Boot error page.

9.14.11 Zuul Eager Application Context Loading

Zuul internally uses Ribbon for calling the remote url’s and Ribbon clients are by default lazily loaded up by Spring Cloud on first call. +}

9.15.10 How Zuul Errors Work

If an exception is thrown during any portion of the Zuul filter lifecycle, the error filters are executed. The SendErrorFilter is only run if RequestContext.getThrowable() is not null. It then sets specific javax.servlet.error.* attributes in the request and forwards the request to the Spring Boot error page.

9.15.11 Zuul Eager Application Context Loading

Zuul internally uses Ribbon for calling the remote url’s and Ribbon clients are by default lazily loaded up by Spring Cloud on first call. This behavior can be changed for Zuul using the following configuration and will result in the child Ribbon related Application contexts being eagerly loaded up at application startup time.

application.yml. 

zuul:
   ribbon:
diff --git a/multi/multi_netflix-metrics.html b/multi/multi_netflix-metrics.html
index 236315d41..da8db9b3f 100644
--- a/multi/multi_netflix-metrics.html
+++ b/multi/multi_netflix-metrics.html
@@ -24,7 +24,7 @@ restTemplate.getForObject(</dependency>

In Spectator parlance, a meter is a named, typed, and tagged configuration and a metric represents the value of a given meter at a point in time. Spectator meters are created and controlled by a registry, which currently has several different implementations. Spectator provides 4 meter types: counter, timer, gauge, and distribution summary.

Spring Cloud Spectator integration configures an injectable com.netflix.spectator.api.Registry instance for you. Specifically, it configures a ServoRegistry instance in order to unify the collection of REST metrics and the exporting of metrics to the Atlas backend under a single Servo API. Practically, this means that your code may use a mixture of Servo monitors and Spectator meters and both will be scooped up by Spring Boot Actuator MetricReader instances and both will be shipped to the Atlas backend.

12.3.1 Spectator Counter

A counter is used to measure the rate at which some event is occurring.

// create a counter with a name and a set of tags
 Counter counter = registry.counter("counterName", "tagKey1", "tagValue1", ...);
 counter.increment(); // increment when an event occurs
-counter.increment(10); // increment by a discrete amount

The counter records a single time-normalized statistic.

12.3.2 Spectator Timer

A timer is used to measure how long some event is taking. Spring Cloud automatically records timers for Spring MVC requests and conditionally RestTemplate requests, which can later be used to create dashboards for request related metrics like latency:

Figure 12.1. Request Latency

RequestLatency

// create a timer with a name and a set of tags
+counter.increment(10); // increment by a discrete amount

The counter records a single time-normalized statistic.

12.3.2 Spectator Timer

A timer is used to measure how long some event is taking. Spring Cloud automatically records timers for Spring MVC requests and conditionally RestTemplate requests, which can later be used to create dashboards for request related metrics like latency:

Figure 12.1. Request Latency

RequestLatency

// create a timer with a name and a set of tags
 Timer timer = registry.timer("timerName", "tagKey1", "tagValue1", ...);
 
 // execute an operation and time it at the same time
diff --git a/multi/multi_spring-cloud-netflix.html b/multi/multi_spring-cloud-netflix.html
index 472b68af4..9d05b351a 100644
--- a/multi/multi_spring-cloud-netflix.html
+++ b/multi/multi_spring-cloud-netflix.html
@@ -1,3 +1,3 @@
 
       
-   Spring Cloud Netflix

Spring Cloud Netflix


Table of Contents

1. Service Discovery: Eureka Clients
1.1. How to Include Eureka Client
1.2. Registering with Eureka
1.3. Authenticating with the Eureka Server
1.4. Status Page and Health Indicator
1.5. Registering a Secure Application
1.6. Eureka’s Health Checks
1.7. Eureka Metadata for Instances and Clients
1.7.1. Using Eureka on Cloudfoundry
1.7.2. Using Eureka on AWS
1.7.3. Changing the Eureka Instance ID
1.8. Using the EurekaClient
1.8.1. EurekaClient without Jersey
1.9. Alternatives to the native Netflix EurekaClient
1.10. Why is it so Slow to Register a Service?
1.11. Zones
2. Service Discovery: Eureka Server
2.1. How to Include Eureka Server
2.2. How to Run a Eureka Server
2.3. High Availability, Zones and Regions
2.4. Standalone Mode
2.5. Peer Awareness
2.6. Prefer IP Address
3. Circuit Breaker: Hystrix Clients
3.1. How to Include Hystrix
3.2. Propagating the Security Context or using Spring Scopes
3.3. Health Indicator
3.4. Hystrix Metrics Stream
4. Circuit Breaker: Hystrix Dashboard
5. Hystrix Timeouts And Ribbon Clients
5.1. How to Include Hystrix Dashboard
5.2. Turbine
5.3. Turbine Stream
6. Client Side Load Balancer: Ribbon
6.1. How to Include Ribbon
6.2. Customizing the Ribbon Client
6.3. Customizing default for all Ribbon Clients
6.4. Customizing the Ribbon Client using properties
6.5. Using Ribbon with Eureka
6.6. Example: How to Use Ribbon Without Eureka
6.7. Example: Disable Eureka use in Ribbon
6.8. Using the Ribbon API Directly
6.9. Caching of Ribbon Configuration
6.10. How to Configure Hystrix thread pools
7. Declarative REST Client: Feign
7.1. How to Include Feign
7.2. Overriding Feign Defaults
7.3. Creating Feign Clients Manually
7.4. Feign Hystrix Support
7.5. Feign Hystrix Fallbacks
7.6. Feign and @Primary
7.7. Feign Inheritance Support
7.8. Feign request/response compression
7.9. Feign logging
8. External Configuration: Archaius
9. Router and Filter: Zuul
9.1. How to Include Zuul
9.2. Embedded Zuul Reverse Proxy
9.3. Zuul Http Client
9.4. Cookies and Sensitive Headers
9.5. Ignored Headers
9.6. Management Endpoints
9.6.1. Routes Endpoint
9.6.2. Filters Endpoint
9.7. Strangulation Patterns and Local Forwards
9.8. Uploading Files through Zuul
9.9. Query String Encoding
9.10. Plain Embedded Zuul
9.11. Disable Zuul Filters
9.12. Providing Hystrix Fallbacks For Routes
9.13. Rewriting Location header
9.14. Zuul Developer Guide
9.14.1. The Zuul Servlet
9.14.2. Zuul RequestContext
9.14.3. @EnableZuulProxy vs. @EnableZuulServer
9.14.4. @EnableZuulServer Filters
9.14.5. @EnableZuulProxy Filters
9.14.6. Custom Zuul Filter examples
9.14.7. How to Write a Pre Filter
9.14.8. How to Write a Route Filter
9.14.9. How to Write a Post Filter
9.14.10. How Zuul Errors Work
9.14.11. Zuul Eager Application Context Loading
10. Polyglot support with Sidecar
11. RxJava with Spring MVC
12. Metrics: Spectator, Servo, and Atlas
12.1. Dimensional vs. Hierarchical Metrics
12.2. Default Metrics Collection
12.3. Metrics Collection: Spectator
12.3.1. Spectator Counter
12.3.2. Spectator Timer
12.3.3. Spectator Gauge
12.3.4. Spectator Distribution Summaries
12.4. Metrics Collection: Servo
12.4.1. Creating Servo Monitors
12.5. Metrics Backend: Atlas
12.5.1. Global tags
12.5.2. Using Atlas
12.6. Retrying Failed Requests
12.6.1. Configuration
12.6.2. Zuul
13. HTTP Clients
\ No newline at end of file + Spring Cloud Netflix

Spring Cloud Netflix


Table of Contents

1. Service Discovery: Eureka Clients
1.1. How to Include Eureka Client
1.2. Registering with Eureka
1.3. Authenticating with the Eureka Server
1.4. Status Page and Health Indicator
1.5. Registering a Secure Application
1.6. Eureka’s Health Checks
1.7. Eureka Metadata for Instances and Clients
1.7.1. Using Eureka on Cloudfoundry
1.7.2. Using Eureka on AWS
1.7.3. Changing the Eureka Instance ID
1.8. Using the EurekaClient
1.8.1. EurekaClient without Jersey
1.9. Alternatives to the native Netflix EurekaClient
1.10. Why is it so Slow to Register a Service?
1.11. Zones
2. Service Discovery: Eureka Server
2.1. How to Include Eureka Server
2.2. How to Run a Eureka Server
2.3. High Availability, Zones and Regions
2.4. Standalone Mode
2.5. Peer Awareness
2.6. Prefer IP Address
3. Circuit Breaker: Hystrix Clients
3.1. How to Include Hystrix
3.2. Propagating the Security Context or using Spring Scopes
3.3. Health Indicator
3.4. Hystrix Metrics Stream
4. Circuit Breaker: Hystrix Dashboard
5. Hystrix Timeouts And Ribbon Clients
5.1. How to Include Hystrix Dashboard
5.2. Turbine
5.3. Turbine Stream
6. Client Side Load Balancer: Ribbon
6.1. How to Include Ribbon
6.2. Customizing the Ribbon Client
6.3. Customizing default for all Ribbon Clients
6.4. Customizing the Ribbon Client using properties
6.5. Using Ribbon with Eureka
6.6. Example: How to Use Ribbon Without Eureka
6.7. Example: Disable Eureka use in Ribbon
6.8. Using the Ribbon API Directly
6.9. Caching of Ribbon Configuration
6.10. How to Configure Hystrix thread pools
7. Declarative REST Client: Feign
7.1. How to Include Feign
7.2. Overriding Feign Defaults
7.3. Creating Feign Clients Manually
7.4. Feign Hystrix Support
7.5. Feign Hystrix Fallbacks
7.6. Feign and @Primary
7.7. Feign Inheritance Support
7.8. Feign request/response compression
7.9. Feign logging
8. External Configuration: Archaius
9. Router and Filter: Zuul
9.1. How to Include Zuul
9.2. Embedded Zuul Reverse Proxy
9.3. Zuul Http Client
9.4. Cookies and Sensitive Headers
9.5. Ignored Headers
9.6. Management Endpoints
9.6.1. Routes Endpoint
9.6.2. Filters Endpoint
9.7. Strangulation Patterns and Local Forwards
9.8. Uploading Files through Zuul
9.9. Query String Encoding
9.10. Plain Embedded Zuul
9.11. Disable Zuul Filters
9.12. Providing Hystrix Fallbacks For Routes
9.13. Zuul Timeouts
9.14. Rewriting Location header
9.15. Zuul Developer Guide
9.15.1. The Zuul Servlet
9.15.2. Zuul RequestContext
9.15.3. @EnableZuulProxy vs. @EnableZuulServer
9.15.4. @EnableZuulServer Filters
9.15.5. @EnableZuulProxy Filters
9.15.6. Custom Zuul Filter examples
9.15.7. How to Write a Pre Filter
9.15.8. How to Write a Route Filter
9.15.9. How to Write a Post Filter
9.15.10. How Zuul Errors Work
9.15.11. Zuul Eager Application Context Loading
10. Polyglot support with Sidecar
11. RxJava with Spring MVC
12. Metrics: Spectator, Servo, and Atlas
12.1. Dimensional vs. Hierarchical Metrics
12.2. Default Metrics Collection
12.3. Metrics Collection: Spectator
12.3.1. Spectator Counter
12.3.2. Spectator Timer
12.3.3. Spectator Gauge
12.3.4. Spectator Distribution Summaries
12.4. Metrics Collection: Servo
12.4.1. Creating Servo Monitors
12.5. Metrics Backend: Atlas
12.5.1. Global tags
12.5.2. Using Atlas
12.6. Retrying Failed Requests
12.6.1. Configuration
12.6.2. Zuul
13. HTTP Clients
\ No newline at end of file diff --git a/single/spring-cloud-netflix.html b/single/spring-cloud-netflix.html index b8334c3dc..8781b7c40 100644 --- a/single/spring-cloud-netflix.html +++ b/single/spring-cloud-netflix.html @@ -1,6 +1,6 @@ - Spring Cloud Netflix

Spring Cloud Netflix


Table of Contents

1. Service Discovery: Eureka Clients
1.1. How to Include Eureka Client
1.2. Registering with Eureka
1.3. Authenticating with the Eureka Server
1.4. Status Page and Health Indicator
1.5. Registering a Secure Application
1.6. Eureka’s Health Checks
1.7. Eureka Metadata for Instances and Clients
1.7.1. Using Eureka on Cloudfoundry
1.7.2. Using Eureka on AWS
1.7.3. Changing the Eureka Instance ID
1.8. Using the EurekaClient
1.8.1. EurekaClient without Jersey
1.9. Alternatives to the native Netflix EurekaClient
1.10. Why is it so Slow to Register a Service?
1.11. Zones
2. Service Discovery: Eureka Server
2.1. How to Include Eureka Server
2.2. How to Run a Eureka Server
2.3. High Availability, Zones and Regions
2.4. Standalone Mode
2.5. Peer Awareness
2.6. Prefer IP Address
3. Circuit Breaker: Hystrix Clients
3.1. How to Include Hystrix
3.2. Propagating the Security Context or using Spring Scopes
3.3. Health Indicator
3.4. Hystrix Metrics Stream
4. Circuit Breaker: Hystrix Dashboard
5. Hystrix Timeouts And Ribbon Clients
5.1. How to Include Hystrix Dashboard
5.2. Turbine
5.3. Turbine Stream
6. Client Side Load Balancer: Ribbon
6.1. How to Include Ribbon
6.2. Customizing the Ribbon Client
6.3. Customizing default for all Ribbon Clients
6.4. Customizing the Ribbon Client using properties
6.5. Using Ribbon with Eureka
6.6. Example: How to Use Ribbon Without Eureka
6.7. Example: Disable Eureka use in Ribbon
6.8. Using the Ribbon API Directly
6.9. Caching of Ribbon Configuration
6.10. How to Configure Hystrix thread pools
7. Declarative REST Client: Feign
7.1. How to Include Feign
7.2. Overriding Feign Defaults
7.3. Creating Feign Clients Manually
7.4. Feign Hystrix Support
7.5. Feign Hystrix Fallbacks
7.6. Feign and @Primary
7.7. Feign Inheritance Support
7.8. Feign request/response compression
7.9. Feign logging
8. External Configuration: Archaius
9. Router and Filter: Zuul
9.1. How to Include Zuul
9.2. Embedded Zuul Reverse Proxy
9.3. Zuul Http Client
9.4. Cookies and Sensitive Headers
9.5. Ignored Headers
9.6. Management Endpoints
9.6.1. Routes Endpoint
9.6.2. Filters Endpoint
9.7. Strangulation Patterns and Local Forwards
9.8. Uploading Files through Zuul
9.9. Query String Encoding
9.10. Plain Embedded Zuul
9.11. Disable Zuul Filters
9.12. Providing Hystrix Fallbacks For Routes
9.13. Rewriting Location header
9.14. Zuul Developer Guide
9.14.1. The Zuul Servlet
9.14.2. Zuul RequestContext
9.14.3. @EnableZuulProxy vs. @EnableZuulServer
9.14.4. @EnableZuulServer Filters
9.14.5. @EnableZuulProxy Filters
9.14.6. Custom Zuul Filter examples
9.14.7. How to Write a Pre Filter
9.14.8. How to Write a Route Filter
9.14.9. How to Write a Post Filter
9.14.10. How Zuul Errors Work
9.14.11. Zuul Eager Application Context Loading
10. Polyglot support with Sidecar
11. RxJava with Spring MVC
12. Metrics: Spectator, Servo, and Atlas
12.1. Dimensional vs. Hierarchical Metrics
12.2. Default Metrics Collection
12.3. Metrics Collection: Spectator
12.3.1. Spectator Counter
12.3.2. Spectator Timer
12.3.3. Spectator Gauge
12.3.4. Spectator Distribution Summaries
12.4. Metrics Collection: Servo
12.4.1. Creating Servo Monitors
12.5. Metrics Backend: Atlas
12.5.1. Global tags
12.5.2. Using Atlas
12.6. Retrying Failed Requests
12.6.1. Configuration
12.6.2. Zuul
13. HTTP Clients

1.4.0.BUILD-SNAPSHOT

This project provides Netflix OSS integrations for Spring Boot apps through autoconfiguration + Spring Cloud Netflix

Spring Cloud Netflix


Table of Contents

1. Service Discovery: Eureka Clients
1.1. How to Include Eureka Client
1.2. Registering with Eureka
1.3. Authenticating with the Eureka Server
1.4. Status Page and Health Indicator
1.5. Registering a Secure Application
1.6. Eureka’s Health Checks
1.7. Eureka Metadata for Instances and Clients
1.7.1. Using Eureka on Cloudfoundry
1.7.2. Using Eureka on AWS
1.7.3. Changing the Eureka Instance ID
1.8. Using the EurekaClient
1.8.1. EurekaClient without Jersey
1.9. Alternatives to the native Netflix EurekaClient
1.10. Why is it so Slow to Register a Service?
1.11. Zones
2. Service Discovery: Eureka Server
2.1. How to Include Eureka Server
2.2. How to Run a Eureka Server
2.3. High Availability, Zones and Regions
2.4. Standalone Mode
2.5. Peer Awareness
2.6. Prefer IP Address
3. Circuit Breaker: Hystrix Clients
3.1. How to Include Hystrix
3.2. Propagating the Security Context or using Spring Scopes
3.3. Health Indicator
3.4. Hystrix Metrics Stream
4. Circuit Breaker: Hystrix Dashboard
5. Hystrix Timeouts And Ribbon Clients
5.1. How to Include Hystrix Dashboard
5.2. Turbine
5.3. Turbine Stream
6. Client Side Load Balancer: Ribbon
6.1. How to Include Ribbon
6.2. Customizing the Ribbon Client
6.3. Customizing default for all Ribbon Clients
6.4. Customizing the Ribbon Client using properties
6.5. Using Ribbon with Eureka
6.6. Example: How to Use Ribbon Without Eureka
6.7. Example: Disable Eureka use in Ribbon
6.8. Using the Ribbon API Directly
6.9. Caching of Ribbon Configuration
6.10. How to Configure Hystrix thread pools
7. Declarative REST Client: Feign
7.1. How to Include Feign
7.2. Overriding Feign Defaults
7.3. Creating Feign Clients Manually
7.4. Feign Hystrix Support
7.5. Feign Hystrix Fallbacks
7.6. Feign and @Primary
7.7. Feign Inheritance Support
7.8. Feign request/response compression
7.9. Feign logging
8. External Configuration: Archaius
9. Router and Filter: Zuul
9.1. How to Include Zuul
9.2. Embedded Zuul Reverse Proxy
9.3. Zuul Http Client
9.4. Cookies and Sensitive Headers
9.5. Ignored Headers
9.6. Management Endpoints
9.6.1. Routes Endpoint
9.6.2. Filters Endpoint
9.7. Strangulation Patterns and Local Forwards
9.8. Uploading Files through Zuul
9.9. Query String Encoding
9.10. Plain Embedded Zuul
9.11. Disable Zuul Filters
9.12. Providing Hystrix Fallbacks For Routes
9.13. Zuul Timeouts
9.14. Rewriting Location header
9.15. Zuul Developer Guide
9.15.1. The Zuul Servlet
9.15.2. Zuul RequestContext
9.15.3. @EnableZuulProxy vs. @EnableZuulServer
9.15.4. @EnableZuulServer Filters
9.15.5. @EnableZuulProxy Filters
9.15.6. Custom Zuul Filter examples
9.15.7. How to Write a Pre Filter
9.15.8. How to Write a Route Filter
9.15.9. How to Write a Post Filter
9.15.10. How Zuul Errors Work
9.15.11. Zuul Eager Application Context Loading
10. Polyglot support with Sidecar
11. RxJava with Spring MVC
12. Metrics: Spectator, Servo, and Atlas
12.1. Dimensional vs. Hierarchical Metrics
12.2. Default Metrics Collection
12.3. Metrics Collection: Spectator
12.3.1. Spectator Counter
12.3.2. Spectator Timer
12.3.3. Spectator Gauge
12.3.4. Spectator Distribution Summaries
12.4. Metrics Collection: Servo
12.4.1. Creating Servo Monitors
12.5. Metrics Backend: Atlas
12.5.1. Global tags
12.5.2. Using Atlas
12.6. Retrying Failed Requests
12.6.1. Configuration
12.6.2. Zuul
13. HTTP Clients

1.4.0.BUILD-SNAPSHOT

This project provides Netflix OSS integrations for Spring Boot apps through autoconfiguration and binding to the Spring Environment and other Spring programming model idioms. With a few simple annotations you can quickly enable and configure the common patterns inside your application and build large distributed systems with battle-tested Netflix components. The @@ -1135,7 +1135,10 @@ type ZuulFallbackProvider and have the

9.13 Rewriting Location header

If Zuul is fronting a web application then there may be a need to re-write the Location header when the web application redirects through a http status code of 3XX, otherwise the browser will end up redirecting to the web application’s url instead of the Zuul url. +}

9.13 Zuul Timeouts

If you want to configure the socket timeouts and read timeouts for requests proxied through +Zuul there are two options based on your configuration.

If Zuul is using service discovery than you need to configure these timeouts via Ribbon properties, +ribbon.ReadTimeout and ribbon.SocketTimeout.

If you have configured Zuul routes by specifying URLs than you will need to use +zuul.host.connect-timeout-millis and zuul.host.socket-timeout-millis.

9.14 Rewriting Location header

If Zuul is fronting a web application then there may be a need to re-write the Location header when the web application redirects through a http status code of 3XX, otherwise the browser will end up redirecting to the web application’s url instead of the Zuul url. A LocationRewriteFilter Zuul filter can be configured to re-write the Location header to the Zuul’s url, it also adds back the stripped global and route specific prefixes. The filter can be added the following way via a Spring Configuration file:

import org.springframework.cloud.netflix.zuul.filters.post.LocationRewriteFilter;
 ...
 
@@ -1146,7 +1149,7 @@ A LocationRewriteFilter Zuul filter can  be configu
     public LocationRewriteFilter locationRewriteFilter() {
         return new LocationRewriteFilter();
     }
-}
[Warning]Warning

Use this filter with caution though, the filter acts on the Location header of ALL 3XX response codes which may not be appropriate in all scenarios, say if the user is redirecting to an external URL.

9.14 Zuul Developer Guide

For a general overview of how Zuul works, please see the Zuul Wiki.

9.14.1 The Zuul Servlet

Zuul is implemented as a Servlet. For the general cases, Zuul is embedded into the Spring Dispatch mechanism. This allows Spring MVC to be in control of the routing. In this case, Zuul is configured to buffer requests. If there is a need to go through Zuul without buffering requests (e.g. for large file uploads), the Servlet is also installed outside of the Spring Dispatcher. By default, this is located at /zuul. This path can be changed with the zuul.servlet-path property.

9.14.2 Zuul RequestContext

To pass information between filters, Zuul uses a RequestContext. Its data is held in a ThreadLocal specific to each request. Information about where to route requests, errors and the actual HttpServletRequest and HttpServletResponse are stored there. The RequestContext extends ConcurrentHashMap, so anything can be stored in the context. FilterConstants contains the keys that are used by the filters installed by Spring Cloud Netflix (more on these later).

9.14.3 @EnableZuulProxy vs. @EnableZuulServer

Spring Cloud Netflix installs a number of filters based on which annotation was used to enable Zuul. @EnableZuulProxy is a superset of @EnableZuulServer. In other words, @EnableZuulProxy contains all filters installed by @EnableZuulServer. The additional filters in the "proxy" enable routing functionality. If you want a "blank" Zuul, you should use @EnableZuulServer.

9.14.4 @EnableZuulServer Filters

Creates a SimpleRouteLocator that loads route definitions from Spring Boot configuration files.

The following filters are installed (as normal Spring Beans):

Pre filters:

  • ServletDetectionFilter: Detects if the request is through the Spring Dispatcher. Sets boolean with key FilterConstants.IS_DISPATCHER_SERVLET_REQUEST_KEY.
  • FormBodyWrapperFilter: Parses form data and reencodes it for downstream requests.
  • DebugFilter: if the debug request parameter is set, this filter sets RequestContext.setDebugRouting() and RequestContext.setDebugRequest() to true.

Route filters:

  • SendForwardFilter: This filter forwards requests using the Servlet RequestDispatcher. The forwarding location is stored in the RequestContext attribute FilterConstants.FORWARD_TO_KEY. This is useful for forwarding to endpoints in the current application.

Post filters:

  • SendResponseFilter: Writes responses from proxied requests to the current response.

Error filters:

  • SendErrorFilter: Forwards to /error (by default) if RequestContext.getThrowable() is not null. The default forwarding path (/error) can be changed by setting the error.path property.

9.14.5 @EnableZuulProxy Filters

Creates a DiscoveryClientRouteLocator that loads route definitions from a DiscoveryClient (like Eureka), as well as from properties. A route is created for each serviceId from the DiscoveryClient. As new services are added, the routes will be refreshed.

In addition to the filters described above, the following filters are installed (as normal Spring Beans):

Pre filters:

  • PreDecorationFilter: This filter determines where and how to route based on the supplied RouteLocator. It also sets various proxy-related headers for downstream requests.

Route filters:

  • RibbonRoutingFilter: This filter uses Ribbon, Hystrix and pluggable HTTP clients to send requests. Service ids are found in the RequestContext attribute FilterConstants.SERVICE_ID_KEY. This filter can use different HTTP clients. They are:

    • Apache HttpClient. This is the default client.
    • Squareup OkHttpClient v3. This is enabled by having the com.squareup.okhttp3:okhttp library on the classpath and setting ribbon.okhttp.enabled=true.
    • Netflix Ribbon HTTP client. This is enabled by setting ribbon.restclient.enabled=true. This client has limitations, such as it doesn’t support the PATCH method, but also has built-in retry.
  • SimpleHostRoutingFilter: This filter sends requests to predetermined URLs via an Apache HttpClient. URLs are found in RequestContext.getRouteHost().

9.14.6 Custom Zuul Filter examples

Most of the following "How to Write" examples below are included Sample Zuul Filters project. There are also examples of manipulating the request or response body in that repository.

9.14.7 How to Write a Pre Filter

Pre filters are used to set up data in the RequestContext for use in filters downstream. The main use case is to set information required for route filters.

public class QueryParamPreFilter extends ZuulFilter {
+}
[Warning]Warning

Use this filter with caution though, the filter acts on the Location header of ALL 3XX response codes which may not be appropriate in all scenarios, say if the user is redirecting to an external URL.

9.15 Zuul Developer Guide

For a general overview of how Zuul works, please see the Zuul Wiki.

9.15.1 The Zuul Servlet

Zuul is implemented as a Servlet. For the general cases, Zuul is embedded into the Spring Dispatch mechanism. This allows Spring MVC to be in control of the routing. In this case, Zuul is configured to buffer requests. If there is a need to go through Zuul without buffering requests (e.g. for large file uploads), the Servlet is also installed outside of the Spring Dispatcher. By default, this is located at /zuul. This path can be changed with the zuul.servlet-path property.

9.15.2 Zuul RequestContext

To pass information between filters, Zuul uses a RequestContext. Its data is held in a ThreadLocal specific to each request. Information about where to route requests, errors and the actual HttpServletRequest and HttpServletResponse are stored there. The RequestContext extends ConcurrentHashMap, so anything can be stored in the context. FilterConstants contains the keys that are used by the filters installed by Spring Cloud Netflix (more on these later).

9.15.3 @EnableZuulProxy vs. @EnableZuulServer

Spring Cloud Netflix installs a number of filters based on which annotation was used to enable Zuul. @EnableZuulProxy is a superset of @EnableZuulServer. In other words, @EnableZuulProxy contains all filters installed by @EnableZuulServer. The additional filters in the "proxy" enable routing functionality. If you want a "blank" Zuul, you should use @EnableZuulServer.

9.15.4 @EnableZuulServer Filters

Creates a SimpleRouteLocator that loads route definitions from Spring Boot configuration files.

The following filters are installed (as normal Spring Beans):

Pre filters:

  • ServletDetectionFilter: Detects if the request is through the Spring Dispatcher. Sets boolean with key FilterConstants.IS_DISPATCHER_SERVLET_REQUEST_KEY.
  • FormBodyWrapperFilter: Parses form data and reencodes it for downstream requests.
  • DebugFilter: if the debug request parameter is set, this filter sets RequestContext.setDebugRouting() and RequestContext.setDebugRequest() to true.

Route filters:

  • SendForwardFilter: This filter forwards requests using the Servlet RequestDispatcher. The forwarding location is stored in the RequestContext attribute FilterConstants.FORWARD_TO_KEY. This is useful for forwarding to endpoints in the current application.

Post filters:

  • SendResponseFilter: Writes responses from proxied requests to the current response.

Error filters:

  • SendErrorFilter: Forwards to /error (by default) if RequestContext.getThrowable() is not null. The default forwarding path (/error) can be changed by setting the error.path property.

9.15.5 @EnableZuulProxy Filters

Creates a DiscoveryClientRouteLocator that loads route definitions from a DiscoveryClient (like Eureka), as well as from properties. A route is created for each serviceId from the DiscoveryClient. As new services are added, the routes will be refreshed.

In addition to the filters described above, the following filters are installed (as normal Spring Beans):

Pre filters:

  • PreDecorationFilter: This filter determines where and how to route based on the supplied RouteLocator. It also sets various proxy-related headers for downstream requests.

Route filters:

  • RibbonRoutingFilter: This filter uses Ribbon, Hystrix and pluggable HTTP clients to send requests. Service ids are found in the RequestContext attribute FilterConstants.SERVICE_ID_KEY. This filter can use different HTTP clients. They are:

    • Apache HttpClient. This is the default client.
    • Squareup OkHttpClient v3. This is enabled by having the com.squareup.okhttp3:okhttp library on the classpath and setting ribbon.okhttp.enabled=true.
    • Netflix Ribbon HTTP client. This is enabled by setting ribbon.restclient.enabled=true. This client has limitations, such as it doesn’t support the PATCH method, but also has built-in retry.
  • SimpleHostRoutingFilter: This filter sends requests to predetermined URLs via an Apache HttpClient. URLs are found in RequestContext.getRouteHost().

9.15.6 Custom Zuul Filter examples

Most of the following "How to Write" examples below are included Sample Zuul Filters project. There are also examples of manipulating the request or response body in that repository.

9.15.7 How to Write a Pre Filter

Pre filters are used to set up data in the RequestContext for use in filters downstream. The main use case is to set information required for route filters.

public class QueryParamPreFilter extends ZuulFilter {
 	@Override
 	public int filterOrder() {
 		return PRE_DECORATION_FILTER_ORDER - 1; // run before PreDecoration
@@ -1173,7 +1176,7 @@ A LocationRewriteFilter Zuul filter can  be configu
     	}
         return null;
     }
-}

The filter above populates SERVICE_ID_KEY from the foo request parameter. In reality, it’s not a good idea to do that kind of direct mapping, but the service id should be looked up from the value of foo instead.

Now that SERVICE_ID_KEY is populated, PreDecorationFilter won’t run and RibbonRoutingFilter will. If you wanted to route to a full URL instead, call ctx.setRouteHost(url) instead.

To modify the path that routing filters will forward to, set the REQUEST_URI_KEY.

9.14.8 How to Write a Route Filter

Route filters are run after pre filters and are used to make requests to other services. Much of the work here is to translate request and response data to and from the client required model.

public class OkHttpRoutingFilter extends ZuulFilter {
+}

The filter above populates SERVICE_ID_KEY from the foo request parameter. In reality, it’s not a good idea to do that kind of direct mapping, but the service id should be looked up from the value of foo instead.

Now that SERVICE_ID_KEY is populated, PreDecorationFilter won’t run and RibbonRoutingFilter will. If you wanted to route to a full URL instead, call ctx.setRouteHost(url) instead.

To modify the path that routing filters will forward to, set the REQUEST_URI_KEY.

9.15.8 How to Write a Route Filter

Route filters are run after pre filters and are used to make requests to other services. Much of the work here is to translate request and response data to and from the client required model.

public class OkHttpRoutingFilter extends ZuulFilter {
 	@Autowired
 	private ProxyRequestHelper helper;
 
@@ -1247,7 +1250,7 @@ A LocationRewriteFilter Zuul filter can  be configu
 		context.setRouteHost(null); // prevent SimpleHostRoutingFilter from running
 		return null;
     }
-}

The above filter translates Servlet request information into OkHttp3 request information, executes an HTTP request, then translates OkHttp3 reponse information to the Servlet response. WARNING: this filter might have bugs and not function correctly.

9.14.9 How to Write a Post Filter

Post filters typically manipulate the response. In the filter below, we add a random UUID as the X-Foo header. Other manipulations, such as transforming the response body, are much more complex and compute-intensive.

public class AddResponseHeaderFilter extends ZuulFilter {
+}

The above filter translates Servlet request information into OkHttp3 request information, executes an HTTP request, then translates OkHttp3 reponse information to the Servlet response. WARNING: this filter might have bugs and not function correctly.

9.15.9 How to Write a Post Filter

Post filters typically manipulate the response. In the filter below, we add a random UUID as the X-Foo header. Other manipulations, such as transforming the response body, are much more complex and compute-intensive.

public class AddResponseHeaderFilter extends ZuulFilter {
 	@Override
 	public String filterType() {
 		return POST_TYPE;
@@ -1270,7 +1273,7 @@ A LocationRewriteFilter Zuul filter can  be configu
 		servletResponse.addHeader("X-Foo", UUID.randomUUID().toString());
 		return null;
 	}
-}

9.14.10 How Zuul Errors Work

If an exception is thrown during any portion of the Zuul filter lifecycle, the error filters are executed. The SendErrorFilter is only run if RequestContext.getThrowable() is not null. It then sets specific javax.servlet.error.* attributes in the request and forwards the request to the Spring Boot error page.

9.14.11 Zuul Eager Application Context Loading

Zuul internally uses Ribbon for calling the remote url’s and Ribbon clients are by default lazily loaded up by Spring Cloud on first call. +}

9.15.10 How Zuul Errors Work

If an exception is thrown during any portion of the Zuul filter lifecycle, the error filters are executed. The SendErrorFilter is only run if RequestContext.getThrowable() is not null. It then sets specific javax.servlet.error.* attributes in the request and forwards the request to the Spring Boot error page.

9.15.11 Zuul Eager Application Context Loading

Zuul internally uses Ribbon for calling the remote url’s and Ribbon clients are by default lazily loaded up by Spring Cloud on first call. This behavior can be changed for Zuul using the following configuration and will result in the child Ribbon related Application contexts being eagerly loaded up at application startup time.

application.yml. 

zuul:
   ribbon:
@@ -1425,7 +1428,7 @@ restTemplate.getForObject(</dependency>

In Spectator parlance, a meter is a named, typed, and tagged configuration and a metric represents the value of a given meter at a point in time. Spectator meters are created and controlled by a registry, which currently has several different implementations. Spectator provides 4 meter types: counter, timer, gauge, and distribution summary.

Spring Cloud Spectator integration configures an injectable com.netflix.spectator.api.Registry instance for you. Specifically, it configures a ServoRegistry instance in order to unify the collection of REST metrics and the exporting of metrics to the Atlas backend under a single Servo API. Practically, this means that your code may use a mixture of Servo monitors and Spectator meters and both will be scooped up by Spring Boot Actuator MetricReader instances and both will be shipped to the Atlas backend.

12.3.1 Spectator Counter

A counter is used to measure the rate at which some event is occurring.

// create a counter with a name and a set of tags
 Counter counter = registry.counter("counterName", "tagKey1", "tagValue1", ...);
 counter.increment(); // increment when an event occurs
-counter.increment(10); // increment by a discrete amount

The counter records a single time-normalized statistic.

12.3.2 Spectator Timer

A timer is used to measure how long some event is taking. Spring Cloud automatically records timers for Spring MVC requests and conditionally RestTemplate requests, which can later be used to create dashboards for request related metrics like latency:

Figure 12.1. Request Latency

RequestLatency

// create a timer with a name and a set of tags
+counter.increment(10); // increment by a discrete amount

The counter records a single time-normalized statistic.

12.3.2 Spectator Timer

A timer is used to measure how long some event is taking. Spring Cloud automatically records timers for Spring MVC requests and conditionally RestTemplate requests, which can later be used to create dashboards for request related metrics like latency:

Figure 12.1. Request Latency

RequestLatency

// create a timer with a name and a set of tags
 Timer timer = registry.timer("timerName", "tagKey1", "tagValue1", ...);
 
 // execute an operation and time it at the same time
diff --git a/spring-cloud-netflix.xml b/spring-cloud-netflix.xml
index 1ac4bd794..b7244536d 100644
--- a/spring-cloud-netflix.xml
+++ b/spring-cloud-netflix.xml
@@ -1988,6 +1988,15 @@ type ZuulFallbackProvider and have the getRoute
 
+
+Zuul Timeouts +If you want to configure the socket timeouts and read timeouts for requests proxied through +Zuul there are two options based on your configuration. +If Zuul is using service discovery than you need to configure these timeouts via Ribbon properties, +ribbon.ReadTimeout and ribbon.SocketTimeout. +If you have configured Zuul routes by specifying URLs than you will need to use +zuul.host.connect-timeout-millis and zuul.host.socket-timeout-millis. +
Rewriting <literal>Location</literal> header If Zuul is fronting a web application then there may be a need to re-write the Location header when the web application redirects through a http status code of 3XX, otherwise the browser will end up redirecting to the web application’s url instead of the Zuul url.