parent
c536af0bea
commit
5e35a34cba
|
@ -105,7 +105,7 @@ some compilations for Spring Boot as we include a maven plugin and use it within
|
||||||
samples. The standard build works around this restriction by launching the samples via
|
samples. The standard build works around this restriction by launching the samples via
|
||||||
the `maven-invoker-plugin` so that they are not part of the reactor. This works fine
|
the `maven-invoker-plugin` so that they are not part of the reactor. This works fine
|
||||||
most of the time, however, sometimes it's useful to run a build that includes all modules
|
most of the time, however, sometimes it's useful to run a build that includes all modules
|
||||||
(for example when using `maven-versions-plugin`. We use the full build on our CI servers
|
(for example when using `maven-versions-plugin`). We use the full build on our CI servers
|
||||||
and during the release process.
|
and during the release process.
|
||||||
|
|
||||||
Running a full build is a two phase process.
|
Running a full build is a two phase process.
|
||||||
|
|
|
@ -166,7 +166,7 @@ these include:
|
||||||
* The `SpringApplication` class, providing static convenience methods that make it easy
|
* The `SpringApplication` class, providing static convenience methods that make it easy
|
||||||
to write a stand-alone Spring Application. Its sole job is to create and refresh an
|
to write a stand-alone Spring Application. Its sole job is to create and refresh an
|
||||||
appropriate Spring `ApplicationContext`
|
appropriate Spring `ApplicationContext`
|
||||||
* Embedded web applications with a choice of container (Tomcat or Jetty for now)
|
* Embedded web applications with a choice of container (Tomcat, Jetty or Undertow)
|
||||||
* First class externalized configuration support
|
* First class externalized configuration support
|
||||||
* Convenience `ApplicationContext` initializers, including support for sensible logging
|
* Convenience `ApplicationContext` initializers, including support for sensible logging
|
||||||
defaults
|
defaults
|
||||||
|
@ -178,7 +178,7 @@ Spring Boot can configure large parts of common applications based on the conten
|
||||||
of their classpath. A single `@EnableAutoConfiguration` annotation triggers
|
of their classpath. A single `@EnableAutoConfiguration` annotation triggers
|
||||||
auto-configuration of the Spring context.
|
auto-configuration of the Spring context.
|
||||||
|
|
||||||
Auto-configuration attempts to deduce which beans a user might need. For example, If
|
Auto-configuration attempts to deduce which beans a user might need. For example, if
|
||||||
`HSQLDB` is on the classpath, and the user has not configured any database connections,
|
`HSQLDB` is on the classpath, and the user has not configured any database connections,
|
||||||
then they probably want an in-memory database to be defined. Auto-configuration will
|
then they probably want an in-memory database to be defined. Auto-configuration will
|
||||||
always back away as the user starts to define their own beans.
|
always back away as the user starts to define their own beans.
|
||||||
|
|
|
@ -31,10 +31,10 @@ import org.springframework.boot.actuate.autoconfigure.metrics.export.PropertiesC
|
||||||
class AtlasPropertiesConfigAdapter extends
|
class AtlasPropertiesConfigAdapter extends
|
||||||
PropertiesConfigAdapter<AtlasProperties, AtlasConfig> implements AtlasConfig {
|
PropertiesConfigAdapter<AtlasProperties, AtlasConfig> implements AtlasConfig {
|
||||||
|
|
||||||
private static final AtlasConfig DEFAUTLS = (k) -> null;
|
private static final AtlasConfig DEFAULTS = (k) -> null;
|
||||||
|
|
||||||
AtlasPropertiesConfigAdapter(AtlasProperties properties) {
|
AtlasPropertiesConfigAdapter(AtlasProperties properties) {
|
||||||
super(properties, DEFAUTLS);
|
super(properties, DEFAULTS);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -85,12 +85,12 @@ public class RestTemplateMetricsConfiguration {
|
||||||
@Override
|
@Override
|
||||||
public Object postProcessAfterInitialization(Object bean, String beanName) {
|
public Object postProcessAfterInitialization(Object bean, String beanName) {
|
||||||
if (bean instanceof RestTemplate) {
|
if (bean instanceof RestTemplate) {
|
||||||
geCustomizer().customize((RestTemplate) bean);
|
getCustomizer().customize((RestTemplate) bean);
|
||||||
}
|
}
|
||||||
return bean;
|
return bean;
|
||||||
}
|
}
|
||||||
|
|
||||||
private MetricsRestTemplateCustomizer geCustomizer() {
|
private MetricsRestTemplateCustomizer getCustomizer() {
|
||||||
if (this.customizer == null) {
|
if (this.customizer == null) {
|
||||||
this.customizer = this.applicationContext
|
this.customizer = this.applicationContext
|
||||||
.getBean(MetricsRestTemplateCustomizer.class);
|
.getBean(MetricsRestTemplateCustomizer.class);
|
||||||
|
|
|
@ -56,7 +56,7 @@ public class SpringIntegrationMetricsIntegrationTests {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void springIntegrationMetrics() {
|
public void springIntegrationMetrics() {
|
||||||
this.converter.fahrenheitToCelcius(68.0);
|
this.converter.fahrenheitToCelsius(68.0);
|
||||||
assertThat(this.registry.find("spring.integration.channel.sends")
|
assertThat(this.registry.find("spring.integration.channel.sends")
|
||||||
.tags("channel", "convert.input").value(Statistic.Count, 1).meter())
|
.tags("channel", "convert.input").value(Statistic.Count, 1).meter())
|
||||||
.isPresent();
|
.isPresent();
|
||||||
|
@ -98,7 +98,7 @@ public class SpringIntegrationMetricsIntegrationTests {
|
||||||
return (f) -> f
|
return (f) -> f
|
||||||
.transform((payload) -> "{\"fahrenheit\":" + payload + "}",
|
.transform((payload) -> "{\"fahrenheit\":" + payload + "}",
|
||||||
(e) -> e.id("toJson"))
|
(e) -> e.id("toJson"))
|
||||||
.handle(String.class, this::fahrenheitToCelcius,
|
.handle(String.class, this::fahrenheitToCelsius,
|
||||||
(e) -> e.id("temperatureConverter"))
|
(e) -> e.id("temperatureConverter"))
|
||||||
.transform(this::extractResult, e -> e.id("toResponse"));
|
.transform(this::extractResult, e -> e.id("toResponse"));
|
||||||
}
|
}
|
||||||
|
@ -106,19 +106,19 @@ public class SpringIntegrationMetricsIntegrationTests {
|
||||||
private double extractResult(String json) {
|
private double extractResult(String json) {
|
||||||
try {
|
try {
|
||||||
return (double) new ObjectMapper().readValue(json, Map.class)
|
return (double) new ObjectMapper().readValue(json, Map.class)
|
||||||
.get("celcius");
|
.get("celsius");
|
||||||
}
|
}
|
||||||
catch (IOException ex) {
|
catch (IOException ex) {
|
||||||
throw new RuntimeException(ex);
|
throw new RuntimeException(ex);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private String fahrenheitToCelcius(String payload, Map<String, Object> headers) {
|
private String fahrenheitToCelsius(String payload, Map<String, Object> headers) {
|
||||||
try {
|
try {
|
||||||
double fahrenheit = (double) new ObjectMapper()
|
double fahrenheit = (double) new ObjectMapper()
|
||||||
.readValue(payload, Map.class).get("fahrenheit");
|
.readValue(payload, Map.class).get("fahrenheit");
|
||||||
double celcius = (fahrenheit - 32) * (5.0 / 9.0);
|
double celsius = (fahrenheit - 32) * (5.0 / 9.0);
|
||||||
return "{\"celcius\":" + celcius + "}";
|
return "{\"celsius\":" + celsius + "}";
|
||||||
}
|
}
|
||||||
catch (Exception ex) {
|
catch (Exception ex) {
|
||||||
throw new RuntimeException(ex);
|
throw new RuntimeException(ex);
|
||||||
|
@ -129,7 +129,7 @@ public class SpringIntegrationMetricsIntegrationTests {
|
||||||
public interface TempConverter {
|
public interface TempConverter {
|
||||||
|
|
||||||
@Gateway(requestChannel = "convert.input")
|
@Gateway(requestChannel = "convert.input")
|
||||||
double fahrenheitToCelcius(double fahren);
|
double fahrenheitToCelsius(double fahrenheit);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -36,7 +36,7 @@ import org.springframework.core.io.support.SpringFactoriesLoader;
|
||||||
/**
|
/**
|
||||||
* Enable auto-configuration of the Spring Application Context, attempting to guess and
|
* Enable auto-configuration of the Spring Application Context, attempting to guess and
|
||||||
* configure beans that you are likely to need. Auto-configuration classes are usually
|
* configure beans that you are likely to need. Auto-configuration classes are usually
|
||||||
* applied based on your classpath and what beans you have defined. For example, If you
|
* applied based on your classpath and what beans you have defined. For example, if you
|
||||||
* have {@code tomcat-embedded.jar} on your classpath you are likely to want a
|
* have {@code tomcat-embedded.jar} on your classpath you are likely to want a
|
||||||
* {@link TomcatServletWebServerFactory} (unless you have defined your own
|
* {@link TomcatServletWebServerFactory} (unless you have defined your own
|
||||||
* {@link ServletWebServerFactory} bean).
|
* {@link ServletWebServerFactory} bean).
|
||||||
|
|
|
@ -901,7 +901,7 @@ To customize the tags, provide a `@Bean` that implements `WebMvcTagsProvider`.
|
||||||
=== WebFlux metrics
|
=== WebFlux metrics
|
||||||
Auto-configuration will enable the instrumentation of all requests handled by WebFlux
|
Auto-configuration will enable the instrumentation of all requests handled by WebFlux
|
||||||
controllers. A helper class, `RouterFunctionMetrics`, is also provided that can be
|
controllers. A helper class, `RouterFunctionMetrics`, is also provided that can be
|
||||||
used to instrument applications using WebFlux's funtional programming model.
|
used to instrument applications using WebFlux's functional programming model.
|
||||||
|
|
||||||
Metrics will, by default, be generated with the name `http.server.requests`. The name
|
Metrics will, by default, be generated with the name `http.server.requests`. The name
|
||||||
can be customized using the `spring.metrics.web.server.requests-metrics-name` property.
|
can be customized using the `spring.metrics.web.server.requests-metrics-name` property.
|
||||||
|
@ -945,7 +945,7 @@ can be customized using the `spring.metrics.web.client.requests-metrics-name` pr
|
||||||
|
|
||||||
[[production-ready-metrics-rest-template-tags]]
|
[[production-ready-metrics-rest-template-tags]]
|
||||||
==== RestTemplate metric tags
|
==== RestTemplate metric tags
|
||||||
Metrics generated by an instrumeted `RestTemplate` will, by default, be tagged with
|
Metrics generated by an instrumented `RestTemplate` will, by default, be tagged with
|
||||||
the following:
|
the following:
|
||||||
|
|
||||||
- Request's method
|
- Request's method
|
||||||
|
|
|
@ -1350,7 +1350,7 @@ http://logging.apache.org/log4j/2.x/[Log4J2] and http://logback.qos.ch/[Logback]
|
||||||
case loggers are pre-configured to use console output with optional file output also
|
case loggers are pre-configured to use console output with optional file output also
|
||||||
available.
|
available.
|
||||||
|
|
||||||
By default, If you use the '`Starters`', Logback will be used for logging. Appropriate
|
By default, if you use the '`Starters`', Logback will be used for logging. Appropriate
|
||||||
Logback routing is also included to ensure that dependent libraries that use
|
Logback routing is also included to ensure that dependent libraries that use
|
||||||
Java Util Logging, Commons Logging, Log4J or SLF4J will all work correctly.
|
Java Util Logging, Commons Logging, Log4J or SLF4J will all work correctly.
|
||||||
|
|
||||||
|
|
|
@ -433,7 +433,7 @@ annotation to load XML configuration files.
|
||||||
[[using-boot-auto-configuration]]
|
[[using-boot-auto-configuration]]
|
||||||
== Auto-configuration
|
== Auto-configuration
|
||||||
Spring Boot auto-configuration attempts to automatically configure your Spring
|
Spring Boot auto-configuration attempts to automatically configure your Spring
|
||||||
application based on the jar dependencies that you have added. For example, If
|
application based on the jar dependencies that you have added. For example, if
|
||||||
`HSQLDB` is on your classpath, and you have not manually configured any database
|
`HSQLDB` is on your classpath, and you have not manually configured any database
|
||||||
connection beans, then we will auto-configure an in-memory database.
|
connection beans, then we will auto-configure an in-memory database.
|
||||||
|
|
||||||
|
@ -579,7 +579,7 @@ One of the biggest advantages of packaging your application as jar and using an
|
||||||
HTTP server is that you can run your application as you would any other. Debugging Spring
|
HTTP server is that you can run your application as you would any other. Debugging Spring
|
||||||
Boot applications is also easy; you don't need any special IDE plugins or extensions.
|
Boot applications is also easy; you don't need any special IDE plugins or extensions.
|
||||||
|
|
||||||
NOTE: This section only covers jar based packaging, If you choose to package your
|
NOTE: This section only covers jar based packaging, if you choose to package your
|
||||||
application as a war file you should refer to your server and IDE documentation.
|
application as a war file you should refer to your server and IDE documentation.
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue