Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

otelcol/exporter/kafka: key jaeger messages on traceid #2855

Merged
merged 1 commit into from
Apr 8, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions exporter/kafkaexporter/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ The following settings can be optionally configured:
- `encoding` (default = otlp_proto): The encoding of the traces sent to kafka. All available encodings:
- `otlp_proto`: payload is Protobuf serialized from `ExportTraceServiceRequest` if set as a traces exporter or `ExportMetricsServiceRequest` for metrics.
- The following encodings are valid *only* for **traces**.
- `jaeger_proto`: the payload is serialized to a single Jaeger proto `Span`.
- `jaeger_json`: the payload is serialized to a single Jaeger JSON Span using `jsonpb`.
- `jaeger_proto`: the payload is serialized to a single Jaeger proto `Span`, and keyed by TraceID.
- `jaeger_json`: the payload is serialized to a single Jaeger JSON Span using `jsonpb`, and keyed by TraceID.
- `auth`
- `plain_text`
- `username`: The username to use.
Expand Down
3 changes: 2 additions & 1 deletion exporter/kafkaexporter/jaeger_marshaller.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,8 @@ func (j jaegerMarshaller) Marshal(traces pdata.Traces) ([]Message, error) {
errs = append(errs, err)
continue
}
messages = append(messages, Message{Value: bts})
key := []byte(span.TraceID.String())
messages = append(messages, Message{Value: bts, Key: key})
}
}
return messages, consumererror.CombineErrors(errs)
Expand Down
5 changes: 3 additions & 2 deletions exporter/kafkaexporter/jaeger_marshaller_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ func TestJaegerMarshaller(t *testing.T) {

batches[0].Spans[0].Process = batches[0].Process
jaegerProtoBytes, err := batches[0].Spans[0].Marshal()
messageKey := []byte(batches[0].Spans[0].TraceID.String())
require.NoError(t, err)
require.NotNil(t, jaegerProtoBytes)

Expand All @@ -58,7 +59,7 @@ func TestJaegerMarshaller(t *testing.T) {
marshaller: jaegerProtoSpanMarshaller{},
},
encoding: "jaeger_proto",
messages: []Message{{Value: jaegerProtoBytes}},
messages: []Message{{Value: jaegerProtoBytes, Key: messageKey}},
},
{
unmarshaller: jaegerMarshaller{
Expand All @@ -67,7 +68,7 @@ func TestJaegerMarshaller(t *testing.T) {
},
},
encoding: "jaeger_json",
messages: []Message{{Value: jsonByteBuffer.Bytes()}},
messages: []Message{{Value: jsonByteBuffer.Bytes(), Key: messageKey}},
},
}
for _, test := range tests {
Expand Down
1 change: 1 addition & 0 deletions exporter/kafkaexporter/kafka_exporter.go
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,7 @@ func producerMessages(messages []Message, topic string) []*sarama.ProducerMessag
producerMessages[i] = &sarama.ProducerMessage{
Topic: topic,
Value: sarama.ByteEncoder(messages[i].Value),
Key: sarama.ByteEncoder(messages[i].Key),
}
}
return producerMessages
Expand Down
1 change: 1 addition & 0 deletions exporter/kafkaexporter/marshaller.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ type MetricsMarshaller interface {
// Message encapsulates Kafka's message payload.
type Message struct {
Value []byte
Key []byte
}

// tracesMarshallers returns map of supported encodings with TracesMarshaller.
Expand Down