diff --git a/configprops.yml b/configprops.yml new file mode 100644 index 00000000..99e7cb73 --- /dev/null +++ b/configprops.yml @@ -0,0 +1,6 @@ +spring: + main: + webEnvironment: false + cloud: + consul: + enabled: false diff --git a/spring-cloud.html b/spring-cloud.html index a4a08330..ed9e5849 100644 --- a/spring-cloud.html +++ b/spring-cloud.html @@ -572,7 +572,7 @@ body.book #toc,body.book #preamble,body.book h1.sect0,body.book .sect1>h2{page-b
  • Configuration options -
  • +
  • Spring Cloud Bus + +
  • +
  • Spring Cloud Sleuth + +
  • +
  • Spring Cloud Consul + +
  • +
  • Spring Cloud Zookeeper + +
  • +
  • Spring Boot Cloud CLI + +
  • +
  • Spring Cloud Security + +
  • +
  • Spring Cloud for Cloud Foundry + +
  • +
  • Spring Cloud Cluster + +
  • +
  • Appendix: Compendium of Configuration Properties
  • @@ -5696,8 +5860,8 @@ RabbitMQ Consumer instance for its group’s Queue.

    All configuration options can be provided to Spring Cloud Stream applications via all the mechanisms supported by Spring Boot: application arguments, environment variables, YML files etc.

    -
    -

    Spring Cloud Stream Properties

    +
    +

    Spring Cloud Stream Properties

    spring.cloud.stream.instanceCount
    @@ -6441,89 +6605,108 @@ hello world 1458595076731 hello world 1458595077732 hello world 1458595078733 hello world 1458595079734 -hello world 1458595080735 - -= Spring Cloud Bus -:github: https://github.com/spring-cloud/spring-cloud-config -:githubmaster: {github}/tree/master -:docslink: {githubmaster}/docs/src/main/asciidoc -:toc: - +hello world 1458595080735 +
    +
    +
    + +

    Spring Cloud Bus

    +
    +
    Spring Cloud Bus links nodes of a distributed system with a lightweight message broker. This can then be used to broadcast state changes (e.g. configuration changes) or other management instructions. A key idea is that the Bus is like a distributed Actuator for a Spring Boot application that is scaled out, but it can also be used as a communication channel between apps. The only implementation currently is with an AMQP broker as the transport, but the same basic feature set (and some more depending on the transport) is on the roadmap for other transports. - - - -== Quick Start - -Spring Cloud Bus works by adding Spring Boot autconfiguration if it detects itself on the classpath. All you need to do to enable the bus is to add `spring-cloud-starter-bus-amqp` to your dependency management and Spring Cloud takes care of the rest. Make sure RabbitMQ is available and configured to provide a `ConnectionFactory`: running on localhost you shouldn't have to do anything, but if you are running remotely use Spring Cloud Connectors, or Spring Boot conventions to define the broker credentials, e.g. - -.application.yml
    +
    +

    Quick Start

    +
    -

    spring: +

    Spring Cloud Bus works by adding Spring Boot autconfiguration if it detects itself on the classpath. All you need to do to enable the bus is to add spring-cloud-starter-bus-amqp to your dependency management and Spring Cloud takes care of the rest. Make sure RabbitMQ is available and configured to provide a ConnectionFactory: running on localhost you shouldn’t have to do anything, but if you are running remotely use Spring Cloud Connectors, or Spring Boot conventions to define the broker credentials, e.g.

    +
    +
    +
    application.yml
    +
    +
    spring:
       rabbitmq:
         host: mybroker.com
         port: 5672
         username: user
    -    password: secret

    + password: secret
    -
    -
    -
    The bus currently supports sending messages to all nodes listening or all nodes for a particular service (as defined by Eureka).  More selector criteria will be added in the future (ie. only service X nodes in data center Y, etc...). The http endpoints are under the `/bus/*` actuator namespace.  There are currently two implemented.  The first, `/bus/env`, sends key/values pairs to update each nodes Spring Environment.  The second, `/bus/refresh`, will reload each application's configuration, just as if they had all been pinged on their `/refresh` endpoint.
    -
    -== Addressing an Instance
    -
    -The HTTP endpoints accept a "destination" parameter, e.g. "/bus/refresh?destination=customers:9000", where the destination is an `ApplicationContext` ID. If the ID is owned by an instance on the Bus then it will process the message and all other instances will ignore it. Spring Boot sets the ID for you in the `ContextIdApplicationContextInitializer` to a combination of the `spring.application.name`, active profiles and `server.port` by default.
    -
    -== Addressing all instances of a service
    -
    -The "destination" parameter is used in a Spring `PathMatcher` (with the path separator as a colon `:`) to determine if an instance will process the message.   Using the example from above, "/bus/refresh?destination=customers:**" will  target  all instances of the "customers" service regardless of the profiles and ports set as the `ApplicationContext` ID.
    -
    -== Application Context ID must be unique
    -
    -The bus tries to eliminate processing an event twice, once from the original `ApplicationEvent` and once from the queue.  To do this, it checks the sending application context id againts the current application context id.  If multiple instances of a service have the same application context id, events will not be processed.  Running on a local machine, each service will be on a different port and that will be part of the application context id.  Cloud Foundry supplies an index to differentiate.  To ensure that the application context id is the unique, set `spring.application.index` to something unique for each instance of a service.  For example, in lattice, set `spring.application.index=${INSTANCE_INDEX}` in application.properties (or bootstrap.properties if using configserver).
    -
    -== Customizing the Message Broker
    -
    -Spring Cloud Bus uses
    -https://cloud.spring.io/spring-cloud-stream[Spring Cloud Stream] to
    +
    +
    +

    The bus currently supports sending messages to all nodes listening or all nodes for a particular service (as defined by Eureka). More selector criteria will be added in the future (ie. only service X nodes in data center Y, etc…​). The http endpoints are under the /bus/* actuator namespace. There are currently two implemented. The first, /bus/env, sends key/values pairs to update each nodes Spring Environment. The second, /bus/refresh, will reload each application’s configuration, just as if they had all been pinged on their /refresh endpoint.

    +
    +
    +
    +
    +

    Addressing an Instance

    +
    +
    +

    The HTTP endpoints accept a "destination" parameter, e.g. "/bus/refresh?destination=customers:9000", where the destination is an ApplicationContext ID. If the ID is owned by an instance on the Bus then it will process the message and all other instances will ignore it. Spring Boot sets the ID for you in the ContextIdApplicationContextInitializer to a combination of the spring.application.name, active profiles and server.port by default.

    +
    +
    +
    +
    +

    Addressing all instances of a service

    +
    +
    +

    The "destination" parameter is used in a Spring PathMatcher (with the path separator as a colon :) to determine if an instance will process the message. Using the example from above, "/bus/refresh?destination=customers:**" will target all instances of the "customers" service regardless of the profiles and ports set as the ApplicationContext ID.

    +
    +
    +
    +
    +

    Application Context ID must be unique

    +
    +
    +

    The bus tries to eliminate processing an event twice, once from the original ApplicationEvent and once from the queue. To do this, it checks the sending application context id againts the current application context id. If multiple instances of a service have the same application context id, events will not be processed. Running on a local machine, each service will be on a different port and that will be part of the application context id. Cloud Foundry supplies an index to differentiate. To ensure that the application context id is the unique, set spring.application.index to something unique for each instance of a service. For example, in lattice, set spring.application.index=${INSTANCE_INDEX} in application.properties (or bootstrap.properties if using configserver).

    +
    +
    +
    +
    +

    Customizing the Message Broker

    +
    +
    +

    Spring Cloud Bus uses +Spring Cloud Stream to broadcast the messages so to get messages to flow you only need to include the binder implementation of your choice in the classpath. There are convenient starters specifically for the bus with AMQP (RabbitMQ) and Kafka -(`spring-cloud-starter-bus-[amqp,kafka]`). Generally speaking +(spring-cloud-starter-bus-[amqp,kafka]). Generally speaking Spring Cloud Stream relies on Spring Boot autoconfiguration conventions for configuring middleware, so for instance the AMQP -broker address can be changed with `spring.rabbitmq.{asterisk}` +broker address can be changed with spring.rabbitmq.* configuration properties. Spring Cloud Bus has a handful of native -configuration properties in `spring.cloud.bus.{asterisk}` -(e.g. `spring.cloud.bus.destination` is the name of the topic to use -the the externall middleware). Normally the defaults will suffice. - -To lean more about how to customize the message broker settings -consult the Spring Cloud Stream documentation. - -== Tracing Bus Events - -Bus events (subclasses of `RemoteApplicationEvent`) can be traced by -setting `spring.cloud.bus.trace.enabled=true`. If you do this then the -Spring Boot `TraceRepository` (if it is present) will show each event -sent and all the acks from each service instance. Example (from the -`/trace` endpoint): - -[source,json] -

    +configuration properties in spring.cloud.bus.* +(e.g. spring.cloud.bus.destination is the name of the topic to use +the the externall middleware). Normally the defaults will suffice.

    -

    { +

    To lean more about how to customize the message broker settings +consult the Spring Cloud Stream documentation.

    +
    +
    +
    +
    +

    Tracing Bus Events

    +
    +
    +

    Bus events (subclasses of RemoteApplicationEvent) can be traced by +setting spring.cloud.bus.trace.enabled=true. If you do this then the +Spring Boot TraceRepository (if it is present) will show each event +sent and all the acks from each service instance. Example (from the +/trace endpoint):

    +
    +
    +
    +
    {
       "timestamp": "2015-11-26T10:24:44.411+0000",
       "info": {
         "signal": "spring.cloud.bus.ack",
         "type": "RefreshRemoteApplicationEvent",
         "id": "c4d374b7-58ea-4928-a312-31984def293b",
         "origin": "stores:8081",
    -    "destination": ":"
    +    "destination": "*:**"
       }
       },
       {
    @@ -6533,7 +6716,7 @@ sent and all the acks from each service instance. Example (from the
         "type": "RefreshRemoteApplicationEvent",
         "id": "c4d374b7-58ea-4928-a312-31984def293b",
         "origin": "customers:9000",
    -    "destination": ":"
    +    "destination": "*:**"
       }
       },
       {
    @@ -6543,239 +6726,409 @@ sent and all the acks from each service instance. Example (from the
         "type": "RefreshRemoteApplicationEvent",
         "id": "c4d374b7-58ea-4928-a312-31984def293b",
         "origin": "customers:9000",
    -    "destination": ":*"
    +    "destination": "*:**"
       }
    -}

    +}
    +
    +
    +
    +

    This trace shows that a RefreshRemoteApplicationEvent was sent from +customers:9000, broadcast to all services, and it was received +(acked) by customers:9000 and stores:8081.

    +
    +
    +

    To handle the ack signals yourself you could add an @EventListener +for the AckRemoteApplicationEvent and SentApplicationEvent types +to your app (and enable tracing). Or you could tap into the +TraceRepository and mine the data from there.

    +
    +
    + + + + + +
    +
    Note
    +
    +Any Bus application can trace acks, but sometimes it will be +useful to do this in a central service that can do more complex +queries on the data. Or forward it to a specialized tracing service. +
    +
    +
    +
    +
    +

    Broadcasting Your Own Events

    +
    +
    +

    The Bus can carry any event of type RemoteApplicationEvent, but the +default transport is JSON and the deserializer needs to know which +types are going to be used ahead of time. To register a new type you +can use @JsonTypeName on your custom class.

    +
    +
    +
    +

    Spring Cloud Sleuth

    +
    +
    +
    +

    Adrian Cole, Spencer Gibb, Marcin Grzejszczak, Dave Syer +:doctype: book

    +
    +
    +

    Spring Cloud Sleuth implements a distributed tracing solution for Spring Cloud.

    +
    +
    +
    +
    +

    Terminology

    +
    +

    Spring Cloud Sleuth borrows Dapper’s terminology.

    +
    +
    +

    Span: The basic unit of work. For example, sending an RPC is a new span, as is sending a response to an +RPC. Span’s are identified by a unique 64-bit ID for the span and another 64-bit ID for the trace the span +is a part of. Spans also have other data, such as descriptions, timestamped events, key-value +annotations (tags), the ID of the span that caused them, and process ID’s (normally IP address).

    +
    +
    +

    Spans are started and stopped, and they keep track of their timing information. Once you create a +span, you must stop it at some point in the future.

    +
    +
    +

    Trace: A set of spans forming a tree-like structure. For example, if you are running a distributed +big-data store, a trace might be formed by a put request.

    +
    +
    +

    Annotation: is used to record existence of an event in time. Some of the core annotations used to define +the start and stop of a request are:

    +
    +
    +
      +
    • +

      cs - Client Sent - The client has made a request. This annotation depicts the start of the span.

      +
    • +
    • +

      sr - Server Received - The server side got the request and will start processing it. +If one subtracts the cs timestamp from this timestamp one will receive the network latency.

      +
    • +
    • +

      ss - Server Sent - Annotated upon completion of request processing (when the response +got sent back to the client). If one subtracts the sr timestamp from this timestamp one +will receive the time needed by the server side to process the request.

      +
    • +
    • +

      cr - Client Received - Signifies the end of the span. The client has successfully received the +response from the server side. If one subtracts the cs timestamp from this timestamp one +will receive the whole time needed by the client to receive the response from the server.

      +
    • +
    +
    +
    +

    Visualization of what Span and Trace will look in a system together with the Zipkin annotations:

    +
    +
    +
    +Trace Info propagation +
    +
    +
    +

    Each color of a note signifies a span (7 spans - from A to G). If you have such information in the note:

    -
    This trace shows that a `RefreshRemoteApplicationEvent` was sent from
    -`customers:9000`, broadcast to all services, and it was received
    -(acked) by `customers:9000` and `stores:8081`.
    -
    -To handle the ack signals yourself you could add an `@EventListener`
    -for the `AckRemoteApplicationEvent` and `SentApplicationEvent` types
    -to your app (and enable tracing). Or you could tap into the
    -`TraceRepository` and mine the data from there.
    -
    -NOTE: Any Bus application can trace acks, but sometimes it will be
    -useful to do this in a central service that can do more complex
    -queries on the data. Or forward it to a specialized tracing service.
    -
    -== Broadcasting Your Own Events
    -
    -The Bus can carry any event of type `RemoteApplicationEvent`, but the
    -default transport is JSON and the deserializer needs to know which
    -types are going to be used ahead of time. To register a new type you
    -can use `@JsonTypeName` on your custom class.
    -
    -:github-tag: master
    -:github-repo: spring-cloud/spring-cloud-sleuth
    -:github-raw: http://raw.github.com/{github-repo}/{github-tag}
    -:github-code: http://github.com/{github-repo}/tree/{github-tag}
    -:toc: left
    -
    -Spring Cloud Sleuth
    -====================
    -Adrian Cole, Spencer Gibb, Marcin Grzejszczak, Dave Syer
    -:doctype: book
    -
    -Spring Cloud Sleuth implements a distributed tracing solution for http://cloud.spring.io[Spring Cloud].
    -
    -=== Terminology
    -
    -Spring Cloud Sleuth borrows http://research.google.com/pubs/pub36356.html[Dapper's] terminology.
    -
    -*Span:* The basic unit of work. For example, sending an RPC is a new span, as is sending a response to an
    -RPC. Span's are identified by a unique 64-bit ID for the span and another 64-bit ID for the trace the span
    -is a part of.  Spans also have other data, such as descriptions, timestamped events, key-value
    -annotations (tags), the ID of the span that caused them, and process ID's (normally IP address).
    -
    -Spans are started and stopped, and they keep track of their timing information.  Once you create a
    -span, you must stop it at some point in the future.
    -
    -*Trace:* A set of spans forming a tree-like structure.  For example, if you are running a distributed
    -big-data store, a trace might be formed by a put request.
    -
    -*Annotation:*  is used to record existence of an event in time. Some of the core annotations used to define
    -the start and stop of a request are:
    -
    -    - *cs* - Client Sent - The client has made a request. This annotation depicts the start of the span.
    -    - *sr* - Server Received -  The server side got the request and will start processing it.
    -    If one subtracts the cs timestamp from this timestamp one will receive the network latency.
    -    - *ss* - Server Sent -  Annotated upon completion of request processing (when the response
    -    got sent back to the client). If one subtracts the sr timestamp from this timestamp one
    -    will receive the time needed by the server side to process the request.
    -    - *cr* - Client Received - Signifies the end of the span. The client has successfully received the
    -    response from the server side. If one subtracts the cs timestamp from this timestamp one
    -    will receive the whole time needed by the client to receive the response from the server.
    -
    -Visualization of what *Span* and *Trace* will look in a system together with the Zipkin annotations:
    -
    -image::https://raw.githubusercontent.com/spring-cloud/spring-cloud-sleuth/master/docs/src/main/asciidoc/images/trace-id.png[Trace Info propagation]
    -
    -Each color of a note signifies a span (7 spans - from *A* to *G*). If you have such information in the note:
    -
    -[source]
    -Trace Id = X
    +
    Trace Id = X
     Span Id = D
    -Client Sent
    -
    -That means that the current span has *Trace-Id* set to *X*, *Span-Id* set to *D*. It also has emitted
    - *Client Sent* event.
    -
    -This is how the visualization of the parent / child relationship of spans would look like:
    -
    -image::https://raw.githubusercontent.com/spring-cloud/spring-cloud-sleuth/master/docs/src/main/asciidoc/images/parents.png[Parent child relationship]
    -
    -=== Purpose
    -
    -In the following sections the example from the image above will be taken into consideration.
    -
    -==== Distributed tracing with Zipkin
    -
    -Altogether there are *10 spans* . If you go to traces in Zipkin you will see this number:
    -
    -image::https://raw.githubusercontent.com/spring-cloud/spring-cloud-sleuth/master/docs/src/main/asciidoc/images/zipkin-traces.png[Traces]
    -
    -However if you pick a particular trace then you will see *7 spans*:
    -
    -image::https://raw.githubusercontent.com/spring-cloud/spring-cloud-sleuth/master/docs/src/main/asciidoc/images/zipkin-ui.png[Traces Info propagation]
    -
    -NOTE: When picking a particular trace you will see merged spans. That means that if there were 2 spans sent to
    +Client Sent
    +
    +
    +
    +

    That means that the current span has Trace-Id set to X, Span-Id set to D. It also has emitted + Client Sent event.

    +
    +
    +

    This is how the visualization of the parent / child relationship of spans would look like:

    +
    +
    +
    +Parent child relationship +
    +
    +
    +
    +

    Purpose

    +
    +

    In the following sections the example from the image above will be taken into consideration.

    +
    +
    +

    Distributed tracing with Zipkin

    +
    +

    Altogether there are 10 spans . If you go to traces in Zipkin you will see this number:

    +
    +
    +
    +Traces +
    +
    +
    +

    However if you pick a particular trace then you will see 7 spans:

    +
    +
    +
    +Traces Info propagation +
    +
    +
    + + + + + +
    +
    Note
    +
    +When picking a particular trace you will see merged spans. That means that if there were 2 spans sent to Zipkin with Server Received and Server Sent / Client Received and Client Sent annotations then they will presented as a single span. - -In the image depicting the visualization of what *Span* and *Trace* is you can see 20 -colorful labels. How does it happen that in Zipkin 10 spans are received? - - - 2 span *A* labels signify span started and closed. Upon closing a single span is sent to Zipkin. - - 4 span *B* labels are in fact are single span with 4 annotations. However this span is composed of - two separate instances. One sent from service 1 and one from service 2. So in fact two span instances will be sent - to Zipkin and merged there. - - 2 span *C* labels signify span started and closed. Upon closing a single span is sent to Zipkin. - - 4 span *B* labels are in fact are single span with 4 annotations. However this span is composed of - two separate instances. One sent from service 2 and one from service 3. So in fact two span instances will be sent - to Zipkin and merged there. - - 2 span *E* labels signify span started and closed. Upon closing a single span is sent to Zipkin. - - 4 span *B* labels are in fact are single span with 4 annotations. However this span is composed of - two separate instances. One sent from service 2 and one from service 4. So in fact two span instances will be sent - to Zipkin and merged there. - - 2 span *G* labels signify span started and closed. Upon closing a single span is sent to Zipkin. - -So 1 span from *A*, 2 spans from *B*, 1 span from *C*, 2 spans from *D*, 1 span from *E*, 2 spans from *F* and 1 from *G*. -Altogether *10* spans. - -==== Log correlation - -When grepping the logs of those four applications by trace id equal to e.g. `2485ec27856c56f4` one would get the following: - -[source] -service1.log:2016-02-26 11:15:47.561 INFO [service1,2485ec27856c56f4,2485ec27856c56f4,true] 68058 --- [nio-8081-exec-1] i.s.c.sleuth.docs.service1.Application : Hello from service1. Calling service2 +
    +
    +
    +

    In the image depicting the visualization of what Span and Trace is you can see 20 +colorful labels. How does it happen that in Zipkin 10 spans are received?

    +
    +
    +
      +
    • +

      2 span A labels signify span started and closed. Upon closing a single span is sent to Zipkin.

      +
    • +
    • +

      4 span B labels are in fact are single span with 4 annotations. However this span is composed of +two separate instances. One sent from service 1 and one from service 2. So in fact two span instances will be sent +to Zipkin and merged there.

      +
    • +
    • +

      2 span C labels signify span started and closed. Upon closing a single span is sent to Zipkin.

      +
    • +
    • +

      4 span B labels are in fact are single span with 4 annotations. However this span is composed of +two separate instances. One sent from service 2 and one from service 3. So in fact two span instances will be sent +to Zipkin and merged there.

      +
    • +
    • +

      2 span E labels signify span started and closed. Upon closing a single span is sent to Zipkin.

      +
    • +
    • +

      4 span B labels are in fact are single span with 4 annotations. However this span is composed of +two separate instances. One sent from service 2 and one from service 4. So in fact two span instances will be sent +to Zipkin and merged there.

      +
    • +
    • +

      2 span G labels signify span started and closed. Upon closing a single span is sent to Zipkin.

      +
    • +
    +
    +
    +

    So 1 span from A, 2 spans from B, 1 span from C, 2 spans from D, 1 span from E, 2 spans from F and 1 from G. +Altogether 10 spans.

    +
    +
    +
    +

    Log correlation

    +
    +

    When grepping the logs of those four applications by trace id equal to e.g. 2485ec27856c56f4 one would get the following:

    +
    +
    +
    +
    service1.log:2016-02-26 11:15:47.561  INFO [service1,2485ec27856c56f4,2485ec27856c56f4,true] 68058 --- [nio-8081-exec-1] i.s.c.sleuth.docs.service1.Application   : Hello from service1. Calling service2
     service2.log:2016-02-26 11:15:47.710  INFO [service2,2485ec27856c56f4,9aa10ee6fbde75fa,true] 68059 --- [nio-8082-exec-1] i.s.c.sleuth.docs.service2.Application   : Hello from service2. Calling service3 and then service4
     service3.log:2016-02-26 11:15:47.895  INFO [service3,2485ec27856c56f4,1210be13194bfe5,true] 68060 --- [nio-8083-exec-1] i.s.c.sleuth.docs.service3.Application   : Hello from service3
     service2.log:2016-02-26 11:15:47.924  INFO [service2,2485ec27856c56f4,9aa10ee6fbde75fa,true] 68059 --- [nio-8082-exec-1] i.s.c.sleuth.docs.service2.Application   : Got response from service3 [Hello from service3]
     service4.log:2016-02-26 11:15:48.134  INFO [service4,2485ec27856c56f4,1b1845262ffba49d,true] 68061 --- [nio-8084-exec-1] i.s.c.sleuth.docs.service4.Application   : Hello from service4
     service2.log:2016-02-26 11:15:48.156  INFO [service2,2485ec27856c56f4,9aa10ee6fbde75fa,true] 68059 --- [nio-8082-exec-1] i.s.c.sleuth.docs.service2.Application   : Got response from service4 [Hello from service4]
    -service1.log:2016-02-26 11:15:48.182  INFO [service1,2485ec27856c56f4,2485ec27856c56f4,true] 68058 --- [nio-8081-exec-1] i.s.c.sleuth.docs.service1.Application   : Got response from service2 [Hello from service2, response from service3 [Hello from service3] and from service4 [Hello from service4]]
    -
    -If you're using a log aggregating tool like https://www.elastic.co/products/kibana[Kibana],
    -http://www.splunk.com/[Splunk] etc. you can order the events that took place. An example of
    -Kibana would look like this:
    -
    -image::https://raw.githubusercontent.com/spring-cloud/spring-cloud-sleuth/master/docs/src/main/asciidoc/images/kibana.png[Log correlation with Kibana]
    -
    -If you want to use https://www.elastic.co/guide/en/logstash/current/index.html[Logstash] here is the Grok pattern for Logstash:
    -
    -[source]
    -filter {
    +service1.log:2016-02-26 11:15:48.182  INFO [service1,2485ec27856c56f4,2485ec27856c56f4,true] 68058 --- [nio-8081-exec-1] i.s.c.sleuth.docs.service1.Application   : Got response from service2 [Hello from service2, response from service3 [Hello from service3] and from service4 [Hello from service4]]
    +
    +
    +
    +

    If you’re using a log aggregating tool like Kibana, +Splunk etc. you can order the events that took place. An example of +Kibana would look like this:

    +
    +
    +
    +Log correlation with Kibana +
    +
    +
    +

    If you want to use Logstash here is the Grok pattern for Logstash:

    +
    +
    +
    +
    filter {
            # pattern matching logback pattern
            grok {
                   match => { "message" => "%{TIMESTAMP_ISO8601:timestamp}\s+%{LOGLEVEL:severity}\s+\[%{DATA:service},%{DATA:trace},%{DATA:span},%{DATA:exportable}\]\s+%{DATA:pid}---\s+\[%{DATA:thread}\]\s+%{DATA:class}\s+:\s+%{GREEDYDATA:rest}" }
            }
    -}
    -
    -NOTE: If you want to use Grok together with the logs from Cloud Foundry you have to use this pattern:
    -[source]
    -filter {
    +}
    +
    +
    +
    + + + + + +
    +
    Note
    +
    +If you want to use Grok together with the logs from Cloud Foundry you have to use this pattern: +
    +
    +
    +
    +
    filter {
            # pattern matching logback pattern
            grok {
                   match => { "message" => "(?m)OUT\s+%{TIMESTAMP_ISO8601:timestamp}\s+%{LOGLEVEL:severity}\s+\[%{DATA:service},%{DATA:trace},%{DATA:span},%{DATA:exportable}\]\s+%{DATA:pid}---\s+\[%{DATA:thread}\]\s+%{DATA:class}\s+:\s+%{GREEDYDATA:rest}" }
            }
    -}
    -
    -=== Adding to the project
    -
    -In general if you want to profit only from Spring Cloud Sleuth without the Zipkin integration just add
    -the *spring-cloud-starter-sleuth* module to your project.
    -
    -If you want both Sleuth and Zipkin just add the *spring-cloud-starter-zipkin* dependency.
    -
    -== Features
    -
    -* Adds trace and span ids to the Slf4J MDC, so you can extract all the logs from a given trace or span in a log aggregator. Example logs:
    -+
    +} +
    +
    +
    +
    +
    +

    Adding to the project

    +
    +

    In general if you want to profit only from Spring Cloud Sleuth without the Zipkin integration just add +the spring-cloud-starter-sleuth module to your project.

    +
    +
    +

    If you want both Sleuth and Zipkin just add the spring-cloud-starter-zipkin dependency.

    +
    +
    +
    +

    Features

    +
    +
    +
      +
    • +

      Adds trace and span ids to the Slf4J MDC, so you can extract all the logs from a given trace or span in a log aggregator. Example logs:

      +
      +
      +
      2016-02-02 15:30:57.902  INFO [bar,6bfd228dc00d216b,6bfd228dc00d216b,false] 23030 --- [nio-8081-exec-3] ...
      +2016-02-02 15:30:58.372 ERROR [bar,6bfd228dc00d216b,6bfd228dc00d216b,false] 23030 --- [nio-8081-exec-3] ...
      +2016-02-02 15:31:01.936  INFO [bar,46ab0d418373cbc9,46ab0d418373cbc9,false] 23030 --- [nio-8081-exec-4] ...
      -

      2016-02-02 15:30:57.902 INFO [bar,6bfd228dc00d216b,6bfd228dc00d216b,false] 23030 --- [nio-8081-exec-3] …​ -2016-02-02 15:30:58.372 ERROR [bar,6bfd228dc00d216b,6bfd228dc00d216b,false] 23030 --- [nio-8081-exec-3] …​ -2016-02-02 15:31:01.936 INFO [bar,46ab0d418373cbc9,46ab0d418373cbc9,false] 23030 --- [nio-8081-exec-4] …​

      +

      notice the [appname,traceId,spanId,exportable] entries from the MDC:

      -
      -
      -
      +
      -notice the `[appname,traceId,spanId,exportable]` entries from the MDC:
      -
      -    - *spanId* - the id of a specific operation that took place
      -    - *appname* - the name of the application that logged the span
      -    - *traceId* - the id of the latency graph that contains the span
      -    - *exportable* - whether the log should be exported to Zipkin or not. When would you like the span not to be
      -    exportable? In the case in which you want to wrap some operation in a Span and have it written to the logs
      -    only.
      -
      -* Provides an abstraction over common distributed tracing data models: traces, spans (forming a DAG), annotations,
      -key-value annotations. Loosely based on HTrace, but Zipkin (Dapper) compatible.
      -
      -* Sleuth records timing information to aid in latency analysis. Using sleuth, you can pinpoint causes of
      -latency in your applications. Sleuth is written to not log too much, and to not cause your production application to crash.
      -  - propagates structural data about your call-graph in-band, and the rest out-of-band.
      -  - includes opinionated instrumentation of layers such as HTTP
      -  - includes sampling policy to manage volume
      -  - can report to a Zipkin system for query and visualization
      -
      -* Instruments common ingress and egress points from Spring applications (servlet filter, async endpoints,
      -rest template, scheduled actions, message channels, zuul filters, feign client).
      -
      -* Sleuth includes default logic to join a trace across http or messaging boundaries. For example, http propagation
      +
      +
        +
      • +

        spanId - the id of a specific operation that took place

        +
      • +
      • +

        appname - the name of the application that logged the span

        +
      • +
      • +

        traceId - the id of the latency graph that contains the span

        +
      • +
      • +

        exportable - whether the log should be exported to Zipkin or not. When would you like the span not to be +exportable? In the case in which you want to wrap some operation in a Span and have it written to the logs +only.

        +
      • +
      +
      +
    • +
    • +

      Provides an abstraction over common distributed tracing data models: traces, spans (forming a DAG), annotations, +key-value annotations. Loosely based on HTrace, but Zipkin (Dapper) compatible.

      +
    • +
    • +

      Sleuth records timing information to aid in latency analysis. Using sleuth, you can pinpoint causes of +latency in your applications. Sleuth is written to not log too much, and to not cause your production application to crash.

      +
      +
        +
      • +

        propagates structural data about your call-graph in-band, and the rest out-of-band.

        +
      • +
      • +

        includes opinionated instrumentation of layers such as HTTP

        +
      • +
      • +

        includes sampling policy to manage volume

        +
      • +
      • +

        can report to a Zipkin system for query and visualization

        +
      • +
      +
      +
    • +
    • +

      Instruments common ingress and egress points from Spring applications (servlet filter, async endpoints, +rest template, scheduled actions, message channels, zuul filters, feign client).

      +
    • +
    • +

      Sleuth includes default logic to join a trace across http or messaging boundaries. For example, http propagation works via Zipkin-compatible request headers. This propagation logic is defined and customized via -`SpanInjector` and `SpanExtractor` implementations. - -* Provides simple metrics of accepted / dropped spans. - -* If `spring-cloud-sleuth-zipkin` then the app will generate and collect Zipkin-compatible traces. +SpanInjector and SpanExtractor implementations.

      +
    • +
    • +

      Provides simple metrics of accepted / dropped spans.

      +
    • +
    • +

      If spring-cloud-sleuth-zipkin then the app will generate and collect Zipkin-compatible traces. By default it sends them via HTTP to a Zipkin server on localhost (port 9411). -Configure the location of the service using `spring.zipkin.baseUrl`. - -* If `spring-cloud-sleuth-stream` then the app will generate and collect traces via https://github.com/spring-cloud/spring-cloud-stream[Spring Cloud Stream]. +Configure the location of the service using spring.zipkin.baseUrl.

      +
    • +
    • +

      If spring-cloud-sleuth-stream then the app will generate and collect traces via Spring Cloud Stream. Your app automatically becomes a producer of tracer messages that are sent over your broker of choice -(e.g. RabbitMQ, Apache Kafka, Redis). - -IMPORTANT: If using Zipkin or Stream, configure the percentage of spans exported using `spring.sleuth.sampler.percentage` -(default 0.1, i.e. 10%). *Otherwise you might think that Sleuth is not working cause it's omitting some spans.* - -NOTE: the SLF4J MDC is always set and logback users will immediately see the trace and span ids in logs per the example +(e.g. RabbitMQ, Apache Kafka, Redis).

      +
    • +
    +
    +
    + + + + + +
    +
    Important
    +
    +If using Zipkin or Stream, configure the percentage of spans exported using spring.sleuth.sampler.percentage +(default 0.1, i.e. 10%). Otherwise you might think that Sleuth is not working cause it’s omitting some spans. +
    +
    +
    + + + + + +
    +
    Note
    +
    +the SLF4J MDC is always set and logback users will immediately see the trace and span ids in logs per the example above. Other logging systems have to configure their own formatter to get the same result. The default is - `logging.pattern.level` set to `%clr(%5p) %clr([${spring.application.name:},%X{X-B3-TraceId:-},%X{X-B3-SpanId:-},%X{X-Span-Export:-}]){yellow}` + logging.pattern.level set to %clr(%5p) %clr([${spring.application.name:},%X{X-B3-TraceId:-},%X{X-B3-SpanId:-},%X{X-Span-Export:-}]){yellow} (this is a Spring Boot feature for logback users). - *This means that if you're not using SLF4J this pattern WILL NOT be automatically applied*. - -== Sampling - -In distributed tracing the data volumes can be very high so sampling -can be important (you usually don't need to export all spans to get a + This means that if you’re not using SLF4J this pattern WILL NOT be automatically applied. +
    +
    +
    +
    +
    +

    Sampling

    +
    +
    +

    In distributed tracing the data volumes can be very high so sampling +can be important (you usually don’t need to export all spans to get a good picture of what is happening). Spring Cloud Sleuth has a -`Sampler` strategy that you can implement to take control of the +Sampler strategy that you can implement to take control of the sampling algorithm. Samplers do not stop span (correlation) ids from being generated, but they do prevent the tags and events being attached and exported. By default you get a strategy that continues to @@ -6784,156 +7137,238 @@ non-exportable. If all your apps run with this sampler you will see traces in logs, but not in any remote store. For testing the default is often enough, and it probably is all you need if you are only using the logs (e.g. with an ELK aggregator). If you are exporting span data -to Zipkin or Spring Cloud Stream, there is also an `AlwaysSampler` -that exports everything and a `PercentageBasedSampler` that samples a -fixed fraction of spans. - -NOTE: the `PercentageBasedSampler` is the default if you are using -`spring-cloud-sleuth-zipkin` or `spring-cloud-sleuth-stream`. You can -configure the exports using `spring.sleuth.sampler.percentage`. - -A sampler can be installed just by creating a bean definition, e.g: - -[source,java] +to Zipkin or Spring Cloud Stream, there is also an AlwaysSampler +that exports everything and a PercentageBasedSampler that samples a +fixed fraction of spans.

    +
    + + + + + +
    +
    Note
    +
    +the PercentageBasedSampler is the default if you are using +spring-cloud-sleuth-zipkin or spring-cloud-sleuth-stream. You can +configure the exports using spring.sleuth.sampler.percentage. +
    -

    @Bean -public Sampler defaultSampler() { - return new AlwaysSampler(); -}

    +

    A sampler can be installed just by creating a bean definition, e.g:

    -
    == Instrumentation
    -
    -Spring Cloud Sleuth instruments all your Spring application
    -automatically, so you shouldn't have to do anything to activate
    +
    @Bean
    +public Sampler defaultSampler() {
    +    return new AlwaysSampler();
    +}
    +
    +
    +
    +
    +
    +

    Instrumentation

    +
    +
    +

    Spring Cloud Sleuth instruments all your Spring application +automatically, so you shouldn’t have to do anything to activate it. The instrumentation is added using a variety of technologies according to the stack that is available, e.g. for a servlet web -application we use a `Filter`, and for Spring Integration we use -`ChannelInterceptors`. - -You can customize the keys used in span tags. To limit the volume of -span data, by default an HTTP request will be tagged only with a -handful of metadata like the status code, host and URL. You can add -request headers by configuring `spring.sleuth.keys.http.headers` (a -list of header names). - -NOTE: Remember that tags are only collected and exported if there is a -`Sampler` that allows it (by default there is not, so there is no -danger of accidentally collecting too much data without configuring -something). - -NOTE: Currently the instrumentation in Spring Cloud Sleuth is eager - it means that -we're actively trying to pass the tracing context between threads. Also timing events -are captured even when sleuth isn't exporting data to a tracing system. -This approach may change in the future towards being lazy on this matter. - -== Span lifecycle - -You can do the following operations on the Span by means of *Tracer* interface: - -- <<creating-and-closing-spans, start>> - when you start a span its name is assigned and start timestamp is recorded. -- <<creating-and-closing-spans, close>> - the span gets finished (the end time of the span is recorded) and if -the span is *exportable* then it will be eligible for collection to Zipkin. -The span is also removed from the current thread. -- <<continuing-spans, continue>> - a new instance of span will be created whereas it will be a copy of the -one that it continues. -- <<continuing-spans, detach>> - the span doesn't get stopped or closed. It only gets removed from the current thread. -- <<creating-spans-with-explicit-parent, create with explicit parent>> - you can create a new span and set an explicit parent to it - -=== Creating and closing spans [[creating-and-closing-spans]] - -You can manually create spans by using the *Tracer* interface. - -[source,java] -

    +application we use a Filter, and for Spring Integration we use +ChannelInterceptors.

    -

    Span newSpan = this.tracer.createSpan("calculateTax"); +

    You can customize the keys used in span tags. To limit the volume of +span data, by default an HTTP request will be tagged only with a +handful of metadata like the status code, host and URL. You can add +request headers by configuring spring.sleuth.keys.http.headers (a +list of header names).

    +
    +
    + + + + + +
    +
    Note
    +
    +Remember that tags are only collected and exported if there is a +Sampler that allows it (by default there is not, so there is no +danger of accidentally collecting too much data without configuring +something). +
    +
    +
    + + + + + +
    +
    Note
    +
    +Currently the instrumentation in Spring Cloud Sleuth is eager - it means that +we’re actively trying to pass the tracing context between threads. Also timing events +are captured even when sleuth isn’t exporting data to a tracing system. +This approach may change in the future towards being lazy on this matter. +
    +
    +
    +
    +
    +

    Span lifecycle

    +
    +
    +

    You can do the following operations on the Span by means of Tracer interface:

    +
    +
    +
      +
    • +

      start - when you start a span its name is assigned and start timestamp is recorded.

      +
    • +
    • +

      close - the span gets finished (the end time of the span is recorded) and if +the span is exportable then it will be eligible for collection to Zipkin. +The span is also removed from the current thread.

      +
    • +
    • +

      continue - a new instance of span will be created whereas it will be a copy of the +one that it continues.

      +
    • +
    • +

      detach - the span doesn’t get stopped or closed. It only gets removed from the current thread.

      +
    • +
    • +

      create with explicit parent - you can create a new span and set an explicit parent to it

      +
    • +
    +
    +
    +

    Creating and closing spans

    +
    +

    You can manually create spans by using the Tracer interface.

    +
    +
    +
    +
    // Start a span. If there was a span present in this thread it will become
    +// the `newSpan`'s parent.
    +Span newSpan = this.tracer.createSpan("calculateTax");
     try {
    -    // …​
    +    // ...
         // You can tag a span
         this.tracer.addTag("taxValue", taxValue);
    -    // …​
    +    // ...
         // You can log an event on a span
         newSpan.logEvent("taxCalculated");
     } finally {
         // Once done remember to close the span. This will allow collecting
         // the span to send it to Zipkin
         this.tracer.close(newSpan);
    -}

    -
    -
    -
    -
    In this example we could see how to create a new instance of span. Assuming that there already
    -was a span present in this thread then it would become the parent of that span.
    -
    -IMPORTANT: Always clean after you create a span! Don't forget to close a span if you want to send it to Zipkin.
    -
    -=== Continuing spans [[continuing-spans]]
    -
    -Sometimes you don't want to create a new span but you want to continue one. Example of such a
    -situation might be (of course it all depends on the use-case):
    -
    -    - *AOP* - If there was already a span created before an aspect was reached then you might not want to create a new span.
    -    - *Hystrix* - executing a Hystrix command is most likely a logical part of the current processing. It's in fact
    -    only a technical implementation detail that you wouldn't necessarily want to reflect in tracing as a separate being.
    -
    -The continued instance of span is equal to the one that it continues:
    -[source,java]
    +}
    -

    Span continuedSpan = this.tracer.continueSpan(spanToContinue); -assertThat(continuedSpan).isEqualTo(spanToContinue);

    +

    In this example we could see how to create a new instance of span. Assuming that there already +was a span present in this thread then it would become the parent of that span.

    +
    +
    + + + + + +
    +
    Important
    +
    +Always clean after you create a span! Don’t forget to close a span if you want to send it to Zipkin. +
    +
    +
    +
    +

    Continuing spans

    +
    +

    Sometimes you don’t want to create a new span but you want to continue one. Example of such a +situation might be (of course it all depends on the use-case):

    +
    +
    +
      +
    • +

      AOP - If there was already a span created before an aspect was reached then you might not want to create a new span.

      +
    • +
    • +

      Hystrix - executing a Hystrix command is most likely a logical part of the current processing. It’s in fact +only a technical implementation detail that you wouldn’t necessarily want to reflect in tracing as a separate being.

      +
    • +
    +
    +
    +

    The continued instance of span is equal to the one that it continues:

    -
    To continue a span you can use the *Tracer* interface.
    -
    -[source,java]
    +
    Span continuedSpan = this.tracer.continueSpan(spanToContinue);
    +assertThat(continuedSpan).isEqualTo(spanToContinue);
    -

    Span continuedSpan = this.tracer.continueSpan(initialSpan); +

    To continue a span you can use the Tracer interface.

    +
    +
    +
    +
    // let's assume that we're in a thread Y and we've received
    +// the `initialSpan` from thread X
    +Span continuedSpan = this.tracer.continueSpan(initialSpan);
     try {
    -    // …​
    +    // ...
         // You can tag a span
         this.tracer.addTag("taxValue", taxValue);
    -    // …​
    +    // ...
         // You can log an event on a span
         continuedSpan.logEvent("taxCalculated");
     } finally {
    -    // Once done remember to detach the span. That way you’ll
    +    // Once done remember to detach the span. That way you'll
         // safely remove it from the current thread without closing it
         this.tracer.detach(continuedSpan);
    -}

    +}
    +
    +
    +
    + + + + + +
    +
    Important
    +
    +Always clean after you create a span! Don’t forget to detach a span if some work was done started in one + thread (e.g. thread X) and it’s waiting for other threads (e.g. Y, Z) to finish. + Then the spans in the threads Y, Z should be detached at the end of their work. When the results are collected + the span in thread X should be closed. +
    +
    +
    +
    +

    Creating spans with an explicit parent

    +
    +

    There is a possibility that you want to start a new span and provide an explicit parent of that span. +Let’s assume that the parent of a span is in one thread and you want to start a new span in another thread. The +startSpan method of the Tracer interface is the method you are looking for.

    -
    IMPORTANT: Always clean after you create a span! Don't forget to detach a span if some work was done started in one
    - thread (e.g. thread X) and it's waiting for other threads (e.g. Y, Z) to finish.
    - Then the spans in the threads Y, Z should be detached at the end of their work. When the results are collected
    - the span in thread X should be closed.
    -
    -=== Creating spans with an explicit parent [[creating-spans-with-explicit-parent]]
    -
    -There is a possibility that you want to start a new span and provide an explicit parent of that span.
    -Let's assume that the parent of a span is in one thread and you want to start a new span in another thread. The
    -`startSpan` method of the `Tracer` interface is the method you are looking for.
    -
    -[source,java]
    -
    -
    -
    -

    Span newSpan = this.tracer.createSpan("calculateCommission", initialSpan); +

    // let's assume that we're in a thread Y and we've received
    +// the `initialSpan` from thread X. `initialSpan` will be the parent
    +// of the `newSpan`
    +Span newSpan = this.tracer.createSpan("calculateCommission", initialSpan);
     try {
    -    // …​
    +    // ...
         // You can tag a span
         this.tracer.addTag("commissionValue", commissionValue);
    -    // …​
    +    // ...
         // You can log an event on a span
         newSpan.logEvent("commissionCalculated");
     } finally {
    @@ -6941,179 +7376,214 @@ try {
         // the span to send it to Zipkin. The tags and events set on the
         // newSpan will not be present on the parent
         this.tracer.close(newSpan);
    -}

    +}
    +
    +
    +
    + + + + + +
    +
    Important
    +
    +After having created such a span remember to close it. Otherwise you will see a lot of warnings in your logs + related to the fact that you have a span present in the current thread other than the one you’re trying to close. + What’s worse your spans won’t get closed properly thus will not get collected to Zipkin. +
    +
    +
    +
    +
    +
    +

    Naming spans

    +
    +
    +

    Picking a span name is not a trivial task. Span name should depict an operation name. The name should +be low cardinality (e.g. not include identifiers).

    +
    +
    +

    Since there is a lot of instrumentation going on some of the span names will be +artificial like:

    +
    +
    +
      +
    • +

      http:path when received an http request on a given path

      +
    • +
    • +

      async for asynchronous operations done via wrapped Callable and Runnable.

      +
    • +
    • +

      @Scheduled annotated methods will return the simple name of the class.

      +
    • +
    +
    +
    +

    Fortunately, for the asynchronous processing you can provide explicit naming.

    +
    +
    +

    @SpanName annotation

    +
    +

    You can do name the span explicitly via the @SpanName annotation.

    -
    IMPORTANT: After having created such a span remember to close it. Otherwise you will see a lot of warnings in your logs
    - related to the fact that you have a span present in the current thread other than the one you're trying to close.
    - What's worse your spans won't get closed properly thus will not get collected to Zipkin.
    +
    @SpanName("calculateTax")
    +class TaxCountingRunnable implements Runnable {
     
    -== Naming spans
    -
    -Picking a span name is not a trivial task. Span name should depict an operation name. The name should
    -be low cardinality (e.g. not include identifiers).
    -
    -Since there is a lot of instrumentation going on some of the span names will be
    -artificial like:
    -
    -- `http:path` when received an http request on a given path
    -- `async` for asynchronous operations done via wrapped `Callable` and `Runnable`.
    -- `@Scheduled` annotated methods will return the simple name of the class.
    -
    -Fortunately, for the asynchronous processing you can provide explicit naming.
    -
    -=== @SpanName annotation
    -
    -You can do name the span explicitly via the `@SpanName` annotation.
    -
    -[source,java]
    -
    -
    -
    -

    @SpanName("calculateTax") -class TaxCountingRunnable implements Runnable {

    -
    -
    -
    -
        @Override public void run() {
    -        // perform logic
    -    }
    -}
    -
    -
    -
    -
    -
    In this case, when processed in the following manner:
    -
    -[source,java]
    -
    -
    -
    -

    Runnable runnable = new TraceRunnable(tracer, spanNamer, new TaxCountingRunnable()); -Future<?> future = executorService.submit(runnable); -future.get();

    -
    -
    -
    -
    The span will be named `calculateTax`.
    -
    -=== toString() method
    -
    -It's pretty rare to create separate classes for `Runnable` or `Callable`. Typically one creates an anonymous
    -instance of those classes. You can't annotate such classes thus to override that, if there is no `@SpanName` annotation present,
    -we're checking if the class has a custom implementation of the `toString()` method.
    -
    -So executing such code:
    -
    -[source,java]
    -
    -
    -
    -

    Runnable runnable = new TraceRunnable(tracer, spanNamer, new Runnable() { @Override public void run() { // perform logic - }

    + } +}
    -
    +
    +
    +

    In this case, when processed in the following manner:

    +
    +
    -
        @Override public String toString() {
    +
    Runnable runnable = new TraceRunnable(tracer, spanNamer, new TaxCountingRunnable());
    +Future<?> future = executorService.submit(runnable);
    +// ... some additional logic ...
    +future.get();
    +
    +
    +
    +

    The span will be named calculateTax.

    +
    +
    +
    +

    toString() method

    +
    +

    It’s pretty rare to create separate classes for Runnable or Callable. Typically one creates an anonymous +instance of those classes. You can’t annotate such classes thus to override that, if there is no @SpanName annotation present, +we’re checking if the class has a custom implementation of the toString() method.

    +
    +
    +

    So executing such code:

    +
    +
    +
    +
    Runnable runnable = new TraceRunnable(tracer, spanNamer, new Runnable() {
    +    @Override public void run() {
    +        // perform logic
    +    }
    +
    +    @Override public String toString() {
             return "calculateTax";
         }
     });
     Future<?> future = executorService.submit(runnable);
     // ... some additional logic ...
    -future.get();
    +future.get();
    -
    -
    -
    will lead in creating a span named `calculateTax`.
    -
    -== Customizations
    -
    -Thanks to the `SpanInjector` and `SpanExtractor` you can customize the way spans
    -are created and propagated.
    -
    -There are currently two built-in ways to pass tracing information between processes:
    -
    - * via Spring Integration
    - * via HTTP
    -
    -Span ids are extracted from Zipkin-compatible (B3) headers (either `Message`
    +
    +

    will lead in creating a span named calculateTax.

    +
    +
    +
    +
    +
    +

    Customizations

    +
    +
    +

    Thanks to the SpanInjector and SpanExtractor you can customize the way spans +are created and propagated.

    +
    +
    +

    There are currently two built-in ways to pass tracing information between processes:

    +
    +
    +
      +
    • +

      via Spring Integration

      +
    • +
    • +

      via HTTP

      +
    • +
    +
    +
    +

    Span ids are extracted from Zipkin-compatible (B3) headers (either Message or HTTP headers), to start or join an existing trace. Trace information is -injected into any outbound requests so the next hop can extract them. - -=== Spring Integration - -For Spring Integration these are the beans responsible for creation of a Span from a `Message` - and filling in the `MessageBuilder` with tracing information. - -[source,java] -

    +injected into any outbound requests so the next hop can extract them.

    +
    +

    Spring Integration

    -

    @Bean +

    For Spring Integration these are the beans responsible for creation of a Span from a Message + and filling in the MessageBuilder with tracing information.

    +
    +
    +
    +
    @Bean
     public SpanExtractor<Message> messagingSpanExtractor() {
    -    …​
    -}

    -
    -
    -

    @Bean + ... +} + +@Bean public SpanInjector<MessageBuilder> messagingSpanInjector() { - …​ -}

    -
    -
    -
    -
    You can override them by providing your own implementation and by adding a `@Primary` annotation
    -to your bean definition.
    -
    -=== HTTP
    -
    -For HTTP these are the beans responsible for creation of a Span from a `HttpServletRequest`
    -  and filling in the `HttpServletResponse` with tracing information.
    -
    -[source,java]
    + ... +}
    -

    @Bean +

    You can override them by providing your own implementation and by adding a @Primary annotation +to your bean definition.

    +
    +
    +
    +

    HTTP

    +
    +

    For HTTP these are the beans responsible for creation of a Span from a HttpServletRequest + and filling in the HttpServletResponse with tracing information.

    +
    +
    +
    +
    @Bean
     public SpanExtractor<HttpServletRequest> httpServletRequestSpanExtractor() {
    -    …​
    -}

    + ... +} + +@Bean +public SpanInjector<HttpServletResponse> httpServletResponseSpanInjector() { + ... +}
    +
    -

    @Bean -public SpanInjector<HttpServletResponse> httpServletResponseSpanInjector() { - …​ -}

    +

    You can override them by providing your own implementation and by adding a @Primary annotation +to your bean definition.

    +
    +
    +
    +

    Example

    +
    +

    Let’s assume that instead of the standard Zipkin compatible tracing HTTP header names +you have

    +
    +
    +
      +
    • +

      for trace id - correlationId

      +
    • +
    • +

      for span id - mySpanId

      +
    • +
    +
    +
    +

    This is a an example of a SpanExtractor

    -
    You can override them by providing your own implementation and by adding a `@Primary` annotation
    -to your bean definition.
    +
    static class CustomHttpServletRequestSpanExtractor
    +        implements SpanExtractor<HttpServletRequest> {
     
    -=== Example
    -
    -Let's assume that instead of the standard Zipkin compatible tracing HTTP header names
    -you have
    -
    -* for trace id - `correlationId`
    -* for span id - `mySpanId`
    -
    -This is a an example of a `SpanExtractor`
    -
    -[source,java]
    -
    -
    -
    -

    static class CustomHttpServletRequestSpanExtractor - implements SpanExtractor<HttpServletRequest> {

    -
    -
    -
    -
        @Override
    +    @Override
         public Span joinTrace(HttpServletRequest carrier) {
             long traceId = Span.hexToId(carrier.getHeader("correlationId"));
             long spanId = Span.hexToId(carrier.getHeader("mySpanId"));
    @@ -7122,101 +7592,94 @@ This is a an example of a `SpanExtractor`
             // build rest of the Span
             return builder.build();
         }
    -}
    -
    -
    -
    -
    -
    The following `SpanInjector` could be created
    -
    -[source,java]
    +}
    -

    static class CustomHttpServletResponseSpanInjector - implements SpanInjector<HttpServletResponse> {

    +

    The following SpanInjector could be created

    -
    +
    -
        @Override
    +
    static class CustomHttpServletResponseSpanInjector
    +        implements SpanInjector<HttpServletResponse> {
    +
    +    @Override
         public void inject(Span span, HttpServletResponse carrier) {
             carrier.addHeader("correlationId", Span.idToHex(span.getTraceId()));
             carrier.addHeader("mySpanId", Span.idToHex(span.getSpanId()));
             // inject the rest of Span values to the header
         }
    -}
    -
    -
    -
    -
    -
    And you could register them like this:
    -
    -[source,java]
    +}
    -

    @Bean +

    And you could register them like this:

    +
    +
    +
    +
    @Bean
     @Primary
     SpanExtractor<HttpServletRequest> customHttpServletRequestSpanExtractor() {
         return new CustomHttpServletRequestSpanExtractor();
    -}

    -
    -
    -

    @Bean +} + +@Bean @Primary SpanInjector<HttpServletResponse> customHttpServletResponseSpanInjector() { return new CustomHttpServletResponseSpanInjector(); -}

    +}
    +
    +
    +
    +
    +
    +
    +

    Span Data as Messages

    +
    +
    +

    You can accumulate and send span data over +Spring Cloud Stream by +including the spring-cloud-sleuth-stream jar as a dependency, and +adding a Channel Binder implementation +(e.g. spring-cloud-starter-stream-rabbit for RabbitMQ or +spring-cloud-starter-stream-kafka for Kafka). This will +automatically turn your app into a producer of messages with payload +type Spans.

    +
    +
    +

    Zipkin Consumer

    +
    +

    There is a special convenience annotation for setting up a message consumer +for the Span data and pushing it into a Zipkin SpanStore. This application

    -
    == Span Data as Messages
    -
    -You can accumulate and send span data over
    -http://cloud.spring.io/spring-cloud-stream[Spring Cloud Stream] by
    -including the `spring-cloud-sleuth-stream` jar as a dependency, and
    -adding a Channel Binder implementation
    -(e.g. `spring-cloud-starter-stream-rabbit` for RabbitMQ or
    -`spring-cloud-starter-stream-kafka` for Kafka). This will
    -automatically turn your app into a producer of messages with payload
    -type `Spans`.
    -
    -=== Zipkin Consumer
    -
    -There is a special convenience annotation for setting up a message consumer
    -for the Span data and pushing it into a Zipkin `SpanStore`. This application
    -
    -[source,java]
    -
    -
    -
    -

    @SpringBootApplication +

    @SpringBootApplication
     @EnableZipkinStreamServer
     public class Consumer {
     	public static void main(String[] args) {
     		SpringApplication.run(Consumer.class, args);
     	}
    -}

    -
    -
    -
    -
    will listen for the Span data on whatever transport you provide via a
    -Spring Cloud Stream `Binder` (e.g. include
    -`spring-cloud-starter-stream-rabbit` for RabbitMQ, and similar
    -starters exist for Redis and Kafka). The app will also be a
    -https://github.com/openzipkin/zipkin-java[Zipkin server], which hosts
    -the UI and api on port 9411.
    -
    -The default `SpanStore` is in-memory (good for demos and getting
    -started quickly). For a more robust solution you can add MySQL and
    -`spring-boot-starter-jdbc` to your classpath and enable the JDBC
    -`SpanStore` via configuration, e.g.:
    -
    -[source,yaml]
    +}
    -

    spring: +

    will listen for the Span data on whatever transport you provide via a +Spring Cloud Stream Binder (e.g. include +spring-cloud-starter-stream-rabbit for RabbitMQ, and similar +starters exist for Redis and Kafka). The app will also be a +Zipkin server, which hosts +the UI and api on port 9411.

    +
    +
    +

    The default SpanStore is in-memory (good for demos and getting +started quickly). For a more robust solution you can add MySQL and +spring-boot-starter-jdbc to your classpath and enable the JDBC +SpanStore via configuration, e.g.:

    +
    +
    +
    +
    spring:
       rabbitmq:
         host: ${RABBIT_HOST:localhost}
       datasource:
    @@ -7231,74 +7694,95 @@ started quickly). For a more robust solution you can add MySQL and
         enabled: false
     zipkin:
       store:
    -    type: mysql

    + type: mysql
    +
    +
    +
    + + + + + +
    +
    Note
    +
    +The @EnableZipkinStreamServer is also annotated with +@EnableZipkinServer so the process will also expose the standard +Zipkin server endpoints for collecting spans over HTTP, and for +querying in the Zipkin Web UI. +
    +
    +
    +
    +

    Custom Consumer

    +
    +

    A custom consumer can also easily be implemented using +spring-cloud-sleuth-stream and binding to the SleuthSink. Example:

    -
    NOTE: The `@EnableZipkinStreamServer` is also annotated with
    -`@EnableZipkinServer` so the process will also expose the standard
    -Zipkin server endpoints for collecting spans over HTTP, and for
    -querying in the Zipkin Web UI.
    -
    -=== Custom Consumer
    -
    -A custom consumer can also easily be implemented using
    -`spring-cloud-sleuth-stream` and binding to the `SleuthSink`. Example:
    -
    -[source,java]
    -
    -
    -
    -

    @EnableBinding(SleuthSink.class) +

    @EnableBinding(SleuthSink.class)
     @SpringBootApplication(exclude = SleuthStreamAutoConfiguration.class)
     @MessageEndpoint
    -public class Consumer {

    -
    -
    -
    -
        @ServiceActivator(inputChannel = SleuthSink.INPUT)
    +public class Consumer {
    +
    +    @ServiceActivator(inputChannel = SleuthSink.INPUT)
         public void sink(Spans input) throws Exception {
             // ... process spans
         }
    -}
    +}
    +
    + + + + + +
    +
    Note
    +
    +the sample consumer application above explicitly excludes +SleuthStreamAutoConfiguration so it doesn’t send messages to itself, +but this is optional (you might actually want to trace requests into +the consumer app). +
    +
    +
    +
    +
    +
    +

    Metrics

    +
    +
    +

    Currently Spring Cloud Sleuth registers very simple metrics related to spans. +It’s using the Spring Boot’s metrics support +to calculate the number of accepted and dropped spans. Each time a span gets +sent to Zipkin the number of accepted spans will increase. If there’s an error then +the number of dropped spans will get increased.

    +
    +
    +
    +
    +

    Integrations

    +
    +
    +

    Runnable and Callable

    +
    +

    If you’re wrapping your logic in Runnable or Callable it’s enough to wrap those classes in their Sleuth representative.

    +
    +
    +

    Example for Runnable:

    +
    -
    NOTE: the sample consumer application above explicitly excludes
    -`SleuthStreamAutoConfiguration` so it doesn't send messages to itself,
    -but this is optional (you might actually want to trace requests into
    -the consumer app).
    -
    -== Metrics
    -
    -Currently Spring Cloud Sleuth registers very simple metrics related to spans.
    -It's using the http://docs.spring.io/spring-boot/docs/current/reference/html/production-ready-metrics.html#production-ready-recording-metrics[Spring Boot's metrics support]
    -to calculate the number of accepted and dropped spans. Each time a span gets
    -sent to Zipkin the number of accepted spans will increase. If there's an error then
    -the number of dropped spans will get increased.
    -
    -== Integrations
    -
    -=== Runnable and Callable
    -
    -If you're wrapping your logic in `Runnable` or `Callable` it's enough to wrap those classes in their Sleuth representative.
    -
    -Example for `Runnable`:
    -
    -[source,java]
    -
    -
    -
    -

    Runnable runnable = new Runnable() { +

    Runnable runnable = new Runnable() {
         @Override
         public void run() {
             // do some work
    -    }

    -
    -
    -
    -
        @Override
    +    }
    +
    +    @Override
         public String toString() {
             return "spanNameFromToStringMethod";
         }
    @@ -7307,26 +7791,21 @@ Example for `Runnable`:
     Runnable traceRunnable = new TraceRunnable(tracer, spanNamer, runnable, "calculateTax");
     // Wrapping `Runnable` with `Tracer`. The Span name will be taken either from the
     // `@SpanName` annotation or from `toString` method
    -Runnable traceRunnableFromTracer = tracer.wrap(runnable);
    -
    -
    -
    -
    -
    Example for `Callable`:
    -
    -[source,java]
    +Runnable traceRunnableFromTracer = tracer.wrap(runnable);
    -

    Callable<String> callable = new Callable<String>() { +

    Example for Callable:

    +
    +
    +
    +
    Callable<String> callable = new Callable<String>() {
         @Override
         public String call() throws Exception {
             return someLogic();
    -    }

    -
    -
    -
    -
        @Override
    +    }
    +
    +    @Override
         public String toString() {
             return "spanNameFromToStringMethod";
         }
    @@ -7335,139 +7814,180 @@ Runnable traceRunnableFromTracer = tracer.wrap(runnable);
    Callable<String> traceCallable = new TraceCallable<>(tracer, spanNamer, callable, "calculateTax"); // Wrapping `Callable` with `Tracer`. The Span name will be taken either from the // `@SpanName` annotation or from `toString` method -Callable<String> traceCallableFromTracer = tracer.wrap(callable); -
    -
    -
    -
    -
    That way you will ensure that a new Span is created and closed for each execution.
    -
    -=== Hystrix
    -
    -==== Custom Concurrency Strategy
    -
    -We're registering a custom https://github.com/Netflix/Hystrix/wiki/Plugins#concurrencystrategy[`HystrixConcurrencyStrategy`]
    -that wraps all `Callable` instances into their Sleuth representative -
    -the `TraceCallable`. The strategy either starts or continues a span depending on the fact whether tracing was already going
    -on before the Hystrix command was called. To disable the custom Hystrix Concurrency Strategy set the `spring.sleuth.hystrix.strategy.enabled` to `false`.
    -
    -==== Manual Command setting
    -
    -Assuming that you have the following `HystrixCommand`:
    -
    -[source,java]
    +Callable<String> traceCallableFromTracer = tracer.wrap(callable);
    -

    HystrixCommand<String> hystrixCommand = new HystrixCommand<String>(setter) { +

    That way you will ensure that a new Span is created and closed for each execution.

    +
    +
    +
    +

    Hystrix

    +
    +

    Custom Concurrency Strategy

    +
    +

    We’re registering a custom HystrixConcurrencyStrategy +that wraps all Callable instances into their Sleuth representative - +the TraceCallable. The strategy either starts or continues a span depending on the fact whether tracing was already going +on before the Hystrix command was called. To disable the custom Hystrix Concurrency Strategy set the spring.sleuth.hystrix.strategy.enabled to false.

    +
    +
    +
    +

    Manual Command setting

    +
    +

    Assuming that you have the following HystrixCommand:

    +
    +
    +
    +
    HystrixCommand<String> hystrixCommand = new HystrixCommand<String>(setter) {
         @Override
         protected String run() throws Exception {
             return someLogic();
         }
    -};

    -
    -
    -
    -
    In order to pass the tracing information you have to wrap the same logic in the Sleuth version of the `HystrixCommand` which is the
    -`TraceCommand`:
    -
    -[source,java]
    +};
    -

    TraceCommand<String> traceCommand = new TraceCommand<String>(tracer, traceKeys, setter) { +

    In order to pass the tracing information you have to wrap the same logic in the Sleuth version of the HystrixCommand which is the +TraceCommand:

    +
    +
    +
    +
    TraceCommand<String> traceCommand = new TraceCommand<String>(tracer, traceKeys, setter) {
         @Override
         public String doRun() throws Exception {
             return someLogic();
         }
    -};

    +};
    -
    -
    -
    === HTTP integration
    -
    -Features from this section can be disabled by providing the `spring.sleuth.web.enabled` property with value equal to `false`.
    -
    -==== HTTP Filter
    -
    -Via the `TraceFilter` all sampled incoming requests result in creation of a Span. That Span's name is `http:` + the path to which
    - the request was sent. E.g. if the request was sent to `/foo/bar` then the name will be `http:/foo/bar`. You can configure which URIs you would
    - like to skip via the `spring.sleuth.web.skipPattern` property. If you have `ManagementServerProperties` on classpath then
    - its value of `contextPath` gets appended to the provided skip pattern.
    -
    -==== Async Servlet support
    -
    -If your controller returns a `Callable` or a `WebAsyncTask` Spring Cloud Sleuth will continue the existing span instead of creating a new one.
    -
    -=== HTTP client integration
    -
    -==== Synchronous Rest Template
    -
    -We're injecting a `RestTemplate` interceptor that ensures that all the tracing information is passed to the requests. Each time a
    -call is made a new Span is created. It gets closed upon receiving the response. In order to block the synchronous `RestTemplate` features
    -just set `spring.sleuth.web.client.enabled` to `false`.
    -
    -==== Asynchronous Rest Template
    -
    -Custom instrumentation is set to create and close Spans upon sending and receiving requests. To block the `AsyncRestTemplate`
    -features set `spring.sleuth.web.async.client.enabled` to `false`.
    -
    -=== Feign
    -
    -By default Spring Cloud Sleuth provides integration with feign via the `TraceFeignClientAutoConfiguration`. You can disable it entirely
    -by setting `spring.sleuth.feign.enabled` to false. If you do so then no Feign related instrumentation will take place.
    -
    -Part of Feign instrumentation is done via a `FeignBeanPostProcessor`. You can disable it by providing the `spring.sleuth.feign.processor.enabled` equal to `false`.
    +
    +
    +
    +
    +

    HTTP integration

    +
    +

    Features from this section can be disabled by providing the spring.sleuth.web.enabled property with value equal to false.

    +
    +
    +

    HTTP Filter

    +
    +

    Via the TraceFilter all sampled incoming requests result in creation of a Span. That Span’s name is http: + the path to which + the request was sent. E.g. if the request was sent to /foo/bar then the name will be http:/foo/bar. You can configure which URIs you would + like to skip via the spring.sleuth.web.skipPattern property. If you have ManagementServerProperties on classpath then + its value of contextPath gets appended to the provided skip pattern.

    +
    +
    +
    +

    Async Servlet support

    +
    +

    If your controller returns a Callable or a WebAsyncTask Spring Cloud Sleuth will continue the existing span instead of creating a new one.

    +
    +
    +
    +
    +

    HTTP client integration

    +
    +

    Synchronous Rest Template

    +
    +

    We’re injecting a RestTemplate interceptor that ensures that all the tracing information is passed to the requests. Each time a +call is made a new Span is created. It gets closed upon receiving the response. In order to block the synchronous RestTemplate features +just set spring.sleuth.web.client.enabled to false.

    +
    +
    +
    +

    Asynchronous Rest Template

    +
    +

    Custom instrumentation is set to create and close Spans upon sending and receiving requests. To block the AsyncRestTemplate +features set spring.sleuth.web.async.client.enabled to false.

    +
    +
    +
    +
    +

    Feign

    +
    +

    By default Spring Cloud Sleuth provides integration with feign via the TraceFeignClientAutoConfiguration. You can disable it entirely +by setting spring.sleuth.feign.enabled to false. If you do so then no Feign related instrumentation will take place.

    +
    +
    +

    Part of Feign instrumentation is done via a FeignBeanPostProcessor. You can disable it by providing the spring.sleuth.feign.processor.enabled equal to false. If you set it like this then Spring Cloud Sleuth will not instrument any of your custom Feign components. All the default instrumentation -however will be still there. - -=== Asynchronous communication - -==== @Async annotated methods - -In Spring Cloud Sleuth we're instrumenting async related components so that the tracing information is passed between threads. You can disable this behaviour -by setting the value of `spring.sleuth.async.enabled` to `false`. - -If you annotate your method with `@Async` then we'll automatically create a new Span with the following characteristics: - - - the Span name will be the annotated method name - - the Span will be tagged with that method's class name and the method name too - -==== @Scheduled annotated methods - -In Spring Cloud Sleuth we're instrumenting scheduled method execution so that the tracing information is passed between threads. You can disable this behaviour -by setting the value of `spring.sleuth.scheduled.enabled` to `false`. - -If you annotate your method with `@Scheduled` then we'll automatically create a new Span with the following characteristics: - - - the Span name will be the annotated method name - - the Span will be tagged with that method's class name and the method name too - -If you want to skip Span creation for some `@Scheduled` annotated classes you can set the -`spring.sleuth.scheduled.skipPattern` with a regular expression that will match the fully qualified name of the -`@Scheduled` annotated class. - -==== Executor, ExecutorService and ScheduledExecutorService - -We're providing `LazyTraceExecutor`, `TraceableExecutorService` and `TraceableScheduledExecutorService`. Those implementations -are creating Spans each time a new task is submitted, invoked or scheduled. - -=== Messaging - -Spring Cloud Sleuth integrates with http://projects.spring.io/spring-integration/[Spring Integration]. It creates spans for publish and -subscribe events. To disable Spring Integration instrumentation, set `spring.sleuth.integration.enabled` to false. - -=== Zuul - -We're registering Zuul filters to propagate the tracing information (the request header is enriched with tracing data). -To disable Zuul support set the `spring.sleuth.zuul.enabled` property to `false`. - -:github-tag: master -:github-repo: spring-cloud/spring-cloud-consul -:github-raw: http://raw.github.com/{github-repo}/{github-tag} -:github-code: http://github.com/{github-repo}/tree/{github-tag} -= Spring Cloud Consul - +however will be still there.

    +
    +
    +
    +

    Asynchronous communication

    +
    +

    @Async annotated methods

    +
    +

    In Spring Cloud Sleuth we’re instrumenting async related components so that the tracing information is passed between threads. You can disable this behaviour +by setting the value of spring.sleuth.async.enabled to false.

    +
    +
    +

    If you annotate your method with @Async then we’ll automatically create a new Span with the following characteristics:

    +
    +
    +
      +
    • +

      the Span name will be the annotated method name

      +
    • +
    • +

      the Span will be tagged with that method’s class name and the method name too

      +
    • +
    +
    +
    +
    +

    @Scheduled annotated methods

    +
    +

    In Spring Cloud Sleuth we’re instrumenting scheduled method execution so that the tracing information is passed between threads. You can disable this behaviour +by setting the value of spring.sleuth.scheduled.enabled to false.

    +
    +
    +

    If you annotate your method with @Scheduled then we’ll automatically create a new Span with the following characteristics:

    +
    +
    +
      +
    • +

      the Span name will be the annotated method name

      +
    • +
    • +

      the Span will be tagged with that method’s class name and the method name too

      +
    • +
    +
    +
    +

    If you want to skip Span creation for some @Scheduled annotated classes you can set the +spring.sleuth.scheduled.skipPattern with a regular expression that will match the fully qualified name of the +@Scheduled annotated class.

    +
    +
    +
    +

    Executor, ExecutorService and ScheduledExecutorService

    +
    +

    We’re providing LazyTraceExecutor, TraceableExecutorService and TraceableScheduledExecutorService. Those implementations +are creating Spans each time a new task is submitted, invoked or scheduled.

    +
    +
    +
    +
    +

    Messaging

    +
    +

    Spring Cloud Sleuth integrates with Spring Integration. It creates spans for publish and +subscribe events. To disable Spring Integration instrumentation, set spring.sleuth.integration.enabled to false.

    +
    +
    +
    +

    Zuul

    +
    +

    We’re registering Zuul filters to propagate the tracing information (the request header is enriched with tracing data). +To disable Zuul support set the spring.sleuth.zuul.enabled property to false.

    +
    +
    +
    +
    +

    Spring Cloud Consul

    +
    +
    This project provides Consul 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 @@ -7475,352 +7995,407 @@ application and build large distributed systems with Consul based components. Th patterns provided include Service Discovery, Control Bus and Configuration. Intelligent Routing (Zuul) and Client Side Load Balancing (Ribbon), Circuit Breaker (Hystrix) are provided by integration with Spring Cloud Netflix. - - -[[spring-cloud-consul-install]] -== Install Consul -Please see the https://www.consul.io/intro/getting-started/install.html[installation documentation] for instructions on how to install Consul. - -[[spring-cloud-consul-agent]] -== Consul Agent - -A Consul Agent client must be available to all Spring Cloud Consul applications. By default, the Agent client is expected to be at `localhost:8500`. See the https://consul.io/docs/agent/basics.html[Agent documentation] for specifics on how to start an Agent client and how to connect to a cluster of Consul Agent Servers. For development, after you have installed consul, you may start a Consul Agent using the following command:
    +
    +

    Install Consul

    +
    +
    +

    Please see the installation documentation for instructions on how to install Consul.

    +
    +
    +
    +
    +

    Consul Agent

    +
    +
    +

    A Consul Agent client must be available to all Spring Cloud Consul applications. By default, the Agent client is expected to be at localhost:8500. See the Agent documentation for specifics on how to start an Agent client and how to connect to a cluster of Consul Agent Servers. For development, after you have installed consul, you may start a Consul Agent using the following command:

    +
    -
    /src/main/bash/local_run_consul.sh
    -
    This will start an agent in server mode on port 8500, with the ui available at http://localhost:8500
    -
    -[[spring-cloud-consul-discovery]]
    -== Service Discovery with Consul
    -
    -Service Discovery is one of the key tenets of a microservice based architecture. Trying to hand configure each client or some form of convention can be very difficult to do and can be very brittle.  Consul provides Service Discovery services via an https://www.consul.io/docs/agent/http.html[HTTP API] and https://www.consul.io/docs/agent/dns.html[DNS].  Spring Cloud Consul leverages the HTTP API for service registration and discovery.  This does not prevent non-Spring Cloud applications from leveraging the DNS interface.  Consul Agents servers are run in a https://www.consul.io/docs/internals/architecture.html[cluster] that communicates via a https://www.consul.io/docs/internals/gossip.html[gossip protocol] and uses the https://www.consul.io/docs/internals/consensus.html[Raft consensus protocol].
    -
    -=== Registering with Consul
    -
    -When a client registers with Consul, it provides meta-data about itself such as host and port, id, name and tags.  An HTTP https://www.consul.io/docs/agent/checks.html[Check] is created by default that Consul hits the `/health` endpoint every 10 seconds.  If the health check fails, the service instance is marked as critical.
    -
    -Example Consul client:
    -
    -[source,java,indent=0]
    +
    ./src/main/bash/local_run_consul.sh
    -

    @SpringBootApplication +

    This will start an agent in server mode on port 8500, with the ui available at http://localhost:8500

    +
    +
    +
    +
    +

    Service Discovery with Consul

    +
    +
    +

    Service Discovery is one of the key tenets of a microservice based architecture. Trying to hand configure each client or some form of convention can be very difficult to do and can be very brittle. Consul provides Service Discovery services via an HTTP API and DNS. Spring Cloud Consul leverages the HTTP API for service registration and discovery. This does not prevent non-Spring Cloud applications from leveraging the DNS interface. Consul Agents servers are run in a cluster that communicates via a gossip protocol and uses the Raft consensus protocol.

    +
    +
    +

    Registering with Consul

    +
    +

    When a client registers with Consul, it provides meta-data about itself such as host and port, id, name and tags. An HTTP Check is created by default that Consul hits the /health endpoint every 10 seconds. If the health check fails, the service instance is marked as critical.

    +
    +
    +

    Example Consul client:

    +
    +
    +
    +
    @SpringBootApplication
     @EnableDiscoveryClient
     @RestController
    -public class Application {

    -
    -
    -
    -
    @RequestMapping("/")
    -public String home() {
    -    return "Hello world";
    -}
    -
    -
    -
    -
    -
    public static void main(String[] args) {
    -    new SpringApplicationBuilder(Application.class).web(true).run(args);
    -}
    +public class Application { + + @RequestMapping("/") + public String home() { + return "Hello world"; + } + + public static void main(String[] args) { + new SpringApplicationBuilder(Application.class).web(true).run(args); + } + +}
    -

    }

    +

    (i.e. utterly normal Spring Boot app). If the Consul client is located somewhere other than localhost:8500, the configuration is required to locate the client. Example:

    +
    application.yml
    -
    (i.e. utterly normal Spring Boot app).  If the Consul client is located somewhere other than `localhost:8500`, the configuration is required to locate the client. Example:
    -
    -.application.yml
    -
    -
    -
    -

    spring: +

    spring:
       cloud:
         consul:
           host: localhost
    -      port: 8500

    + port: 8500
    -
    -
    -
    CAUTION: If you use <<spring-cloud-consul-config,Spring Cloud Consul Config>>, the above values will need to be placed in `bootstrap.yml` instead of `application.yml`.
    -
    -The default service name, instance id and port, taken from the `Environment`, are `${spring.application.name}`, the Spring Context ID and `${server.port}` respectively.
    -
    -`@EnableDiscoveryClient` make the app into both a Consul "service" (i.e. it registers itself) and a "client" (i.e. it can query Consul to locate other services).
    -
    -=== HTTP Health Check
    -
    -The health check for a Consul instance defaults to "/health", which is the default locations of a useful endpoint in a Spring Boot Actuator application. You need to change these, even for an Actuator application if you use a non-default context path or servlet path (e.g. `server.servletPath=/foo`) or management endpoint path (e.g. `management.contextPath=/admin`). The interval that Consul uses to check the health endpoint may also be configured.  "10s" and "1m" represent 10 seconds and 1 minute respectively.  Example:
    -
    -.application.yml
    +
    + + + + + +
    +
    Caution
    +
    +If you use Spring Cloud Consul Config, the above values will need to be placed in bootstrap.yml instead of application.yml. +
    -

    spring: +

    The default service name, instance id and port, taken from the Environment, are ${spring.application.name}, the Spring Context ID and ${server.port} respectively.

    +
    +
    +

    @EnableDiscoveryClient make the app into both a Consul "service" (i.e. it registers itself) and a "client" (i.e. it can query Consul to locate other services).

    +
    +
    +
    +

    HTTP Health Check

    +
    +

    The health check for a Consul instance defaults to "/health", which is the default locations of a useful endpoint in a Spring Boot Actuator application. You need to change these, even for an Actuator application if you use a non-default context path or servlet path (e.g. server.servletPath=/foo) or management endpoint path (e.g. management.contextPath=/admin). The interval that Consul uses to check the health endpoint may also be configured. "10s" and "1m" represent 10 seconds and 1 minute respectively. Example:

    +
    +
    +
    application.yml
    +
    +
    spring:
       cloud:
         consul:
           discovery:
             healthCheckPath: ${management.contextPath}/health
    -        healthCheckInterval: 15s

    + healthCheckInterval: 15s
    +
    +
    +
    +

    Making the Consul Instance ID Unique

    +
    +

    By default a consul instance is registered with an ID that is equal to its Spring Application Context ID. By default, the Spring Application Context ID is ${spring.application.name}:comma,separated,profiles:${server.port}. For most cases, this will allow multiple instances of one service to run on one machine. If further uniqueness is required, Using Spring Cloud you can override this by providing a unique identifier in spring.cloud.consul.discovery.instanceId. For example:

    +
    application.yml
    -
    ==== Making the Consul Instance ID Unique
    -
    -By default a consul instance is registered with an ID that is equal to its Spring Application Context ID. By default, the Spring Application Context ID is `${spring.application.name}:comma,separated,profiles:${server.port}`. For most cases, this will allow multiple instances of one service to run on one machine.  If further uniqueness is required, Using Spring Cloud you can override this by providing a unique identifier in `spring.cloud.consul.discovery.instanceId`. For example:
    -
    -.application.yml
    -
    -
    -
    -

    spring: +

    spring:
       cloud:
         consul:
           discovery:
    -        instanceId: ${spring.application.name}:${spring.application.instance_id:${random.value}}

    + instanceId: ${spring.application.name}:${spring.application.instance_id:${random.value}}
    +
    +
    +
    +

    With this metadata, and multiple service instances deployed on localhost, the random value will kick in there to make the instance unique. In Cloudfoundry the spring.application.instance_id will be populated automatically in a Spring Boot Actuator application, so the random value will not be needed.

    +
    +
    +
    +
    +

    Using the DiscoveryClient

    +
    +

    Spring Cloud has support for Feign (a REST client builder) and also Spring RestTemplate using the logical service names instead of physical URLs.

    +
    +
    +

    You can also use the org.springframework.cloud.client.discovery.DiscoveryClient which provides a simple API for discovery clients that is not specific to Netflix, e.g.

    -
    With this metadata, and multiple service instances deployed on localhost, the random value will kick in there to make the instance unique. In Cloudfoundry the `spring.application.instance_id` will be populated automatically in a Spring Boot Actuator application, so the random value will not be needed.
    +
    @Autowired
    +private DiscoveryClient discoveryClient;
     
    -=== Using the DiscoveryClient
    -Spring Cloud has support for https://github.com/spring-cloud/spring-cloud-netflix/blob/master/docs/src/main/asciidoc/spring-cloud-netflix.adoc#spring-cloud-feign[Feign] (a REST client builder) and also https://github.com/spring-cloud/spring-cloud-netflix/blob/master/docs/src/main/asciidoc/spring-cloud-netflix.adoc#spring-cloud-ribbon[Spring `RestTemplate`] using the logical service names instead of physical URLs.
    -
    -You can also use the `org.springframework.cloud.client.discovery.DiscoveryClient` which provides a simple API for discovery clients that is not specific to Netflix, e.g.
    -
    -
    -
    -

    @Autowired -private DiscoveryClient discoveryClient;

    -
    -
    -

    public String serviceUrl() { +public String serviceUrl() { List<ServiceInstance> list = client.getInstances("STORES"); if (list != null && list.size() > 0 ) { return list.get(0).getUri(); } return null; -}

    +} +
    +
    +
    +
    +
    +
    +

    Distributed Configuration with Consul

    +
    +
    +

    Consul provides a Key/Value Store for storing configuration and other metadata. Spring Cloud Consul Config is an alternative to the Config Server and Client. Configuration is loaded into the Spring Environment during the special "bootstrap" phase. Configuration is stored in the /config folder by default. Multiple PropertySource instances are created based on the application’s name and the active profiles that mimicks the Spring Cloud Config order of resolving properties. For example, an application with the name "testApp" and with the "dev" profile will have the following property sources created:

    -
    [[spring-cloud-consul-config]]
    -== Distributed Configuration with Consul
    -
    -Consul provides a https://consul.io/docs/agent/http/kv.html[Key/Value Store] for storing configuration and other metadata.  Spring Cloud Consul Config is an alternative to the https://github.com/spring-cloud/spring-cloud-config[Config Server and Client].  Configuration is loaded into the Spring Environment during the special "bootstrap" phase.  Configuration is stored in the `/config` folder by default.  Multiple `PropertySource` instances are created based on the application's name and the active profiles that mimicks the Spring Cloud Config order of resolving properties.  For example, an application with the name "testApp" and with the "dev" profile will have the following property sources created:
    -
    -
    -
    -

    config/testApp,dev/ +

    config/testApp,dev/
     config/testApp/
     config/application,dev/
    -config/application/

    -
    -
    -
    -
    The most specific property source is at the top, with the least specific at the bottom.  Properties is the `config/application` folder are applicable to all applications using consul for configuration.  Properties in the `config/testApp` folder are only available to the instances of the service named "testApp".
    -
    -Configuration is currently read on startup of the application.  Sending a HTTP POST to `/refresh` will cause the configuration to be reloaded.  Watching the key value store (which Consul supports) is not currently possible, but will be a future addition to this project.
    -
    -=== How to activate
    -
    -Including a dependency on `org.springframework.cloud:spring-cloud-consul-config` will enable auto-configuration that will setup Spring Cloud Consul Config.
    -
    -=== Customizing
    -
    -Consul Config may be customized using the following properties:
    -
    -.bootstrap.yml
    +config/application/
    -

    spring: +

    The most specific property source is at the top, with the least specific at the bottom. Properties is the config/application folder are applicable to all applications using consul for configuration. Properties in the config/testApp folder are only available to the instances of the service named "testApp".

    +
    +
    +

    Configuration is currently read on startup of the application. Sending a HTTP POST to /refresh will cause the configuration to be reloaded. Watching the key value store (which Consul supports) is not currently possible, but will be a future addition to this project.

    +
    +
    +

    How to activate

    +
    +

    Including a dependency on org.springframework.cloud:spring-cloud-consul-config will enable auto-configuration that will setup Spring Cloud Consul Config.

    +
    +
    +
    +

    Customizing

    +
    +

    Consul Config may be customized using the following properties:

    +
    +
    +
    bootstrap.yml
    +
    +
    spring:
       cloud:
         consul:
           config:
             enabled: true
             prefix: configuration
             defaultContext: apps
    -        profileSeparator: '::'

    + profileSeparator: '::'
    +
    +
    +
    +
      +
    • +

      enabled setting this value to "false" disables Consul Config

      +
    • +
    • +

      prefix sets the base folder for configuration values

      +
    • +
    • +

      defaultContext sets the folder name used by all applications

      +
    • +
    • +

      profileSeparator sets the value of the separator used to separate the profile name in property sources with profiles

      +
    • +
    +
    +
    +
    +
    +
    +

    YAML or Properties with Config

    +
    +
    +

    It may be more convenient to store a blob of properties in YAML or Properties format as opposed to individual key/value pairs. Set the spring.cloud.consul.config.format property to YAML or PROPERTIES. For example to use YAML:

    +
    bootstrap.yml
    -
    * `enabled` setting this value to "false" disables Consul Config
    -* `prefix` sets the base folder for configuration values
    -* `defaultContext` sets the folder name used by all applications
    -* `profileSeparator` sets the value of the separator used to separate the profile name in property sources with profiles
    -
    -
    -[[spring-cloud-consul-config-format]]
    -== YAML or Properties with Config
    -
    -It may be more convenient to store a blob of properties in YAML or Properties format as opposed to individual key/value pairs.  Set the `spring.cloud.consul.config.format` property to `YAML` or `PROPERTIES`. For example to use YAML:
    -
    -.bootstrap.yml
    -
    -
    -
    -

    spring: +

    spring:
       cloud:
         consul:
           config:
    -        format: YAML

    -
    -
    -
    -
    YAML must be set in the appropriate `data` key in consul. Using the defaults above the keys would look like:
    + format: YAML
    -

    config/testApp,dev/data +

    YAML must be set in the appropriate data key in consul. Using the defaults above the keys would look like:

    +
    +
    +
    +
    config/testApp,dev/data
     config/testApp/data
     config/application,dev/data
    -config/application/data

    -
    -
    -
    -
    You could store a YAML document in any of the keys listed above.
    -
    -You can change the data key using `spring.cloud.consul.config.data-key`.
    -
    -[[spring-cloud-consul-config-git2consul]]
    -== git2consul with Config
    -git2consul is a Consul community project that loads files from a git repository to individual keys into Consul. By default the names of the keys are names of the files. YAML and Properties files are supported with file extensions of `.yml` and `.properties` respectively.  Set the `spring.cloud.consul.config.format` property to `FILES`. For example:
    -
    -.bootstrap.yml
    +config/application/data
    -

    spring: +

    You could store a YAML document in any of the keys listed above.

    +
    +
    +

    You can change the data key using spring.cloud.consul.config.data-key.

    +
    +
    +
    +
    +

    git2consul with Config

    +
    +
    +

    git2consul is a Consul community project that loads files from a git repository to individual keys into Consul. By default the names of the keys are names of the files. YAML and Properties files are supported with file extensions of .yml and .properties respectively. Set the spring.cloud.consul.config.format property to FILES. For example:

    +
    +
    +
    bootstrap.yml
    +
    +
    spring:
       cloud:
         consul:
           config:
    -        format: FILES

    -
    -
    -
    -
    Given the following keys in `/config`, the `development` profile and an application name of `foo`:
    + format: FILES
    -
    gitignore
    -

    application.yml +

    Given the following keys in /config, the development profile and an application name of foo:

    +
    +
    +
    +
    .gitignore
    +application.yml
     bar.properties
     foo-development.properties
     foo-production.yml
     foo.properties
    -master.ref

    -
    -
    -
    -
    the following property sources would be created:
    +master.ref
    -

    config/foo-development.properties -config/foo.properties -config/application.yml

    +

    the following property sources would be created:

    -
    The value of each key needs to be a properly formatted YAML or Properties file.
    -
    -
    -[[spring-cloud-consul-failfast]]
    -== Fail Fast
    -
    -It may be convenient in certain circumstances (like local development or certain test scenarios) to not fail if consul isn't available for configuration. Setting `spring.cloud.consul.config.failFast=false` in `bootstrap.yml` will cause the configuration module to log a warning rather than throw an exception. This will allow the application to continue startup normally.
    -
    -[[spring-cloud-consul-retry]]
    -== Consul Retry
    -
    -If you expect that the consul agent may occasionally be unavailable when
    +
    config/foo-development.properties
    +config/foo.properties
    +config/application.yml
    +
    +
    +
    +

    The value of each key needs to be a properly formatted YAML or Properties file.

    +
    +
    +
    +
    +

    Fail Fast

    +
    +
    +

    It may be convenient in certain circumstances (like local development or certain test scenarios) to not fail if consul isn’t available for configuration. Setting spring.cloud.consul.config.failFast=false in bootstrap.yml will cause the configuration module to log a warning rather than throw an exception. This will allow the application to continue startup normally.

    +
    +
    +
    +
    +

    Consul Retry

    +
    +
    +

    If you expect that the consul agent may occasionally be unavailable when your app starts, you can ask it to keep trying after a failure. You need to add -`spring-retry` and `spring-boot-starter-aop` to your classpath. The default +spring-retry and spring-boot-starter-aop to your classpath. The default behaviour is to retry 6 times with an initial backoff interval of 1000ms and an exponential multiplier of 1.1 for subsequent backoffs. You can configure these -properties (and others) using `spring.cloud.consul.retry.*` configuration properties. -This works with both Spring Cloud Consul Config and Discovery registration. - -TIP: To take full control of the retry add a `@Bean` of type -`RetryOperationsInterceptor` with id "consulRetryInterceptor". Spring -Retry has a `RetryInterceptorBuilder` that makes it easy to create one. - -[[spring-cloud-consul-bus]] -== Spring Cloud Bus with Consul - -Coming in a later release. - -[[spring-cloud-consul-hystrix]] -== Circuit Breaker with Hystrix - -Applications can use the Hystrix Circuit Breaker provided by the Spring Cloud Netflix project by including this starter in the projects pom.xml: `spring-cloud-starter-hystrix`. Hystrix doesn't depend on the Netflix Discovery Client. The `@EnableHystrix` annotation should be placed on a configuration class (usually the main class). Then methods can be annotated with `@HystrixCommand` to be protected by a circuit breaker. See http://projects.spring.io/spring-cloud/spring-cloud.html#_circuit_breaker_hystrix_clients[the documentation] for more details. - - -[[spring-cloud-consul-turbine]] -== Hystrix metrics aggregation with Turbine and Consul - -Turbine (provided by the Spring Cloud Netflix project), aggregates multiple instances Hystrix metrics streams, so the dashboard can display an aggregate view. Turbine uses the `DiscoveryClient` interface to lookup relevant instances. To use Turbine with Spring Cloud Consul, configure the Turbine application in a manner similar to the following examples: - -.pom.xml +properties (and others) using spring.cloud.consul.retry.* configuration properties. +This works with both Spring Cloud Consul Config and Discovery registration.

    +
    +
    + + + + + +
    +
    Tip
    +
    +To take full control of the retry add a @Bean of type +RetryOperationsInterceptor with id "consulRetryInterceptor". Spring +Retry has a RetryInterceptorBuilder that makes it easy to create one. +
    +
    +
    +

    Spring Cloud Bus with Consul

    +
    -

    <dependency> +

    Coming in a later release.

    +
    +
    +
    +
    +

    Circuit Breaker with Hystrix

    +
    +
    +

    Applications can use the Hystrix Circuit Breaker provided by the Spring Cloud Netflix project by including this starter in the projects pom.xml: spring-cloud-starter-hystrix. Hystrix doesn’t depend on the Netflix Discovery Client. The @EnableHystrix annotation should be placed on a configuration class (usually the main class). Then methods can be annotated with @HystrixCommand to be protected by a circuit breaker. See the documentation for more details.

    +
    +
    +
    +
    +

    Hystrix metrics aggregation with Turbine and Consul

    +
    +
    +

    Turbine (provided by the Spring Cloud Netflix project), aggregates multiple instances Hystrix metrics streams, so the dashboard can display an aggregate view. Turbine uses the DiscoveryClient interface to lookup relevant instances. To use Turbine with Spring Cloud Consul, configure the Turbine application in a manner similar to the following examples:

    +
    +
    +
    pom.xml
    +
    +
    <dependency>
         <groupId>org.springframework.cloud</groupId>
         <artifactId>spring-cloud-netflix-turbine</artifactId>
     </dependency>
     <dependency>
         <groupId>org.springframework.cloud</groupId>
         <artifactId>spring-cloud-starter-consul-discovery</artifactId>
    -</dependency>

    -
    -
    -
    -
    Notice that the Turbine dependency is not a starter. The turbine starter includes support for Netflix Eureka.
    -
    -.application.yml
    +</dependency>
    -

    spring.application.name: turbine +

    Notice that the Turbine dependency is not a starter. The turbine starter includes support for Netflix Eureka.

    +
    +
    +
    application.yml
    +
    +
    spring.application.name: turbine
     applications: consulhystrixclient
     turbine:
       aggregator:
         clusterConfig: ${applications}
    -  appConfig: ${applications}

    -
    -
    -
    -
    The `clusterConfig` and `appConfig` sections must match, so it's useful to put the comma-separated list of service ID's into a separate configuration property.
    -
    -.Turbine.java
    + appConfig: ${applications}
    -

    @EnableTurbine +

    The clusterConfig and appConfig sections must match, so it’s useful to put the comma-separated list of service ID’s into a separate configuration property.

    +
    +
    +
    Turbine.java
    +
    +
    @EnableTurbine
     @EnableDiscoveryClient
     @SpringBootApplication
     public class Turbine {
         public static void main(String[] args) {
             SpringApplication.run(DemoturbinecommonsApplication.class, args);
         }
    -}

    +}
    -
    +
    +
    +
    +

    Spring Cloud Zookeeper

    +
    -
    :github-tag: master
    -:github-repo: spring-cloud/spring-cloud-zookeeper
    -:github-raw: http://raw.github.com/{github-repo}/{github-tag}
    -:github-code: http://github.com/{github-repo}/tree/{github-tag}
    -:toc: left
    -
    -= Spring Cloud Zookeeper
    -
     This project provides Zookeeper 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
    @@ -7828,124 +8403,150 @@ application and build large distributed systems with Zookeeper based components.
     patterns provided include Service Discovery and Configuration.
     Intelligent Routing (Zuul) and Client Side Load Balancing (Ribbon), Circuit Breaker
     (Hystrix) are provided by integration with Spring Cloud Netflix.
    -
    -
    -[[spring-cloud-zookeeper-install]]
    -== Install Zookeeper
    -Please see the http://zookeeper.apache.org/doc/current/zookeeperStarted.html[installation documentation] for instructions on how to install Zookeeper.
    -
    -[[spring-cloud-zookeeper-discovery]]
    -== Service Discovery with Zookeeper
    -
    -Service Discovery is one of the key tenets of a microservice based architecture. Trying to hand configure each client or some form of convention can be very difficult to do and can be very brittle. http://curator.apache.org[Curator](A java library for Zookeeper) provides Service Discovery services via http://curator.apache.org/curator-x-discovery/[Service Discovery Extension]. Spring Cloud Zookeeper leverages this extension for service registration and discovery.
    -
    -=== How to activate
    -
    -Including a dependency on `org.springframework.cloud:spring-cloud-starter-zookeeper-discovery` will enable auto-configuration that will setup Spring Cloud Zookeeper Discovery.
    -
    -=== Registering with Zookeeper
    -
    -When a client registers with Zookeeper, it provides meta-data about itself such as host and port, id and name.
    -
    -Example Zookeeper client:
    -
    -[source,java,indent=0]
    +
    +

    Install Zookeeper

    +
    +
    +

    Please see the installation documentation for instructions on how to install Zookeeper.

    +
    +
    +
    +
    +

    Service Discovery with Zookeeper

    +
    +
    +

    Service Discovery is one of the key tenets of a microservice based architecture. Trying to hand configure each client or some form of convention can be very difficult to do and can be very brittle. Curator(A java library for Zookeeper) provides Service Discovery services via Service Discovery Extension. Spring Cloud Zookeeper leverages this extension for service registration and discovery.

    +
    +
    +

    How to activate

    +
    +

    Including a dependency on org.springframework.cloud:spring-cloud-starter-zookeeper-discovery will enable auto-configuration that will setup Spring Cloud Zookeeper Discovery.

    +
    +
    +
    +

    Registering with Zookeeper

    +
    +

    When a client registers with Zookeeper, it provides meta-data about itself such as host and port, id and name.

    +
    -

    @SpringBootApplication +

    Example Zookeeper client:

    +
    +
    +
    +
    @SpringBootApplication
     @EnableDiscoveryClient
     @RestController
    -public class Application {

    -
    -
    -
    -
    @RequestMapping("/")
    -public String home() {
    -    return "Hello world";
    -}
    -
    -
    -
    -
    -
    public static void main(String[] args) {
    -    new SpringApplicationBuilder(Application.class).web(true).run(args);
    -}
    +public class Application { + + @RequestMapping("/") + public String home() { + return "Hello world"; + } + + public static void main(String[] args) { + new SpringApplicationBuilder(Application.class).web(true).run(args); + } + +}
    -

    }

    +

    (i.e. utterly normal Spring Boot app). If Zookeeper is located somewhere other than localhost:2181, the configuration is required to locate the server. Example:

    +
    application.yml
    -
    (i.e. utterly normal Spring Boot app).  If Zookeeper is located somewhere other than `localhost:2181`, the configuration is required to locate the server. Example:
    -
    -.application.yml
    -
    -
    -
    -

    spring: +

    spring:
       cloud:
         zookeeper:
    -      connect-string: localhost:2181

    + connect-string: localhost:2181
    +
    +
    +
    + + + + + +
    +
    Caution
    +
    +If you use Spring Cloud Zookeeper Config, the above values will need to be placed in bootstrap.yml instead of application.yml. +
    +
    +
    +

    The default service name, instance id and port, taken from the Environment, are ${spring.application.name}, the Spring Context ID and ${server.port} respectively.

    +
    +
    +

    @EnableDiscoveryClient makes the app into both a Zookeeper "service" (i.e. it registers itself) and a "client" (i.e. it can query Zookeeper to locate other services).

    +
    +
    +
    +

    Using the DiscoveryClient

    +
    +

    Spring Cloud has support for Feign (a REST client builder) and also Spring RestTemplate using the logical service names instead of physical URLs.

    +
    +
    +

    You can also use the org.springframework.cloud.client.discovery.DiscoveryClient which provides a simple API for discovery clients that is not specific to Netflix, e.g.

    -
    CAUTION: If you use <<spring-cloud-zookeeper-config,Spring Cloud Zookeeper Config>>, the above values will need to be placed in `bootstrap.yml` instead of `application.yml`.
    +
    @Autowired
    +private DiscoveryClient discoveryClient;
     
    -The default service name, instance id and port, taken from the `Environment`, are `${spring.application.name}`, the Spring Context ID and `${server.port}` respectively.
    -
    -`@EnableDiscoveryClient` makes the app into both a Zookeeper "service" (i.e. it registers itself) and a "client" (i.e. it can query Zookeeper to locate other services).
    -
    -
    -=== Using the DiscoveryClient
    -Spring Cloud has support for https://github.com/spring-cloud/spring-cloud-netflix/blob/master/docs/src/main/asciidoc/spring-cloud-netflix.adoc#spring-cloud-feign[Feign] (a REST client builder) and also https://github.com/spring-cloud/spring-cloud-netflix/blob/master/docs/src/main/asciidoc/spring-cloud-netflix.adoc#spring-cloud-ribbon[Spring `RestTemplate`] using the logical service names instead of physical URLs.
    -
    -You can also use the `org.springframework.cloud.client.discovery.DiscoveryClient` which provides a simple API for discovery clients that is not specific to Netflix, e.g.
    -
    -
    -
    -

    @Autowired -private DiscoveryClient discoveryClient;

    -
    -
    -

    public String serviceUrl() { +public String serviceUrl() { List<ServiceInstance> list = discoveryClient.getInstances("STORES"); if (list != null && list.size() > 0 ) { return list.get(0).getUri().toString(); } return null; -}

    +}
    -
    -
    -
    [[spring-cloud-zookeeper-dependencies]]
    -
    -== Zookeeper Dependencies
    -
    -=== Using the Zookeeper Dependencies
    -
    -Spring Cloud Zookeeper gives you a possibility to provide dependencies of your application as properties. As dependencies you can understand other applications that are registered
    -in Zookeeper and which you would like to call via https://github.com/spring-cloud/spring-cloud-netflix/blob/master/docs/src/main/asciidoc/spring-cloud-netflix.adoc#spring-cloud-feign[Feign] (a REST client builder)
    -and also https://github.com/spring-cloud/spring-cloud-netflix/blob/master/docs/src/main/asciidoc/spring-cloud-netflix.adoc#spring-cloud-ribbon[Spring `RestTemplate`].
    -
    -You can also benefit from the Zookeeper Dependency Watchers functionality that lets you control and monitor what is the state of your dependencies and decide what to do with that.
    -
    -=== How to activate Zookeeper Dependencies
    -
    -- Including a dependency on `org.springframework.cloud:spring-cloud-starter-zookeeper-discovery` will enable auto-configuration that will setup Spring Cloud Zookeeper Dependencies.
    -- In addition to that you have to set the property `spring.cloud.zookeeper.dependencies.enabled` to true (defaults to `true` if not set explicitly).
    -- You have to have the `spring.cloud.zookeeper.dependencies` section properly set up - check the subsequent section for more details.
    -
    -=== Setting up Zookeeper Dependencies
    -
    -Let's take a closer look at an example of dependencies representation:
    -
    -.application.yml
    +
    +
    +
    +

    Zookeeper Dependencies

    +
    +
    +

    Using the Zookeeper Dependencies

    +
    +

    Spring Cloud Zookeeper gives you a possibility to provide dependencies of your application as properties. As dependencies you can understand other applications that are registered +in Zookeeper and which you would like to call via Feign (a REST client builder) +and also Spring RestTemplate.

    +
    -

    spring.application.name: yourServiceName +

    You can also benefit from the Zookeeper Dependency Watchers functionality that lets you control and monitor what is the state of your dependencies and decide what to do with that.

    +
    +
    +
    +

    How to activate Zookeeper Dependencies

    +
    +
      +
    • +

      Including a dependency on org.springframework.cloud:spring-cloud-starter-zookeeper-discovery will enable auto-configuration that will setup Spring Cloud Zookeeper Dependencies.

      +
    • +
    • +

      In addition to that you have to set the property spring.cloud.zookeeper.dependencies.enabled to true (defaults to true if not set explicitly).

      +
    • +
    • +

      You have to have the spring.cloud.zookeeper.dependencies section properly set up - check the subsequent section for more details.

      +
    • +
    +
    +
    +
    +

    Setting up Zookeeper Dependencies

    +
    +

    Let’s take a closer look at an example of dependencies representation:

    +
    +
    +
    application.yml
    +
    +
    spring.application.name: yourServiceName
     spring.cloud.zookeeper:
       dependencies:
         newsletter:
    @@ -7965,355 +8566,463 @@ spring.cloud.zookeeper:
           loadBalancerType: ROUND_ROBIN
           contentTypeTemplate: application/vnd.mailing.$version+json
           version: v1
    -      required: true

    -
    -
    -
    -
    Let's now go through each part of the dependency one by one. The root property name is `spring.cloud.zookeeper.dependencies`.
    -
    -==== Aliases
    -
    -Below the root property you have to represent each dependency has by an alias due to the constraints of Ribbon (the application id has to be placed in the URL
    -thus you can't pass any complex path like /foo/bar/name). The alias will be the name that you will use instead of serviceId for `DiscoveryClient`, `Feign` or `RestTemplate`.
    -
    -In the aforementioned examples the aliases are `newsletter` and `mailing`. Example of Feign usage with `newsletter` would be:
    + required: true
    -

    @FeignClient("newsletter") +

    Let’s now go through each part of the dependency one by one. The root property name is spring.cloud.zookeeper.dependencies.

    +
    +
    +

    Aliases

    +
    +

    Below the root property you have to represent each dependency has by an alias due to the constraints of Ribbon (the application id has to be placed in the URL +thus you can’t pass any complex path like /foo/bar/name). The alias will be the name that you will use instead of serviceId for DiscoveryClient, Feign or RestTemplate.

    +
    +
    +

    In the aforementioned examples the aliases are newsletter and mailing. Example of Feign usage with newsletter would be:

    +
    +
    +
    +
    @FeignClient("newsletter")
     public interface NewsletterService {
             @RequestMapping(method = RequestMethod.GET, value = "/newsletter")
             String getNewsletters();
    -}

    +}
    +
    +
    +
    +
    +

    Path

    +
    +

    Represented by path yaml property.

    +
    +
    +

    Path is the path under which the dependency is registered under Zookeeper. Like presented before Ribbon operates on URLs thus this path is not compliant with its requirement. +That is why Spring Cloud Zookeeper maps the alias to the proper path.

    +
    +
    +
    +

    Load balancer type

    +
    +

    Represented by loadBalancerType yaml property.

    +
    +
    +

    If you know what kind of load balancing strategy has to be applied when calling this particular dependency then you can provide it in the yaml file and it will be automatically applied. +You can choose one of the following load balancing strategies

    +
    +
    +
      +
    • +

      STICKY - once chosen the instance will always be called

      +
    • +
    • +

      RANDOM - picks an instance randomly

      +
    • +
    • +

      ROUND_ROBIN - iterates over instances over and over again

      +
    • +
    +
    +
    +
    +

    Content-Type template and version

    +
    +

    Represented by contentTypeTemplate and version yaml property.

    +
    +
    +

    If you version your api via the Content-Type header then you don’t want to add this header to each of your requests. Also if you want to call a new version of the API you don’t want to +roam around your code to bump up the API version. That’s why you can provide a contentTypeTemplate with a special $version placeholder. That placeholder will be filled by the value of the +version yaml property. Let’s take a look at an example.

    +
    +
    +

    Having the following contentTypeTemplate:

    -
    ==== Path
    -
    -Represented by `path` yaml property.
    -
    -Path is the path under which the dependency is registered under Zookeeper. Like presented before Ribbon operates on URLs thus this path is not compliant with its requirement.
    -That is why Spring Cloud Zookeeper maps the alias to the proper path.
    -
    -==== Load balancer type
    -
    -Represented by `loadBalancerType` yaml property.
    -
    -If you know what kind of load balancing strategy has to be applied when calling this particular dependency then you can provide it in the yaml file and it will be automatically applied.
    -You can choose one of the following load balancing strategies
    -
    -- STICKY - once chosen the instance will always be called
    -- RANDOM - picks an instance randomly
    -- ROUND_ROBIN - iterates over instances over and over again
    -
    -==== Content-Type template and version
    -
    -Represented by `contentTypeTemplate` and `version` yaml property.
    -
    -If you version your api via the `Content-Type` header then you don't want to add this header to each of your requests. Also if you want to call a new version of the API you don't want to
    -roam around your code to bump up the API version. That's why you can provide a `contentTypeTemplate` with a special `$version` placeholder. That placeholder will be filled by the value of the
    -`version` yaml property. Let's take a look at an example.
    -
    -Having the following `contentTypeTemplate`:
    +
    application/vnd.newsletter.$version+json
    -

    application/vnd.newsletter.$version+json

    +

    and the following version:

    -
    and the following `version`:
    +
    v1
    -

    v1

    +

    Will result in setting up of a Content-Type header for each request:

    -
    Will result in setting up of a `Content-Type` header for each request:
    +
    application/vnd.newsletter.v1+json
    +
    +
    +

    Default headers

    +
    +

    Represented by headers map in yaml

    +
    -

    application/vnd.newsletter.v1+json

    +

    Sometimes each call to a dependency requires setting up of some default headers. In order not to do that in code you can set them up in the yaml file. +Having the following headers section:

    -
    ==== Default headers
    -
    -Represented by `headers` map in yaml
    -
    -Sometimes each call to a dependency requires setting up of some default headers. In order not to do that in code you can set them up in the yaml file.
    -Having the following `headers` section:
    -
    -
    -
    -

    headers: +

    headers:
         Accept:
             - text/html
             - application/xhtml+xml
         Cache-Control:
    -        - no-cache

    -
    -
    -
    -
    Results in adding the `Accept` and `Cache-Control` headers with appropriate list of values in your HTTP request.
    -
    -==== Obligatory dependencies
    -
    -Represented by `required` property in yaml
    -
    -If one of your dependencies is required to be up and running when your application is booting then it's enough to set up the `required: true` property in the yaml file.
    -
    -If your application can't localize the required dependency during boot time it will throw an exception and the Spring Context will fail to set up.
    -In other words your application won't be able to start if the required dependency is not registered in Zookeeper.
    -
    -You can read more about Spring Cloud Zookeeper Presence Checker in the following sections.
    -
    -==== Stubs
    -
    -You can provide a colon separated path to the JAR containing stubs of the dependency. Example
    -
    -```
    -stubs: org.springframework:foo:stubs
    -```
    -
    -means that for a particular dependencies can be found under:
    -
    -* groupId: `org.springframework`
    -* artifactId: `foo`
    -* classifier: `stubs` - this is the default value
    -
    -This is actually equal to
    -
    -```
    -stubs: org.springframework:foo
    -```
    -
    -since `stubs` is the default classifier.
    -
    -=== Configuring Spring Cloud Zookeeper Dependencies
    -
    -There is a bunch of properties that you can set to enable / disable parts of Zookeeper Dependencies functionalities.
    -
    -- `spring.cloud.zookeeper.dependencies` - if you don't set this property you won't benefit from Zookeeper Dependencies
    -- `spring.cloud.zookeeper.dependencies.ribbon.enabled` (enabled by default) - Ribbon requires explicit global configuration or a particular one for a dependency. By turning on this property
    - runtime load balancing strategy resolution is possible and you can profit from the `loadBalancerType` section of the Zookeeper Dependencies. The configuration that needs this property
    - has an implementation of `LoadBalancerClient` that delegates to the `ILoadBalancer` presented in the next bullet
    -- `spring.cloud.zookeeper.dependencies.ribbon.loadbalancer` (enabled by default) - thanks to this property the custom `ILoadBalancer` knows that the part of the URI passed to Ribbon might
    -actually be the alias that has to be resolved to a proper path in Zookeeper. Without this property you won't be able to register applications under nested paths.
    -- `spring.cloud.zookeeper.dependencies.headers.enabled` (enabled by default) - this property registers such a `RibbonClient` that automatically will append appropriate headers and content
    -types with version as presented in the Dependency configuration. Without this setting of those two parameters will not be operational.
    -- `spring.cloud.zookeeper.dependencies.resttemplate.enabled` (enabled by default) - when enabled will modify the request headers of `@LoadBalanced` annotated `RestTemplate` so that it passes
    -headers and content type with version set in Dependency configuration. Wihtout this setting of those two parameters will not be operational.
    -
    -
    -[[spring-cloud-zookeeper-dependency-watcher]]
    -
    -== Spring Cloud Zookeeper Dependency Watcher
    -
    -The Dependency Watcher mechanism allows you to register listeners to your dependencies. The functionality is in fact an implementation of the `Observator` pattern. When a dependency changes
    -its state (UP or DOWN) then some custom logic can be applied.
    -
    -=== How to activate
    -
    -Spring Cloud Zookeeper Dependencies functionality needs to be enabled to profit from Dependency Watcher mechanism.
    -
    -=== Registering a listener
    -
    -In order to register a listener you have to implement an interface `org.springframework.cloud.zookeeper.discovery.watcher.DependencyWatcherListener` and register it as a bean.
    -The interface gives you one method:
    -
    -
    -
    -
    -
    void stateChanged(String dependencyName, DependencyState newState);
    -
    -
    -
    -
    -
    If you want to register a listener for a particular dependency then the `dependencyName` would be the discriminator for your concrete implementation. `newState` will provide you with information
    - whether your dependency has changed to `CONNECTED` or `DISCONNECTED`.
    -
    -=== Presence Checker
    -
    -Bound with Dependency Watcher is the functionality called Presence Checker. It allows you to provide custom behaviour upon booting of your application to react accordingly to the state
    -of your dependencies.
    -
    -The default implementation of the abstract `org.springframework.cloud.zookeeper.discovery.watcher.presence.DependencyPresenceOnStartupVerifier` class is the
    -`org.springframework.cloud.zookeeper.discovery.watcher.presence.DefaultDependencyPresenceOnStartupVerifier` which works in the following way.
    -
    -- If the dependency is marked us `required` and it's not in Zookeeper then upon booting your application will throw an exception and shutdown
    -- If dependency is not `required` the `org.springframework.cloud.zookeeper.discovery.watcher.presence.LogMissingDependencyChecker` will log that application is missing at `WARN` level
    -
    -The functionality can be overriden since the `DefaultDependencyPresenceOnStartupVerifier` is registered only when there is no bean of `DependencyPresenceOnStartupVerifier`.
    -
    -
    -[[spring-cloud-zookeeper-config]]
    -
    -== Distributed Configuration with Zookeeper
    -
    -Zookeeper provides a http://zookeeper.apache.org/doc/current/zookeeperOver.html#sc_dataModelNameSpace[hierarchical namespace] that allows clients to store arbitrary data, such as configuration data.  Spring Cloud Zookeeper Config is an alternative to the https://github.com/spring-cloud/spring-cloud-config[Config Server and Client].  Configuration is loaded into the Spring Environment during the special "bootstrap" phase.  Configuration is stored in the `/config` namespace by default.  Multiple `PropertySource` instances are created based on the application's name and the active profiles that mimicks the Spring Cloud Config order of resolving properties.  For example, an application with the name "testApp" and with the "dev" profile will have the following property sources created:
    + - no-cache
    -

    config/testApp,dev +

    Results in adding the Accept and Cache-Control headers with appropriate list of values in your HTTP request.

    +
    +
    +
    +

    Obligatory dependencies

    +
    +

    Represented by required property in yaml

    +
    +
    +

    If one of your dependencies is required to be up and running when your application is booting then it’s enough to set up the required: true property in the yaml file.

    +
    +
    +

    If your application can’t localize the required dependency during boot time it will throw an exception and the Spring Context will fail to set up. +In other words your application won’t be able to start if the required dependency is not registered in Zookeeper.

    +
    +
    +

    You can read more about Spring Cloud Zookeeper Presence Checker in the following sections.

    +
    +
    +
    +

    Stubs

    +
    +

    You can provide a colon separated path to the JAR containing stubs of the dependency. Example

    +
    +
    +
    +
    stubs: org.springframework:foo:stubs
    +
    +
    +
    +

    means that for a particular dependencies can be found under:

    +
    +
    +
      +
    • +

      groupId: org.springframework

      +
    • +
    • +

      artifactId: foo

      +
    • +
    • +

      classifier: stubs - this is the default value

      +
    • +
    +
    +
    +

    This is actually equal to

    +
    +
    +
    +
    stubs: org.springframework:foo
    +
    +
    +
    +

    since stubs is the default classifier.

    +
    +
    +
    +
    +

    Configuring Spring Cloud Zookeeper Dependencies

    +
    +

    There is a bunch of properties that you can set to enable / disable parts of Zookeeper Dependencies functionalities.

    +
    +
    +
      +
    • +

      spring.cloud.zookeeper.dependencies - if you don’t set this property you won’t benefit from Zookeeper Dependencies

      +
    • +
    • +

      spring.cloud.zookeeper.dependencies.ribbon.enabled (enabled by default) - Ribbon requires explicit global configuration or a particular one for a dependency. By turning on this property +runtime load balancing strategy resolution is possible and you can profit from the loadBalancerType section of the Zookeeper Dependencies. The configuration that needs this property +has an implementation of LoadBalancerClient that delegates to the ILoadBalancer presented in the next bullet

      +
    • +
    • +

      spring.cloud.zookeeper.dependencies.ribbon.loadbalancer (enabled by default) - thanks to this property the custom ILoadBalancer knows that the part of the URI passed to Ribbon might +actually be the alias that has to be resolved to a proper path in Zookeeper. Without this property you won’t be able to register applications under nested paths.

      +
    • +
    • +

      spring.cloud.zookeeper.dependencies.headers.enabled (enabled by default) - this property registers such a RibbonClient that automatically will append appropriate headers and content +types with version as presented in the Dependency configuration. Without this setting of those two parameters will not be operational.

      +
    • +
    • +

      spring.cloud.zookeeper.dependencies.resttemplate.enabled (enabled by default) - when enabled will modify the request headers of @LoadBalanced annotated RestTemplate so that it passes +headers and content type with version set in Dependency configuration. Wihtout this setting of those two parameters will not be operational.

      +
    • +
    +
    +
    +
    +
    +
    +

    Spring Cloud Zookeeper Dependency Watcher

    +
    +
    +

    The Dependency Watcher mechanism allows you to register listeners to your dependencies. The functionality is in fact an implementation of the Observator pattern. When a dependency changes +its state (UP or DOWN) then some custom logic can be applied.

    +
    +
    +

    How to activate

    +
    +

    Spring Cloud Zookeeper Dependencies functionality needs to be enabled to profit from Dependency Watcher mechanism.

    +
    +
    +
    +

    Registering a listener

    +
    +

    In order to register a listener you have to implement an interface org.springframework.cloud.zookeeper.discovery.watcher.DependencyWatcherListener and register it as a bean. +The interface gives you one method:

    +
    +
    +
    +
        void stateChanged(String dependencyName, DependencyState newState);
    +
    +
    +
    +

    If you want to register a listener for a particular dependency then the dependencyName would be the discriminator for your concrete implementation. newState will provide you with information + whether your dependency has changed to CONNECTED or DISCONNECTED.

    +
    +
    +
    +

    Presence Checker

    +
    +

    Bound with Dependency Watcher is the functionality called Presence Checker. It allows you to provide custom behaviour upon booting of your application to react accordingly to the state +of your dependencies.

    +
    +
    +

    The default implementation of the abstract org.springframework.cloud.zookeeper.discovery.watcher.presence.DependencyPresenceOnStartupVerifier class is the +org.springframework.cloud.zookeeper.discovery.watcher.presence.DefaultDependencyPresenceOnStartupVerifier which works in the following way.

    +
    +
    +
      +
    • +

      If the dependency is marked us required and it’s not in Zookeeper then upon booting your application will throw an exception and shutdown

      +
    • +
    • +

      If dependency is not required the org.springframework.cloud.zookeeper.discovery.watcher.presence.LogMissingDependencyChecker will log that application is missing at WARN level

      +
    • +
    +
    +
    +

    The functionality can be overriden since the DefaultDependencyPresenceOnStartupVerifier is registered only when there is no bean of DependencyPresenceOnStartupVerifier.

    +
    +
    +
    +
    +
    +

    Distributed Configuration with Zookeeper

    +
    +
    +

    Zookeeper provides a hierarchical namespace that allows clients to store arbitrary data, such as configuration data. Spring Cloud Zookeeper Config is an alternative to the Config Server and Client. Configuration is loaded into the Spring Environment during the special "bootstrap" phase. Configuration is stored in the /config namespace by default. Multiple PropertySource instances are created based on the application’s name and the active profiles that mimicks the Spring Cloud Config order of resolving properties. For example, an application with the name "testApp" and with the "dev" profile will have the following property sources created:

    +
    +
    +
    +
    config/testApp,dev
     config/testApp
     config/application,dev
    -config/application

    -
    -
    -
    -
    The most specific property source is at the top, with the least specific at the bottom.  Properties is the `config/application` namespace are applicable to all applications using zookeeper for configuration.  Properties in the `config/testApp` namespace are only available to the instances of the service named "testApp".
    -
    -Configuration is currently read on startup of the application.  Sending a HTTP POST to `/refresh` will cause the configuration to be reloaded.  Watching the configuration namespace (which Zookeeper supports) is not currently implemented, but will be a future addition to this project.
    -
    -=== How to activate
    -
    -Including a dependency on `org.springframework.cloud:spring-cloud-starter-zookeeper-config` will enable auto-configuration that will setup Spring Cloud Zookeeper Config.
    -
    -=== Customizing
    -
    -Zookeeper Config may be customized using the following properties:
    -
    -.bootstrap.yml
    +config/application
    -

    spring: +

    The most specific property source is at the top, with the least specific at the bottom. Properties is the config/application namespace are applicable to all applications using zookeeper for configuration. Properties in the config/testApp namespace are only available to the instances of the service named "testApp".

    +
    +
    +

    Configuration is currently read on startup of the application. Sending a HTTP POST to /refresh will cause the configuration to be reloaded. Watching the configuration namespace (which Zookeeper supports) is not currently implemented, but will be a future addition to this project.

    +
    +
    +

    How to activate

    +
    +

    Including a dependency on org.springframework.cloud:spring-cloud-starter-zookeeper-config will enable auto-configuration that will setup Spring Cloud Zookeeper Config.

    +
    +
    +
    +

    Customizing

    +
    +

    Zookeeper Config may be customized using the following properties:

    +
    +
    +
    bootstrap.yml
    +
    +
    spring:
       cloud:
         zookeeper:
           config:
             enabled: true
             root: configuration
             defaultContext: apps
    -        profileSeparator: '::'

    + profileSeparator: '::'
    +
    +
    +
    +
      +
    • +

      enabled setting this value to "false" disables Zookeeper Config

      +
    • +
    • +

      root sets the base namespace for configuration values

      +
    • +
    • +

      defaultContext sets the name used by all applications

      +
    • +
    • +

      profileSeparator sets the value of the separator used to separate the profile name in property sources with profiles

      +
    • +
    +
    +
    +
    +
    +

    Spring Boot Cloud CLI

    +
    +
    +Spring Boot CLI provides Spring Boot command line features for +Spring Cloud. You can write Groovy scripts to run Spring Cloud component applications +(e.g. @EnableEurekaServer). You can also easily do things like encryption and decryption to support Spring Cloud +Config clients with secret configuration values. +
    +
    +
    +

    Installation

    +
    +
    +

    To install, make +sure you have +Spring Boot CLI +(1.3.0 or better):

    +
    +
    +
    +
    $ spring version
    +Spring CLI v1.3.2.RELEASE
    +
    +
    +
    +

    E.g. for SDKMan users

    -
    * `enabled` setting this value to "false" disables Zookeeper Config
    -* `root` sets the base namespace for configuration values
    -* `defaultContext` sets the name used by all applications
    -* `profileSeparator` sets the value of the separator used to separate the profile name in property sources with profiles
    -
    -
    -= Spring Boot Cloud CLI
    -:github: https://github.com/spring-cloud/spring-cloud-cli
    -:githubmaster: {github}/tree/master
    -:docslink: {githubmaster}/docs/src/main/asciidoc
    -
    -Spring Boot CLI provides http://projects.spring.io/spring-boot[Spring Boot] command line features for
    -https://github.com/spring-cloud[Spring Cloud]. You can write Groovy scripts to run Spring Cloud component applications
    -(e.g. `@EnableEurekaServer`). You can also easily do things like encryption and decryption to support Spring Cloud
    -Config clients with secret configuration values.
    -
    -
    -
    -== Installation
    -
    -To install, make
    -sure you have
    -https://github.com/spring-projects/spring-boot[Spring Boot CLI]
    -(1.3.0 or better):
    -
    -    $ spring version
    -    Spring CLI v1.3.2.RELEASE
    -
    -E.g. for SDKMan users
    -
    -```
    -$ sdk install springboot 1.3.2.RELEASE
    -$ sdk use springboot 1.3.2.RELEASE
    -```
    -
    -and install the Spring Cloud plugin:
    -
    -```
    -$ mvn install
    -$ spring install org.springframework.cloud:spring-cloud-cli:1.1.0.RC1
    -```
    -
    -IMPORTANT: **Prerequisites:** to use the encryption and decryption features
    -you need the full-strength JCE installed in your JVM (it's not there by default).
    +
    $ sdk install springboot 1.3.2.RELEASE
    +$ sdk use springboot 1.3.2.RELEASE
    +
    +
    +
    +

    and install the Spring Cloud plugin:

    +
    +
    +
    +
    $ mvn install
    +$ spring install org.springframework.cloud:spring-cloud-cli:1.1.0.RC1
    +
    +
    +
    + + + + + +
    +
    Important
    +
    +Prerequisites: to use the encryption and decryption features +you need the full-strength JCE installed in your JVM (it’s not there by default). You can download the "Java Cryptography Extension (JCE) Unlimited Strength Jurisdiction Policy Files" from Oracle, and follow instructions for installation (essentially replace the 2 policy files in the JRE lib/security directory with the ones that you downloaded). - -== Writing Groovy Scripts and Running Applications - -Spring Cloud CLI has support for most of the Spring Cloud declarative -features, such as the `@Enable*` class of annotations. For example, -here is a fully functional Eureka server - -.app.groovy -[source,groovy,indent=0] +
    +
    +
    +
    +
    +

    Writing Groovy Scripts and Running Applications

    +
    +
    +

    Spring Cloud CLI has support for most of the Spring Cloud declarative +features, such as the @Enable* class of annotations. For example, +here is a fully functional Eureka server

    +
    +
    +
    app.groovy
    +
    +
    @EnableEurekaServer
    +class Eureka {}
    -

    @EnableEurekaServer -class Eureka {}

    +

    which you can run from the command line like this

    -
    which you can run from the command line like this
    +
    $ spring run app.groovy
    -

    $ spring run app.groovy

    -
    -
    -
    -
    To include additional dependencies, often it suffices just to add the
    -appropriate feature-enabling annotation, e.g. `@EnableConfigServer`,
    -`@EnableOAuth2Sso` or `@EnableEurekaClient`. To manually include a
    -dependency you can use a `@Grab` with the special "Spring Boot" short
    +

    To include additional dependencies, often it suffices just to add the +appropriate feature-enabling annotation, e.g. @EnableConfigServer, +@EnableOAuth2Sso or @EnableEurekaClient. To manually include a +dependency you can use a @Grab with the special "Spring Boot" short style artifact co-ordinates, i.e. with just the artifact ID (no need for group or version information), e.g. to set up a client app to -listen on AMQP for management events from the Spring CLoud Bus: - -.app.groovy -[source,groovy,indent=0]

    +listen on AMQP for management events from the Spring CLoud Bus:

    -
    -
    -

    @Grab('spring-cloud-starter-bus-amqp') +

    +
    app.groovy
    +
    +
    @Grab('spring-cloud-starter-bus-amqp')
     @RestController
     class Service {
       @RequestMapping('/')
       def home() { [message: 'Hello'] }
    -}

    +}
    +
    +
    +
    +
    +
    +

    Encryption and Decryption

    +
    +
    +

    The Spring Cloud CLI comes with an "encrypt" and a "decrypt" +command. Both accept arguments in the same form with a key specified +as a mandatory "--key", e.g.

    -
    == Encryption and Decryption
    -
    -The Spring Cloud CLI comes with an "encrypt" and a "decrypt"
    -command. Both accept arguments in the same form with a key specified
    -as a mandatory "--key", e.g.
    -
    -
    -
    -

    $ spring encrypt mysecret --key foo +

    $ spring encrypt mysecret --key foo
     682bc583f4641835fa2db009355293665d2647dade3375c0ee201de2a49f7bda
     $ spring decrypt --key foo 682bc583f4641835fa2db009355293665d2647dade3375c0ee201de2a49f7bda
    -mysecret

    -
    -
    -
    -
    To use a key in a file (e.g. an RSA public key for encyption) prepend
    -the key value with "@" and provide the file path, e.g.
    +mysecret
    -

    $ spring encrypt mysecret --key @${HOME}/.ssh/id_rsa.pub -AQAjPgt3eFZQXwt8tsHAVv/QHiY5sI2dRcR+…​

    +

    To use a key in a file (e.g. an RSA public key for encyption) prepend +the key value with "@" and provide the file path, e.g.

    -
    = Spring Cloud Security
    -:github: https://github.com/spring-cloud/spring-cloud-security
    -:githubmaster: {github}/tree/master
    -:docslink: {githubmaster}/src/main/asciidoc
    -
    +
    $ spring encrypt mysecret --key @${HOME}/.ssh/id_rsa.pub
    +AQAjPgt3eFZQXwt8tsHAVv/QHiY5sI2dRcR+...
    +
    +
    +
    +
    +

    Spring Cloud Security

    +
    +
    Spring Cloud Security offers a set of primitives for building secure applications and services with minimum fuss. A declarative model which can be heavily configured externally (or centrally) lends itself to @@ -8323,1348 +9032,2310 @@ easy to use in a service platform like Cloud Foundry. Building on Spring Boot and Spring Security OAuth2 we can quickly create systems that implement common patterns like single sign on, token relay and token exchange. - - -== Quickstart - -=== OAuth2 Single Sign On - -Here's a Spring Cloud "Hello World" app with HTTP Basic -authentication and a single user account: - -.app.groovy -[source,java]
    +
    +

    Quickstart

    +
    +
    +

    OAuth2 Single Sign On

    -

    @Grab('spring-boot-starter-security') +

    Here’s a Spring Cloud "Hello World" app with HTTP Basic +authentication and a single user account:

    +
    +
    +
    app.groovy
    +
    +
    @Grab('spring-boot-starter-security')
     @Controller
    -class Application {

    -
    -
    -
    -
    @RequestMapping('/')
    -String home() {
    -  'Hello World'
    -}
    +class Application { + + @RequestMapping('/') + String home() { + 'Hello World' + } + +}
    -

    }

    +

    You can run it with spring run app.groovy and watch the logs for the password (username is "user"). So far this is just the default for a Spring Boot app.

    +
    +
    +

    Here’s a Spring Cloud app with OAuth2 SSO:

    +
    app.groovy
    -
    You can run it with `spring run app.groovy` and watch the logs for the password (username is "user"). So far this is just the default for a Spring Boot app.
    -
    -Here's a Spring Cloud app with OAuth2 SSO:
    -
    -.app.groovy
    -[source,java]
    -
    -
    -
    -

    @Controller +

    @Controller
     @EnableOAuth2Sso
    -class Application {

    -
    -
    -
    -
    @RequestMapping('/')
    -String home() {
    -  'Hello World'
    -}
    +class Application { + + @RequestMapping('/') + String home() { + 'Hello World' + } + +}
    -

    }

    +

    Spot the difference? This app will actually behave exactly the same as +the previous one, because it doesn’t know it’s OAuth2 credentals +yet.

    -
    -
    -
    Spot the difference? This app will actually behave exactly the same as
    -the previous one, because it doesn't know it's OAuth2 credentals
    -yet.
    -
    -You can register an app in github quite easily, so try that if you
    +
    +

    You can register an app in github quite easily, so try that if you want a production app on your own domain. If you are happy to test on localhost:8080, then set up these properties in your application -configuration: - -.application.yml -[source,yaml]

    +configuration:

    -
    -
    -

    spring: +

    +
    application.yml
    +
    +
    spring:
       oauth2:
         client:
           clientId: bd1c0a783ccdd1c9b9e4
           clientSecret: 1a9030fbca47a5b2c28e92f19050bb77824b5ad1
    -      accessTokenUri: https://github.com/login/oauth/access_token
    -      userAuthorizationUri: https://github.com/login/oauth/authorize
    +      accessTokenUri: https://github.com/login/oauth/access_token
    +      userAuthorizationUri: https://github.com/login/oauth/authorize
           clientAuthenticationScheme: form
         resource:
    -      userInfoUri: https://api.github.com/user
    -      preferTokenInfo: false

    + userInfoUri: https://api.github.com/user + preferTokenInfo: false
    -
    -
    -
    run the app above and it will redirect to github for authorization. If
    -you are already signed into github you won't even notice that it has
    +
    +
    +

    run the app above and it will redirect to github for authorization. If +you are already signed into github you won’t even notice that it has authenticated. These credentials will only work if your app is -running on port 8080. - -To limit the scope that the client asks for when it obtains an access token -you can set `spring.oauth2.client.scope` (comma separated or an array in YAML). By +running on port 8080.

    +
    +
    +

    To limit the scope that the client asks for when it obtains an access token +you can set spring.oauth2.client.scope (comma separated or an array in YAML). By default the scope is empty and it is up to to Authorization Server to decide what the defaults should be, usually depending on the settings in -the client registration that it holds. - -NOTE: The examples above are all Groovy scripts. If you want to write the +the client registration that it holds.

    +
    +
    + + + + + +
    +
    Note
    +
    +The examples above are all Groovy scripts. If you want to write the same code in Java (or Groovy) you need to add Spring Security OAuth2 to the classpath (e.g. see the -https://github.com/spring-cloud-samples/sso[sample here]). - -=== OAuth2 Protected Resource - -You want to protect an API resource with an OAuth2 token? Here's a -simple example (paired with the client above): - -.app.groovy -[source,java] +sample here). +
    +
    +

    OAuth2 Protected Resource

    -

    @Grab('spring-cloud-starter-security') +

    You want to protect an API resource with an OAuth2 token? Here’s a +simple example (paired with the client above):

    +
    +
    +
    app.groovy
    +
    +
    @Grab('spring-cloud-starter-security')
     @RestController
     @EnableResourceServer
    -class Application {

    -
    -
    -
    -
    @RequestMapping('/')
    -def home() {
    -  [message: 'Hello World']
    -}
    +class Application { + + @RequestMapping('/') + def home() { + [message: 'Hello World'] + } + +}
    -

    }

    +

    and

    +
    application.yml
    -
    and
    -
    -.application.yml
    -[source,yaml]
    -
    -
    -
    -

    spring: +

    spring:
       oauth2:
         resource:
    -      userInfoUri: https://api.github.com/user
    -      preferTokenInfo: false

    + userInfoUri: https://api.github.com/user + preferTokenInfo: false
    -
    -
    -
    == More Detail
    -
    -=== Single Sign On
    -
    -NOTE: All of the OAuth2 SSO and resource server features moved to Spring Boot
    +
    +
    +
    +
    +
    +

    More Detail

    +
    +
    +

    Single Sign On

    +
    + + + + + +
    +
    Note
    +
    +All of the OAuth2 SSO and resource server features moved to Spring Boot in version 1.3. You can find documentation in the -http://docs.spring.io/spring-boot/docs/current/reference/htmlsingle/[Spring Boot user guide]. - -=== Token Relay - -A Token Relay is where an OAuth2 consumer acts as a Client and +Spring Boot user guide. +
    +
    +
    +
    +

    Token Relay

    +
    +

    A Token Relay is where an OAuth2 consumer acts as a Client and forwards the incoming token to outgoing resource requests. The consumer can be a pure Client (like an SSO application) or a Resource -Server. - -==== Client Token Relay - -If your app has a -http://cloud.spring.io/spring-cloud.html#netflix-zuul-reverse-proxy[Spring -Cloud Zuul] embedded reverse proxy (using `@EnableZuulProxy`) then you +Server.

    +
    +
    +

    Client Token Relay

    +
    +

    If your app has a +Spring +Cloud Zuul embedded reverse proxy (using @EnableZuulProxy) then you can ask it to forward OAuth2 access tokens downstream to the services -it is proxying. Thus the SSO app above can be enhanced simply like this: - -.app.groovy -[source,java] -

    -
    -
    -

    @Controller -@EnableOAuth2Sso -@EnableZuulProxy -class Application {

    -
    -
    -

    }

    +it is proxying. Thus the SSO app above can be enhanced simply like this:

    +
    app.groovy
    -
    and it will (in addition to loggin the user in and grabbing a token)
    -pass the authentication token downstream to the `/proxy/*`
    +
    @Controller
    +@EnableOAuth2Sso
    +@EnableZuulProxy
    +class Application {
    +
    +}
    +
    +
    +
    +

    and it will (in addition to loggin the user in and grabbing a token) +pass the authentication token downstream to the /proxy/* services. If those services are implemented with -`@EnableOAuth2Resource` then they will get a valid token in the -correct header. - -How does it work? The `@EnableOAuth2Sso` annotation pulls in -`spring-cloud-starter-security` (which you could do manually in a +@EnableOAuth2Resource then they will get a valid token in the +correct header.

    +
    +
    +

    How does it work? The @EnableOAuth2Sso annotation pulls in +spring-cloud-starter-security (which you could do manually in a traditional app), and that in turn triggers some autoconfiguration for -a `ZuulFilter`, which itself is activated because Zuul is on the -classpath (via `@EnableZuulProxy`). The -{githubmaster}/src/main/java/org/springframework/cloud/security/oauth2/proxy/OAuth2TokenRelayFilter.java[filter] +a ZuulFilter, which itself is activated because Zuul is on the +classpath (via @EnableZuulProxy). The +filter just extracts an access token from the currently authenticated user, -and puts it in a request header for the downstream requests. - -==== Resource Server Token Relay - -If your app has `@EnableOAuth2Resource` and also is a Client (i.e. it -has a `spring.oauth2.client.clientId`, even if it doesn't use it), -then the `OAuth2RestOperations` that is provided for `@Autowired` -users by Spring Cloud (it is declared as `@Primary`) will also forward -tokens. If you don't want to forward tokens (and that is a valid +and puts it in a request header for the downstream requests.

    +
    +
    +
    +

    Resource Server Token Relay

    +
    +

    If your app has @EnableOAuth2Resource and also is a Client (i.e. it +has a spring.oauth2.client.clientId, even if it doesn’t use it), +then the OAuth2RestOperations that is provided for @Autowired +users by Spring Cloud (it is declared as @Primary) will also forward +tokens. If you don’t want to forward tokens (and that is a valid choice, since you might want to act as yourself, rather than the client that sent you the token), then you only need to create your own -`OAuth2RestOperations` instead of autowiring the default one. Here's +OAuth2RestOperations instead of autowiring the default one. Here’s a basic example showing the use of the autowired rest template ("foo.com" -is a Resource Server accepting the same tokens as the surrounding app): +is a Resource Server accepting the same tokens as the surrounding app):

    +
    +
    +
    MyController.java
    +
    +
    @Autowired
    +private OAuth2RestOperations restTemplate;
     
    -.MyController.java
    -[source,java]
    -
    -
    -
    -

    @Autowired -private OAuth2RestOperations restTemplate;

    -
    -
    -

    @RequestMapping("/relay") +@RequestMapping("/relay") public String relay() { ResponseEntity<String> response = restTemplate.getForEntity("https://foo.com/bar", String.class); return "Success! (" + response.getBody() + ")"; -}

    +}
    +
    +
    +
    +
    +
    +
    +
    +

    Configuring Authentication Downstream of a Zuul Proxy

    +
    +
    +

    You can control the authorization behaviour downstream of an +@EnableZuulProxy through the proxy.auth.* settings. Example:

    +
    application.yml
    -
    == Configuring Authentication Downstream of a Zuul Proxy
    -
    -You can control the authorization behaviour downstream of an
    -`@EnableZuulProxy` through the `proxy.auth.*` settings. Example:
    -
    -.application.yml
    -[source,yaml]
    -
    -
    -
    -

    proxy: +

    proxy:
       auth:
         routes:
           customers: oauth2
           stores: passthru
    -      recommendations: none

    + recommendations: none
    -
    -
    -
    In this example the "customers" service gets an OAuth2 token relay,
    +
    +
    +

    In this example the "customers" service gets an OAuth2 token relay, the "stores" service gets a passthrough (the authorization header is just passed downstream), and the "recommendations" service has its authorization header removed. The default behaviour is to do a token -relay if there is a token available, and passthru otherwise. - -See -{githubmaster}/src/main/java/org/springframework/cloud/security/oauth2/proxy/ProxyAuthenticationProperties[ -ProxyAuthenticationProperties] for full details. - -= Spring Cloud for Cloud Foundry - -Spring Cloud for Cloudfoundry makes it easy to run -https://github.com/spring-cloud[Spring Cloud] apps in -https://github.com/cloudfoundry[Cloud Foundry] (the Platform as a +relay if there is a token available, and passthru otherwise.

    +
    +
    +

    See + +ProxyAuthenticationProperties for full details.

    +
    +
    +
    +

    Spring Cloud for Cloud Foundry

    +
    +
    +
    +

    Spring Cloud for Cloudfoundry makes it easy to run +Spring Cloud apps in +Cloud Foundry (the Platform as a Service). Cloud Foundry has the notion of a "service", which is middlware that you "bind" to an app, essentially providing it with an environment variable containing credentials (e.g. the location and -username to use for the service). - -The `spring-cloud-cloudfoundry-web` project provides basic support for +username to use for the service).

    +
    +
    +

    The spring-cloud-cloudfoundry-web project provides basic support for some enhanced features of webapps in Cloud Foundry: binding automatically to single-sign-on services and optionally enabling -sticky routing for discovery. - -The `spring-cloud-cloudfoundry-discovery` project provides an -implementation of Spring Cloud Commons `DiscoveryClient` so you can -`@EnableDiscoveryClient` and provide your credentials as -`spring.cloud.cloudfoundry.discovery.[email,password]` and then you -can use the `DiscoveryClient` directly or via a `LoadBalancerClient` -(also `*.url` if you are not connecting to [Pivotal Web -Services](https://run.pivotal.io)). - -The first time you use it the discovery client might be slow owing to -the fact that it has to get an access token from Cloud Foundry. - -== Quickstart - -Here's a Spring Cloud app with Cloud Foundry discovery: - -.app.groovy -[source,java] -

    +sticky routing for discovery.

    -

    @Grab('org.springframework.cloud:spring-cloud-cloudfoundry') +

    The spring-cloud-cloudfoundry-discovery project provides an +implementation of Spring Cloud Commons DiscoveryClient so you can +@EnableDiscoveryClient and provide your credentials as +spring.cloud.cloudfoundry.discovery.[email,password] and then you +can use the DiscoveryClient directly or via a LoadBalancerClient +(also *.url if you are not connecting to [Pivotal Web +Services](https://run.pivotal.io)).

    +
    +
    +

    The first time you use it the discovery client might be slow owing to +the fact that it has to get an access token from Cloud Foundry.

    +
    +
    +
    +
    +

    Quickstart

    +
    +
    +

    Here’s a Spring Cloud app with Cloud Foundry discovery:

    +
    +
    +
    app.groovy
    +
    +
    @Grab('org.springframework.cloud:spring-cloud-cloudfoundry')
     @RestController
     @EnableDiscoveryClient
    -class Application {

    -
    -
    -
    -
    @Autowired
    -DiscoveryClient client
    -
    -
    -
    -
    -
    @RequestMapping('/')
    -String home() {
    -  'Hello from ' + client.getLocalServiceInstance()
    -}
    +class Application { + + @Autowired + DiscoveryClient client + + @RequestMapping('/') + String home() { + 'Hello from ' + client.getLocalServiceInstance() + } + +}
    -

    }

    +

    If you run it without any service bindings:

    -
    If you run it without any service bindings:
    +
    $ spring jar app.jar app.groovy
    +$ cf push -p app.jar
    -

    $ spring jar app.jar app.groovy -$ cf push -p app.jar

    +

    It will show its app name in the home page.

    -
    -
    -
    It will show its app name in the home page.
    -
    -
    -=== Single Sign On
    -
    -NOTE: All of the OAuth2 SSO and resource server features moved to Spring Boot
    +
    +

    Single Sign On

    +
    + + + + + +
    +
    Note
    +
    +All of the OAuth2 SSO and resource server features moved to Spring Boot in version 1.3. You can find documentation in the -http://docs.spring.io/spring-boot/docs/current/reference/htmlsingle/[Spring Boot user guide]. - -This project provides automatic binding from CloudFoundry service +Spring Boot user guide. +
    +
    +
    +

    This project provides automatic binding from CloudFoundry service credentials to the Spring Boot features. If you have a CloudFoundry service called "sso", for instance, with credentials containing "client_id", "client_secret" and "auth_domain", it will bind automatically to the Spring OAuth2 client that you enable with -`@EnableOAuth2Sso` (from Spring Boot). The name of the service can be -parameterized using `spring.oauth2.sso.serviceId`. - - -= Spring Cloud Cluster - +@EnableOAuth2Sso (from Spring Boot). The name of the service can be +parameterized using spring.oauth2.sso.serviceId.

    +
    +
    +
    +
    +

    Spring Cloud Cluster

    +
    +
    Spring Cloud Cluster offers a set of primitives for building "cluster" features into a distributed system. Example are leadership election, consistent storage of cluster state, global locks and one-time tokens. - -== Leader Election - -Leader election allows application to work together with other -applications to coordinate a cluster leadership via a third party system. -Currently we provide integrations with `zookeeper`, `hazelcast` and `etcd`. - -From user perspective election is working via interfaces -`org.springframework.cloud.cluster.leader.Candidate` and -`org.springframework.cloud.cluster.leader.Context`. `Candidate` -contains access to leadership's `role` and `id` and also have methods -`onGranted` and `onRevoked`. These callback methods are useful if -default `Candidate` implementation is changed. - -Leader election is auto-configured if `spring-cloud-cluster-autoconfigure` -and either `spring-cloud-cluster-hazelcast`, `spring-cloud-cluster-zookeeper` -or `spring-cloud-cluster-etcd` jars are found from a classpath. In -case where both jars are found leader election is created using both -systems. See sections <<spring-cloud-cluster-leaderelection-zookeeper>>, -<<spring-cloud-cluster-leaderelection-hazelcast>> and -<<spring-cloud-cluster-leaderelection-etcd>> for more -information about a created beans. - -Default `Candidate` created from auto-configuration is -`org.springframework.cloud.cluster.leader.DefaultCandidate` which -currently only logs granted and revoked events. - -If there's a need for disable all leader related auto-configuration, -a `spring.cloud.cluster.leader.enabled` can be set to false which -then allows to do manual configuration even if the jars an on a -classpath. Properties `spring.cloud.cluster.leader.id` and -`spring.cloud.cluster.leader.role` can be used to set default -identifier and role. - -If you are interested to simple get notification of granted and -revoked events one option is to attach event listener into spring -application context. Events `OnGrantedEvent` and `OnRevokedEvent` are -sent as spring event objects. - -Simply create your own event listener class: -[source,java]
    +
    +

    Leader Election

    +
    +
    +

    Leader election allows application to work together with other +applications to coordinate a cluster leadership via a third party system. +Currently we provide integrations with zookeeper, hazelcast and etcd.

    +
    -

    class MyEventListener implements ApplicationListener<AbstractLeaderEvent> {

    +

    From user perspective election is working via interfaces +org.springframework.cloud.cluster.leader.Candidate and +org.springframework.cloud.cluster.leader.Context. Candidate +contains access to leadership’s role and id and also have methods +onGranted and onRevoked. These callback methods are useful if +default Candidate implementation is changed.

    -
    -
    -
      @Override
    -  public void onApplicationEvent(AbstractLeaderEvent event) {
    -    // do something with OnGrantedEvent or OnRevokedEvent
    -  }
    -}
    +
    +

    Leader election is auto-configured if spring-cloud-cluster-autoconfigure +and either spring-cloud-cluster-hazelcast, spring-cloud-cluster-zookeeper +or spring-cloud-cluster-etcd jars are found from a classpath. In +case where both jars are found leader election is created using both +systems. See sections Zookeeper, +Hazelcast and +Etcd for more +information about a created beans.

    +
    +

    Default Candidate created from auto-configuration is +org.springframework.cloud.cluster.leader.DefaultCandidate which +currently only logs granted and revoked events.

    +
    +
    +

    If there’s a need for disable all leader related auto-configuration, +a spring.cloud.cluster.leader.enabled can be set to false which +then allows to do manual configuration even if the jars an on a +classpath. Properties spring.cloud.cluster.leader.id and +spring.cloud.cluster.leader.role can be used to set default +identifier and role.

    +
    +
    +

    If you are interested to simple get notification of granted and +revoked events one option is to attach event listener into spring +application context. Events OnGrantedEvent and OnRevokedEvent are +sent as spring event objects.

    +
    +
    +

    Simply create your own event listener class:

    -
    and then create it as a bean.
    +
    class MyEventListener implements ApplicationListener<AbstractLeaderEvent> {
     
    -[source,java]
    + @Override + public void onApplicationEvent(AbstractLeaderEvent event) { + // do something with OnGrantedEvent or OnRevokedEvent + } +}
    -

    @Configuration +

    and then create it as a bean.

    +
    +
    +
    +
    @Configuration
     static class Config {
       @Bean
       public MyEventListener myEventListener() {
         return new MyEventListener();
       }
    -}

    +}
    +
    +
    +
    +

    For simply log events you can also use a utility class +LoggingListener which allows easy configuration.

    -
    For simply log events you can also use a utility class
    -`LoggingListener` which allows easy configuration.
    +
    import org.springframework.cloud.cluster.leader.event.LoggingListener;
     
    -[source,java]
    -
    -
    -
    -

    import org.springframework.cloud.cluster.leader.event.LoggingListener;

    -
    -
    -

    @Configuration +@Configuration static class Config { @Bean public LoggingListener loggingListener() { return new LoggingListener("info"); } -}

    +}
    -
    -
    -
    [[spring-cloud-cluster-leaderelection-zookeeper]]
    -=== Zookeeper
    -`Candidate` implementation for zookeeper is created with a bean name
    -`zookeeperLeaderCandidate` which can be used to override the one
    -created during auto-configuration.
    -
    -Zookeeper based election can be explicitly disabled using property
    -`spring.cloud.cluster.zookeeper.leader.enabled`.
    -
    -Other properties `spring.cloud.cluster.zookeeper.namespace` and
    -`spring.cloud.cluster.zookeeper.connect` can be used to set the
    -zookeeper base namespace path and connect string.
    -
    -[[spring-cloud-cluster-leaderelection-hazelcast]]
    -=== Hazelcast
    -`Candidate` implementation for hazelcast is created with a bean name
    -`hazelcastLeaderCandidate` which can be used to override the one
    -created during auto-configuration.
    -
    -Hazelcast based election can be explicitly disabled using property
    -`spring.cloud.cluster.hazelcast.leader.enabled`. If you want to provide xml
    +
    +
    +

    Zookeeper

    +
    +

    Candidate implementation for zookeeper is created with a bean name +zookeeperLeaderCandidate which can be used to override the one +created during auto-configuration.

    +
    +
    +

    Zookeeper based election can be explicitly disabled using property +spring.cloud.cluster.zookeeper.leader.enabled.

    +
    +
    +

    Other properties spring.cloud.cluster.zookeeper.namespace and +spring.cloud.cluster.zookeeper.connect can be used to set the +zookeeper base namespace path and connect string.

    +
    +
    +
    +

    Hazelcast

    +
    +

    Candidate implementation for hazelcast is created with a bean name +hazelcastLeaderCandidate which can be used to override the one +created during auto-configuration.

    +
    +
    +

    Hazelcast based election can be explicitly disabled using property +spring.cloud.cluster.hazelcast.leader.enabled. If you want to provide xml based configuration for Hazelcast instance use property -`spring.cloud.cluster.hazelcast.config-location` to tell location of a -Hazelcast xml configuration file. `config-location` is a normal spring -`Resource`. - -[[spring-cloud-cluster-leaderelection-etcd]] -=== Etcd -`Candidate` implementation for etcd is created with a bean name -`etcdLeaderCandidate` which can be used to override the one -created during auto-configuration. - -Etcd based election can be explicitly disabled using property -`spring.cloud.cluster.etcd.leader.enabled`. - -Multiple etcd cluster uris can be specified using property -`spring.cloud.cluster.etcd.connect` - -= Appendix: Compendium of Configuration Properties - -|=== -|Name | Default | Description - -|encrypt.fail-on-error | true | Flag to say that a process should fail if there is an encryption or decryption - error. - -|encrypt.key | | A symmetric key. As a stronger alternative consider using a keystore. - -|encrypt.key-store.alias | | Alias for a key in the store. - -|encrypt.key-store.location | | Location of the key store file, e.g. classpath:/keystore.jks. - -|encrypt.key-store.password | | Password that locks the keystore. - -|encrypt.key-store.secret | | Secret protecting the key (defaults to the same as the password). - -|encrypt.rsa.algorithm | | The RSA algorithm to use (DEFAULT or OEAP). Once it is set do not change it (or - existing ciphers will not a decryptable). - -|encrypt.rsa.salt | deadbeef | Salt for the random secret used to encrypt cipher text. Once it is set do not - change it (or existing ciphers will not a decryptable). - -|encrypt.rsa.strong | false | Flag to indicate that "strong" AES encryption should be used internally. If +spring.cloud.cluster.hazelcast.config-location to tell location of a +Hazelcast xml configuration file. config-location is a normal spring +Resource.

    +
    +
    +
    +

    Etcd

    +
    +

    Candidate implementation for etcd is created with a bean name +etcdLeaderCandidate which can be used to override the one +created during auto-configuration.

    +
    +
    +

    Etcd based election can be explicitly disabled using property +spring.cloud.cluster.etcd.leader.enabled.

    +
    +
    +

    Multiple etcd cluster uris can be specified using property +spring.cloud.cluster.etcd.connect

    +
    +
    +
    +
    +

    Appendix: Compendium of Configuration Properties

    +
    +
    + +++++ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameDefaultDescription

    encrypt.fail-on-error

    true

    Flag to say that a process should fail if there is an encryption or decryption + error.

    encrypt.key

    A symmetric key. As a stronger alternative consider using a keystore.

    encrypt.key-store.alias

    Alias for a key in the store.

    encrypt.key-store.location

    Location of the key store file, e.g. classpath:/keystore.jks.

    encrypt.key-store.password

    Password that locks the keystore.

    encrypt.key-store.secret

    Secret protecting the key (defaults to the same as the password).

    encrypt.rsa.algorithm

    The RSA algorithm to use (DEFAULT or OEAP). Once it is set do not change it (or + existing ciphers will not a decryptable).

    encrypt.rsa.salt

    deadbeef

    Salt for the random secret used to encrypt cipher text. Once it is set do not + change it (or existing ciphers will not a decryptable).

    encrypt.rsa.strong

    false

    Flag to indicate that "strong" AES encryption should be used internally. If true then the GCM algorithm is applied to the AES encrypted bytes. Default is false (in which case "standard" CBC is used instead). Once it is set do not - change it (or existing ciphers will not a decryptable). - -|endpoints.bus.enabled | | - -|endpoints.bus.id | | - -|endpoints.bus.sensitive | | - -|endpoints.consul.enabled | | - -|endpoints.consul.id | | - -|endpoints.consul.sensitive | | - -|endpoints.features.enabled | | - -|endpoints.features.id | | - -|endpoints.features.sensitive | | - -|endpoints.pause.enabled | | - -|endpoints.pause.id | | - -|endpoints.pause.sensitive | | - -|endpoints.refresh.enabled | | - -|endpoints.refresh.id | | - -|endpoints.refresh.sensitive | | - -|endpoints.restart.enabled | | - -|endpoints.restart.id | | - -|endpoints.restart.pause-endpoint.enabled | | - -|endpoints.restart.pause-endpoint.id | | - -|endpoints.restart.pause-endpoint.sensitive | | - -|endpoints.restart.resume-endpoint.enabled | | - -|endpoints.restart.resume-endpoint.id | | - -|endpoints.restart.resume-endpoint.sensitive | | - -|endpoints.restart.sensitive | | - -|endpoints.restart.timeout | 0 | - -|endpoints.resume.enabled | | - -|endpoints.resume.id | | - -|endpoints.resume.sensitive | | - -|eureka.client.allow-redirects | false | Indicates whether server can redirect a client request to a backup server/cluster. + change it (or existing ciphers will not a decryptable).

    endpoints.bus.enabled

    endpoints.bus.id

    endpoints.bus.sensitive

    endpoints.consul.enabled

    endpoints.consul.id

    endpoints.consul.sensitive

    endpoints.features.enabled

    endpoints.features.id

    endpoints.features.sensitive

    endpoints.pause.enabled

    endpoints.pause.id

    endpoints.pause.sensitive

    endpoints.refresh.enabled

    endpoints.refresh.id

    endpoints.refresh.sensitive

    endpoints.restart.enabled

    endpoints.restart.id

    endpoints.restart.pause-endpoint.enabled

    endpoints.restart.pause-endpoint.id

    endpoints.restart.pause-endpoint.sensitive

    endpoints.restart.resume-endpoint.enabled

    endpoints.restart.resume-endpoint.id

    endpoints.restart.resume-endpoint.sensitive

    endpoints.restart.sensitive

    endpoints.restart.timeout

    0

    endpoints.resume.enabled

    endpoints.resume.id

    endpoints.resume.sensitive

    eureka.client.allow-redirects

    false

    Indicates whether server can redirect a client request to a backup server/cluster. If set to false, the server will handle the request directly, If set to true, it - may send HTTP redirect to the client, with a new server location. - -|eureka.client.availability-zones | | Gets the list of availability zones (used in AWS data centers) for the region in + may send HTTP redirect to the client, with a new server location.

    eureka.client.availability-zones

    Gets the list of availability zones (used in AWS data centers) for the region in which this instance resides. - - The changes are effective at runtime at the next registry fetch cycle as specified - by registryFetchIntervalSeconds. - -|eureka.client.backup-registry-impl | | Gets the name of the implementation which implements BackupRegistry to fetch the +

    The changes are effective at runtime at the next registry fetch cycle as specified + by registryFetchIntervalSeconds.

    eureka.client.backup-registry-impl

    Gets the name of the implementation which implements BackupRegistry to fetch the registry information as a fall back option for only the first time when the eureka client starts. - - This may be needed for applications which needs additional resiliency for registry - information without which it cannot operate. - -|eureka.client.cache-refresh-executor-exponential-back-off-bound | 10 | Cache refresh executor exponential back off related property. It is a maximum - multiplier value for retry delay, in case where a sequence of timeouts occurred. - -|eureka.client.cache-refresh-executor-thread-pool-size | 2 | The thread pool size for the cacheRefreshExecutor to initialise with - -|eureka.client.client-data-accept | | EurekaAccept name for client data accept - -|eureka.client.decoder-name | | This is a transient config and once the latest codecs are stable, can be removed - (as there will only be one) - -|eureka.client.disable-delta | false | Indicates whether the eureka client should disable fetching of delta and should +

    This may be needed for applications which needs additional resiliency for registry + information without which it cannot operate.

    eureka.client.cache-refresh-executor-exponential-back-off-bound

    10

    Cache refresh executor exponential back off related property. It is a maximum + multiplier value for retry delay, in case where a sequence of timeouts occurred.

    eureka.client.cache-refresh-executor-thread-pool-size

    2

    The thread pool size for the cacheRefreshExecutor to initialise with

    eureka.client.client-data-accept

    EurekaAccept name for client data accept

    eureka.client.decoder-name

    This is a transient config and once the latest codecs are stable, can be removed + (as there will only be one)

    eureka.client.disable-delta

    false

    Indicates whether the eureka client should disable fetching of delta and should rather resort to getting the full registry information. - - Note that the delta fetches can reduce the traffic tremendously, because the rate +

    Note that the delta fetches can reduce the traffic tremendously, because the rate of change with the eureka server is normally much lower than the rate of fetches. - - The changes are effective at runtime at the next registry fetch cycle as specified - by registryFetchIntervalSeconds - -|eureka.client.dollar-replacement | _- | Get a replacement string for Dollar sign <code>$</code> during - serializing/deserializing information in eureka server. - -|eureka.client.enabled | true | Flag to indicate that the Eureka client is enabled. - -|eureka.client.encoder-name | | This is a transient config and once the latest codecs are stable, can be removed - (as there will only be one) - -|eureka.client.escape-char-replacement | __ | Get a replacement string for underscore sign <code>_</code> during - serializing/deserializing information in eureka server. - -|eureka.client.eureka-connection-idle-timeout-seconds | 30 | Indicates how much time (in seconds) that the HTTP connections to eureka server can +

    The changes are effective at runtime at the next registry fetch cycle as specified + by registryFetchIntervalSeconds

    eureka.client.dollar-replacement

    _-

    Get a replacement string for Dollar sign <code>$</code> during + serializing/deserializing information in eureka server.

    eureka.client.enabled

    true

    Flag to indicate that the Eureka client is enabled.

    eureka.client.encoder-name

    This is a transient config and once the latest codecs are stable, can be removed + (as there will only be one)

    eureka.client.escape-char-replacement

    __

    Get a replacement string for underscore sign <code>_</code> during + serializing/deserializing information in eureka server.

    eureka.client.eureka-connection-idle-timeout-seconds

    30

    Indicates how much time (in seconds) that the HTTP connections to eureka server can stay idle before it can be closed. - - In the AWS environment, it is recommended that the values is 30 seconds or less, +

    In the AWS environment, it is recommended that the values is 30 seconds or less, since the firewall cleans up the connection information after a few mins leaving - the connection hanging in limbo - -|eureka.client.eureka-server-connect-timeout-seconds | 5 | Indicates how long to wait (in seconds) before a connection to eureka server needs + the connection hanging in limbo

    eureka.client.eureka-server-connect-timeout-seconds

    5

    Indicates how long to wait (in seconds) before a connection to eureka server needs to timeout. Note that the connections in the client are pooled by org.apache.http.client.HttpClient and this setting affects the actual connection - creation and also the wait time to get the connection from the pool. - -|eureka.client.eureka-server-dnsname | | Gets the DNS name to be queried to get the list of eureka servers.This information + creation and also the wait time to get the connection from the pool.

    eureka.client.eureka-server-dnsname

    Gets the DNS name to be queried to get the list of eureka servers.This information is not required if the contract returns the service urls by implementing serviceUrls. - - The DNS mechanism is used when useDnsForFetchingServiceUrls is set to true and the +

    The DNS mechanism is used when useDnsForFetchingServiceUrls is set to true and the eureka client expects the DNS to configured a certain way so that it can fetch changing eureka servers dynamically. - - The changes are effective at runtime. - -|eureka.client.eureka-server-port | | Gets the port to be used to construct the service url to contact eureka server when +

    The changes are effective at runtime.

    eureka.client.eureka-server-port

    Gets the port to be used to construct the service url to contact eureka server when the list of eureka servers come from the DNS.This information is not required if the contract returns the service urls eurekaServerServiceUrls(String). - - The DNS mechanism is used when useDnsForFetchingServiceUrls is set to true and the +

    The DNS mechanism is used when useDnsForFetchingServiceUrls is set to true and the eureka client expects the DNS to configured a certain way so that it can fetch changing eureka servers dynamically. - - The changes are effective at runtime. - -|eureka.client.eureka-server-read-timeout-seconds | 8 | Indicates how long to wait (in seconds) before a read from eureka server needs to - timeout. - -|eureka.client.eureka-server-total-connections | 200 | Gets the total number of connections that is allowed from eureka client to all - eureka servers. - -|eureka.client.eureka-server-total-connections-per-host | 50 | Gets the total number of connections that is allowed from eureka client to a eureka - server host. - -|eureka.client.eureka-server-urlcontext | | Gets the URL context to be used to construct the service url to contact eureka +

    The changes are effective at runtime.

    eureka.client.eureka-server-read-timeout-seconds

    8

    Indicates how long to wait (in seconds) before a read from eureka server needs to + timeout.

    eureka.client.eureka-server-total-connections

    200

    Gets the total number of connections that is allowed from eureka client to all + eureka servers.

    eureka.client.eureka-server-total-connections-per-host

    50

    Gets the total number of connections that is allowed from eureka client to a eureka + server host.

    eureka.client.eureka-server-urlcontext

    Gets the URL context to be used to construct the service url to contact eureka server when the list of eureka servers come from the DNS. This information is not required if the contract returns the service urls from eurekaServerServiceUrls. - - The DNS mechanism is used when useDnsForFetchingServiceUrls is set to true and the +

    The DNS mechanism is used when useDnsForFetchingServiceUrls is set to true and the eureka client expects the DNS to configured a certain way so that it can fetch - changing eureka servers dynamically. The changes are effective at runtime. - -|eureka.client.eureka-service-url-poll-interval-seconds | 0 | Indicates how often(in seconds) to poll for changes to eureka server information. + changing eureka servers dynamically. The changes are effective at runtime.

    eureka.client.eureka-service-url-poll-interval-seconds

    0

    Indicates how often(in seconds) to poll for changes to eureka server information. Eureka servers could be added or removed and this setting controls how soon the - eureka clients should know about it. - -|eureka.client.fetch-registry | true | Indicates whether this client should fetch eureka registry information from eureka - server. - -|eureka.client.fetch-remote-regions-registry | | Comma separated list of regions for which the eureka registry information will be + eureka clients should know about it.

    eureka.client.fetch-registry

    true

    Indicates whether this client should fetch eureka registry information from eureka + server.

    eureka.client.fetch-remote-regions-registry

    Comma separated list of regions for which the eureka registry information will be fetched. It is mandatory to define the availability zones for each of these regions as returned by availabilityZones. Failing to do so, will result in failure of - discovery client startup. - -|eureka.client.filter-only-up-instances | true | Indicates whether to get the applications after filtering the applications for - instances with only InstanceStatus UP states. - -|eureka.client.g-zip-content | true | Indicates whether the content fetched from eureka server has to be compressed + discovery client startup.

    eureka.client.filter-only-up-instances

    true

    Indicates whether to get the applications after filtering the applications for + instances with only InstanceStatus UP states.

    eureka.client.g-zip-content

    true

    Indicates whether the content fetched from eureka server has to be compressed whenever it is supported by the server. The registry information from the eureka - server is compressed for optimum network traffic. - -|eureka.client.heartbeat-executor-exponential-back-off-bound | 10 | Heartbeat executor exponential back off related property. It is a maximum - multiplier value for retry delay, in case where a sequence of timeouts occurred. - -|eureka.client.heartbeat-executor-thread-pool-size | 2 | The thread pool size for the heartbeatExecutor to initialise with - -|eureka.client.initial-instance-info-replication-interval-seconds | 40 | Indicates how long initially (in seconds) to replicate instance info to the eureka - server - -|eureka.client.instance-info-replication-interval-seconds | 30 | Indicates how often(in seconds) to replicate instance changes to be replicated to - the eureka server. - -|eureka.client.log-delta-diff | false | Indicates whether to log differences between the eureka server and the eureka + server is compressed for optimum network traffic.

    eureka.client.heartbeat-executor-exponential-back-off-bound

    10

    Heartbeat executor exponential back off related property. It is a maximum + multiplier value for retry delay, in case where a sequence of timeouts occurred.

    eureka.client.heartbeat-executor-thread-pool-size

    2

    The thread pool size for the heartbeatExecutor to initialise with

    eureka.client.initial-instance-info-replication-interval-seconds

    40

    Indicates how long initially (in seconds) to replicate instance info to the eureka + server

    eureka.client.instance-info-replication-interval-seconds

    30

    Indicates how often(in seconds) to replicate instance changes to be replicated to + the eureka server.

    eureka.client.log-delta-diff

    false

    Indicates whether to log differences between the eureka server and the eureka client in terms of registry information. - - Eureka client tries to retrieve only delta changes from eureka server to minimize +

    Eureka client tries to retrieve only delta changes from eureka server to minimize network traffic. After receiving the deltas, eureka client reconciles the information from the server to verify it has not missed out some information. Reconciliation failures could happen when the client has had network issues communicating to server.If the reconciliation fails, eureka client gets the full registry information. - - While getting the full registry information, the eureka client can log the +

    While getting the full registry information, the eureka client can log the differences between the client and the server and this setting controls that. - - The changes are effective at runtime at the next registry fetch cycle as specified - by registryFetchIntervalSecondsr - -|eureka.client.on-demand-update-status-change | true | If set to true, local status updates via ApplicationInfoManager will trigger - on-demand (but rate limited) register/updates to remote eureka servers - -|eureka.client.prefer-same-zone-eureka | true | Indicates whether or not this instance should try to use the eureka server in the +

    The changes are effective at runtime at the next registry fetch cycle as specified + by registryFetchIntervalSecondsr

    eureka.client.on-demand-update-status-change

    true

    If set to true, local status updates via ApplicationInfoManager will trigger + on-demand (but rate limited) register/updates to remote eureka servers

    eureka.client.prefer-same-zone-eureka

    true

    Indicates whether or not this instance should try to use the eureka server in the same zone for latency and/or other reason. - - Ideally eureka clients are configured to talk to servers in the same zone - - The changes are effective at runtime at the next registry fetch cycle as specified - by registryFetchIntervalSeconds - -|eureka.client.property-resolver | | - -|eureka.client.proxy-host | | Gets the proxy host to eureka server if any. - -|eureka.client.proxy-password | | Gets the proxy password if any. - -|eureka.client.proxy-port | | Gets the proxy port to eureka server if any. - -|eureka.client.proxy-user-name | | Gets the proxy user name if any. - -|eureka.client.region | us-east-1 | Gets the region (used in AWS datacenters) where this instance resides. - -|eureka.client.register-with-eureka | true | Indicates whether or not this instance should register its information with eureka +

    Ideally eureka clients are configured to talk to servers in the same zone +

    The changes are effective at runtime at the next registry fetch cycle as specified + by registryFetchIntervalSeconds

    eureka.client.property-resolver

    eureka.client.proxy-host

    Gets the proxy host to eureka server if any.

    eureka.client.proxy-password

    Gets the proxy password if any.

    eureka.client.proxy-port

    Gets the proxy port to eureka server if any.

    eureka.client.proxy-user-name

    Gets the proxy user name if any.

    eureka.client.region

    us-east-1

    Gets the region (used in AWS datacenters) where this instance resides.

    eureka.client.register-with-eureka

    true

    Indicates whether or not this instance should register its information with eureka server for discovery by others. - - In some cases, you do not want your instances to be discovered whereas you just - want do discover other instances. - -|eureka.client.registry-fetch-interval-seconds | 30 | Indicates how often(in seconds) to fetch the registry information from the eureka - server. - -|eureka.client.registry-refresh-single-vip-address | | Indicates whether the client is only interested in the registry information for a - single VIP. - -|eureka.client.service-url | | Map of availability zone to list of fully qualified URLs to communicate with eureka +

    In some cases, you do not want your instances to be discovered whereas you just + want do discover other instances.

    eureka.client.registry-fetch-interval-seconds

    30

    Indicates how often(in seconds) to fetch the registry information from the eureka + server.

    eureka.client.registry-refresh-single-vip-address

    Indicates whether the client is only interested in the registry information for a + single VIP.

    eureka.client.service-url

    Map of availability zone to list of fully qualified URLs to communicate with eureka server. Each value can be a single URL or a comma separated list of alternative locations. - - Typically the eureka server URLs carry protocol,host,port,context and version +

    Typically the eureka server URLs carry protocol,host,port,context and version information if any. Example: - http://ec2-256-156-243-129.compute-1.amazonaws.com:7001/eureka/ - - The changes are effective at runtime at the next service url refresh cycle as - specified by eurekaServiceUrlPollIntervalSeconds. - -|eureka.client.transport | | - -|eureka.client.use-dns-for-fetching-service-urls | false | Indicates whether the eureka client should use the DNS mechanism to fetch a list of + http://ec2-256-156-243-129.compute-1.amazonaws.com:7001/eureka/ +

    The changes are effective at runtime at the next service url refresh cycle as + specified by eurekaServiceUrlPollIntervalSeconds.

    eureka.client.transport

    eureka.client.use-dns-for-fetching-service-urls

    false

    Indicates whether the eureka client should use the DNS mechanism to fetch a list of eureka servers to talk to. When the DNS name is updated to have additional servers, that information is used immediately after the eureka client polls for that information as specified in eurekaServiceUrlPollIntervalSeconds. - - Alternatively, the service urls can be returned serviceUrls, but the users should +

    Alternatively, the service urls can be returned serviceUrls, but the users should implement their own mechanism to return the updated list in case of changes. - - The changes are effective at runtime. - -|eureka.dashboard.enabled | true | Flag to enable the Eureka dashboard. Default true. - -|eureka.dashboard.path | / | The path to the Eureka dashboard (relative to the servlet path). Defaults to "/". - -|eureka.instance.a-sgname | | Gets the AWS autoscaling group name associated with this instance. This information +

    The changes are effective at runtime.

    eureka.dashboard.enabled

    true

    Flag to enable the Eureka dashboard. Default true.

    eureka.dashboard.path

    /

    The path to the Eureka dashboard (relative to the servlet path). Defaults to "/".

    eureka.instance.a-sgname

    Gets the AWS autoscaling group name associated with this instance. This information is specifically used in an AWS environment to automatically put an instance out of - service after the instance is launched and it has been disabled for traffic.. - -|eureka.instance.app-group-name | | Get the name of the application group to be registered with eureka. - -|eureka.instance.appname | unknown | Get the name of the application to be registered with eureka. - -|eureka.instance.data-center-info | | Returns the data center this instance is deployed. This information is used to get - some AWS specific instance information if the instance is deployed in AWS. - -|eureka.instance.default-address-resolution-order | [] | - -|eureka.instance.health-check-url | | Gets the absolute health check page URL for this instance. The users can provide + service after the instance is launched and it has been disabled for traffic..

    eureka.instance.app-group-name

    Get the name of the application group to be registered with eureka.

    eureka.instance.appname

    unknown

    Get the name of the application to be registered with eureka.

    eureka.instance.data-center-info

    Returns the data center this instance is deployed. This information is used to get + some AWS specific instance information if the instance is deployed in AWS.

    eureka.instance.default-address-resolution-order

    []

    eureka.instance.health-check-url

    Gets the absolute health check page URL for this instance. The users can provide the healthCheckUrlPath if the health check page resides in the same instance talking to eureka, else in the cases where the instance is a proxy for some other server, users can provide the full URL. If the full URL is provided it takes precedence. - - <p> +

    <p> It is normally used for making educated decisions based on the health of the instance - for example, it can be used to determine whether to proceed deployments to an entire farm or stop the deployments without causing further damage. The full - URL should follow the format http://${eureka.hostname}:7001/ where the value - ${eureka.hostname} is replaced at runtime. - -|eureka.instance.health-check-url-path | /health | Gets the relative health check URL path for this instance. The health check page + URL should follow the format http://${eureka.hostname}:7001/ where the value + ${eureka.hostname} is replaced at runtime.

    eureka.instance.health-check-url-path

    /health

    Gets the relative health check URL path for this instance. The health check page URL is then constructed out of the hostname and the type of communication - secure or unsecure as specified in securePort and nonSecurePort. - - It is normally used for making educated decisions based on the health of the +

    It is normally used for making educated decisions based on the health of the instance - for example, it can be used to determine whether to proceed deployments - to an entire farm or stop the deployments without causing further damage. - -|eureka.instance.home-page-url | | Gets the absolute home page URL for this instance. The users can provide the + to an entire farm or stop the deployments without causing further damage.

    eureka.instance.home-page-url

    Gets the absolute home page URL for this instance. The users can provide the homePageUrlPath if the home page resides in the same instance talking to eureka, else in the cases where the instance is a proxy for some other server, users can provide the full URL. If the full URL is provided it takes precedence. - - It is normally used for informational purposes for other services to use it as a - landing page. The full URL should follow the format http://${eureka.hostname}:7001/ - where the value ${eureka.hostname} is replaced at runtime. - -|eureka.instance.home-page-url-path | / | Gets the relative home page URL Path for this instance. The home page URL is then +

    It is normally used for informational purposes for other services to use it as a + landing page. The full URL should follow the format http://${eureka.hostname}:7001/ + where the value ${eureka.hostname} is replaced at runtime.

    eureka.instance.home-page-url-path

    /

    Gets the relative home page URL Path for this instance. The home page URL is then constructed out of the hostName and the type of communication - secure or unsecure. - - It is normally used for informational purposes for other services to use it as a - landing page. - -|eureka.instance.host-info | | - -|eureka.instance.hostname | | The hostname if it can be determined at configuration time (otherwise it will be - guessed from OS primitives). - -|eureka.instance.inet-utils | | - -|eureka.instance.initial-status | | Initial status to register with rmeote Eureka server. - -|eureka.instance.instance-enabled-onit | false | Indicates whether the instance should be enabled for taking traffic as soon as it +

    It is normally used for informational purposes for other services to use it as a + landing page.

    eureka.instance.host-info

    eureka.instance.hostname

    The hostname if it can be determined at configuration time (otherwise it will be + guessed from OS primitives).

    eureka.instance.inet-utils

    eureka.instance.initial-status

    Initial status to register with rmeote Eureka server.

    eureka.instance.instance-enabled-onit

    false

    Indicates whether the instance should be enabled for taking traffic as soon as it is registered with eureka. Sometimes the application might need to do some - pre-processing before it is ready to take traffic. - -|eureka.instance.instance-id | | Get the unique Id (within the scope of the appName) of this instance to be - registered with eureka. - -|eureka.instance.ip-address | | Get the IPAdress of the instance. This information is for academic purposes only as + pre-processing before it is ready to take traffic.

    eureka.instance.instance-id

    Get the unique Id (within the scope of the appName) of this instance to be + registered with eureka.

    eureka.instance.ip-address

    Get the IPAdress of the instance. This information is for academic purposes only as the communication from other instances primarily happen using the information - supplied in {@link #getHostName(boolean)}. - -|eureka.instance.lease-expiration-duration-in-seconds | 90 | Indicates the time in seconds that the eureka server waits since it received the + supplied in {@link #getHostName(boolean)}.

    eureka.instance.lease-expiration-duration-in-seconds

    90

    Indicates the time in seconds that the eureka server waits since it received the last heartbeat before it can remove this instance from its view and there by disallowing traffic to this instance. - - Setting this value too long could mean that the traffic could be routed to the +

    Setting this value too long could mean that the traffic could be routed to the instance even though the instance is not alive. Setting this value too small could mean, the instance may be taken out of traffic because of temporary network glitches.This value to be set to atleast higher than the value specified in - leaseRenewalIntervalInSeconds. - -|eureka.instance.lease-renewal-interval-in-seconds | 30 | Indicates how often (in seconds) the eureka client needs to send heartbeats to + leaseRenewalIntervalInSeconds.

    eureka.instance.lease-renewal-interval-in-seconds

    30

    Indicates how often (in seconds) the eureka client needs to send heartbeats to eureka server to indicate that it is still alive. If the heartbeats are not received for the period specified in leaseExpirationDurationInSeconds, eureka server will remove the instance from its view, there by disallowing traffic to this instance. - - Note that the instance could still not take traffic if it implements - HealthCheckCallback and then decides to make itself unavailable. - -|eureka.instance.metadata-map | | Gets the metadata name/value pairs associated with this instance. This information - is sent to eureka server and can be used by other instances. - -|eureka.instance.namespace | eureka | Get the namespace used to find properties. Ignored in Spring Cloud. - -|eureka.instance.non-secure-port | 80 | Get the non-secure port on which the instance should receive traffic. - -|eureka.instance.non-secure-port-enabled | true | Indicates whether the non-secure port should be enabled for traffic or not. - -|eureka.instance.prefer-ip-address | false | Flag to say that, when guessing a hostname, the IP address of the server should be - used in prference to the hostname reported by the OS. - -|eureka.instance.secure-health-check-url | | Gets the absolute secure health check page URL for this instance. The users can +

    Note that the instance could still not take traffic if it implements + HealthCheckCallback and then decides to make itself unavailable.

    eureka.instance.metadata-map

    Gets the metadata name/value pairs associated with this instance. This information + is sent to eureka server and can be used by other instances.

    eureka.instance.namespace

    eureka

    Get the namespace used to find properties. Ignored in Spring Cloud.

    eureka.instance.non-secure-port

    80

    Get the non-secure port on which the instance should receive traffic.

    eureka.instance.non-secure-port-enabled

    true

    Indicates whether the non-secure port should be enabled for traffic or not.

    eureka.instance.prefer-ip-address

    false

    Flag to say that, when guessing a hostname, the IP address of the server should be + used in prference to the hostname reported by the OS.

    eureka.instance.secure-health-check-url

    Gets the absolute secure health check page URL for this instance. The users can provide the secureHealthCheckUrl if the health check page resides in the same instance talking to eureka, else in the cases where the instance is a proxy for some other server, users can provide the full URL. If the full URL is provided it takes precedence. - - <p> +

    <p> It is normally used for making educated decisions based on the health of the instance - for example, it can be used to determine whether to proceed deployments to an entire farm or stop the deployments without causing further damage. The full - URL should follow the format http://${eureka.hostname}:7001/ where the value - ${eureka.hostname} is replaced at runtime. - -|eureka.instance.secure-port | 443 | Get the Secure port on which the instance should receive traffic. - -|eureka.instance.secure-port-enabled | false | Indicates whether the secure port should be enabled for traffic or not. - -|eureka.instance.secure-virtual-host-name | | Gets the secure virtual host name defined for this instance. - - This is typically the way other instance would find this instance by using the + URL should follow the format http://${eureka.hostname}:7001/ where the value + ${eureka.hostname} is replaced at runtime.

    eureka.instance.secure-port

    443

    Get the Secure port on which the instance should receive traffic.

    eureka.instance.secure-port-enabled

    false

    Indicates whether the secure port should be enabled for traffic or not.

    eureka.instance.secure-virtual-host-name

    Gets the secure virtual host name defined for this instance. +

    This is typically the way other instance would find this instance by using the secure virtual host name.Think of this as similar to the fully qualified domain - name, that the users of your services will need to find this instance. - -|eureka.instance.status-page-url | | Gets the absolute status page URL path for this instance. The users can provide the + name, that the users of your services will need to find this instance.

    eureka.instance.status-page-url

    Gets the absolute status page URL path for this instance. The users can provide the statusPageUrlPath if the status page resides in the same instance talking to eureka, else in the cases where the instance is a proxy for some other server, users can provide the full URL. If the full URL is provided it takes precedence. - - It is normally used for informational purposes for other services to find about the +

    It is normally used for informational purposes for other services to find about the status of this instance. Users can provide a simple HTML indicating what is the - current status of the instance. - -|eureka.instance.status-page-url-path | /info | Gets the relative status page URL path for this instance. The status page URL is + current status of the instance.

    eureka.instance.status-page-url-path

    /info

    Gets the relative status page URL path for this instance. The status page URL is then constructed out of the hostName and the type of communication - secure or unsecure as specified in securePort and nonSecurePort. - - It is normally used for informational purposes for other services to find about the +

    It is normally used for informational purposes for other services to find about the status of this instance. Users can provide a simple HTML indicating what is the - current status of the instance. - -|eureka.instance.virtual-host-name | | Gets the virtual host name defined for this instance. - - This is typically the way other instance would find this instance by using the + current status of the instance.

    eureka.instance.virtual-host-name

    Gets the virtual host name defined for this instance. +

    This is typically the way other instance would find this instance by using the virtual host name.Think of this as similar to the fully qualified domain name, that - the users of your services will need to find this instance. - -|eureka.server.a-sgcache-expiry-timeout-ms | 0 | - -|eureka.server.a-sgquery-timeout-ms | 300 | - -|eureka.server.a-sgupdate-interval-ms | 0 | - -|eureka.server.a-wsaccess-id | | - -|eureka.server.a-wssecret-key | | - -|eureka.server.batch-replication | false | - -|eureka.server.binding-strategy | | - -|eureka.server.delta-retention-timer-interval-in-ms | 0 | - -|eureka.server.disable-delta | false | - -|eureka.server.disable-delta-for-remote-regions | false | - -|eureka.server.disable-transparent-fallback-to-other-region | false | - -|eureka.server.e-ipbind-rebind-retries | 3 | - -|eureka.server.e-ipbinding-retry-interval-ms | 0 | - -|eureka.server.e-ipbinding-retry-interval-ms-when-unbound | 0 | - -|eureka.server.enable-replicated-request-compression | false | - -|eureka.server.enable-self-preservation | true | - -|eureka.server.eviction-interval-timer-in-ms | 0 | - -|eureka.server.g-zip-content-from-remote-region | true | - -|eureka.server.json-codec-name | | - -|eureka.server.list-auto-scaling-groups-role-name | ListAutoScalingGroups | - -|eureka.server.log-identity-headers | true | - -|eureka.server.max-elements-in-peer-replication-pool | 10000 | - -|eureka.server.max-elements-in-status-replication-pool | 10000 | - -|eureka.server.max-idle-thread-age-in-minutes-for-peer-replication | 15 | - -|eureka.server.max-idle-thread-in-minutes-age-for-status-replication | 10 | - -|eureka.server.max-threads-for-peer-replication | 20 | - -|eureka.server.max-threads-for-status-replication | 1 | - -|eureka.server.max-time-for-replication | 30000 | - -|eureka.server.min-threads-for-peer-replication | 5 | - -|eureka.server.min-threads-for-status-replication | 1 | - -|eureka.server.number-of-replication-retries | 5 | - -|eureka.server.peer-eureka-nodes-update-interval-ms | 0 | - -|eureka.server.peer-eureka-status-refresh-time-interval-ms | 0 | - -|eureka.server.peer-node-connect-timeout-ms | 200 | - -|eureka.server.peer-node-connection-idle-timeout-seconds | 30 | - -|eureka.server.peer-node-read-timeout-ms | 200 | - -|eureka.server.peer-node-total-connections | 1000 | - -|eureka.server.peer-node-total-connections-per-host | 500 | - -|eureka.server.prime-aws-replica-connections | true | - -|eureka.server.property-resolver | | - -|eureka.server.rate-limiter-burst-size | 10 | - -|eureka.server.rate-limiter-enabled | false | - -|eureka.server.rate-limiter-full-fetch-average-rate | 100 | - -|eureka.server.rate-limiter-privileged-clients | | - -|eureka.server.rate-limiter-registry-fetch-average-rate | 500 | - -|eureka.server.rate-limiter-throttle-standard-clients | false | - -|eureka.server.registry-sync-retries | 0 | - -|eureka.server.registry-sync-retry-wait-ms | 0 | - -|eureka.server.remote-region-app-whitelist | | - -|eureka.server.remote-region-connect-timeout-ms | 1000 | - -|eureka.server.remote-region-connection-idle-timeout-seconds | 30 | - -|eureka.server.remote-region-fetch-thread-pool-size | 20 | - -|eureka.server.remote-region-read-timeout-ms | 1000 | - -|eureka.server.remote-region-registry-fetch-interval | 30 | - -|eureka.server.remote-region-total-connections | 1000 | - -|eureka.server.remote-region-total-connections-per-host | 500 | - -|eureka.server.remote-region-trust-store | | - -|eureka.server.remote-region-trust-store-password | changeit | - -|eureka.server.remote-region-urls | | - -|eureka.server.remote-region-urls-with-name | | - -|eureka.server.renewal-percent-threshold | 0.85 | - -|eureka.server.renewal-threshold-update-interval-ms | 0 | - -|eureka.server.response-cache-auto-expiration-in-seconds | 180 | - -|eureka.server.response-cache-update-interval-ms | 0 | - -|eureka.server.retention-time-in-msin-delta-queue | 0 | - -|eureka.server.route53-bind-rebind-retries | 3 | - -|eureka.server.route53-binding-retry-interval-ms | 0 | - -|eureka.server.route53-domain-ttl | 30 | - -|eureka.server.sync-when-timestamp-differs | true | - -|eureka.server.use-read-only-response-cache | true | - -|eureka.server.wait-time-in-ms-when-sync-empty | 0 | - -|eureka.server.xml-codec-name | | - -|feign.compression.request.mime-types | [text/xml, application/xml, application/json] | The list of supported mime types. - -|feign.compression.request.min-request-size | 2048 | The minimum threshold content size. - -|health.config.enabled | false | Flag to indicate that the config server health indicator should be installed. - -|health.hystrix.enabled | false | Flag to inidicate that the hystrix health indicator should be installed. - -|netflix.atlas.batch-size | 10000 | - -|netflix.atlas.enabled | true | - -|netflix.atlas.uri | | - -|proxy.auth.load-balanced | false | - -|proxy.auth.routes | | Authentication strategy per route. - -|spring.cloud.bus.ack.destination-service | | Service that wants to listen to acks. By default null (meaning all services). - -|spring.cloud.bus.ack.enabled | true | Flag to switch off acks (default on). - -|spring.cloud.bus.destination | springCloudBus | Name of Spring Cloud Stream destination for messages. - -|spring.cloud.bus.enabled | true | Flag to indicate that the bus is enabled. - -|spring.cloud.bus.env.enabled | true | Flag to switch off environment change events (default on). - -|spring.cloud.bus.refresh.enabled | true | Flag to switch off refresh events (default on). - -|spring.cloud.bus.trace.enabled | false | Flag to switch on tracing of acks (default off). - -|spring.cloud.cloudfoundry.discovery.email | | Email address of user to authenticate. - -|spring.cloud.cloudfoundry.discovery.enabled | true | Flag to indicate that discovery is enabled. - -|spring.cloud.cloudfoundry.discovery.password | | Password for user to authenticate and obtain token. - -|spring.cloud.cloudfoundry.discovery.url | https://api.run.pivotal.io | URL of Cloud Foundry API (Cloud Controller). - -|spring.cloud.config.allow-override | true | Flag to indicate that {@link #isSystemPropertiesOverride() + the users of your services will need to find this instance.

    eureka.server.a-sgcache-expiry-timeout-ms

    0

    eureka.server.a-sgquery-timeout-ms

    300

    eureka.server.a-sgupdate-interval-ms

    0

    eureka.server.a-wsaccess-id

    eureka.server.a-wssecret-key

    eureka.server.batch-replication

    false

    eureka.server.binding-strategy

    eureka.server.delta-retention-timer-interval-in-ms

    0

    eureka.server.disable-delta

    false

    eureka.server.disable-delta-for-remote-regions

    false

    eureka.server.disable-transparent-fallback-to-other-region

    false

    eureka.server.e-ipbind-rebind-retries

    3

    eureka.server.e-ipbinding-retry-interval-ms

    0

    eureka.server.e-ipbinding-retry-interval-ms-when-unbound

    0

    eureka.server.enable-replicated-request-compression

    false

    eureka.server.enable-self-preservation

    true

    eureka.server.eviction-interval-timer-in-ms

    0

    eureka.server.g-zip-content-from-remote-region

    true

    eureka.server.json-codec-name

    eureka.server.list-auto-scaling-groups-role-name

    ListAutoScalingGroups

    eureka.server.log-identity-headers

    true

    eureka.server.max-elements-in-peer-replication-pool

    10000

    eureka.server.max-elements-in-status-replication-pool

    10000

    eureka.server.max-idle-thread-age-in-minutes-for-peer-replication

    15

    eureka.server.max-idle-thread-in-minutes-age-for-status-replication

    10

    eureka.server.max-threads-for-peer-replication

    20

    eureka.server.max-threads-for-status-replication

    1

    eureka.server.max-time-for-replication

    30000

    eureka.server.min-threads-for-peer-replication

    5

    eureka.server.min-threads-for-status-replication

    1

    eureka.server.number-of-replication-retries

    5

    eureka.server.peer-eureka-nodes-update-interval-ms

    0

    eureka.server.peer-eureka-status-refresh-time-interval-ms

    0

    eureka.server.peer-node-connect-timeout-ms

    200

    eureka.server.peer-node-connection-idle-timeout-seconds

    30

    eureka.server.peer-node-read-timeout-ms

    200

    eureka.server.peer-node-total-connections

    1000

    eureka.server.peer-node-total-connections-per-host

    500

    eureka.server.prime-aws-replica-connections

    true

    eureka.server.property-resolver

    eureka.server.rate-limiter-burst-size

    10

    eureka.server.rate-limiter-enabled

    false

    eureka.server.rate-limiter-full-fetch-average-rate

    100

    eureka.server.rate-limiter-privileged-clients

    eureka.server.rate-limiter-registry-fetch-average-rate

    500

    eureka.server.rate-limiter-throttle-standard-clients

    false

    eureka.server.registry-sync-retries

    0

    eureka.server.registry-sync-retry-wait-ms

    0

    eureka.server.remote-region-app-whitelist

    eureka.server.remote-region-connect-timeout-ms

    1000

    eureka.server.remote-region-connection-idle-timeout-seconds

    30

    eureka.server.remote-region-fetch-thread-pool-size

    20

    eureka.server.remote-region-read-timeout-ms

    1000

    eureka.server.remote-region-registry-fetch-interval

    30

    eureka.server.remote-region-total-connections

    1000

    eureka.server.remote-region-total-connections-per-host

    500

    eureka.server.remote-region-trust-store

    eureka.server.remote-region-trust-store-password

    changeit

    eureka.server.remote-region-urls

    eureka.server.remote-region-urls-with-name

    eureka.server.renewal-percent-threshold

    0.85

    eureka.server.renewal-threshold-update-interval-ms

    0

    eureka.server.response-cache-auto-expiration-in-seconds

    180

    eureka.server.response-cache-update-interval-ms

    0

    eureka.server.retention-time-in-msin-delta-queue

    0

    eureka.server.route53-bind-rebind-retries

    3

    eureka.server.route53-binding-retry-interval-ms

    0

    eureka.server.route53-domain-ttl

    30

    eureka.server.sync-when-timestamp-differs

    true

    eureka.server.use-read-only-response-cache

    true

    eureka.server.wait-time-in-ms-when-sync-empty

    0

    eureka.server.xml-codec-name

    feign.compression.request.mime-types

    [text/xml, application/xml, application/json]

    The list of supported mime types.

    feign.compression.request.min-request-size

    2048

    The minimum threshold content size.

    health.config.enabled

    false

    Flag to indicate that the config server health indicator should be installed.

    health.hystrix.enabled

    false

    Flag to inidicate that the hystrix health indicator should be installed.

    netflix.atlas.batch-size

    10000

    netflix.atlas.enabled

    true

    netflix.atlas.uri

    proxy.auth.load-balanced

    false

    proxy.auth.routes

    Authentication strategy per route.

    spring.cloud.bus.ack.destination-service

    Service that wants to listen to acks. By default null (meaning all services).

    spring.cloud.bus.ack.enabled

    true

    Flag to switch off acks (default on).

    spring.cloud.bus.destination

    springCloudBus

    Name of Spring Cloud Stream destination for messages.

    spring.cloud.bus.enabled

    true

    Flag to indicate that the bus is enabled.

    spring.cloud.bus.env.enabled

    true

    Flag to switch off environment change events (default on).

    spring.cloud.bus.refresh.enabled

    true

    Flag to switch off refresh events (default on).

    spring.cloud.bus.trace.enabled

    false

    Flag to switch on tracing of acks (default off).

    spring.cloud.cloudfoundry.discovery.email

    Email address of user to authenticate.

    spring.cloud.cloudfoundry.discovery.enabled

    true

    Flag to indicate that discovery is enabled.

    spring.cloud.cloudfoundry.discovery.password

    Password for user to authenticate and obtain token.

    spring.cloud.cloudfoundry.discovery.url

    https://api.run.pivotal.io

    URL of Cloud Foundry API (Cloud Controller).

    spring.cloud.config.allow-override

    true

    Flag to indicate that {@link #isSystemPropertiesOverride() systemPropertiesOverride} can be used. Set to false to prevent users from changing - the default accidentally. Default true. - -|spring.cloud.config.discovery.enabled | false | Flag to indicate that config server discovery is enabled (config server URL will be - looked up via discovery). - -|spring.cloud.config.discovery.service-id | CONFIGSERVER | Service id to locate config server. - -|spring.cloud.config.enabled | true | Flag to say that remote configuration is enabled. Default true; - -|spring.cloud.config.fail-fast | false | Flag to indicate that failure to connect to the server is fatal (default false). - -|spring.cloud.config.label | | The label name to use to pull remote configuration properties. The default is set - on the server (generally "master" for a git based server). - -|spring.cloud.config.name | | Name of application used to fetch remote properties. - -|spring.cloud.config.override-none | false | Flag to indicate that when {@link #setAllowOverride(boolean) allowOverride} is + the default accidentally. Default true.

    spring.cloud.config.discovery.enabled

    false

    Flag to indicate that config server discovery is enabled (config server URL will be + looked up via discovery).

    spring.cloud.config.discovery.service-id

    CONFIGSERVER

    Service id to locate config server.

    spring.cloud.config.enabled

    true

    Flag to say that remote configuration is enabled. Default true;

    spring.cloud.config.fail-fast

    false

    Flag to indicate that failure to connect to the server is fatal (default false).

    spring.cloud.config.label

    The label name to use to pull remote configuration properties. The default is set + on the server (generally "master" for a git based server).

    spring.cloud.config.name

    Name of application used to fetch remote properties.

    spring.cloud.config.override-none

    false

    Flag to indicate that when {@link #setAllowOverride(boolean) allowOverride} is true, external properties should take lowest priority, and not override any - existing property sources (including local config files). Default false. - -|spring.cloud.config.override-system-properties | true | Flag to indicate that the external properties should override system properties. - Default true. - -|spring.cloud.config.password | | The password to use (HTTP Basic) when contacting the remote server. - -|spring.cloud.config.profile | default | The default profile to use when fetching remote configuration (comma-separated). - Default is "default". - -|spring.cloud.config.retry.initial-interval | 1000 | Initial retry interval in milliseconds. - -|spring.cloud.config.retry.max-attempts | 6 | Maximum number of attempts. - -|spring.cloud.config.retry.max-interval | 2000 | Maximum interval for backoff. - -|spring.cloud.config.retry.multiplier | 1.1 | Multiplier for next interval. - -|spring.cloud.config.uri | http://localhost:8888 | The URI of the remote server (default http://localhost:8888). - -|spring.cloud.config.username | | The username to use (HTTP Basic) when contacting the remote server. - -|spring.cloud.consul.config.acl-token | | - -|spring.cloud.consul.config.data-key | data | If format is Format.PROPERTIES or Format.YAML - then the following field is used as key to look up consul for configuration. - -|spring.cloud.consul.config.default-context | application | - -|spring.cloud.consul.config.enabled | true | - -|spring.cloud.consul.config.fail-fast | true | Throw exceptions during config lookup if true, otherwise, log warnings. - -|spring.cloud.consul.config.format | | - -|spring.cloud.consul.config.prefix | config | - -|spring.cloud.consul.config.profile-separator | , | - -|spring.cloud.consul.config.watch.delay | 10 | - -|spring.cloud.consul.config.watch.enabled | true | - -|spring.cloud.consul.config.watch.wait-time | 2 | - -|spring.cloud.consul.discovery.acl-token | | - -|spring.cloud.consul.discovery.catalog-services-watch-delay | 10 | - -|spring.cloud.consul.discovery.catalog-services-watch-timeout | 2 | - -|spring.cloud.consul.discovery.enabled | true | Is service discovery enabled? - -|spring.cloud.consul.discovery.health-check-interval | 10s | How often to perform the health check (e.g. 10s) - -|spring.cloud.consul.discovery.health-check-path | /health | Alternate server path to invoke for health checking - -|spring.cloud.consul.discovery.health-check-timeout | | Timeout for health check (e.g. 10s) - -|spring.cloud.consul.discovery.health-check-url | | Custom health check url to override default - -|spring.cloud.consul.discovery.heartbeat.enabled | false | - -|spring.cloud.consul.discovery.heartbeat.heartbeat-interval | | - -|spring.cloud.consul.discovery.heartbeat.interval-ratio | | - -|spring.cloud.consul.discovery.heartbeat.ttl-unit | s | - -|spring.cloud.consul.discovery.heartbeat.ttl-value | 30 | - -|spring.cloud.consul.discovery.host-info | | - -|spring.cloud.consul.discovery.hostname | | Hostname to use when accessing server - -|spring.cloud.consul.discovery.instance-id | | Unique service instance id - -|spring.cloud.consul.discovery.ip-address | | IP address to use when accessing service (must also set preferIpAddress - to use) - -|spring.cloud.consul.discovery.lifecycle.enabled | true | - -|spring.cloud.consul.discovery.management-suffix | management | Suffix to use when registering management service - -|spring.cloud.consul.discovery.management-tags | | Tags to use when registering management service - -|spring.cloud.consul.discovery.port | | Port to register the service under (defaults to listening port) - -|spring.cloud.consul.discovery.prefer-agent-address | false | Source of how we will determine the address to use - -|spring.cloud.consul.discovery.prefer-ip-address | false | Use ip address rather than hostname during registration - -|spring.cloud.consul.discovery.query-passing | false | Add the 'passing` parameter to /v1/health/service/serviceName. - This pushes health check passing to the server. - -|spring.cloud.consul.discovery.register | true | Register as a service in consul. - -|spring.cloud.consul.discovery.register-health-check | true | Register health check in consul. Useful during development of a service. - -|spring.cloud.consul.discovery.scheme | http | Whether to register an http or https service - -|spring.cloud.consul.discovery.server-list-query-tags | | Map of serviceId's -> tag to query for in server list. - This allows filtering services by a single tag. - -|spring.cloud.consul.discovery.service-name | | Service name - -|spring.cloud.consul.discovery.tags | | Tags to use when registering service - -|spring.cloud.consul.enabled | true | Is spring cloud consul enabled - -|spring.cloud.consul.host | localhost | Consul agent hostname. Defaults to 'localhost'. - -|spring.cloud.consul.port | 8500 | Consul agent port. Defaults to '8500'. - -|spring.cloud.consul.retry.initial-interval | 1000 | Initial retry interval in milliseconds. - -|spring.cloud.consul.retry.max-attempts | 6 | Maximum number of attempts. - -|spring.cloud.consul.retry.max-interval | 2000 | Maximum interval for backoff. - -|spring.cloud.consul.retry.multiplier | 1.1 | Multiplier for next interval. - -|spring.cloud.hypermedia.refresh.fixed-delay | 5000 | - -|spring.cloud.hypermedia.refresh.initial-delay | 10000 | - -|spring.cloud.inetutils.default-hostname | localhost | The default hostname. Used in case of errors. - -|spring.cloud.inetutils.default-ip-address | 127.0.0.1 | The default ipaddress. Used in case of errors. - -|spring.cloud.inetutils.ignored-interfaces | | List of Java regex expressions for network interfaces that will be ignored. - -|spring.cloud.inetutils.timeout-seconds | 1 | Timeout in seconds for calculating hostname. - -|spring.cloud.stream.binders | | - -|spring.cloud.stream.bindings | | - -|spring.cloud.stream.consumer-defaults | | - -|spring.cloud.stream.default-binder | | - -|spring.cloud.stream.dynamic-destinations | [] | - -|spring.cloud.stream.ignore-unknown-properties | true | - -|spring.cloud.stream.instance-count | 1 | - -|spring.cloud.stream.instance-index | 0 | - -|spring.cloud.stream.producer-defaults | | - -|spring.cloud.stream.rabbit.binder.addresses | [] | - -|spring.cloud.stream.rabbit.binder.admin-adresses | [] | - -|spring.cloud.stream.rabbit.binder.compression-level | 0 | - -|spring.cloud.stream.rabbit.binder.nodes | [] | - -|spring.cloud.stream.rabbit.binder.password | | - -|spring.cloud.stream.rabbit.binder.ssl-properties-location | | - -|spring.cloud.stream.rabbit.binder.use-ssl | false | - -|spring.cloud.stream.rabbit.binder.username | | - -|spring.cloud.stream.rabbit.binder.vhost | | - -|spring.cloud.stream.rabbit.bindings | | - -|spring.cloud.zookeeper.default-health-endpoint | | Default health endpoint that will be checked to verify that a dependency is alive - -|spring.cloud.zookeeper.dependencies | | Mapping of alias to ZookeeperDependency. From Ribbon perspective the alias - is actually serviceID since Ribbon can't accept nested structures in serviceID - -|spring.cloud.zookeeper.dependency-configurations | | - -|spring.cloud.zookeeper.dependency-names | | - -|spring.cloud.zookeeper.discovery.enabled | true | - -|spring.cloud.zookeeper.discovery.instance-host | | - -|spring.cloud.zookeeper.discovery.metadata | | Gets the metadata name/value pairs associated with this instance. This information - is sent to zookeeper and can be used by other instances. - -|spring.cloud.zookeeper.discovery.root | /services | - -|spring.cloud.zookeeper.discovery.uri-spec | {scheme}://{address}:{port} | - -|spring.cloud.zookeeper.prefix | | Common prefix that will be applied to all Zookeeper dependencies' paths - -|spring.integration.poller.fixed-delay | 1000 | Fixed delay for default poller. - -|spring.integration.poller.max-messages-per-poll | 1 | Maximum messages per poll for the default poller. - -|spring.sleuth.keys.async.class-name-key | class | Simple name of the class with a method annotated with {@code @Async} + existing property sources (including local config files). Default false.

    spring.cloud.config.override-system-properties

    true

    Flag to indicate that the external properties should override system properties. + Default true.

    spring.cloud.config.password

    The password to use (HTTP Basic) when contacting the remote server.

    spring.cloud.config.profile

    default

    The default profile to use when fetching remote configuration (comma-separated). + Default is "default".

    spring.cloud.config.retry.initial-interval

    1000

    Initial retry interval in milliseconds.

    spring.cloud.config.retry.max-attempts

    6

    Maximum number of attempts.

    spring.cloud.config.retry.max-interval

    2000

    Maximum interval for backoff.

    spring.cloud.config.retry.multiplier

    1.1

    Multiplier for next interval.

    spring.cloud.config.uri

    http://localhost:8888

    The URI of the remote server (default http://localhost:8888).

    spring.cloud.config.username

    The username to use (HTTP Basic) when contacting the remote server.

    spring.cloud.consul.config.acl-token

    spring.cloud.consul.config.data-key

    data

    If format is Format.PROPERTIES or Format.YAML + then the following field is used as key to look up consul for configuration.

    spring.cloud.consul.config.default-context

    application

    spring.cloud.consul.config.enabled

    true

    spring.cloud.consul.config.fail-fast

    true

    Throw exceptions during config lookup if true, otherwise, log warnings.

    spring.cloud.consul.config.format

    spring.cloud.consul.config.prefix

    config

    spring.cloud.consul.config.profile-separator

    ,

    spring.cloud.consul.config.watch.delay

    10

    spring.cloud.consul.config.watch.enabled

    true

    spring.cloud.consul.config.watch.wait-time

    2

    spring.cloud.consul.discovery.acl-token

    spring.cloud.consul.discovery.catalog-services-watch-delay

    10

    spring.cloud.consul.discovery.catalog-services-watch-timeout

    2

    spring.cloud.consul.discovery.enabled

    true

    Is service discovery enabled?

    spring.cloud.consul.discovery.health-check-interval

    10s

    How often to perform the health check (e.g. 10s)

    spring.cloud.consul.discovery.health-check-path

    /health

    Alternate server path to invoke for health checking

    spring.cloud.consul.discovery.health-check-timeout

    Timeout for health check (e.g. 10s)

    spring.cloud.consul.discovery.health-check-url

    Custom health check url to override default

    spring.cloud.consul.discovery.heartbeat.enabled

    false

    spring.cloud.consul.discovery.heartbeat.heartbeat-interval

    spring.cloud.consul.discovery.heartbeat.interval-ratio

    spring.cloud.consul.discovery.heartbeat.ttl-unit

    s

    spring.cloud.consul.discovery.heartbeat.ttl-value

    30

    spring.cloud.consul.discovery.host-info

    spring.cloud.consul.discovery.hostname

    Hostname to use when accessing server

    spring.cloud.consul.discovery.instance-id

    Unique service instance id

    spring.cloud.consul.discovery.ip-address

    IP address to use when accessing service (must also set preferIpAddress + to use)

    spring.cloud.consul.discovery.lifecycle.enabled

    true

    spring.cloud.consul.discovery.management-suffix

    management

    Suffix to use when registering management service

    spring.cloud.consul.discovery.management-tags

    Tags to use when registering management service

    spring.cloud.consul.discovery.port

    Port to register the service under (defaults to listening port)

    spring.cloud.consul.discovery.prefer-agent-address

    false

    Source of how we will determine the address to use

    spring.cloud.consul.discovery.prefer-ip-address

    false

    Use ip address rather than hostname during registration

    spring.cloud.consul.discovery.query-passing

    false

    Add the 'passing` parameter to /v1/health/service/serviceName. + This pushes health check passing to the server.

    spring.cloud.consul.discovery.register

    true

    Register as a service in consul.

    spring.cloud.consul.discovery.register-health-check

    true

    Register health check in consul. Useful during development of a service.

    spring.cloud.consul.discovery.scheme

    http

    Whether to register an http or https service

    spring.cloud.consul.discovery.server-list-query-tags

    Map of serviceId’s → tag to query for in server list. + This allows filtering services by a single tag.

    spring.cloud.consul.discovery.service-name

    Service name

    spring.cloud.consul.discovery.tags

    Tags to use when registering service

    spring.cloud.consul.enabled

    true

    Is spring cloud consul enabled

    spring.cloud.consul.host

    localhost

    Consul agent hostname. Defaults to 'localhost'.

    spring.cloud.consul.port

    8500

    Consul agent port. Defaults to '8500'.

    spring.cloud.consul.retry.initial-interval

    1000

    Initial retry interval in milliseconds.

    spring.cloud.consul.retry.max-attempts

    6

    Maximum number of attempts.

    spring.cloud.consul.retry.max-interval

    2000

    Maximum interval for backoff.

    spring.cloud.consul.retry.multiplier

    1.1

    Multiplier for next interval.

    spring.cloud.hypermedia.refresh.fixed-delay

    5000

    spring.cloud.hypermedia.refresh.initial-delay

    10000

    spring.cloud.inetutils.default-hostname

    localhost

    The default hostname. Used in case of errors.

    spring.cloud.inetutils.default-ip-address

    127.0.0.1

    The default ipaddress. Used in case of errors.

    spring.cloud.inetutils.ignored-interfaces

    List of Java regex expressions for network interfaces that will be ignored.

    spring.cloud.inetutils.timeout-seconds

    1

    Timeout in seconds for calculating hostname.

    spring.cloud.stream.binders

    spring.cloud.stream.bindings

    spring.cloud.stream.consumer-defaults

    spring.cloud.stream.default-binder

    spring.cloud.stream.dynamic-destinations

    []

    spring.cloud.stream.ignore-unknown-properties

    true

    spring.cloud.stream.instance-count

    1

    spring.cloud.stream.instance-index

    0

    spring.cloud.stream.producer-defaults

    spring.cloud.stream.rabbit.binder.addresses

    []

    spring.cloud.stream.rabbit.binder.admin-adresses

    []

    spring.cloud.stream.rabbit.binder.compression-level

    0

    spring.cloud.stream.rabbit.binder.nodes

    []

    spring.cloud.stream.rabbit.binder.password

    spring.cloud.stream.rabbit.binder.ssl-properties-location

    spring.cloud.stream.rabbit.binder.use-ssl

    false

    spring.cloud.stream.rabbit.binder.username

    spring.cloud.stream.rabbit.binder.vhost

    spring.cloud.stream.rabbit.bindings

    spring.cloud.zookeeper.default-health-endpoint

    Default health endpoint that will be checked to verify that a dependency is alive

    spring.cloud.zookeeper.dependencies

    Mapping of alias to ZookeeperDependency. From Ribbon perspective the alias + is actually serviceID since Ribbon can’t accept nested structures in serviceID

    spring.cloud.zookeeper.dependency-configurations

    spring.cloud.zookeeper.dependency-names

    spring.cloud.zookeeper.discovery.enabled

    true

    spring.cloud.zookeeper.discovery.instance-host

    spring.cloud.zookeeper.discovery.metadata

    Gets the metadata name/value pairs associated with this instance. This information + is sent to zookeeper and can be used by other instances.

    spring.cloud.zookeeper.discovery.root

    /services

    spring.cloud.zookeeper.discovery.uri-spec

    {scheme}://{address}:{port}

    spring.cloud.zookeeper.prefix

    Common prefix that will be applied to all Zookeeper dependencies' paths

    spring.integration.poller.fixed-delay

    1000

    Fixed delay for default poller.

    spring.integration.poller.max-messages-per-poll

    1

    Maximum messages per poll for the default poller.

    spring.sleuth.keys.async.class-name-key

    class

    Simple name of the class with a method annotated with {@code @Async} from which the asynchronous process started - - @see org.springframework.scheduling.annotation.Async - -|spring.sleuth.keys.async.method-name-key | method | Name of the method annotated with {@code @Async} - - @see org.springframework.scheduling.annotation.Async - -|spring.sleuth.keys.async.prefix | | Prefix for header names if they are added as tags. - -|spring.sleuth.keys.async.thread-name-key | thread | Name of the thread that executed the async method - - @see org.springframework.scheduling.annotation.Async - -|spring.sleuth.keys.http.headers | | Additional headers that should be added as tags if they exist. If the header +

    @see org.springframework.scheduling.annotation.Async

    spring.sleuth.keys.async.method-name-key

    method

    Name of the method annotated with {@code @Async} +

    @see org.springframework.scheduling.annotation.Async

    spring.sleuth.keys.async.prefix

    Prefix for header names if they are added as tags.

    spring.sleuth.keys.async.thread-name-key

    thread

    Name of the thread that executed the async method +

    @see org.springframework.scheduling.annotation.Async

    spring.sleuth.keys.http.headers

    Additional headers that should be added as tags if they exist. If the header value is multi-valued, the tag value will be a comma-separated, single-quoted - list. - -|spring.sleuth.keys.http.host | http.host | The domain portion of the URL or host header. Example: - "mybucket.s3.amazonaws.com". Used to filter by host as opposed to ip address. - -|spring.sleuth.keys.http.method | http.method | The HTTP method, or verb, such as "GET" or "POST". Used to filter against an - http route. - -|spring.sleuth.keys.http.path | http.path | The absolute http path, without any query parameters. Example: + list.

    spring.sleuth.keys.http.host

    http.host

    The domain portion of the URL or host header. Example: + "mybucket.s3.amazonaws.com". Used to filter by host as opposed to ip address.

    spring.sleuth.keys.http.method

    http.method

    The HTTP method, or verb, such as "GET" or "POST". Used to filter against an + http route.

    spring.sleuth.keys.http.path

    http.path

    The absolute http path, without any query parameters. Example: "/objects/abcd-ff". Used to filter against an http route, portably with zipkin v1. In zipkin v1, only equals filters are supported. Dropping query parameters makes the number of distinct URIs less. For example, one can query for the same @@ -9672,111 +11343,198 @@ Multiple etcd cluster uris can be specified using property not reduce cardinality to a HTTP single route. For example, it is common to express a route as an http URI template like "/resource/{resource_id}". In systems where only equals queries are available, searching for - {@code http.uri=/resource} won't match if the actual request was + {@code http.uri=/resource} won’t match if the actual request was "/resource/abcd-ff". Historical note: This was commonly expressed as "http.uri" - in zipkin, eventhough it was most often just a path. - -|spring.sleuth.keys.http.prefix | http. | Prefix for header names if they are added as tags. - -|spring.sleuth.keys.http.request-size | http.request.size | The size of the non-empty HTTP request body, in bytes. Ex. "16384" - - <p>Large uploads can exceed limits or contribute directly to latency. - -|spring.sleuth.keys.http.response-size | http.response.size | The size of the non-empty HTTP response body, in bytes. Ex. "16384" - - <p>Large downloads can exceed limits or contribute directly to latency. - -|spring.sleuth.keys.http.status-code | http.status_code | The HTTP response code, when not in 2xx range. Ex. "503" Used to filter for + in zipkin, eventhough it was most often just a path.

    spring.sleuth.keys.http.prefix

    http.

    Prefix for header names if they are added as tags.

    spring.sleuth.keys.http.request-size

    http.request.size

    The size of the non-empty HTTP request body, in bytes. Ex. "16384" +

    <p>Large uploads can exceed limits or contribute directly to latency.

    spring.sleuth.keys.http.response-size

    http.response.size

    The size of the non-empty HTTP response body, in bytes. Ex. "16384" +

    <p>Large downloads can exceed limits or contribute directly to latency.

    spring.sleuth.keys.http.status-code

    http.status_code

    The HTTP response code, when not in 2xx range. Ex. "503" Used to filter for error status. 2xx range are not logged as success codes are less interesting - for latency troubleshooting. Omitting saves at least 20 bytes per span. - -|spring.sleuth.keys.http.url | http.url | The entire URL, including the scheme, host and query parameters if available. + for latency troubleshooting. Omitting saves at least 20 bytes per span.

    spring.sleuth.keys.http.url

    http.url

    The entire URL, including the scheme, host and query parameters if available. Ex. - "https://mybucket.s3.amazonaws.com/objects/abcd-ff?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Algorithm=AWS4-HMAC-SHA256..." + "https://mybucket.s3.amazonaws.com/objects/abcd-ff?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Algorithm=AWS4-HMAC-SHA256…​" Combined with {@link #method}, you can understand the fully-qualified request line. This is optional as it may include private data or be of - considerable length. - -|spring.sleuth.keys.hystrix.command-group | commandGroup | Name of the command group. Hystrix uses the command group key to group + considerable length.

    spring.sleuth.keys.hystrix.command-group

    commandGroup

    Name of the command group. Hystrix uses the command group key to group together commands such as for reporting, alerting, dashboards, or team/library ownership. - - @see com.netflix.hystrix.HystrixCommandGroupKey - -|spring.sleuth.keys.hystrix.command-key | commandKey | Name of the command key. Describes the name for the given command. +

    @see com.netflix.hystrix.HystrixCommandGroupKey

    spring.sleuth.keys.hystrix.command-key

    commandKey

    Name of the command key. Describes the name for the given command. A key to represent a {@link com.netflix.hystrix.HystrixCommand} for monitoring, circuit-breakers, metrics publishing, caching and other such uses. - - @see com.netflix.hystrix.HystrixCommandKey - -|spring.sleuth.keys.hystrix.prefix | | Prefix for header names if they are added as tags. - -|spring.sleuth.keys.hystrix.thread-pool-key | threadPoolKey | Name of the thread pool key. The thread-pool key represents a {@link com.netflix.hystrix.HystrixThreadPool} +

    @see com.netflix.hystrix.HystrixCommandKey

    spring.sleuth.keys.hystrix.prefix

    Prefix for header names if they are added as tags.

    spring.sleuth.keys.hystrix.thread-pool-key

    threadPoolKey

    Name of the thread pool key. The thread-pool key represents a {@link com.netflix.hystrix.HystrixThreadPool} for monitoring, metrics publishing, caching, and other such uses. A {@link com.netflix.hystrix.HystrixCommand} is associated with a single {@link com.netflix.hystrix.HystrixThreadPool} as retrieved by the {@link com.netflix.hystrix.HystrixThreadPoolKey} injected into it, or it defaults to one created using the {@link com.netflix.hystrix.HystrixCommandGroupKey} it is created with. - - @see com.netflix.hystrix.HystrixThreadPoolKey - -|spring.sleuth.keys.message.headers | | Additional headers that should be added as tags if they exist. If the header +

    @see com.netflix.hystrix.HystrixThreadPoolKey

    spring.sleuth.keys.message.headers

    Additional headers that should be added as tags if they exist. If the header value is not a String it will be converted to a String using its toString() - method. - -|spring.sleuth.keys.message.payload.size | message/payload-size | An estimate of the size of the payload if available. - -|spring.sleuth.keys.message.payload.type | message/payload-type | The type of the payload. - -|spring.sleuth.keys.message.prefix | message/ | Prefix for header names if they are added as tags. - -|spring.sleuth.metric.span.accepted-name | counter.span.accepted | - -|spring.sleuth.metric.span.dropped-name | counter.span.dropped | - -|spring.sleuth.sampler.percentage | 0.1 | Percentage of requests that should be sampled. E.g. 1.0 - 100% requests should be - sampled. The precision is whole-numbers only (i.e. there's no support for 0.1% of - the traces). - -|zuul.add-proxy-headers | true | - -|zuul.host.max-per-route-connections | 20 | - -|zuul.host.max-total-connections | 200 | - -|zuul.ignore-local-service | true | - -|zuul.ignored-headers | | - -|zuul.ignored-patterns | | - -|zuul.ignored-services | | - -|zuul.prefix | | - -|zuul.remove-semicolon-content | true | - -|zuul.retryable | | - -|zuul.routes | | - -|zuul.security_headers | | - -|zuul.servlet-path | /zuul | - -|zuul.strip-prefix | true | - -|zuul.trace-request-body | true | - -|=== - - + method.

    spring.sleuth.keys.message.payload.size

    message/payload-size

    An estimate of the size of the payload if available.

    spring.sleuth.keys.message.payload.type

    message/payload-type

    The type of the payload.

    spring.sleuth.keys.message.prefix

    message/

    Prefix for header names if they are added as tags.

    spring.sleuth.metric.span.accepted-name

    counter.span.accepted

    spring.sleuth.metric.span.dropped-name

    counter.span.dropped

    spring.sleuth.sampler.percentage

    0.1

    Percentage of requests that should be sampled. E.g. 1.0 - 100% requests should be + sampled. The precision is whole-numbers only (i.e. there’s no support for 0.1% of + the traces).

    zuul.add-proxy-headers

    true

    zuul.host.max-per-route-connections

    20

    zuul.host.max-total-connections

    200

    zuul.ignore-local-service

    true

    zuul.ignored-headers

    zuul.ignored-patterns

    zuul.ignored-services

    zuul.prefix

    zuul.remove-semicolon-content

    true

    zuul.retryable

    zuul.routes

    zuul.security_headers

    zuul.servlet-path

    /zuul

    zuul.strip-prefix

    true

    zuul.trace-request-body

    true