/** * Interface method implementation. * @see com.github.kristofa.brave.SpanCollector#addDefaultAnnotation(java.lang.String, java.lang.String) */ public void addDefaultAnnotation(String key, String value) { try { final ByteBuffer bb = ByteBuffer.wrap(value.getBytes(UTF_8)); final BinaryAnnotation binaryAnnotation = new BinaryAnnotation(); binaryAnnotation.setKey(key); binaryAnnotation.setValue(bb); binaryAnnotation.setAnnotation_type(AnnotationType.STRING); this.defaultAnnotations.add(binaryAnnotation); } catch (final UnsupportedEncodingException e) { throw new IllegalStateException(e); } }
/** * {@inheritDoc} */ @Override public void addDefaultAnnotation(final String key, final String value) { defaultAnnotations.add(BinaryAnnotation.create(key, value, null)); }
public Object getFieldValue(_Fields field) { switch (field) { case KEY: return getKey(); case VALUE: return getValue(); case ANNOTATION_TYPE: return getAnnotation_type(); case HOST: return getHost(); } throw new IllegalStateException(); }
case KEY: if (value == null) { unsetKey(); } else { setKey((String)value); unsetValue(); } else { setValue((ByteBuffer)value); unsetAnnotation_type(); } else { setAnnotation_type((AnnotationType)value); unsetHost(); } else { setHost((Endpoint)value);
_elem5 = new BinaryAnnotation(); _elem5.read(iprot); struct.binary_annotations.add(_elem5);
public BinaryAnnotation deepCopy() { return new BinaryAnnotation(this); }
public BinaryAnnotation setValue(byte[] value) { setValue(value == null ? (ByteBuffer)null : ByteBuffer.wrap(value)); return this; }
private static BinaryAnnotation convert(com.twitter.zipkin.gen.BinaryAnnotation annotation) { return new BinaryAnnotation.Builder() .key(annotation.key) .value(annotation.getValue()) .type(convert(annotation.annotation_type)) .endpoint(convert(annotation.host)) .build(); }
@Override public boolean equals(Object that) { if (that == null) return false; if (that instanceof BinaryAnnotation) return this.equals((BinaryAnnotation)that); return false; }
@Override void address(Span span, String key, Endpoint endpoint) { BinaryAnnotation address = BinaryAnnotation.address(key, endpoint); synchronized (span) { span.addToBinary_annotations(address); } }
case KEY: if (value == null) { unsetKey(); } else { setKey((String)value); unsetValue(); } else { setValue((ByteBuffer)value); unsetAnnotation_type(); } else { setAnnotation_type((AnnotationType)value); unsetHost(); } else { setHost((Endpoint)value);
_elem15 = new BinaryAnnotation(); _elem15.read(iprot); struct.binary_annotations.add(_elem15);
public BinaryAnnotation deepCopy() { return new BinaryAnnotation(this); }
public BinaryAnnotation setValue(byte[] value) { setValue(value == null ? (ByteBuffer)null : ByteBuffer.wrap(value)); return this; }
@Override public boolean equals(Object that) { if (that == null) return false; if (that instanceof BinaryAnnotation) return this.equals((BinaryAnnotation)that); return false; }
/** * Internal api for submitting an address. Until a naming function is added, this coerces null * {@code serviceName} to "unknown", as that's zipkin's convention. * * @param ipv4 ipv4 host address as int. Ex for the ip 1.2.3.4, it would be (1 << 24) | (2 << 16) | (3 << 8) | 4 * @param port Port for service * @param serviceName Name of service. Should be lowercase and not empty. {@code null} will coerce to "unknown", as that's zipkin's convention. */ void submitAddress(String key, int ipv4, int port, @Nullable String serviceName) { Span span = spanAndEndpoint().span(); if (span != null) { serviceName = serviceName != null ? serviceName : "unknown"; Endpoint endpoint = Endpoint.create(serviceName, ipv4, port); BinaryAnnotation ba = BinaryAnnotation.address(key, endpoint); addBinaryAnnotation(span, ba); } }
/** * Submits a binary annotation with custom type. * * @param span Span. * @param endPoint Endpoint, optional, can be <code>null</code>. * @param key Key, should not be empty. * @param value Should not be null. * @param annotationType Indicates the type of the value. */ private void submitBinaryAnnotation(final Span span, final Endpoint endPoint, final String key, final ByteBuffer value, final AnnotationType annotationType) { Validate.notBlank(key); Validate.notNull(value); final BinaryAnnotation binaryAnnotation = new BinaryAnnotation(); binaryAnnotation.setKey(key); binaryAnnotation.setValue(value); binaryAnnotation.setAnnotation_type(annotationType); binaryAnnotation.setHost(endPoint); addBinaryAnnotation(span, binaryAnnotation); }
case KEY: if (value == null) { unsetKey(); } else { setKey((String)value); unsetValue(); } else { setValue((ByteBuffer)value); unsetAnnotation_type(); } else { setAnnotation_type((AnnotationType)value); unsetHost(); } else { setHost((Endpoint)value);
@Override public void addDefaultAnnotation(String key, String value) { annotations.add(BinaryAnnotation.create(key, value, null)); } }
_elem15 = new BinaryAnnotation(); _elem15.read(iprot); struct.binary_annotations.add(_elem15);