Metrics: move Witness class to better package names

Part of #7788

Fixes #8065
This commit is contained in:
Jake Landis 2017-08-24 10:58:08 -05:00
parent 8e72b55659
commit dbda826060
22 changed files with 59 additions and 30 deletions

View file

@ -34,7 +34,7 @@ public interface MetricSerializer<T extends Metric<?>> {
* @param gen The {@link JsonGenerator} used to generate JSON
* @return the {@link MetricSerializer} which is the function used to serialize the metric
*/
static MetricSerializer<Metric<Number>> numberSerializer(JsonGenerator gen) {
public static MetricSerializer<Metric<Number>> numberSerializer(JsonGenerator gen) {
return m -> {
if (m != null) {
Number value = m.getValue();
@ -49,7 +49,7 @@ public interface MetricSerializer<T extends Metric<?>> {
* @param gen The {@link JsonGenerator} used to generate JSON
* @return the {@link MetricSerializer} which is the function used to serialize the metric
*/
static MetricSerializer<Metric<Long>> longSerializer(JsonGenerator gen) {
public static MetricSerializer<Metric<Long>> longSerializer(JsonGenerator gen) {
return m -> {
if (m != null) {
Long value = m.getValue();
@ -64,7 +64,7 @@ public interface MetricSerializer<T extends Metric<?>> {
* @param gen The {@link JsonGenerator} used to generate JSON
* @return the {@link MetricSerializer} which is the function used to serialize the metric
*/
static MetricSerializer<Metric<Boolean>> booleanSerializer(JsonGenerator gen) {
public static MetricSerializer<Metric<Boolean>> booleanSerializer(JsonGenerator gen) {
return m -> {
if (m != null) {
Boolean value = m.getValue();
@ -79,7 +79,7 @@ public interface MetricSerializer<T extends Metric<?>> {
* @param gen The {@link JsonGenerator} used to generate JSON
* @return the {@link MetricSerializer} which is the function used to serialize the metric
*/
static MetricSerializer<Metric<String>> stringSerializer(JsonGenerator gen) {
public static MetricSerializer<Metric<String>> stringSerializer(JsonGenerator gen) {
return m -> {
if (m != null) {
gen.writeStringField(m.getName(), m.getValue());
@ -93,7 +93,7 @@ public interface MetricSerializer<T extends Metric<?>> {
* @param gen The {@link JsonGenerator} used to generate JSON
* @return the {@link MetricSerializer} which is the function used to serialize the metric
*/
static MetricSerializer<RubyTimeStampGauge> timestampSerializer(JsonGenerator gen) {
public static MetricSerializer<RubyTimeStampGauge> timestampSerializer(JsonGenerator gen) {
return m -> {
if (m != null) {
gen.writeStringField(m.getName(), m.getValue() != null ? m.getValue().toString() : null);

View file

@ -4,6 +4,10 @@ import com.fasterxml.jackson.core.JsonGenerator;
import com.fasterxml.jackson.databind.SerializerProvider;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.fasterxml.jackson.databind.ser.std.StdSerializer;
import org.logstash.instrument.witness.pipeline.EventsWitness;
import org.logstash.instrument.witness.pipeline.PipelineWitness;
import org.logstash.instrument.witness.pipeline.PipelinesWitness;
import org.logstash.instrument.witness.pipeline.ReloadWitness;
import java.io.IOException;
import java.util.Arrays;

View file

@ -1,4 +1,4 @@
package org.logstash.instrument.witness;
package org.logstash.instrument.witness.configuration;
import com.fasterxml.jackson.core.JsonGenerator;
import com.fasterxml.jackson.databind.SerializerProvider;
@ -8,6 +8,8 @@ import org.logstash.instrument.metrics.Metric;
import org.logstash.instrument.metrics.gauge.BooleanGauge;
import org.logstash.instrument.metrics.gauge.NumberGauge;
import org.logstash.instrument.metrics.gauge.TextGauge;
import org.logstash.instrument.witness.MetricSerializer;
import org.logstash.instrument.witness.SerializableWitness;
import java.io.IOException;

View file

@ -1,4 +1,4 @@
package org.logstash.instrument.witness;
package org.logstash.instrument.witness.pipeline;
import com.fasterxml.jackson.core.JsonGenerator;
import com.fasterxml.jackson.databind.SerializerProvider;
@ -6,6 +6,8 @@ import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.fasterxml.jackson.databind.ser.std.StdSerializer;
import org.logstash.instrument.metrics.Metric;
import org.logstash.instrument.metrics.gauge.NumberGauge;
import org.logstash.instrument.witness.MetricSerializer;
import org.logstash.instrument.witness.SerializableWitness;
import java.io.IOException;

View file

@ -1,4 +1,4 @@
package org.logstash.instrument.witness;
package org.logstash.instrument.witness.pipeline;
import com.fasterxml.jackson.core.JsonGenerator;
import com.fasterxml.jackson.databind.SerializerProvider;
@ -6,11 +6,12 @@ import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.fasterxml.jackson.databind.ser.std.StdSerializer;
import org.logstash.instrument.metrics.Metric;
import org.logstash.instrument.metrics.gauge.TextGauge;
import org.logstash.instrument.witness.MetricSerializer;
import org.logstash.instrument.witness.SerializableWitness;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.PrintStream;
import java.nio.charset.StandardCharsets;
/**
* Witness for errors.
@ -132,7 +133,7 @@ public class ErrorWitness implements SerializableWitness {
/**
* Gets the error message
*
* @return the error message
* @return the error message. May be {@code null}
*/
public String message() {
return witness.message.getValue();
@ -141,7 +142,7 @@ public class ErrorWitness implements SerializableWitness {
/**
* Gets the error stack/back trace
*
* @return the backtrace as a String
* @return the backtrace as a String. May be {@code null}
*/
public String backtrace() {
return witness.backtrace.getValue();

View file

@ -1,4 +1,4 @@
package org.logstash.instrument.witness;
package org.logstash.instrument.witness.pipeline;
import com.fasterxml.jackson.core.JsonGenerator;
import com.fasterxml.jackson.databind.SerializerProvider;
@ -6,6 +6,8 @@ import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.fasterxml.jackson.databind.ser.std.StdSerializer;
import org.logstash.instrument.metrics.Metric;
import org.logstash.instrument.metrics.counter.LongCounter;
import org.logstash.instrument.witness.MetricSerializer;
import org.logstash.instrument.witness.SerializableWitness;
import java.io.IOException;

View file

@ -1,9 +1,11 @@
package org.logstash.instrument.witness;
package org.logstash.instrument.witness.pipeline;
import com.fasterxml.jackson.core.JsonGenerator;
import com.fasterxml.jackson.databind.SerializerProvider;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.fasterxml.jackson.databind.ser.std.StdSerializer;
import org.logstash.instrument.witness.configuration.ConfigWitness;
import org.logstash.instrument.witness.SerializableWitness;
import java.io.IOException;

View file

@ -1,9 +1,10 @@
package org.logstash.instrument.witness;
package org.logstash.instrument.witness.pipeline;
import com.fasterxml.jackson.core.JsonGenerator;
import com.fasterxml.jackson.databind.SerializerProvider;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.fasterxml.jackson.databind.ser.std.StdSerializer;
import org.logstash.instrument.witness.SerializableWitness;
import java.io.IOException;
import java.util.Map;

View file

@ -1,4 +1,4 @@
package org.logstash.instrument.witness;
package org.logstash.instrument.witness.pipeline;
import com.fasterxml.jackson.core.JsonGenerator;
import com.fasterxml.jackson.databind.SerializerProvider;
@ -11,10 +11,11 @@ import org.logstash.instrument.metrics.counter.LongCounter;
import org.logstash.instrument.metrics.gauge.GaugeMetric;
import org.logstash.instrument.metrics.gauge.LazyDelegatingGauge;
import org.logstash.instrument.metrics.gauge.TextGauge;
import org.logstash.instrument.witness.MetricSerializer;
import org.logstash.instrument.witness.SerializableWitness;
import java.io.IOException;
import java.util.Collections;
import java.util.HashMap;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;

View file

@ -1,12 +1,12 @@
package org.logstash.instrument.witness;
package org.logstash.instrument.witness.pipeline;
import com.fasterxml.jackson.core.JsonGenerator;
import com.fasterxml.jackson.databind.SerializerProvider;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.fasterxml.jackson.databind.ser.std.StdSerializer;
import org.logstash.instrument.witness.SerializableWitness;
import java.io.IOException;
import java.util.HashMap;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;

View file

@ -1,4 +1,4 @@
package org.logstash.instrument.witness;
package org.logstash.instrument.witness.pipeline;
import com.fasterxml.jackson.core.JsonGenerator;
import com.fasterxml.jackson.databind.SerializerProvider;
@ -7,6 +7,8 @@ import com.fasterxml.jackson.databind.ser.std.StdSerializer;
import org.logstash.instrument.metrics.Metric;
import org.logstash.instrument.metrics.gauge.NumberGauge;
import org.logstash.instrument.metrics.gauge.TextGauge;
import org.logstash.instrument.witness.MetricSerializer;
import org.logstash.instrument.witness.SerializableWitness;
import java.io.IOException;

View file

@ -1,4 +1,4 @@
package org.logstash.instrument.witness;
package org.logstash.instrument.witness.pipeline;
import com.fasterxml.jackson.core.JsonGenerator;
import com.fasterxml.jackson.databind.SerializerProvider;
@ -9,6 +9,8 @@ import org.logstash.ext.JrubyTimestampExtLibrary;
import org.logstash.instrument.metrics.Metric;
import org.logstash.instrument.metrics.counter.LongCounter;
import org.logstash.instrument.metrics.gauge.RubyTimeStampGauge;
import org.logstash.instrument.witness.MetricSerializer;
import org.logstash.instrument.witness.SerializableWitness;
import java.io.IOException;

View file

@ -1,8 +1,9 @@
package org.logstash.instrument.witness;
package org.logstash.instrument.witness.configuration;
import com.fasterxml.jackson.databind.ObjectMapper;
import org.junit.Before;
import org.junit.Test;
import org.logstash.instrument.witness.configuration.ConfigWitness;
import static org.assertj.core.api.Assertions.assertThat;

View file

@ -1,9 +1,10 @@
package org.logstash.instrument.witness;
package org.logstash.instrument.witness.pipeline;
import com.fasterxml.jackson.databind.ObjectMapper;
import org.junit.Before;
import org.junit.Test;
import org.logstash.instrument.witness.pipeline.DeadLetterQueueWitness;
import static org.assertj.core.api.Assertions.assertThat;

View file

@ -1,8 +1,9 @@
package org.logstash.instrument.witness;
package org.logstash.instrument.witness.pipeline;
import com.fasterxml.jackson.databind.ObjectMapper;
import org.junit.Before;
import org.junit.Test;
import org.logstash.instrument.witness.pipeline.ErrorWitness;
import static org.assertj.core.api.Assertions.assertThat;

View file

@ -1,8 +1,9 @@
package org.logstash.instrument.witness;
package org.logstash.instrument.witness.pipeline;
import com.fasterxml.jackson.databind.ObjectMapper;
import org.junit.Before;
import org.junit.Test;
import org.logstash.instrument.witness.pipeline.EventsWitness;
import static org.assertj.core.api.Assertions.assertThat;

View file

@ -1,8 +1,9 @@
package org.logstash.instrument.witness;
package org.logstash.instrument.witness.pipeline;
import com.fasterxml.jackson.databind.ObjectMapper;
import org.junit.Before;
import org.junit.Test;
import org.logstash.instrument.witness.pipeline.PipelineWitness;
import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.within;

View file

@ -1,8 +1,9 @@
package org.logstash.instrument.witness;
package org.logstash.instrument.witness.pipeline;
import com.fasterxml.jackson.databind.ObjectMapper;
import org.junit.Before;
import org.junit.Test;
import org.logstash.instrument.witness.pipeline.PipelinesWitness;
import static org.assertj.core.api.Assertions.assertThat;

View file

@ -1,4 +1,4 @@
package org.logstash.instrument.witness;
package org.logstash.instrument.witness.pipeline;
import com.fasterxml.jackson.databind.ObjectMapper;
@ -7,6 +7,7 @@ import org.junit.Before;
import org.junit.Test;
import org.logstash.RubyUtil;
import org.logstash.instrument.metrics.MetricType;
import org.logstash.instrument.witness.pipeline.PluginWitness;
import java.io.IOException;
import java.math.BigDecimal;

View file

@ -1,9 +1,10 @@
package org.logstash.instrument.witness;
package org.logstash.instrument.witness.pipeline;
import com.fasterxml.jackson.databind.ObjectMapper;
import org.junit.Before;
import org.junit.Test;
import org.logstash.instrument.witness.pipeline.PluginsWitness;
import static org.assertj.core.api.Assertions.assertThat;

View file

@ -1,8 +1,9 @@
package org.logstash.instrument.witness;
package org.logstash.instrument.witness.pipeline;
import com.fasterxml.jackson.databind.ObjectMapper;
import org.junit.Before;
import org.junit.Test;
import org.logstash.instrument.witness.pipeline.QueueWitness;
import static org.assertj.core.api.Assertions.assertThat;

View file

@ -1,4 +1,4 @@
package org.logstash.instrument.witness;
package org.logstash.instrument.witness.pipeline;
import com.fasterxml.jackson.databind.ObjectMapper;
@ -7,6 +7,7 @@ import org.junit.Test;
import org.junit.runner.RunWith;
import org.logstash.Timestamp;
import org.logstash.ext.JrubyTimestampExtLibrary;
import org.logstash.instrument.witness.pipeline.ReloadWitness;
import org.mockito.Mock;
import org.mockito.runners.MockitoJUnitRunner;