-
Notifications
You must be signed in to change notification settings - Fork 995
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
2b88f69
commit be99318
Showing
13 changed files
with
329 additions
and
130 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
10 changes: 10 additions & 0 deletions
10
src/main/java/org/springframework/metrics/instrument/annotation/TimedSet.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
package org.springframework.metrics.instrument.annotation; | ||
|
||
import java.lang.annotation.*; | ||
|
||
@Target({ElementType.TYPE, ElementType.METHOD}) | ||
@Documented | ||
@Retention(RetentionPolicy.RUNTIME) | ||
public @interface TimedSet { | ||
Timed[] value(); | ||
} |
48 changes: 48 additions & 0 deletions
48
src/main/java/org/springframework/metrics/instrument/internal/TimedUtils.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
package org.springframework.metrics.instrument.internal; | ||
|
||
import org.springframework.metrics.instrument.annotation.Timed; | ||
import org.springframework.metrics.instrument.annotation.TimedSet; | ||
|
||
import java.lang.reflect.Method; | ||
import java.util.Arrays; | ||
import java.util.Collections; | ||
import java.util.Set; | ||
import java.util.function.Predicate; | ||
import java.util.stream.Stream; | ||
|
||
import static java.util.Arrays.stream; | ||
import static java.util.Collections.emptySet; | ||
import static java.util.Collections.singleton; | ||
import static java.util.Comparator.comparing; | ||
import static java.util.stream.Collectors.toSet; | ||
import static java.util.stream.Stream.empty; | ||
import static java.util.stream.Stream.of; | ||
|
||
/** | ||
* @author Jon Schneider | ||
*/ | ||
public class TimedUtils { | ||
public static Stream<Timed> findTimed(Class<?> clazz) { | ||
Timed t = clazz.getAnnotation(Timed.class); | ||
if(t != null) | ||
return of(t); | ||
|
||
TimedSet ts = clazz.getAnnotation(TimedSet.class); | ||
if(ts != null) | ||
return stream(ts.value()).sorted(comparing(Timed::value)); | ||
|
||
return empty(); | ||
} | ||
|
||
public static Stream<Timed> findTimed(Method m) { | ||
Timed t = m.getAnnotation(Timed.class); | ||
if(t != null) | ||
return of(t); | ||
|
||
TimedSet ts = m.getAnnotation(TimedSet.class); | ||
if(ts != null) | ||
return stream(ts.value()).sorted(comparing(Timed::value)); | ||
|
||
return empty(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.