Skip to content

Commit

Permalink
fix zipkin provider can not receive full spans data (#1420)
Browse files Browse the repository at this point in the history
  • Loading branch information
jjtyro authored and wu-sheng committed Jul 4, 2018
1 parent 5941e72 commit 6a7e344
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
Expand Up @@ -31,6 +31,7 @@
import org.apache.skywalking.apm.collector.jetty.manager.JettyManagerModule;
import org.apache.skywalking.apm.collector.jetty.manager.service.JettyManagerService;
import org.apache.skywalking.apm.collector.receiver.zipkin.define.ZipkinReceiverModule;
import org.apache.skywalking.apm.collector.receiver.zipkin.provider.handler.SpanV1JettyHandler;
import org.apache.skywalking.apm.collector.receiver.zipkin.provider.handler.SpanV2JettyHandler;
import org.apache.skywalking.apm.collector.receiver.zipkin.provider.transform.Zipkin2SkyWalkingTransfer;
import org.apache.skywalking.apm.collector.server.jetty.JettyServer;
Expand Down Expand Up @@ -74,6 +75,7 @@ public ZipkinReceiverProvider() {

JettyManagerService managerService = getManager().find(JettyManagerModule.NAME).getService(JettyManagerService.class);
JettyServer jettyServer = managerService.createIfAbsent(config.getHost(), config.getPort(), config.getContextPath());
jettyServer.addHandler(new SpanV1JettyHandler(config, registerServices));
jettyServer.addHandler(new SpanV2JettyHandler(config, registerServices));

ISegmentParseService segmentParseService = getManager().find(AnalysisSegmentParserModule.NAME).getService(ISegmentParseService.class);
Expand Down
Expand Up @@ -21,6 +21,8 @@
import org.apache.skywalking.apm.collector.receiver.zipkin.provider.RegisterServices;
import org.apache.skywalking.apm.collector.receiver.zipkin.provider.ZipkinReceiverConfig;
import org.apache.skywalking.apm.collector.receiver.zipkin.provider.cache.CacheFactory;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import zipkin2.Span;
import zipkin2.codec.SpanBytesDecoder;

Expand All @@ -30,11 +32,23 @@
import java.util.List;

public class SpanProcessor {
private final Logger logger = LoggerFactory.getLogger(SpanProcessor.class);

void convert(ZipkinReceiverConfig config, SpanBytesDecoder decoder, HttpServletRequest request, RegisterServices registerServices) throws IOException {
int len = request.getContentLength();
ServletInputStream iii = request.getInputStream();
byte[] buffer = new byte[len];
iii.read(buffer, 0, len);

int readCntTotal = 0;
int readCntOnce;
while (readCntTotal < len) {
readCntOnce = iii.read(buffer, readCntTotal, len - readCntTotal);
if (readCntOnce <= 0) {
logger.error("Receive spans data failed.");
throw new IOException();
}
readCntTotal += readCntOnce;
}

List<Span> spanList = decoder.decodeList(buffer);

Expand Down

0 comments on commit 6a7e344

Please sign in to comment.