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

tmp for share #4287

Closed
wants to merge 1 commit into from
Closed
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
2 changes: 2 additions & 0 deletions cmd/ingester/app/builder/builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@ func CreateConsumer(logger *zap.Logger, metricsFactory metrics.Factory, spanWrit
unmarshaller = kafka.NewProtobufUnmarshaller()
case kafka.EncodingZipkinThrift:
unmarshaller = kafka.NewZipkinThriftUnmarshaller()
case kafka.EncodingOtlpProto:
unmarshaller = kafka.NewOtlpProtoUnmarshaller()
default:
return nil, fmt.Errorf(`encoding '%s' not recognised, use one of ("%s")`,
options.Encoding, strings.Join(kafka.AllEncodings, "\", \""))
Expand Down
1 change: 1 addition & 0 deletions plugin/storage/kafka/options.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ const (
EncodingProto = "protobuf"
// EncodingZipkinThrift is used for spans encoded as Zipkin Thrift.
EncodingZipkinThrift = "zipkin-thrift"
EncodingOtlpJSON = "otlp-json"

configPrefix = "kafka.producer"
suffixBrokers = ".brokers"
Expand Down
28 changes: 28 additions & 0 deletions plugin/storage/kafka/unmarshaller.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,11 @@ import (

"github.com/gogo/protobuf/jsonpb"
"github.com/gogo/protobuf/proto"
"go.opentelemetry.io/collector/pdata/ptrace/ptraceotlp"

"github.com/jaegertracing/jaeger/model"
"github.com/jaegertracing/jaeger/model/converter/thrift/zipkin"
otlp2jaeger "github.com/open-telemetry/opentelemetry-collector-contrib/pkg/translator/jaeger"
)

// Unmarshaller decodes a byte array to a span
Expand Down Expand Up @@ -80,3 +82,29 @@ func (h *ZipkinThriftUnmarshaller) Unmarshal(msg []byte) (*model.Span, error) {
}
return mSpans[0], err
}

type OtlpJSONUnmarshaller struct{}

func NewOtlpJSONUnmarshaller() *OtlpJSONUnmarshaller {
return &OtlpJSONUnmarshaller{}
}

func (OtlpJSONUnmarshaller) Unmarshal(buf []byte) (*model.Span, error) {
req := ptraceotlp.NewExportRequest()
err := req.UnmarshalJSON(buf)
if err != nil {
return nil, err
}

batch, err := otlp2jaeger.ProtoFromTraces(req.Traces())
if err != nil {
return nil, err
}

// check span & raise err
// if span {

// }

return batch[0].Spans[0], nil
}