Tabnine Logo
JsonCodec
Code IndexAdd Tabnine to your IDE (free)

How to use
JsonCodec
in
zipkin.internal

Best Java code snippets using zipkin.internal.JsonCodec (Showing top 11 results out of 315)

origin: Nike-Inc/wingtips

protected void sendSpans(List<zipkin.Span> spanList) {
  try {
    sendSpans(Codec.JSON.writeSpans(spanList));
  } catch (IOException e) {
    Set<String> affectedTraceIds = new HashSet<>(spanList.size());
    for (zipkin.Span span : spanList) {
      affectedTraceIds.add(String.valueOf(span.traceId));
    }
    logger.error("An error occurred attempting to post Zipkin spans to the Zipkin server. affected_trace_ids={}, exception_cause=\"{}\"",
           affectedTraceIds.toString(), e.toString());
  }
}
origin: io.zipkin.reporter/zipkin-reporter

 @Override public byte[] encode(Span span) {
  return Codec.JSON.writeSpan(span);
 }
};
origin: io.zipkin.java/zipkin-storage-elasticsearch

 @Override public List<DependencyLink> apply(SearchResponse response) {
  if (response.getHits() == null) return ImmutableList.of();
  ImmutableList.Builder<DependencyLink> unmerged = ImmutableList.builder();
  for (SearchHit hit : response.getHits()) {
   DependencyLink link = Codec.JSON.readDependencyLink(hit.getSourceRef().toBytes());
   unmerged.add(link);
  }
  return unmerged.build();
 }
}
origin: Nike-Inc/wingtips

    sentSpans.add(zipkinSpan(random.nextLong(), UUID.randomUUID().toString()));
  long expectedUncompressedPayloadSize = Codec.JSON.writeSpans(sentSpans).length;
  byte[] deserializableBytes = (compressPayload) ? unGzip(receivedPayloadBytes) : receivedPayloadBytes;
  List<zipkin.Span> receivedSpans = Codec.JSON.readSpans(deserializableBytes);
  assertThat(receivedSpans).isEqualTo(sentSpans);
} finally {
origin: io.zipkin.sparkstreaming/zipkin-sparkstreaming

 @Override public Iterable<Span> call(byte[] bytes) throws Exception {
  logInitializer().run();
  if (bytes.length == 0) return Collections.emptyList();
  try {
   if (bytes[0] == '[') {
    return Codec.JSON.readSpans(bytes);
   } else {
    if (bytes[0] == 12 /* TType.STRUCT */) {
     return Codec.THRIFT.readSpans(bytes);
    } else { // historical kafka encoding of single thrift span per message
     return Collections.singletonList(Codec.THRIFT.readSpan(bytes));
    }
   }
  } catch (RuntimeException e) {
   log.warn("unable to decode spans", e);
   return Collections.emptyList();
  }
 }
}
origin: io.zipkin.java/zipkin-storage-elasticsearch

 @Override
 public List<Span> apply(SearchResponse response) {
  if (response.getHits().totalHits() == 0) {
   return null;
  }
  ImmutableList.Builder<Span> trace = ImmutableList.builder();
  for (SearchHit hit : response.getHits()) {
   trace.add(Codec.JSON.readSpan(hit.getSourceRef().toBytes()));
  }
  return trace.build();
 }
});
origin: io.zipkin.java/zipkin-transport-kafka

 /**
  * Conditionally decodes depending on whether the input bytes are encoded as a single span or a
  * list.
  */
 static List<Span> fromBytes(byte[] bytes) {
  // In TBinaryProtocol encoding, the first byte is the TType, in a range 0-16
  // .. If the first byte isn't in that range, it isn't a thrift.
  //
  // When byte(0) == '[' (91), assume it is a list of json-encoded spans
  //
  // When byte(0) <= 16, assume it is a TBinaryProtocol-encoded thrift
  // .. When serializing a Span (Struct), the first byte will be the type of a field
  // .. When serializing a List[ThriftSpan], the first byte is the member type, TType.STRUCT(12)
  // .. As ThriftSpan has no STRUCT fields: so, if the first byte is TType.STRUCT(12), it is a list.
  if (bytes[0] == '[') {
   return Codec.JSON.readSpans(bytes);
  } else if (bytes[0] == 12 /* TType.STRUCT */) {
   return Codec.THRIFT.readSpans(bytes);
  } else {
   return Collections.singletonList(Codec.THRIFT.readSpan(bytes));
  }
 }
}
origin: io.zipkin.java/transport-kafka

 /**
  * Conditionally decodes depending on whether the input bytes are encoded as a single span or a
  * list.
  */
 static List<Span> fromBytes(byte[] bytes) {
  // In TBinaryProtocol encoding, the first byte is the TType, in a range 0-16
  // .. If the first byte isn't in that range, it isn't a thrift.
  //
  // When byte(0) == '[' (91), assume it is a list of json-encoded spans
  //
  // When byte(0) <= 16, assume it is a TBinaryProtocol-encoded thrift
  // .. When serializing a Span (Struct), the first byte will be the type of a field
  // .. When serializing a List[ThriftSpan], the first byte is the member type, TType.STRUCT(12)
  // .. As ThriftSpan has no STRUCT fields: so, if the first byte is TType.STRUCT(12), it is a list.
  if (bytes[0] == '[') {
   return Codec.JSON.readSpans(bytes);
  } else if (bytes[0] == 12 /* TType.STRUCT */) {
   return Codec.THRIFT.readSpans(bytes);
  } else {
   return Collections.singletonList(Codec.THRIFT.readSpan(bytes));
  }
 }
}
origin: com.nike.wingtips/wingtips-zipkin

protected void sendSpans(List<zipkin.Span> spanList) {
  try {
    sendSpans(Codec.JSON.writeSpans(spanList));
  } catch (IOException e) {
    Set<String> affectedTraceIds = new HashSet<>(spanList.size());
    for (zipkin.Span span : spanList) {
      affectedTraceIds.add(String.valueOf(span.traceId));
    }
    logger.error("An error occurred attempting to post Zipkin spans to the Zipkin server. affected_trace_ids={}, exception_cause=\"{}\"",
           affectedTraceIds.toString(), e.toString());
  }
}
origin: io.zipkin.java/zipkin-storage-elasticsearch

public static byte[] toSpanBytes(Span span, Long timestampMillis) {
 return timestampMillis != null
   ? prefixWithTimestampMillis(Codec.JSON.writeSpan(span), timestampMillis)
   : Codec.JSON.writeSpan(span);
}
origin: Nike-Inc/wingtips

@Test
public void sendSpans_with_span_list_delegates_to_sendSpans_with_byte_array() throws IOException {
  // given
  List<zipkin.Span> zipkinSpans = new ArrayList<>();
  for (int i = 0; i < 10; i++) {
    zipkinSpans.add(zipkinSpan(random.nextLong(), UUID.randomUUID().toString()));
  }
  byte[] expectedBytesPayload = Codec.JSON.writeSpans(zipkinSpans);
  // when
  implSpy.sendSpans(zipkinSpans);
  // then
  verify(implSpy).sendSpans(expectedBytesPayload);
}
zipkin.internalJsonCodec

Most used methods

  • readSpans
  • writeSpans
  • writeSpan
  • readDependencyLink
  • readSpan

Popular in Java

  • Creating JSON documents from java classes using gson
  • onCreateOptionsMenu (Activity)
  • scheduleAtFixedRate (ScheduledExecutorService)
  • scheduleAtFixedRate (Timer)
  • GridLayout (java.awt)
    The GridLayout class is a layout manager that lays out a container's components in a rectangular gri
  • System (java.lang)
    Provides access to system-related information and resources including standard input and output. Ena
  • BitSet (java.util)
    The BitSet class implements abit array [http://en.wikipedia.org/wiki/Bit_array]. Each element is eit
  • SortedMap (java.util)
    A map that has its keys ordered. The sorting is according to either the natural ordering of its keys
  • Notification (javax.management)
  • JComboBox (javax.swing)
  • Top plugins for WebStorm
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now