OpenCensusSpan implements Span { @Override public Span value(final byte[] value) { if (value != null) { if (includeValues) { span.putAttribute("value_hex", stringAttributeValue(HEX.encode(value))); } span.putAttribute("value_size_bytes", longAttributeValue(value.length)); } return this; } OpenCensusSpan(final io.opencensus.trace.Span span, final boolean includeValues); @Override Span value(final byte[] value); @Override Span success(); @Override Span failure(); @Override void close();  }
@Test public void includedValue() { final Span span = new OpenCensusSpan(wrapped, true); span.value(VALUE); verify(wrapped).putAttribute("value_size_bytes", longAttributeValue(VALUE.length)); verify(wrapped).putAttribute("value_hex", stringAttributeValue(HEX.encode(VALUE))); }
@Test public void nonIncludedValue() { final Span span = new OpenCensusSpan(wrapped, false); span.value(VALUE); verify(wrapped).putAttribute("value_size_bytes", longAttributeValue(VALUE.length)); verify(wrapped, never()).putAttribute("value_hex", stringAttributeValue(HEX.encode(VALUE))); }
@Test public void nullValue() { final Span span = new OpenCensusSpan(wrapped, true); span.value(null); verifyZeroInteractions(wrapped); }