Skip to content

Commit

Permalink
Merge pull request #9 from kenfinnigan/remove-sysouts
Browse files Browse the repository at this point in the history
Remove System.out usage
  • Loading branch information
kenfinnigan authored Oct 8, 2021
2 parents 499c163 + 29ade31 commit d0cc265
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 9 deletions.
2 changes: 0 additions & 2 deletions src/main/java/com/redhat/MeterController.java
Original file line number Diff line number Diff line change
Expand Up @@ -259,8 +259,6 @@ PodWatcher getWatcher() {
private MeterStatus constructStatus() {
final String currentlyWatching = podWatcher != null ? "TRUE" : "FALSE";
final String watchedPodCount = podWatcher != null ? podWatcher.watchedPods() : "UNKNOWN";
// TODO remove
System.out.println("WATCHED POD STATUS: " + watchedPodCount);
final Resource<ServiceMonitor> serviceMonitor = serviceMonitor();
final String serviceMonitorInstalled = serviceMonitor != null ? (serviceMonitor.get() != null ? "TRUE" : "FALSE") : "UNKNOWN";
return new MeterStatus(currentlyWatching, watchedPodCount, serviceMonitorInstalled);
Expand Down
11 changes: 4 additions & 7 deletions src/main/java/com/redhat/PodWatcher.java
Original file line number Diff line number Diff line change
Expand Up @@ -60,12 +60,10 @@ static Map<String, String> convertListToMap(List<String> productNameMapAsList) {

@Override
public void eventReceived(Action action, Pod resource) {
LOG.info("EVENT RECEIVED FOR POD: " + resource.getMetadata().getName());
if (!shouldWatch(spec.getWatchNamespaces(), resource.getMetadata().getNamespace())) {
// If we're not watching all namespaces or the event is from a namespace we're not watching, do nothing
return;
}
LOG.info("WATCHING NAMESPACE");

if (resource.getMetadata().getLabels().containsKey(config.pod().identifier())) {
// Get/Create metric
Expand All @@ -75,7 +73,7 @@ public void eventReceived(Action action, Pod resource) {
switch (action) {
case ADDED:
if (includePod(config, resource.getMetadata().getLabels(), spec)) {
LOG.info("CREATING METRIC, POD INCLUDED");
LOG.trace("Adding pod to metrics gathering: " + resource.getMetadata().getName() + " in " + resource.getMetadata().getNamespace());
if (podGroup == null) {
podGroup = new PodGroup();
podGroup.addPod(resource.getMetadata().getName(), resource.getMetadata().getNamespace());
Expand All @@ -93,7 +91,6 @@ public void eventReceived(Action action, Pod resource) {
break;
case DELETED:
if (podGroup != null) {
LOG.info("POD DELETE EVENT. REMOVING");
podGroup.removePod(resource.getMetadata().getName());

if (podGroup.list().size() == 0) {
Expand Down Expand Up @@ -170,6 +167,7 @@ void updateSpec(MeterSpec newSpec) {
PodGroup podGroup = metrics.get(tags);

if (includePod(config, pod.getMetadata().getLabels(), newSpec)) {
LOG.trace("Adding pod to metrics gathering: " + pod.getMetadata().getName() + " in " + pod.getMetadata().getNamespace());
if (podGroup == null) {
podGroup = new PodGroup();
podGroup.addPod(pod.getMetadata().getName(), pod.getMetadata().getNamespace());
Expand All @@ -196,8 +194,6 @@ String watchedPods() {
for (PodGroup podGroup : metrics.values()) {
count += podGroup.pods.size();
}
//TODO remove
System.out.println("NUMBER OF WATCHED PODS: " + count);
return Integer.toString(count);
}

Expand Down Expand Up @@ -255,7 +251,8 @@ public double applyAsDouble(PodGroup value) {
}
} catch (KubernetesClientException kce) {
// Ignore, as it likely means a pod is "ready", but no metrics available yet
LOG.info("EXCEPTION RETRIEVING METRICS", kce);
// Log a debug message in case it's an error of a different kind
LOG.debug(kce);
}
} else {
// Ignore, as the pod is not "ready"
Expand Down

0 comments on commit d0cc265

Please sign in to comment.