mirror of
https://github.com/spring-projects/spring-boot.git
synced 2024-09-03 04:26:12 +08:00
Merge branch '3.1.x' into 3.2.x
Closes gh-40482
This commit is contained in:
commit
5c9d5e262f
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2012-2020 the original author or authors.
|
* Copyright 2012-2024 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
@ -20,6 +20,10 @@ import java.time.Duration;
|
|||||||
|
|
||||||
import io.micrometer.core.instrument.Meter;
|
import io.micrometer.core.instrument.Meter;
|
||||||
|
|
||||||
|
import org.springframework.aot.hint.MemberCategory;
|
||||||
|
import org.springframework.aot.hint.RuntimeHints;
|
||||||
|
import org.springframework.aot.hint.RuntimeHintsRegistrar;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A boundary for a service-level objective (SLO) for use when configuring Micrometer. Can
|
* A boundary for a service-level objective (SLO) for use when configuring Micrometer. Can
|
||||||
* be specified as either a {@link Double} (applicable to timers and distribution
|
* be specified as either a {@link Double} (applicable to timers and distribution
|
||||||
@ -67,4 +71,13 @@ public final class ServiceLevelObjectiveBoundary {
|
|||||||
return new ServiceLevelObjectiveBoundary(MeterValue.valueOf(value));
|
return new ServiceLevelObjectiveBoundary(MeterValue.valueOf(value));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static class ServiceLevelObjectiveBoundaryHints implements RuntimeHintsRegistrar {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void registerHints(RuntimeHints hints, ClassLoader classLoader) {
|
||||||
|
hints.reflection().registerType(ServiceLevelObjectiveBoundary.class, MemberCategory.INVOKE_PUBLIC_METHODS);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,2 @@
|
|||||||
|
org.springframework.aot.hint.RuntimeHintsRegistrar=\
|
||||||
|
org.springframework.boot.actuate.autoconfigure.metrics.ServiceLevelObjectiveBoundary.ServiceLevelObjectiveBoundaryHints
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2012-2021 the original author or authors.
|
* Copyright 2012-2024 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
@ -21,6 +21,10 @@ import java.time.Duration;
|
|||||||
import io.micrometer.core.instrument.Meter.Type;
|
import io.micrometer.core.instrument.Meter.Type;
|
||||||
import org.junit.jupiter.api.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
|
import org.springframework.aot.hint.RuntimeHints;
|
||||||
|
import org.springframework.aot.hint.predicate.RuntimeHintsPredicates;
|
||||||
|
import org.springframework.util.ReflectionUtils;
|
||||||
|
|
||||||
import static org.assertj.core.api.Assertions.assertThat;
|
import static org.assertj.core.api.Assertions.assertThat;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -73,4 +77,16 @@ class ServiceLevelObjectiveBoundaryTests {
|
|||||||
assertThat(slo.getValue(Type.DISTRIBUTION_SUMMARY)).isNull();
|
assertThat(slo.getValue(Type.DISTRIBUTION_SUMMARY)).isNull();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void shouldRegisterRuntimeHints() {
|
||||||
|
RuntimeHints runtimeHints = new RuntimeHints();
|
||||||
|
new ServiceLevelObjectiveBoundary.ServiceLevelObjectiveBoundaryHints().registerHints(runtimeHints,
|
||||||
|
getClass().getClassLoader());
|
||||||
|
ReflectionUtils.doWithLocalMethods(ServiceLevelObjectiveBoundary.class, (method) -> {
|
||||||
|
if ("valueOf".equals(method.getName())) {
|
||||||
|
assertThat(RuntimeHintsPredicates.reflection().onMethod(method)).accepts(runtimeHints);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user