The Span Count job
Let's look at how the SpanCountJob
is implemented. The Jaeger collector writes spans to Kafka in Protobuf format, so we need a way to parse them. The package io.jaegertracing.api_v2
is auto-generated by the Protobuf compiler from the IDL file found in the Jaeger codebase (model/proto/model.proto
in Jaeger v1.8). Protobuf-generated classes are not particularly convenient to work with in Flink, so in the model
package we define a simplified model of the trace that only contains the span data that we need for the purpose of the span count calculations:
public class Span implements Serializable { public String traceId; public String spanId; public String serviceName; public String operationName; public long startTimeMicros; public Map<String, String> tags; }
The class model.ProtoUnmarshaler
is used to convert the spans from the Protobuf model to the simplified Span
type. These spans
are then aggregated into a Trace
type:
public class Trace { ...