Skip to content

Commit e0cc0ae

Browse files
committed
Revert to Gradle 3.5 to fix dynamic version substitution in POM, update docs
1 parent cda1634 commit e0cc0ae

File tree

5 files changed

+58
-18
lines changed

5 files changed

+58
-18
lines changed

gradle/wrapper/gradle-wrapper.jar

1.92 KB
Binary file not shown.
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
#Thu May 18 12:01:02 CDT 2017
1+
#Thu May 18 17:28:55 CDT 2017
22
distributionBase=GRADLE_USER_HOME
33
distributionPath=wrapper/dists
44
zipStoreBase=GRADLE_USER_HOME
55
zipStorePath=wrapper/dists
6-
distributionUrl=https\://services.gradle.org/distributions/gradle-4.0-milestone-2-bin.zip
6+
distributionUrl=https\://services.gradle.org/distributions/gradle-3.5-bin.zip

gradlew

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#!/usr/bin/env bash
1+
#!/usr/bin/env sh
22

33
##############################################################################
44
##
@@ -154,16 +154,19 @@ if $cygwin ; then
154154
esac
155155
fi
156156

157-
# Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules
158-
function splitJvmOpts() {
159-
JVM_OPTS=("$@")
157+
# Escape application args
158+
save ( ) {
159+
for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done
160+
echo " "
160161
}
161-
eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS
162-
JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME"
162+
APP_ARGS=$(save "$@")
163+
164+
# Collect all arguments for the java command, following the shell quoting and substitution rules
165+
eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS"
163166

164167
# by default we should be in the correct project dir, but when run from Finder on Mac, the cwd is wrong
165-
if [[ "$(uname)" == "Darwin" ]] && [[ "$HOME" == "$PWD" ]]; then
168+
if [ "$(uname)" = "Darwin" ] && [ "$HOME" = "$PWD" ]; then
166169
cd "$(dirname "$0")"
167170
fi
168171

169-
exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@"
172+
exec "$JAVACMD" "$@"

src/docs/asciidoc/index.adoc

Lines changed: 37 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
:imagesdir: ./images
88
= Spring Metrics
99

10-
image::https://circleci.com/gh/spring-projects/spring-metrics.svg?style=svg[Build Status, link=https://circleci.com/gh/spring-cloud/spring-metrics]
10+
image:https://circleci.com/gh/spring-projects/spring-metrics.svg?style=svg[Build Status, link=https://circleci.com/gh/spring-cloud/spring-metrics]
1111
image:https://badges.gitter.im/Join%20Chat.svg[Gitter, link="https://gitter.im/spring-projects/spring-metrics?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge"]
1212
image:https://img.shields.io/badge/License-Apache%202.0-blue.svg[Apache License,link="http://www.apache.org/licenses/LICENSE-2.0"]
1313

@@ -258,6 +258,18 @@ groups etc. Normally all data can be refreshed in a few minutes. If the AWS
258258
services are having problems it can take much longer. A long duration timer can
259259
be used to track the overall time for refreshing the metadata.
260260

261+
In a Spring application, it is common for such long running processes to be implemented with `@Scheduled`.
262+
`spring-metrics` provides a special `@Timed` annotation for instrumenting these processes with a long
263+
task timer:
264+
265+
```java
266+
@Timed(value = "aws_scrape", longTask = true)
267+
@Scheduled(fixedDelay = 360000)
268+
void scrapeResources() {
269+
// find instances, volumes, auto-scaling groups, etc...
270+
}
271+
```
272+
261273
The charts below show max latency for the refresh using a regular timer and a
262274
long task timer. Regular timer, note that the y-axis is using a logarithmic scale:
263275

@@ -405,7 +417,7 @@ We recommend setting up alerts for production ready apps for (1) if `jvm_gc_paus
405417
is a good general purpose value) and (2) if `jvm_gc_live_data_size` exceeds 70% of the heap.
406418
2. `LogbackMetrics` - Records counts for log event at various levels. Auto-configured in the presence of `logback-core`.
407419

408-
== Spring Web MVC and Spring WebFlux
420+
== Server-side HTTP Instrumentation
409421

410422
`spring-metrics` contains built-in instrumentation for timings of requests made
411423
to Spring MVC and Spring WebFlux server endpoints.
@@ -420,13 +432,16 @@ to time. Add `@Timed` to:
420432

421433
1. A controller class to enable timings on every request handler in the controller.
422434
2. A method to enable for an individual endpoint. This is not necessary if you have it on the class.
435+
3. A method with `longTask = true` to enable a long task timer for the method. Long task timers require a
436+
separate metric name, and can be stacked with a short task timer.
423437

424438
```java
425439
@RestController
426440
@Timed // (1)
427441
public class MyController {
428442
@GetMapping("/api/people")
429443
@Timed // (2)
444+
@Timed(value = "all_people", longTask = true) // (3)
430445
public List<Person> listPeople() { ... }
431446
```
432447

@@ -464,15 +479,33 @@ RouterFunction<ServerResponse> routes = RouterFunctions
464479

465480
The filter applies to all routes defined by this router function.
466481

467-
=== `RestTemplate` Timing
482+
== Client-side HTTP Instrumentation
468483

469-
Adding `@EnableMetrics` to your `@SpringBootApplication` class autoconfigures a `BeanPostProcessor` for `RestTemplate`,
484+
Adding `@EnableMetrics` to your `@SpringBootApplication` class configures a `BeanPostProcessor` for `RestTemplate`,
470485
so every instance you create via the application context will be instrumented.
471486

472487
A timer is recorded for each invocation that includes tags for URI (before parameter substitution), host, and status.
473488
The name of this timer is `http_client_requests`, and can be changed via the `spring.metrics.web.client_requests.name`
474489
property.
475490

491+
== Scheduling Instrumentation
492+
493+
Adding `@EnableMetrics` to your `@SpringBootApplication` class plus enabling AOP configures AOP advice that times
494+
`@Scheduled` methods. For a method to be timed, it must be marked as `@Timed("my_metric_name")` with a name.
495+
496+
Depending on the duration of the scheduled task, you may want to choose to time the method with a `LongTaskTimer`,
497+
a `Timer`, or both. Below is an example of measuring both long task and regular timings to a scheduled task:
498+
499+
```java
500+
@Timed("beep")
501+
@Timed(value = "long_beep", longTask = true)
502+
@Scheduled(fixedRate = 1000)
503+
void longBeep() {
504+
// calculate the meaning of life, then beep...
505+
System.out.println("beep");
506+
}
507+
```
508+
476509
== Prometheus
477510

478511
=== Quickstart for Prometheus-based monitoring

src/main/java/org/springframework/metrics/instrument/web/RouterFunctionMetrics.java

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,20 +26,24 @@
2626
public class RouterFunctionMetrics {
2727
private final MeterRegistry registry;
2828

29-
private String defaultTagName = "http_server_requests";
29+
private String defaultName = "http_server_requests";
3030
private WebMetricsTagProvider tagProvider = new DefaultWebMetricsTagProvider();
3131

3232
public RouterFunctionMetrics(MeterRegistry registry) {
3333
this.registry = registry;
3434
}
3535

36-
public RouterFunctionMetrics setDefaultTagName(String defaultTagName) {
37-
this.defaultTagName = defaultTagName;
36+
public RouterFunctionMetrics setDefaultName(String defaultName) {
37+
this.defaultName = defaultName;
3838
return this;
3939
}
4040

4141
public HandlerFilterFunction<ServerResponse, ServerResponse> timer() {
42-
return timer(defaultTagName, Stream.empty());
42+
return timer(defaultName, Stream.empty());
43+
}
44+
45+
public HandlerFilterFunction<ServerResponse, ServerResponse> timer(Stream<Tag> tags) {
46+
return timer(defaultName, tags);
4347
}
4448

4549
public HandlerFilterFunction<ServerResponse, ServerResponse> timer(String name, Stream<Tag> tags) {

0 commit comments

Comments
 (0)