census-instrumentation / opencensus-service

OpenCensus service allows OpenCensus libraries to export to an exporter service rather than having to link vendor-specific exports.
Apache License 2.0
153 stars 63 forks source link

Kafka Tracing Exporter: Deserialization in Consumer #629

Closed Alexander-Krause-Glau closed 4 years ago

Alexander-Krause-Glau commented 4 years ago

Hello,

I am trying to deserialize the obtained tracing data from my oc-collector/kafka-exporter in my Java Kafka consumer application. I've tried using Kafka's ByteArrayDeserializer to read sequences of bytes in a specific order and length (based on the details of the .proto file). Unfortunately, this did not work for me.

Alexander-Krause-Glau commented 4 years ago

We've found the outsourced Kafka exporter implementation by inspecting the source code of the Open Census Kafka exporter.

The Kafka Exporter sends DumpSpans, i.e., a list of spans. By generating the Java Code for the DumpSpan class, we were able to read the spans in our custom backend.

We used the ByteArrayDeserializer as Kafka key and value deserializer and were able to instantiate a DumpSpans instance via DumpSpans s = DumpSpans.parseFrom(record.value());, where record is a ConsumerRecord<byte[], byte[]>.