@Test public void testAppendSpanTooLarge() { JaegerSpan jaegerSpan = tracer.buildSpan("raza").start(); String msg = ""; for (int i = 0; i < 1001; i++) { msg += "."; } jaegerSpan.log(msg); try { sender.append(jaegerSpan); fail("The line above shoud throw"); } catch (SenderException e) { assertEquals(e.getDroppedSpanCount(), 1); } }
@Override public int append(JaegerSpan span) throws SenderException { byte[] next = encoder.encode(backFillHostOnAnnotations(ThriftSpanConverter.convertSpan(span))); int messageSizeOfNextSpan = delegate.messageSizeInBytes(Collections.singletonList(next)); if (messageSizeOfNextSpan > delegate.messageMaxBytes()) { throw new SenderException( delegate.toString() + " received a span that was too large", null, 1); } spanBuffer.add(next); int nextSizeInBytes = delegate.messageSizeInBytes(spanBuffer); if (nextSizeInBytes <= delegate.messageMaxBytes()) { if (nextSizeInBytes < delegate.messageMaxBytes()) { return 0; } return flush(); } spanBuffer.remove(spanBuffer.size() - 1); int n; try { n = flush(); } catch (SenderException e) { throw new SenderException(e.getMessage(), e.getCause(), e.getDroppedSpanCount() + 1); } spanBuffer.add(next); return n; }
ZipkinSender implements Sender { @Override public int append(JaegerSpan span) throws SenderException { byte[] next = encoder.encode(backFillHostOnAnnotations(ThriftSpanConverter.convertSpan(span))); int messageSizeOfNextSpan = delegate.messageSizeInBytes(Collections.singletonList(next)); if (messageSizeOfNextSpan > delegate.messageMaxBytes()) { throw new SenderException( delegate.toString() + " received a span that was too large", null, 1); } spanBuffer.add(next); int nextSizeInBytes = delegate.messageSizeInBytes(spanBuffer); if (nextSizeInBytes <= delegate.messageMaxBytes()) { if (nextSizeInBytes < delegate.messageMaxBytes()) { return 0; } return flush(); } spanBuffer.remove(spanBuffer.size() - 1); int n; try { n = flush(); } catch (SenderException e) { throw new SenderException(e.getMessage(), e.getCause(), e.getDroppedSpanCount() + 1); } spanBuffer.add(next); return n; } }
ZipkinSender implements Sender { @Override public int append(JaegerSpan span) throws SenderException { byte[] next = encoder.encode(backFillHostOnAnnotations(ThriftSpanConverter.convertSpan(span))); int messageSizeOfNextSpan = delegate.messageSizeInBytes(Collections.singletonList(next)); if (messageSizeOfNextSpan > delegate.messageMaxBytes()) { throw new SenderException( delegate.toString() + " received a span that was too large", null, 1); } spanBuffer.add(next); int nextSizeInBytes = delegate.messageSizeInBytes(spanBuffer); if (nextSizeInBytes <= delegate.messageMaxBytes()) { if (nextSizeInBytes < delegate.messageMaxBytes()) { return 0; } return flush(); } spanBuffer.remove(spanBuffer.size() - 1); int n; try { n = flush(); } catch (SenderException e) { throw new SenderException(e.getMessage(), e.getCause(), e.getDroppedSpanCount() + 1); } spanBuffer.add(next); return n; } ZipkinSender(zipkin2.reporter.Sender delegate); }
ZipkinSender implements Sender { @Override public int append(JaegerSpan span) throws SenderException { byte[] next = encoder.encode(backFillHostOnAnnotations(ThriftSpanConverter.convertSpan(span))); int messageSizeOfNextSpan = delegate.messageSizeInBytes(Collections.singletonList(next)); if (messageSizeOfNextSpan > delegate.messageMaxBytes()) { throw new SenderException( delegate.toString() + " received a span that was too large", null, 1); } spanBuffer.add(next); int nextSizeInBytes = delegate.messageSizeInBytes(spanBuffer); if (nextSizeInBytes <= delegate.messageMaxBytes()) { if (nextSizeInBytes < delegate.messageMaxBytes()) { return 0; } return flush(); } spanBuffer.remove(spanBuffer.size() - 1); int n; try { n = flush(); } catch (SenderException e) { throw new SenderException(e.getMessage(), e.getCause(), e.getDroppedSpanCount() + 1); } spanBuffer.add(next); return n; } ZipkinSender(zipkin2.reporter.Sender delegate); static ZipkinSender create(String endpoint); static ZipkinSender create(zipkin2.reporter.Sender delegate); @Override int append(JaegerSpan span); @Override int flush(); @Override int close(); }
ZipkinSender implements Sender { @Override public int append(JaegerSpan span) throws SenderException { byte[] next = encoder.encode(backFillHostOnAnnotations(ThriftSpanConverter.convertSpan(span))); int messageSizeOfNextSpan = delegate.messageSizeInBytes(Collections.singletonList(next)); if (messageSizeOfNextSpan > delegate.messageMaxBytes()) { throw new SenderException( delegate.toString() + " received a span that was too large", null, 1); } spanBuffer.add(next); int nextSizeInBytes = delegate.messageSizeInBytes(spanBuffer); if (nextSizeInBytes <= delegate.messageMaxBytes()) { if (nextSizeInBytes < delegate.messageMaxBytes()) { return 0; } return flush(); } spanBuffer.remove(spanBuffer.size() - 1); int n; try { n = flush(); } catch (SenderException e) { throw new SenderException(e.getMessage(), e.getCause(), e.getDroppedSpanCount() + 1); } spanBuffer.add(next); return n; } ZipkinSender(zipkin2.reporter.Sender delegate); static ZipkinSender create(String endpoint); static ZipkinSender create(zipkin2.reporter.Sender delegate); @Override int append(JaegerSpan span); @Override int flush(); @Override int close();  }