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

Use official Apache Thrift instead of Jaeger's fork #2861

Merged
merged 1 commit into from
Mar 4, 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
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ BUILD_INFO_IMPORT_PATH=$(JAEGER_IMPORT_PATH)/pkg/version
BUILD_INFO=-ldflags "-X $(BUILD_INFO_IMPORT_PATH).commitSHA=$(GIT_SHA) -X $(BUILD_INFO_IMPORT_PATH).latestVersion=$(GIT_CLOSEST_TAG) -X $(BUILD_INFO_IMPORT_PATH).date=$(DATE)"

SED=sed
THRIFT_VER=0.13
THRIFT_VER=0.14
THRIFT_IMG=jaegertracing/thrift:$(THRIFT_VER)
THRIFT=docker run --rm -u ${shell id -u} -v "${PWD}:/data" $(THRIFT_IMG) thrift
THRIFT_GO_ARGS=thrift_import="github.com/apache/thrift/lib/go/thrift"
Expand Down
4 changes: 2 additions & 2 deletions cmd/agent/app/builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,8 @@ type Protocol string

var (
protocolFactoryMap = map[Protocol]thrift.TProtocolFactory{
compactProtocol: thrift.NewTCompactProtocolFactory(),
binaryProtocol: thrift.NewTBinaryProtocolFactoryDefault(),
compactProtocol: thrift.NewTCompactProtocolFactoryConf(&thrift.TConfiguration{}),
binaryProtocol: thrift.NewTBinaryProtocolFactoryConf(&thrift.TConfiguration{}),
}
)

Expand Down
4 changes: 2 additions & 2 deletions cmd/agent/app/processors/thrift_processor_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,8 @@ import (
// TODO make these tests faster, they take almost 4 seconds

var (
compactFactory = thrift.NewTCompactProtocolFactory()
binaryFactory = thrift.NewTBinaryProtocolFactoryDefault()
compactFactory = thrift.NewTCompactProtocolFactoryConf(&thrift.TConfiguration{})
binaryFactory = thrift.NewTBinaryProtocolFactoryConf(&thrift.TConfiguration{})

testSpanName = "span1"

Expand Down
4 changes: 2 additions & 2 deletions cmd/agent/app/servers/tbuffered_server_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import (
"testing"
"time"

athrift "github.com/apache/thrift/lib/go/thrift"
"github.com/apache/thrift/lib/go/thrift"
jpkrohling marked this conversation as resolved.
Show resolved Hide resolved
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
"github.com/uber/jaeger-lib/metrics/metricstest"
Expand Down Expand Up @@ -64,7 +64,7 @@ func TestTBufferedServer_SendReceive(t *testing.T) {
assert.NotEqual(t, 0, len(readBuf.GetBytes()))

inMemReporter := testutils.NewInMemoryReporter()
protoFact := athrift.NewTCompactProtocolFactory()
protoFact := thrift.NewTCompactProtocolFactoryConf(&thrift.TConfiguration{})
trans := &customtransport.TBufferedReadTransport{}
protocol := protoFact.GetProtocol(trans)

Expand Down
2 changes: 1 addition & 1 deletion cmd/agent/app/testutils/thriftudp_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ func NewZipkinThriftUDPClient(hostPort string) (*agent.AgentClient, io.Closer, e
return nil, nil, err
}

protocolFactory := thrift.NewTCompactProtocolFactory()
protocolFactory := thrift.NewTCompactProtocolFactoryConf(&thrift.TConfiguration{})
client := agent.NewAgentClientFactory(clientTransport, protocolFactory)
return client, clientTransport, nil
}
Expand Down
2 changes: 1 addition & 1 deletion cmd/agent/app/testutils/thriftudp_client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ func TestNewZipkinThriftUDPClient(t *testing.T) {
}

func TestNewJaegerThriftUDPClient(t *testing.T) {
compactFactory := thrift.NewTCompactProtocolFactory()
compactFactory := thrift.NewTCompactProtocolFactoryConf(&thrift.TConfiguration{})

_, _, err := NewJaegerThriftUDPClient("256.2.3:0", compactFactory)
assert.Error(t, err)
Expand Down
2 changes: 1 addition & 1 deletion cmd/collector/app/handler/http_handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ func (aH *APIHandler) SaveSpan(w http.ResponseWriter, r *http.Request) {

tdes := thrift.NewTDeserializer()
batch := &tJaeger.Batch{}
if err = tdes.Read(batch, bodyBytes); err != nil {
if err = tdes.Read(r.Context(), batch, bodyBytes); err != nil {
http.Error(w, fmt.Sprintf(UnableToReadBodyErrFormat, err), http.StatusBadRequest)
return
}
Expand Down
7 changes: 2 additions & 5 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ require (
github.com/DataDog/zstd v1.4.4 // indirect
github.com/HdrHistogram/hdrhistogram-go v0.9.0 // indirect
github.com/Shopify/sarama v1.22.2-0.20190604114437-cd910a683f9f
github.com/apache/thrift v0.13.0
github.com/apache/thrift v0.14.1
github.com/bsm/sarama-cluster v2.1.13+incompatible
github.com/crossdock/crossdock-go v0.0.0-20160816171116-049aabb0122b
github.com/dgraph-io/badger v1.6.2
Expand Down Expand Up @@ -81,7 +81,4 @@ require (
honnef.co/go/tools v0.1.2
)

replace (
github.com/apache/thrift => github.com/jaegertracing/thrift v1.13.0-patch1
github.com/gogo/protobuf => github.com/gogo/protobuf v1.3.2
)
replace github.com/gogo/protobuf => github.com/gogo/protobuf v1.3.2
6 changes: 6 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,12 @@ github.com/alecthomas/units v0.0.0-20151022065526-2efee857e7cf/go.mod h1:ybxpYRF
github.com/alecthomas/units v0.0.0-20190717042225-c3de453c63f4/go.mod h1:ybxpYRFXyAe+OPACYpWeL0wqObRcbAqCMya13uyzqw0=
github.com/andreyvit/diff v0.0.0-20170406064948-c7f18ee00883/go.mod h1:rCTlJbsFo29Kk6CurOXKm700vrz8f0KW0JNfpkRJY/8=
github.com/antihax/optional v0.0.0-20180407024304-ca021399b1a6/go.mod h1:V8iCPQYkqmusNa815XgQio277wI47sdRh1dUOLdyC6Q=
github.com/apache/thrift v0.12.0/go.mod h1:cp2SuWMxlEZw2r+iP2GNCdIi4C1qmUzdZFSVb+bacwQ=
github.com/apache/thrift v0.13.0/go.mod h1:cp2SuWMxlEZw2r+iP2GNCdIi4C1qmUzdZFSVb+bacwQ=
github.com/apache/thrift v0.14.0 h1:vqZ2DP42i8th2OsgCcYZkirtbzvpZEFx53LiWDJXIAs=
github.com/apache/thrift v0.14.0/go.mod h1:cp2SuWMxlEZw2r+iP2GNCdIi4C1qmUzdZFSVb+bacwQ=
github.com/apache/thrift v0.14.1 h1:Yh8v0hpCj63p5edXOLaqTJW0IJ1p+eMW6+YSOqw1d6s=
github.com/apache/thrift v0.14.1/go.mod h1:cp2SuWMxlEZw2r+iP2GNCdIi4C1qmUzdZFSVb+bacwQ=
github.com/armon/circbuf v0.0.0-20150827004946-bbbad097214e/go.mod h1:3U/XgcO3hCbHZ8TKRvWD2dDTCfh9M9ya+I9JpbB7O8o=
github.com/armon/consul-api v0.0.0-20180202201655-eb2c6b5be1b6/go.mod h1:grANhF5doyWs3UAsr3K4I6qtAmlQcZDesFNEHPZAzj8=
github.com/armon/go-metrics v0.0.0-20180917152333-f0300d1749da/go.mod h1:Q73ZrmVTwzkszR9V5SSuryQ31EELlFMUz1kKyl939pY=
Expand Down
18 changes: 11 additions & 7 deletions model/converter/thrift/zipkin/deserialize.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,30 +16,34 @@
package zipkin

import (
"context"

"github.com/apache/thrift/lib/go/thrift"

"github.com/jaegertracing/jaeger/thrift-gen/zipkincore"
)

// SerializeThrift is only used in tests.
func SerializeThrift(spans []*zipkincore.Span) []byte {
ctx := context.Background()
t := thrift.NewTMemoryBuffer()
p := thrift.NewTBinaryProtocolTransport(t)
p.WriteListBegin(thrift.STRUCT, len(spans))
p := thrift.NewTBinaryProtocolConf(t, &thrift.TConfiguration{})
p.WriteListBegin(ctx, thrift.STRUCT, len(spans))
for _, s := range spans {
s.Write(p)
s.Write(ctx, p)
}
p.WriteListEnd()
p.WriteListEnd(ctx)
return t.Buffer.Bytes()
}

// DeserializeThrift decodes Thrift bytes to a list of spans.
func DeserializeThrift(b []byte) ([]*zipkincore.Span, error) {
ctx := context.Background()
buffer := thrift.NewTMemoryBuffer()
buffer.Write(b)

transport := thrift.NewTBinaryProtocolTransport(buffer)
_, size, err := transport.ReadListBegin() // Ignore the returned element type
transport := thrift.NewTBinaryProtocolConf(buffer, &thrift.TConfiguration{})
_, size, err := transport.ReadListBegin(ctx) // Ignore the returned element type
if err != nil {
return nil, err
}
Expand All @@ -49,7 +53,7 @@ func DeserializeThrift(b []byte) ([]*zipkincore.Span, error) {
var spans []*zipkincore.Span
for i := 0; i < size; i++ {
zs := &zipkincore.Span{}
if err = zs.Read(transport); err != nil {
if err = zs.Read(ctx, transport); err != nil {
return nil, err
}
spans = append(spans, zs)
Expand Down
Loading