Skip to content
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

replace servo with spectator in the client #1523

Merged
merged 2 commits into from
Jan 3, 2024
Merged

replace servo with spectator in the client #1523

merged 2 commits into from
Jan 3, 2024

Conversation

joshgord
Copy link
Contributor

No description provided.

@@ -67,6 +69,7 @@ public class TimeConsumingInstanceRegistryTest extends AbstractTester {
* Note that there is a thread retrieving and printing out registry status for debugging purpose.
*/
@Test
@Ignore("NumOfRenewsPerMinThreshold should be updated to 256")
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Was already failing in the master branch

@@ -27,6 +27,8 @@ dependencies {
compile project(':eureka-client')
compile 'org.glassfish.jersey.core:jersey-client:2.23.1'
compile 'org.glassfish.jersey.connectors:jersey-apache-connector:2.23.1'
compile "org.slf4j:slf4j-api:1.7.36"
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

slf4j apparently pulled in transitively via servo

@@ -27,6 +27,8 @@ dependencies {
compile project(':eureka-client')
compile 'org.glassfish.jersey.core:jersey-client:2.23.1'
compile 'org.glassfish.jersey.connectors:jersey-apache-connector:2.23.1'
compile "org.slf4j:slf4j-api:1.7.36"
compile 'com.netflix.spectator:spectator-api:1.7.3'
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should it also use ${spectatorVersion} here?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems like this sub project didn't adopt the version substitution like the others 🤷‍♂️

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

May just need to use double quotes

} catch (Exception e) {
s_logger.error("Unable to register with servo.", e);
}
final CompositeRegistry registry = Spectator.globalRegistry();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You should be able to just use the base Registry type for instrumentation. It makes it easier to swap out which implementation is used later if needed.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah right, this was my IDE autocompleting the type, will update

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed

final CompositeRegistry registry = globalRegistry();
PolledMeter.using(registry)
.withName(METRIC_REGISTRY_PREFIX + "lastSuccessfulRegistryFetchTimePeriod")
.monitorValue(getLastSuccessfulRegistryFetchTimePeriodInternal());
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As written it would just report the initial value. The method that takes a Number is meant for things like AtomicInteger that would get updated over time. Unfortunately though, primitive types are implicitly cast so this compiles. Pass in the lambda so it can be invoked each time to get the updated value. For example:

.monitorValue(this, DiscoveryClient::getLastSuccessfulRegistryFetchTimePeriodInternal)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah good catch. I was going to ping you to see if I managed to convert the monitors correctly, will make this change 👍

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed


if (config.shouldRegisterWithEureka()) {
this.heartbeatStalenessMonitor = new ThresholdLevelsMetric(this, METRIC_REGISTRATION_PREFIX + "lastHeartbeatSec_", new long[]{15L, 30L, 60L, 120L, 240L, 480L});
} else {
this.heartbeatStalenessMonitor = ThresholdLevelsMetric.NO_OP_METRIC;
}
PolledMeter.using(registry)
.withName(METRIC_REGISTRATION_PREFIX + "lastSuccessfulHeartbeatTimePeriod")
.monitorValue(getLastSuccessfulHeartbeatTimePeriodInternal());
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See note on using lambda

@@ -387,6 +395,9 @@ public synchronized BackupRegistry get() {
initTimestampMs = System.currentTimeMillis();
initRegistrySize = this.getApplications().size();
registrySize = initRegistrySize;
PolledMeter.using(registry)
.withName(METRIC_REGISTRY_PREFIX + "localRegistrySize")
.monitorValue(registrySize);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See note on using lambda

final CompositeRegistry registry = Spectator.globalRegistry();
PolledMeter.using(registry)
.withName(METRIC_RESOLVER_PREFIX + "lastLoadTimestamp")
.monitorValue(getLastLoadTimestamp());
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See note on using lambda

Monitors.registerObject(name, this);
PolledMeter.using(registry)
.withName(METRIC_RESOLVER_PREFIX + "endpointsSize")
.monitorValue(getEndpointsSize());
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See note on using lambda

}
PolledMeter.using(Spectator.globalRegistry())
.withName(METRIC_RESOLVER_PREFIX + "lastReloadTimestamp")
.monitorValue(getLastReloadTimestamp());
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See note on using lambda

Monitors.registerObject(name, this);
PolledMeter.using(Spectator.globalRegistry())
.withName(METRIC_TRANSPORT_PREFIX + "currentSessionDuration")
.monitorValue(getCurrentSessionDuration());
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See note on using lambda

}
final CompositeRegistry registry = Spectator.globalRegistry();
executionTimeStats = registry.timer("Eureka-Connection-Cleaner-Time");
cleanupFailed = registry.counter("Eureka-Connection-Cleaner-Failure");
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

indentation

@@ -27,6 +27,8 @@ dependencies {
compile project(':eureka-client')
compile 'org.glassfish.jersey.core:jersey-client:2.23.1'
compile 'org.glassfish.jersey.connectors:jersey-apache-connector:2.23.1'
compile "org.slf4j:slf4j-api:1.7.36"
compile 'com.netflix.spectator:spectator-api:1.7.3'
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

May just need to use double quotes

@joshgord joshgord merged commit c72e465 into master Jan 3, 2024
1 check passed
@joshgord joshgord deleted the josh/servo branch January 3, 2024 22:10
@joshgord joshgord restored the josh/servo branch January 3, 2024 22:46
joshgord pushed a commit that referenced this pull request Jan 6, 2024
This reverts commit c72e465, reversing
changes made to bae5c36.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants