-
Notifications
You must be signed in to change notification settings - Fork 1.1k
micrometer-api module split off from micrometer-core #2980
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
micrometer-api module split off from micrometer-core #2980
Conversation
This moves a portion of existing classes in micrometer-core to a new micrometer-api module. micrometer-core depends on the API module and now micrometer-core contains only the instrumentation that we maintain. Projects that want to write their own instrumentation now only need to depend on the micrometer-api module. This will save some kilobytes in the JAR size for them. End users may continue to depend on micrometer-core to get the instrumentation we provide in addition to the API. Package names are changed, which will require users to update their imports. We could not keep the same package name without causing split packages across micrometer-api and micrometer-core.
micrometer-api/src/main/java/io/micrometer/api/instrument/push/PushRegistryConfig.java
Show resolved
Hide resolved
micrometer-api/src/main/java/io/micrometer/api/instrument/dropwizard/DropwizardCounter.java
Show resolved
Hide resolved
micrometer-api/src/main/java/io/micrometer/api/instrument/dropwizard/DropwizardGauge.java
Show resolved
Hide resolved
...meter-api/src/main/java/io/micrometer/api/instrument/dropwizard/DropwizardMeterRegistry.java
Show resolved
Hide resolved
micrometer-api/src/main/java/io/micrometer/api/instrument/push/PushRegistryConfig.java
Show resolved
Hide resolved
micrometer-api/src/main/java/io/micrometer/api/instrument/push/PushRegistryConfig.java
Show resolved
Hide resolved
micrometer-api/src/main/java/io/micrometer/api/instrument/push/PushRegistryConfig.java
Show resolved
Hide resolved
micrometer-api/src/main/java/io/micrometer/api/instrument/simple/SimpleConfig.java
Show resolved
Hide resolved
micrometer-api/src/main/java/io/micrometer/api/instrument/simple/SimpleConfig.java
Show resolved
Hide resolved
micrometer-api/src/main/java/io/micrometer/api/instrument/util/MeterEquivalence.java
Show resolved
Hide resolved
...ntations/micrometer-registry-atlas/src/main/java/io/micrometer/atlas/AtlasMeterRegistry.java
Show resolved
Hide resolved
shakuzen
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I know this is a huge changeset with mostly uninteresting noise (rename of package in imports), so I've commented on most files that weren't that.
| // This will fail to compile since published Spring Boot versions are based on Micrometer 1.x and | ||
| // we have changed the package for Micrometer API it uses. | ||
| // @Bean | ||
| // WebMvcTagsProvider webMvcTagsProvider() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I had to comment out this stuff because of the package change to Tag but Spring Boot classes still reference the previous package. This really just exemplifies why we shouldn't have Spring Boot samples in this repo - it's a circular dependency.
| * Copy of {@link org.springframework.boot.actuate.metrics.web.reactive.client.MetricsWebClientCustomizer}. | ||
| * Uses {@link PocMetricsWebClientFilterFunction} instead of {@link org.springframework.boot.actuate.metrics.web.reactive.client.MetricsWebClientFilterFunction}. | ||
| */ | ||
| public class PocMetricsWebClientCustomizer implements WebClientCustomizer { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This was copied and modified classes from Spring Boot to demonstrate instrumenting with Timer.start instead of Timer.record. We don't need to maintain it here, and it has the compile problem of depending on Spring Boot that compiles against a version of Micrometer without the package changes made here.
|
|
||
| /** | ||
| * Base class for cache metrics tests. | ||
| * | ||
| * @author Oleksii Bondar | ||
| */ | ||
| abstract class AbstractCacheMetricsTest { | ||
| public abstract class AbstractCacheMetricsTest { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Moved to micrometer-test. I'm not sure we need this and the CacheMeterBinderCompatibilityKit, but I tried to limit this pull request to moving things.
| testImplementation 'com.github.ben-manes.caffeine:caffeine' | ||
| testImplementation 'net.sf.ehcache:ehcache' | ||
| testImplementation 'javax.cache:cache-api' | ||
| testImplementation 'com.hazelcast:hazelcast' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The specific cache metric implementations are in micrometer-core, so moved the tests there, eliminating the need to have these dependencies here also. I think it's better we have only the abstract test in micrometer-test.
|
|
||
| import java.net.SocketTimeoutException; | ||
| import java.util.concurrent.TimeUnit; | ||
|
|
||
| import static com.github.tomakehurst.wiremock.client.WireMock.*; | ||
| import static org.assertj.core.api.Assertions.assertThatExceptionOfType; | ||
|
|
||
| @ExtendWith(WiremockResolver.class) | ||
| @WireMockTest |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I switched to the built-in JUnit Jupiter support now in Wiremock, rather than using the separate dependency to reduce one test dependency needed in micrometer-api. Same in HttpUrlConnectionSenderTests
| @@ -282,7 +283,7 @@ void timeMethodFailureWithLongTaskTimerWhenCompleted() { | |||
|
|
|||
| assertThatExceptionOfType(MeterNotFoundException.class).isThrownBy(() -> { | |||
| failingRegistry.get("longCall") | |||
| .tag("class", "io.micrometer.core.aop.TimedAspectTest$AsyncTimedService") | |||
| .tag("class", this.getClass().getName() + "$AsyncTimedService") | |||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
IntelliJ did not refactor this class name and these tests were failing. So I manually refactored it to be more robust in preparation of the next moving of this test class.
| */ | ||
| package io.micrometer.api.instrument.transport.http.tags; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I fixed the location of the JavaDoc for this package-info. We could do the same for maintenance branches also.
| * | ||
| * @author Jon Schneider | ||
| * @see io.micrometer.core.instrument.binder.jvm.ExecutorServiceMetrics |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ExecutorServiceMetrics is in micrometer-core, but this class is in micrometer-api. Cannot resolve the reference. If we think this note is important, we can ignore the warning.
|
|
||
| // TODO move dropwizard out of api module? | ||
| // DropwizardMeterRegistry for e.g. JMX registry | ||
| optionalApi 'io.dropwizard.metrics:metrics-core' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Left as a potential future task to consider moving dropwizard to its own module to keep it out of micrometer-api.
While passing on the command line, our dependency injection tests for Guice were failing when running from IntelliJ for me. Upgrading to the latest version of Guice resolved this for me.
|
Registry implementations continue to depend on |
| 'io.prometheus:simpleclient_common:latest.release', | ||
| 'io.prometheus:simpleclient_pushgateway:latest.release', | ||
| // TODO support HttpTagsProvider variants based on Jakarta APIs? | ||
| // 'jakarta.servlet:jakarta.servlet-api:latest.release', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In working on this, I noticed we have a javax servlet based http tags provider. We should probably also have jakarta-based one. Supporting either in the instrumentation may be a challenge. But something to work on separately from this PR.
|
On JAR size reduction due to this splitting, With these changes, |
|
@shakuzen This change does not apply to |
|
@kazuki43zoo This change was eventually reverted in #3046 in favor of a micrometer-binder module (#3043), which will be part of today's release of |
This moves a portion of existing classes in micrometer-core to a new micrometer-api module. micrometer-core depends on the API module and now micrometer-core contains only the instrumentation that we maintain.
Projects that want to write their own instrumentation should depend on the micrometer-api module. This will save some kilobytes in the JAR size for them.
End users may continue to depend on micrometer-core to get the instrumentation we provide in addition to the API.
Package names are changed, which will require users to update their imports. We could not keep the same package name without causing split packages across micrometer-api and micrometer-core.