Skip to content

Commit

Permalink
Support otlp-proto encoding for kafka in OTel app
Browse files Browse the repository at this point in the history
Signed-off-by: Sam Xie <xsambundy@gmail.com>
  • Loading branch information
XSAM committed Oct 23, 2020
1 parent ec31e8a commit a99043c
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 0 deletions.
13 changes: 13 additions & 0 deletions cmd/opentelemetry/app/exporter/kafkaexporter/flags.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,25 @@ package kafkaexporter

import (
"flag"
"fmt"

"github.com/jaegertracing/jaeger/plugin/storage/kafka"
)

const (
// encodingOTLPProto is used for spans encoded as OTLP Protobuf.
encodingOTLPProto = "otlp-proto"
)

// AddFlags adds Ingester flags.
func AddFlags(flags *flag.FlagSet) {
opts := &kafka.Options{}
opts.AddOTELFlags(flags)
// Modify kafka.producer.encoding flag
flags.Lookup("kafka.producer.encoding").Usage = fmt.Sprintf(
`Encoding of spans ("%s", "%s" or "%s") sent to kafka.`,
kafka.EncodingJSON,
kafka.EncodingProto,
encodingOTLPProto,
)
}
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,8 @@ func mustOtelEncodingForJaegerEncoding(jaegerEncoding string) string {
return "jaeger_proto"
case kafka.EncodingJSON:
return "jaeger_json"
case encodingOTLPProto:
return "otlp_proto"
}

panic(jaegerEncoding + " is not a supported kafka encoding in the OTEL collector.")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,10 @@ func TestMustOtelEncodingForJaegerEncoding(t *testing.T) {
in: kafka.EncodingJSON,
expected: "jaeger_json",
},
{
in: encodingOTLPProto,
expected: "otlp_proto",
},
{
in: "not-an-encoding",
expectsPanic: true,
Expand Down

0 comments on commit a99043c

Please sign in to comment.