Skip to content

Commit

Permalink
Deprecates constants duplicated from Zipkin (#198)
Browse files Browse the repository at this point in the history
Also deprecates unused `BraveAnnotations` class.
  • Loading branch information
adriancole committed Jul 13, 2016
1 parent 6f3ab5c commit 9f9623f
Show file tree
Hide file tree
Showing 23 changed files with 53 additions and 49 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
import com.github.kristofa.brave.ClientResponseInterceptor;
import com.github.kristofa.brave.ClientTracer;
import com.github.kristofa.brave.SpanId;
import com.github.kristofa.brave.TraceKeys;
import com.github.kristofa.brave.http.BraveHttpHeaders;
import com.github.kristofa.brave.http.DefaultSpanNameProvider;
import com.github.kristofa.test.http.DefaultHttpResponseProvider;
Expand All @@ -22,6 +21,7 @@
import org.junit.Before;
import org.junit.Test;
import org.mockito.InOrder;
import zipkin.TraceKeys;

import java.io.IOException;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
package com.github.kristofa.brave;

import com.twitter.zipkin.gen.zipkinCoreConstants;

/**
* Annotations that add to the {@link zipkinCoreConstants}.
* Annotations that add to the {@link zipkin.Constants}.
*
* @author kristof
* @deprecated unused; will be removed in Brave 2.0
*/
@Deprecated
public class BraveAnnotations {

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ public interface ClientRequestAdapter {
* Provides the remote server address information for additional tracking.
*
* Can be useful when communicating with non-traced services by adding server address to span
* i.e. {@link com.twitter.zipkin.gen.zipkinCoreConstants#SERVER_ADDR}
* i.e. {@link zipkin.Constants#SERVER_ADDR}
*
* @return request's target server endpoint information
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import com.github.kristofa.brave.internal.Nullable;
import com.twitter.zipkin.gen.Endpoint;
import com.twitter.zipkin.gen.Span;
import com.twitter.zipkin.gen.zipkinCoreConstants;
import zipkin.Constants;

import java.util.Random;

Expand Down Expand Up @@ -63,7 +63,7 @@ public Builder state(ServerClientAndLocalSpanState state) {
* Sets 'client sent' event for current thread.
*/
public void setClientSent() {
submitStartAnnotation(zipkinCoreConstants.CLIENT_SEND);
submitStartAnnotation(Constants.CLIENT_SEND);
}

/**
Expand All @@ -75,16 +75,16 @@ public void setClientSent() {
* or null if unknown
*/
public void setClientSent(int ipv4, int port, @Nullable String serviceName) {
submitAddress(zipkinCoreConstants.SERVER_ADDR, ipv4, port, serviceName);
submitStartAnnotation(zipkinCoreConstants.CLIENT_SEND);
submitAddress(Constants.SERVER_ADDR, ipv4, port, serviceName);
submitStartAnnotation(Constants.CLIENT_SEND);
}

/**
* Sets the 'client received' event for current thread. This will also submit span because setting a client received
* event means this span is finished.
*/
public void setClientReceived() {
if (submitEndAnnotation(zipkinCoreConstants.CLIENT_RECV, spanCollector())) {
if (submitEndAnnotation(Constants.CLIENT_RECV, spanCollector())) {
spanAndEndpoint().state().setCurrentClientSpan(null);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@
import com.google.auto.value.AutoValue;
import com.twitter.zipkin.gen.BinaryAnnotation;
import com.twitter.zipkin.gen.Span;
import com.twitter.zipkin.gen.zipkinCoreConstants;
import zipkin.Constants;

import java.util.Random;

import static com.twitter.zipkin.gen.zipkinCoreConstants.LOCAL_COMPONENT;
import static zipkin.Constants.LOCAL_COMPONENT;

/**
* Local tracer is designed for in-process activity that explains latency.
Expand All @@ -30,7 +30,7 @@
* }
* </pre>
*
* @see zipkinCoreConstants#LOCAL_COMPONENT
* @see Constants#LOCAL_COMPONENT
*/
@AutoValue
public abstract class LocalTracer extends AnnotationSubmitter {
Expand Down Expand Up @@ -70,10 +70,10 @@ abstract static class Builder {
/**
* Request a new local span, which starts now.
*
* @param component {@link zipkinCoreConstants#LOCAL_COMPONENT component} responsible for the operation
* @param component {@link Constants#LOCAL_COMPONENT component} responsible for the operation
* @param operation name of the operation that's begun
* @return metadata about the new span or null if one wasn't started due to sampling policy.
* @see zipkinCoreConstants#LOCAL_COMPONENT
* @see Constants#LOCAL_COMPONENT
*/
public SpanId startNewSpan(String component, String operation) {
SpanId spanId = startNewSpan(component, operation, currentTimeMicroseconds());
Expand All @@ -93,11 +93,11 @@ private SpanId getNewSpanId() {
/**
* Request a new local span, which started at the given timestamp.
*
* @param component {@link zipkinCoreConstants#LOCAL_COMPONENT component} responsible for the operation
* @param component {@link Constants#LOCAL_COMPONENT component} responsible for the operation
* @param operation name of the operation that's begun
* @param timestamp time the operation started, in epoch microseconds.
* @return metadata about the new span or null if one wasn't started due to sampling policy.
* @see zipkinCoreConstants#LOCAL_COMPONENT
* @see Constants#LOCAL_COMPONENT
*/
public SpanId startNewSpan(String component, String operation, long timestamp) {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import com.github.kristofa.brave.SpanAndEndpoint.ServerSpanAndEndpoint;
import com.github.kristofa.brave.internal.Nullable;
import com.twitter.zipkin.gen.Endpoint;
import com.twitter.zipkin.gen.zipkinCoreConstants;
import zipkin.Constants;

import java.util.Random;

Expand Down Expand Up @@ -118,7 +118,7 @@ public void setStateUnknown(String spanName) {
* {@link ServerTracer#setStateUnknown(String)}.
*/
public void setServerReceived() {
submitStartAnnotation(zipkinCoreConstants.SERVER_RECV);
submitStartAnnotation(Constants.SERVER_RECV);
}

/**
Expand All @@ -131,15 +131,15 @@ public void setServerReceived() {
* null if unknown
*/
public void setServerReceived(int ipv4, int port, @Nullable String clientService) {
submitAddress(zipkinCoreConstants.CLIENT_ADDR, ipv4, port, clientService);
submitStartAnnotation(zipkinCoreConstants.SERVER_RECV);
submitAddress(Constants.CLIENT_ADDR, ipv4, port, clientService);
submitStartAnnotation(Constants.SERVER_RECV);
}

/**
* Sets the server sent event for current thread.
*/
public void setServerSend() {
if (submitEndAnnotation(zipkinCoreConstants.SERVER_SEND, spanCollector())) {
if (submitEndAnnotation(Constants.SERVER_SEND, spanCollector())) {
spanAndEndpoint().state().setCurrentServerSpan(null);
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
package com.github.kristofa.brave;

/**
* Used for Consistent keys without taking in zipkin-dependency.
* Taken from: https://github.com/openzipkin/zipkin-java/blob/master/zipkin/src/main/java/zipkin/TraceKeys.java
* @deprecated use {@link zipkin.TraceKeys}; will be removed in Brave 2.0
*/
@Deprecated
public final class TraceKeys {

public static final String HTTP_HOST = "http.host";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,10 @@ public class BinaryAnnotation implements Serializable {
static final long serialVersionUID = 1L;

/**
* Special-cased form supporting {@link zipkinCoreConstants#CLIENT_ADDR} and {@link
* zipkinCoreConstants#SERVER_ADDR}.
* Special-cased form supporting {@link zipkin.Constants#CLIENT_ADDR} and {@link
* zipkin.Constants#SERVER_ADDR}.
*
* @param key {@link zipkinCoreConstants#CLIENT_ADDR} or {@link zipkinCoreConstants#SERVER_ADDR}
* @param key {@link zipkin.Constants#CLIENT_ADDR} or {@link zipkin.Constants#SERVER_ADDR}
* @param endpoint associated endpoint.
*/
public static BinaryAnnotation address(String key, Endpoint endpoint) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
package com.twitter.zipkin.gen;

/**
* @deprecated use {@link zipkin.Constants}; will be removed in Brave 2.0
*/
@Deprecated
public class zipkinCoreConstants {

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ public class ClientRequestInterceptorTest {
private static final String SERVICE_NAME = "orderService";
private static final int TARGET_IP = 192 << 24 | 168 << 16 | 1;
private static final int TARGET_PORT = 80;
private static final KeyValueAnnotation ANNOTATION1 = KeyValueAnnotation.create(TraceKeys.HTTP_URL, "/orders/user/4543");
private static final KeyValueAnnotation ANNOTATION1 = KeyValueAnnotation.create(zipkin.TraceKeys.HTTP_URL, "/orders/user/4543");
private static final KeyValueAnnotation ANNOTATION2 = KeyValueAnnotation.create("http.code", "200");
private ClientRequestInterceptor interceptor;
private ClientTracer clientTracer;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,14 @@
import com.twitter.zipkin.gen.BinaryAnnotation;
import com.twitter.zipkin.gen.Endpoint;
import com.twitter.zipkin.gen.Span;
import com.twitter.zipkin.gen.zipkinCoreConstants;
import java.util.Random;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.powermock.api.mockito.PowerMockito;
import org.powermock.core.classloader.annotations.PrepareForTest;
import org.powermock.modules.junit4.PowerMockRunner;
import zipkin.Constants;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
Expand Down Expand Up @@ -71,7 +71,7 @@ public void testSetClientSent() {

final Annotation expectedAnnotation = Annotation.create(
CURRENT_TIME_MICROSECONDS,
zipkinCoreConstants.CLIENT_SEND,
Constants.CLIENT_SEND,
state.endpoint()
);
verifyNoMoreInteractions(mockCollector, mockSampler);
Expand All @@ -89,7 +89,7 @@ public void testSetClientSentServerAddress() {

final Annotation expectedAnnotation = Annotation.create(
CURRENT_TIME_MICROSECONDS,
zipkinCoreConstants.CLIENT_SEND,
Constants.CLIENT_SEND,
state.endpoint()
);
verifyNoMoreInteractions(mockCollector, mockSampler);
Expand All @@ -98,7 +98,7 @@ public void testSetClientSentServerAddress() {
assertEquals(expectedAnnotation, clientSent.getAnnotations().get(0));

BinaryAnnotation serverAddress = BinaryAnnotation.address(
zipkinCoreConstants.SERVER_ADDR,
Constants.SERVER_ADDR,
Endpoint.create("foobar", 1 << 24 | 2 << 16 | 3 << 8 | 4, 9999)
);
assertEquals(serverAddress, clientSent.getBinary_annotations().get(0));
Expand Down Expand Up @@ -132,7 +132,7 @@ public void testSetClientReceived() {

final Annotation expectedAnnotation = Annotation.create(
CURRENT_TIME_MICROSECONDS,
zipkinCoreConstants.CLIENT_RECV,
Constants.CLIENT_RECV,
state.endpoint()
);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ public class ServerRequestInterceptorTest {
private final static long TRACE_ID = 3425;
private final static long SPAN_ID = 43435;
private final static long PARENT_SPAN_ID = 44334435;
private static final KeyValueAnnotation ANNOTATION1 = KeyValueAnnotation.create(TraceKeys.HTTP_URL, "/orders/user/4543");
private static final KeyValueAnnotation ANNOTATION1 = KeyValueAnnotation.create(zipkin.TraceKeys.HTTP_URL, "/orders/user/4543");
private static final KeyValueAnnotation ANNOTATION2 = KeyValueAnnotation.create("http.code", "200");

private ServerRequestInterceptor interceptor;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
import com.twitter.zipkin.gen.BinaryAnnotation;
import com.twitter.zipkin.gen.Endpoint;
import com.twitter.zipkin.gen.Span;
import com.twitter.zipkin.gen.zipkinCoreConstants;
import java.util.Random;
import org.junit.Before;
import org.junit.Test;
Expand All @@ -13,6 +12,7 @@
import org.powermock.api.mockito.PowerMockito;
import org.powermock.core.classloader.annotations.PrepareForTest;
import org.powermock.modules.junit4.PowerMockRunner;
import zipkin.Constants;

import static org.junit.Assert.assertEquals;
import static org.mockito.Mockito.inOrder;
Expand Down Expand Up @@ -141,7 +141,7 @@ public void testSetServerReceived() {

final Annotation expectedAnnotation = Annotation.create(
CURRENT_TIME_MICROSECONDS,
zipkinCoreConstants.SERVER_RECV,
Constants.SERVER_RECV,
mockEndpoint
);

Expand All @@ -165,7 +165,7 @@ public void testSetServerReceivedSentClientAddress() {

final Annotation expectedAnnotation = Annotation.create(
CURRENT_TIME_MICROSECONDS,
zipkinCoreConstants.SERVER_RECV,
Constants.SERVER_RECV,
mockEndpoint
);

Expand All @@ -178,7 +178,7 @@ public void testSetServerReceivedSentClientAddress() {
assertEquals(expectedAnnotation, serverRecv.getAnnotations().get(0));

BinaryAnnotation serverAddress = BinaryAnnotation.address(
zipkinCoreConstants.CLIENT_ADDR,
Constants.CLIENT_ADDR,
Endpoint.create("foobar", 1 << 24 | 2 << 16 | 3 << 8 | 4, 9999)
);
assertEquals(serverAddress, serverRecv.getBinary_annotations().get(0));
Expand Down Expand Up @@ -215,7 +215,7 @@ public void testSetServerSend() {

final Annotation expectedAnnotation = Annotation.create(
CURRENT_TIME_MICROSECONDS,
zipkinCoreConstants.SERVER_SEND,
Constants.SERVER_SEND,
mockEndpoint
);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@
import com.github.kristofa.brave.IdConversion;
import com.github.kristofa.brave.KeyValueAnnotation;
import com.github.kristofa.brave.SpanId;
import com.github.kristofa.brave.TraceKeys;
import com.github.kristofa.brave.internal.Nullable;
import com.twitter.zipkin.gen.Endpoint;
import zipkin.TraceKeys;

import java.net.URI;
import java.util.Arrays;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import com.github.kristofa.brave.ClientResponseAdapter;
import com.github.kristofa.brave.KeyValueAnnotation;
import com.github.kristofa.brave.TraceKeys;
import zipkin.TraceKeys;

import java.util.Arrays;
import java.util.Collection;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@
import com.github.kristofa.brave.ServerRequestAdapter;
import com.github.kristofa.brave.SpanId;
import com.github.kristofa.brave.TraceData;
import com.github.kristofa.brave.TraceKeys;
import java.util.Collection;
import java.util.Collections;
import zipkin.TraceKeys;

import static com.github.kristofa.brave.IdConversion.convertToLong;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import com.github.kristofa.brave.KeyValueAnnotation;
import com.github.kristofa.brave.ServerResponseAdapter;
import com.github.kristofa.brave.TraceKeys;
import zipkin.TraceKeys;

import java.util.Arrays;
import java.util.Collection;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@

import com.github.kristofa.brave.KeyValueAnnotation;
import com.github.kristofa.brave.SpanId;
import com.github.kristofa.brave.TraceKeys;
import org.junit.Before;
import org.junit.Test;
import zipkin.TraceKeys;

import java.net.URI;
import java.util.Collection;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@


import com.github.kristofa.brave.KeyValueAnnotation;
import com.github.kristofa.brave.TraceKeys;
import org.junit.Before;
import org.junit.Test;
import zipkin.TraceKeys;

import java.util.Collection;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@
import com.github.kristofa.brave.KeyValueAnnotation;
import com.github.kristofa.brave.SpanId;
import com.github.kristofa.brave.TraceData;
import com.github.kristofa.brave.TraceKeys;
import org.junit.Before;
import org.junit.Test;
import zipkin.TraceKeys;

import static junit.framework.Assert.assertNull;
import static org.junit.Assert.*;
Expand Down
Loading

0 comments on commit 9f9623f

Please sign in to comment.