Skip to content
This repository has been archived by the owner on Jul 1, 2022. It is now read-only.

Commit

Permalink
Changed @tostring to place exclusions with the fields
Browse files Browse the repository at this point in the history
Signed-off-by: Juraci Paixão Kröhling <juraci@kroehling.de>
  • Loading branch information
jpkrohling committed Aug 23, 2018
1 parent 3b72a4c commit 5eb42c9
Show file tree
Hide file tree
Showing 14 changed files with 65 additions and 51 deletions.
4 changes: 2 additions & 2 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -143,8 +143,8 @@ subprojects {
}

dependencies {
annotationProcessor 'org.projectlombok:lombok:1.16.18'
compileOnly 'org.projectlombok:lombok:1.16.18'
annotationProcessor 'org.projectlombok:lombok:1.18.2'
compileOnly 'org.projectlombok:lombok:1.18.2'
compileOnly 'org.codehaus.mojo:animal-sniffer-annotations:1.16'
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,7 @@ public synchronized JaegerTracer getTracer() {
}

tracer = getTracerBuilder().build();
log.debug("Initialized tracer={}", tracer);
log.info("Initialized tracer={}", tracer);

return tracer;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,24 +58,24 @@
import lombok.ToString;
import lombok.extern.slf4j.Slf4j;

@ToString(exclude = {"registry", "clock", "metrics", "scopeManager"})
@ToString
@Slf4j
public class JaegerTracer implements Tracer, Closeable {

private final String version;
private final String serviceName;
private final Reporter reporter;
private final Sampler sampler;
private final PropagationRegistry registry;
private final Clock clock;
private final Metrics metrics;
private final int ipv4;
private final Map<String, ?> tags;
private final boolean zipkinSharedRpcSpan;
private final ScopeManager scopeManager;
private final BaggageSetter baggageSetter;
private final boolean expandExceptionLogs;
private final JaegerObjectFactory objectFactory;

@ToString.Exclude private final PropagationRegistry registry;
@ToString.Exclude private final Clock clock;
@ToString.Exclude private final Metrics metrics;
@ToString.Exclude private final ScopeManager scopeManager;
@ToString.Exclude private final BaggageSetter baggageSetter;
@ToString.Exclude private final JaegerObjectFactory objectFactory;
@ToString.Exclude private final int ipv4; // human readable representation is present within the tag map

protected JaegerTracer(JaegerTracer.Builder builder) {
this.serviceName = builder.serviceName;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,20 +32,22 @@
/**
* RemoteReporter buffers spans in memory and sends them out of process using Sender.
*/
@ToString(exclude = {"commandQueue", "flushTimer", "queueProcessorThread", "metrics"})
@ToString
@Slf4j
public class RemoteReporter implements Reporter {
private static final int DEFAULT_CLOSE_ENQUEUE_TIMEOUT_MILLIS = 1000;

public static final int DEFAULT_FLUSH_INTERVAL_MS = 1000;
public static final int DEFAULT_MAX_QUEUE_SIZE = 100;

private static final int DEFAULT_CLOSE_ENQUEUE_TIMEOUT_MILLIS = 1000;
private final BlockingQueue<Command> commandQueue;
private final Timer flushTimer;
private final Thread queueProcessorThread;
private final QueueProcessor queueProcessor;
private final Sender sender;
private final int closeEnqueueTimeout;
private final Metrics metrics;

@ToString.Exclude private final BlockingQueue<Command> commandQueue;
@ToString.Exclude private final Timer flushTimer;
@ToString.Exclude private final Thread queueProcessorThread;
@ToString.Exclude private final QueueProcessor queueProcessor;
@ToString.Exclude private final Metrics metrics;

private RemoteReporter(Sender sender, int flushInterval, int maxQueueSize, int closeEnqueueTimeout,
Metrics metrics) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,13 @@
import lombok.ToString;


@ToString(exclude = "gson")
@ToString
public class HttpSamplingManager implements SamplingManager {
public static final String DEFAULT_HOST_PORT = "localhost:5778";
private final Gson gson = new Gson();
private final String hostPort;

@ToString.Exclude private final Gson gson = new Gson();

/**
* This constructor expects running sampling manager on {@link #DEFAULT_HOST_PORT}.
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,13 @@ public class ProbabilisticSampler implements Sampler {
public static final double DEFAULT_SAMPLING_PROBABILITY = 0.001;
public static final String TYPE = "probabilistic";

private final long positiveSamplingBoundary;
private final long negativeSamplingBoundary;
@Getter private final double samplingRate;
private final Map<String, Object> tags;

// exclude from toString as these are represented in the tags map already
@ToString.Exclude private final long positiveSamplingBoundary;
@ToString.Exclude private final long negativeSamplingBoundary;
@ToString.Exclude @Getter private final double samplingRate;

public ProbabilisticSampler(double samplingRate) {
if (samplingRate < 0.0 || samplingRate > 1.0) {
throw new IllegalArgumentException(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,15 +24,16 @@
import lombok.ToString;

@SuppressWarnings("EqualsHashCode")
@ToString(exclude = "rateLimiter")
@ToString
public class RateLimitingSampler implements Sampler {
public static final String TYPE = "ratelimiting";

private final RateLimiter rateLimiter;
@Getter
private final double maxTracesPerSecond;
private final Map<String, Object> tags;

@ToString.Exclude private final RateLimiter rateLimiter;

public RateLimitingSampler(double maxTracesPerSecond) {
this.maxTracesPerSecond = maxTracesPerSecond;
double maxBalance = maxTracesPerSecond < 1.0 ? 1.0 : maxTracesPerSecond;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,21 +32,25 @@
import lombok.extern.slf4j.Slf4j;

@SuppressWarnings("EqualsHashCode")
@ToString(exclude = {"pollTimer", "lock"})
@ToString
@Slf4j
public class RemoteControlledSampler implements Sampler {
public static final String TYPE = "remote";
private static final int DEFAULT_POLLING_INTERVAL_MS = 60000;

private final int maxOperations = 2000;
private final String serviceName;
private final SamplingManager manager;
private final Timer pollTimer;
private final ReentrantReadWriteLock lock = new ReentrantReadWriteLock();
private final Metrics metrics;

@Getter(AccessLevel.PACKAGE)
private Sampler sampler;

// most of the time, toString here is called from the JaegerTracer, which holds this as well
@ToString.Exclude private final String serviceName;

@ToString.Exclude private final Timer pollTimer;
@ToString.Exclude private final ReentrantReadWriteLock lock = new ReentrantReadWriteLock();
@ToString.Exclude private final Metrics metrics;

private RemoteControlledSampler(Builder builder) {
this.serviceName = builder.serviceName;
this.manager = builder.samplingManager;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,15 +29,16 @@
/*
* A thrift transport for sending sending/receiving spans.
*/
@ToString(exclude = {"writeBuffer"})
@ToString
public class ThriftUdpTransport extends TTransport implements Closeable {
public static final int MAX_PACKET_SIZE = 65000;

public final DatagramSocket socket;
public byte[] receiveBuf;
public int receiveOffSet = -1;
public int receiveLength = 0;
public ByteBuffer writeBuffer;

@ToString.Exclude public final DatagramSocket socket;
@ToString.Exclude public byte[] receiveBuf;
@ToString.Exclude public ByteBuffer writeBuffer;

// Create a UDP client for sending data to specific host and port
public static ThriftUdpTransport newThriftUdpClient(String host, int port) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,14 @@
import okhttp3.RequestBody;
import okhttp3.Response;

@ToString(exclude = {"httpClient", "requestBuilder"})
@ToString
public class HttpSender extends ThriftSender {
private static final String HTTP_COLLECTOR_JAEGER_THRIFT_FORMAT_PARAM = "format=jaeger.thrift";
private static final int ONE_MB_IN_BYTES = 1048576;
private static final MediaType MEDIA_TYPE_THRIFT = MediaType.parse("application/x-thrift");
private final OkHttpClient httpClient;
private final Request.Builder requestBuilder;

@ToString.Exclude private final OkHttpClient httpClient;
@ToString.Exclude private final Request.Builder requestBuilder;

protected HttpSender(Builder builder) {
super(ProtocolType.Binary, builder.maxPacketSize);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,15 @@
import java.util.List;
import lombok.ToString;

@ToString(exclude = {"spanBuffer"})
@ToString
public abstract class ThriftSender extends ThriftSenderBase implements Sender {

private Process process;
private int processBytesSize;
private List<io.jaegertracing.thriftjava.Span> spanBuffer;
private int byteBufferSize;

@ToString.Exclude private List<io.jaegertracing.thriftjava.Span> spanBuffer;

/**
* @param protocolType protocol type (compact or binary)
* @param maxPacketSize if 0 it will use default value {@value ThriftUdpTransport#MAX_PACKET_SIZE}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
import org.apache.thrift.protocol.TProtocolFactory;
import org.apache.thrift.transport.AutoExpandingBufferWriteTransport;

@ToString(exclude = {"memoryTransport"})
@ToString
@Slf4j
public abstract class ThriftSenderBase {

Expand All @@ -35,12 +35,12 @@ public enum ProtocolType {

public static final int EMIT_BATCH_OVERHEAD = 33;

private AutoExpandingBufferWriteTransport memoryTransport;

protected final TProtocolFactory protocolFactory;
private final TSerializer serializer;
private final int maxSpanBytes;

@ToString.Exclude private AutoExpandingBufferWriteTransport memoryTransport;

/**
* @param protocolType protocol type (compact or binary)
* @param maxPacketSize if 0 it will use default value {@value ThriftUdpTransport#MAX_PACKET_SIZE}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,13 @@
import java.util.List;
import lombok.ToString;

@ToString(exclude = {"agentClient"})
@ToString
public class UdpSender extends ThriftSender {
public static final String DEFAULT_AGENT_UDP_HOST = "localhost";
public static final int DEFAULT_AGENT_UDP_COMPACT_PORT = 6831;

private Agent.Client agentClient;
private ThriftUdpTransport udpTransport;
@ToString.Exclude private Agent.Client agentClient;
@ToString.Exclude private ThriftUdpTransport udpTransport;

/**
* This constructor expects Jaeger running running on {@value #DEFAULT_AGENT_UDP_HOST}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,11 +57,16 @@
* <p>
* See https://github.com/openzipkin/zipkin/tree/master/zipkin-server
*/
@ToString(exclude = {"spanBuffer", "encoder"})
@ToString
public final class ZipkinSender implements Sender {
static final Set<String> CORE_ANNOTATIONS = new LinkedHashSet<String>(
Arrays.asList(CLIENT_SEND, CLIENT_RECV, SERVER_SEND, SERVER_RECV));

final zipkin2.reporter.Sender delegate;

@ToString.Exclude final ThriftSpanEncoder encoder = new ThriftSpanEncoder();
@ToString.Exclude final List<byte[]> spanBuffer;

/**
* @param endpoint The POST URL for zipkin's <a href="http://zipkin.io/zipkin-api/#/">v1 api</a>,
* usually "http://zipkinhost:9411/api/v1/spans"
Expand Down Expand Up @@ -98,10 +103,6 @@ public static ZipkinSender create(zipkin2.reporter.Sender delegate) {
return new ZipkinSender(delegate);
}

final ThriftSpanEncoder encoder = new ThriftSpanEncoder();
final zipkin2.reporter.Sender delegate;
final List<byte[]> spanBuffer;

ZipkinSender(zipkin2.reporter.Sender delegate) {
this.delegate = delegate;
this.spanBuffer = new ArrayList<byte[]>();
Expand Down

0 comments on commit 5eb42c9

Please sign in to comment.