Skip to content

Commit

Permalink
Updated levels
Browse files Browse the repository at this point in the history
  • Loading branch information
marcingrzejszczak committed Feb 7, 2024
1 parent 64a409d commit 2d318e9
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 50 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,6 @@
*/
public enum Level {

ALL, TRACE, DEBUG, INFO, WARN, ERROR, FATAL, OFF
FULL, DETAILED, BASIC, OFF

}
Original file line number Diff line number Diff line change
Expand Up @@ -1551,7 +1551,7 @@ default <T> T getOrDefault(Object key, Supplier<T> defaultObjectSupplier) {
* @return observation level
*/
default Level getObservationLevel() {
return Level.ALL;
return Level.FULL;
}

}
Expand Down Expand Up @@ -1608,59 +1608,27 @@ public Level getLevel() {
}

/**
* Sets {@link Level#ALL} for observation of the given classs.
* Sets {@link Level#FULL} for observation of the given classs.
* @return observation level
*/
public static ObservationLevel all() {
return new ObservationLevel(Level.ALL);
public static ObservationLevel full() {
return new ObservationLevel(Level.FULL);
}

/**
* Sets {@link Level#TRACE} for observation of the given classs.
* Sets {@link Level#BASIC} for observation of the given classs.
* @return observation level
*/
public static ObservationLevel trace() {
return new ObservationLevel(Level.TRACE);
public static ObservationLevel basic() {
return new ObservationLevel(Level.BASIC);
}

/**
* Sets {@link Level#DEBUG} for observation of the given classs.
* Sets {@link Level#DETAILED} for observation of the given classs.
* @return observation level
*/
public static ObservationLevel debug() {
return new ObservationLevel(Level.DEBUG);
}

/**
* Sets {@link Level#INFO} for observation of the given classs.
* @return observation level
*/
public static ObservationLevel info() {
return new ObservationLevel(Level.INFO);
}

/**
* Sets {@link Level#WARN} for observation of the given classs.
* @return observation level
*/
public static ObservationLevel warn() {
return new ObservationLevel(Level.WARN);
}

/**
* Sets {@link Level#ERROR} for observation of the given classs.
* @return observation level
*/
public static ObservationLevel error() {
return new ObservationLevel(Level.ERROR);
}

/**
* Sets {@link Level#FATAL} for observation of the given classs.
* @return observation level
*/
public static ObservationLevel fatal() {
return new ObservationLevel(Level.FATAL);
public static ObservationLevel detailed() {
return new ObservationLevel(Level.DETAILED);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -154,19 +154,19 @@ public ObservationConfig observationConvention(GlobalObservationConvention<?> ob
}

/**
* Sets an observation level for the given package name.
* @param packageName observation package name
* Sets an observation level for the given observation name.
* @param observationName observation name
* @param level observation level
* @return This configuration instance
*/
public ObservationConfig observationLevel(String packageName, Level level) {
this.observationLevels.put(packageName, level);
public ObservationConfig observationLevel(String observationName, Level level) {
this.observationLevels.put(observationName, level);
return this;
}

/**
* Sets observation levels.
* @param levels observation levels (package to level mappings)
* @param levels observation levels (observation name to level mappings)
* @return This configuration instance
*/
public ObservationConfig observationLevels(Map<String, Level> levels) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,9 +79,9 @@ void notMatchingObservationPredicateShouldResultInNoopObservation() {
void notMatchingObservationLevelShouldResultInPassthroughObservation() {
registry.observationConfig().observationHandler(context -> true);
registry.observationConfig().observationPredicate((s, context) -> true);
registry.observationConfig().observationLevel("foo", Level.ERROR);
registry.observationConfig().observationLevel("foo", Level.BASIC);

Observation observation = Observation.createNotStarted("foo", ObservationLevel.debug(), registry);
Observation observation = Observation.createNotStarted("foo", ObservationLevel.detailed(), registry);

assertThat(observation).isInstanceOf(PassthroughNoopObservation.class);
}
Expand Down

0 comments on commit 2d318e9

Please sign in to comment.