Skip to content

Commit

Permalink
fix validation metrics for default publisher (#974)
Browse files Browse the repository at this point in the history
When using the default publisher, the debug registry was
always null rather than falling back to using the registry
it is publishing for. This means that some of the validation
metrics would be missing.
  • Loading branch information
brharrington authored May 17, 2022
1 parent d46c08b commit 1fe89a9
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
import com.netflix.spectator.api.Clock;
import com.netflix.spectator.api.Registry;
import com.netflix.spectator.api.RegistryConfig;
import com.netflix.spectator.atlas.impl.DefaultPublisher;

import java.time.Duration;
import java.util.Collections;
Expand Down Expand Up @@ -258,6 +257,6 @@ default long initialPollingDelay(Clock clock, long stepSize) {
* path.
*/
default Publisher publisher() {
return new DefaultPublisher(this);
return null;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
import com.netflix.spectator.api.Tag;
import com.netflix.spectator.api.Timer;
import com.netflix.spectator.atlas.impl.Consolidator;
import com.netflix.spectator.atlas.impl.DefaultPublisher;
import com.netflix.spectator.atlas.impl.EvalPayload;
import com.netflix.spectator.atlas.impl.Evaluator;
import com.netflix.spectator.atlas.impl.JsonUtils;
Expand Down Expand Up @@ -136,13 +137,13 @@ public AtlasRegistry(Clock clock, AtlasConfig config) {
this.debugRegistry = Optional.ofNullable(config.debugRegistry()).orElse(this);

this.rollupPolicy = config.rollupPolicy();
this.publisher = config.publisher();

this.subManager = new SubscriptionManager(
new ObjectMapper(),
client != null ? client : HttpClient.create(debugRegistry),
clock,
config);
HttpClient httpClient = client != null ? client : HttpClient.create(debugRegistry);

Publisher pub = config.publisher();
this.publisher = pub == null ? new DefaultPublisher(config, httpClient, debugRegistry) : pub;

this.subManager = new SubscriptionManager(new ObjectMapper(), httpClient, clock, config);
this.evaluator = new Evaluator(commonTags, this::toMap, lwcStepMillis);

if (config.autoStart()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,12 +72,18 @@ public DefaultPublisher(final AtlasConfig config) {
}

public DefaultPublisher(final AtlasConfig config, final HttpClient client) {
this(config, client, config.debugRegistry());
}

public DefaultPublisher(
final AtlasConfig config, final HttpClient client, final Registry registry) {

this.uri = URI.create(config.uri());
this.evalUri = URI.create(config.evalUri());
this.connectTimeout = (int) config.connectTimeout().toMillis();
this.readTimeout = (int) config.readTimeout().toMillis();
this.numThreads = config.numThreads();
this.debugRegistry = Optional.ofNullable(config.debugRegistry()).orElse(new NoopRegistry());
this.debugRegistry = Optional.ofNullable(registry).orElse(new NoopRegistry());

this.client = client != null ? client : HttpClient.create(debugRegistry);

Expand Down

0 comments on commit 1fe89a9

Please sign in to comment.