Removing SpanSerializer interface
This commit is contained in:
parent
3b8517e7ca
commit
8409dada46
|
@ -1,37 +0,0 @@
|
|||
package com.datadoghq.trace;
|
||||
|
||||
import io.opentracing.Span;
|
||||
|
||||
/**
|
||||
* Main interface to serialize/deserialize spans or collection of spans.
|
||||
*/
|
||||
public interface SpanSerializer {
|
||||
|
||||
/**
|
||||
* Serialize a single span
|
||||
*
|
||||
* @param the span to serialize
|
||||
* @return the serialized object
|
||||
* @throws Exception
|
||||
*/
|
||||
String serialize(Span span) throws Exception;
|
||||
|
||||
/**
|
||||
* A collection of Span to serialize
|
||||
*
|
||||
* @param spans List or List of list of Spans
|
||||
* @return the serialized objects
|
||||
* @throws Exception
|
||||
*/
|
||||
String serialize(Object spans) throws Exception;
|
||||
|
||||
/**
|
||||
* Deserialize a string to convert it in a Span or a Trace
|
||||
*
|
||||
* @param str the string to deserialize
|
||||
* @return A Span or a Trace (List<Span>)
|
||||
* @throws Exception
|
||||
*/
|
||||
Object deserialize(String str) throws Exception;
|
||||
|
||||
}
|
|
@ -1,38 +1,36 @@
|
|||
package com.datadoghq.trace.impl;
|
||||
|
||||
import com.datadoghq.trace.writer.impl.DDAgentWriter;
|
||||
import com.fasterxml.jackson.core.JsonProcessingException;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import io.opentracing.Span;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import com.datadoghq.trace.SpanSerializer;
|
||||
import com.datadoghq.trace.writer.impl.DDAgentWriter;
|
||||
import com.fasterxml.jackson.core.JsonProcessingException;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
|
||||
import io.opentracing.Span;
|
||||
|
||||
/**
|
||||
* Main DDSpanSerializer: convert spans and traces to proper JSON
|
||||
*/
|
||||
public class DDSpanSerializer implements SpanSerializer {
|
||||
public class DDSpanSerializer {
|
||||
|
||||
protected final ObjectMapper objectMapper = new ObjectMapper();
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see com.datadoghq.trace.SpanSerializer#serialize(io.opentracing.Span)
|
||||
* @see com.datadoghq.trace.DDSpanSerializer#serialize(io.opentracing.Span)
|
||||
*/
|
||||
public String serialize(Span span) throws JsonProcessingException {
|
||||
return objectMapper.writeValueAsString(span);
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see com.datadoghq.trace.SpanSerializer#serialize(java.lang.Object)
|
||||
* @see com.datadoghq.trace.DDSpanSerializer#serialize(java.lang.Object)
|
||||
*/
|
||||
public String serialize(Object spans) throws JsonProcessingException {
|
||||
return objectMapper.writeValueAsString(spans);
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see com.datadoghq.trace.SpanSerializer#deserialize(java.lang.String)
|
||||
* @see com.datadoghq.trace.DDSpanSerializer#deserialize(java.lang.String)
|
||||
*/
|
||||
public io.opentracing.Span deserialize(String str) throws Exception {
|
||||
throw new UnsupportedOperationException("Deserialisation of spans is not implemented yet");
|
||||
|
|
|
@ -8,9 +8,7 @@ import java.util.List;
|
|||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import com.datadoghq.trace.SpanSerializer;
|
||||
import com.datadoghq.trace.impl.DDSpanSerializer;
|
||||
import com.datadoghq.trace.impl.DDTracer;
|
||||
|
||||
import io.opentracing.Span;
|
||||
|
||||
|
@ -32,13 +30,13 @@ public class DDApi {
|
|||
/**
|
||||
* The spans serializer: can be replaced. By default, it serialize in JSON.
|
||||
*/
|
||||
protected final SpanSerializer spanSerializer;
|
||||
protected final DDSpanSerializer spanSerializer;
|
||||
|
||||
public DDApi(String host, int port) {
|
||||
this(host, port, new DDSpanSerializer());
|
||||
}
|
||||
|
||||
public DDApi(String host, int port, SpanSerializer spanSerializer) {
|
||||
public DDApi(String host, int port, DDSpanSerializer spanSerializer) {
|
||||
super();
|
||||
this.host = host;
|
||||
this.port = port;
|
||||
|
|
|
@ -1,11 +1,9 @@
|
|||
package com.datadoghq.trace.impl;
|
||||
|
||||
import com.datadoghq.trace.SpanSerializer;
|
||||
import io.opentracing.Span;
|
||||
import org.junit.Test;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.mockito.Mockito.mock;
|
||||
|
||||
|
||||
public class DDSpanTest {
|
||||
|
|
Loading…
Reference in New Issue