Skip to content

Commit

Permalink
Changing to use spectator for metrics (#118)
Browse files Browse the repository at this point in the history
* Changing metric collection to spring spectator apis.

* removing unneeded registry and renaming constants

* Changes to address review comments
  • Loading branch information
zhljen authored and tgianos committed May 19, 2017
1 parent 7612b12 commit 32a6ee4
Show file tree
Hide file tree
Showing 50 changed files with 2,650 additions and 1,732 deletions.
4 changes: 4 additions & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,10 @@ configure(javaProjects) {
dependency("com.amazon.redshift:redshift-jdbc42:1.2.1.1001")
dependency("com.github.fge:json-patch:1.9")
dependency("com.github.rholder:guava-retrying:2.0.0")
dependencySet(group: "com.netflix.spectator", version: "0.55.0") {
entry "spectator-api"
entry "spectator-reg-servo"
}
// Guava even with guava.version set to 19.0 in properties keeps going back to 18.0 without this.
dependency("com.google.guava:guava:19.0")
dependencySet(group: "com.google.inject.extensions", version: "4.0") {
Expand Down
4 changes: 1 addition & 3 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,4 @@ tomcat.version=8.0.22

hive_version=1.2.1

## speed up the build process
#org.gradle.parallel=true
org.gradle.jvmargs=-Xmx2G

Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@
package com.netflix.metacat.common.server.connectors;

import com.netflix.metacat.common.server.properties.Config;
import com.netflix.spectator.api.Registry;
import lombok.NonNull;

import javax.annotation.Nonnull;
import java.util.Map;
Expand All @@ -44,15 +46,16 @@ public interface ConnectorPlugin {
* @param config System config
* @param connectorName connector name. This is also the catalog name.
* @param configuration configuration properties
* @param registry registry for spectator
* @return connector factory
*/
ConnectorFactory create(
@Nonnull Config config,
@Nonnull String connectorName,
@Nonnull Map<String, String> configuration
@Nonnull Map<String, String> configuration,
@Nonnull @NonNull Registry registry
);


/**
* Returns the partition service implementation of the connector.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@
*/
package com.netflix.metacat.common.server.events;

import com.netflix.metacat.common.server.monitoring.CounterWrapper;
import com.netflix.metacat.common.server.monitoring.Metrics;
import com.netflix.spectator.api.Registry;
import lombok.NonNull;
import lombok.extern.slf4j.Slf4j;
import org.springframework.context.ApplicationEvent;
Expand All @@ -38,19 +39,23 @@ public class MetacatEventBus {

private final ApplicationEventPublisher eventPublisher;
private final ApplicationEventMulticaster eventMulticaster;
private final Registry registry;

/**
* Constructor.
*
* @param eventPublisher The synchronous event publisher to use
* @param eventMulticaster The asynchronous event multicaster to use
* @param registry The registry to spectator
*/
public MetacatEventBus(
@Nonnull @NonNull final ApplicationEventPublisher eventPublisher,
@Nonnull @NonNull final ApplicationEventMulticaster eventMulticaster
@Nonnull @NonNull final ApplicationEventPublisher eventPublisher,
@Nonnull @NonNull final ApplicationEventMulticaster eventMulticaster,
@Nonnull @NonNull final Registry registry
) {
this.eventPublisher = eventPublisher;
this.eventMulticaster = eventMulticaster;
this.registry = registry;
}

/**
Expand All @@ -60,7 +65,7 @@ public MetacatEventBus(
*/
public void postAsync(final ApplicationEvent event) {
log.debug("Received request to post an event {} asynchronously", event);
CounterWrapper.incrementCounter("metacat.events.async");
registry.counter(Metrics.CounterEventAsync.name()).increment();
this.eventMulticaster.multicastEvent(event);
}

Expand All @@ -71,7 +76,7 @@ public void postAsync(final ApplicationEvent event) {
*/
public void postSync(final ApplicationEvent event) {
log.debug("Received request to post an event {} synchronously", event);
CounterWrapper.incrementCounter("metacat.events.sync");
registry.counter(Metrics.CounterEventSync.name()).increment();
this.eventPublisher.publishEvent(event);
}

Expand Down

This file was deleted.

This file was deleted.

Loading

0 comments on commit 32a6ee4

Please sign in to comment.