diff --git a/Makefile.Thrift.mk b/Makefile.Thrift.mk index 9bef42a02be..9df91604141 100644 --- a/Makefile.Thrift.mk +++ b/Makefile.Thrift.mk @@ -1,7 +1,7 @@ # Copyright (c) 2023 The Jaeger Authors. # SPDX-License-Identifier: Apache-2.0 -THRIFT_VER=0.14 +THRIFT_VER=0.19 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" diff --git a/thrift-gen/agent/GoUnusedProtection__.go b/thrift-gen/agent/GoUnusedProtection__.go index 54cd3b0867a..232c9cf78d1 100644 --- a/thrift-gen/agent/GoUnusedProtection__.go +++ b/thrift-gen/agent/GoUnusedProtection__.go @@ -1,4 +1,4 @@ -// Code generated by Thrift Compiler (0.14.1). DO NOT EDIT. +// Code generated by Thrift Compiler (0.19.0). DO NOT EDIT. package agent diff --git a/thrift-gen/agent/agent-consts.go b/thrift-gen/agent/agent-consts.go index af972ea8b60..2f17ae42079 100644 --- a/thrift-gen/agent/agent-consts.go +++ b/thrift-gen/agent/agent-consts.go @@ -1,13 +1,16 @@ -// Code generated by Thrift Compiler (0.14.1). DO NOT EDIT. +// Code generated by Thrift Compiler (0.19.0). DO NOT EDIT. package agent -import( +import ( "bytes" "context" + "errors" "fmt" "time" - "github.com/apache/thrift/lib/go/thrift" + thrift "github.com/apache/thrift/lib/go/thrift" + "strings" + "regexp" "github.com/jaegertracing/jaeger/thrift-gen/jaeger" "github.com/jaegertracing/jaeger/thrift-gen/zipkincore" @@ -16,9 +19,13 @@ import( // (needed to ensure safety because of naive import list construction.) var _ = thrift.ZERO var _ = fmt.Printf +var _ = errors.New var _ = context.Background var _ = time.Now var _ = bytes.Equal +// (needed by validator.) +var _ = strings.Contains +var _ = regexp.MatchString var _ = jaeger.GoUnusedProtection__ var _ = zipkincore.GoUnusedProtection__ diff --git a/thrift-gen/agent/agent.go b/thrift-gen/agent/agent.go index cc68b54f92d..979cc89a33b 100644 --- a/thrift-gen/agent/agent.go +++ b/thrift-gen/agent/agent.go @@ -1,13 +1,16 @@ -// Code generated by Thrift Compiler (0.14.1). DO NOT EDIT. +// Code generated by Thrift Compiler (0.19.0). DO NOT EDIT. package agent -import( +import ( "bytes" "context" + "errors" "fmt" "time" - "github.com/apache/thrift/lib/go/thrift" + thrift "github.com/apache/thrift/lib/go/thrift" + "strings" + "regexp" "github.com/jaegertracing/jaeger/thrift-gen/jaeger" "github.com/jaegertracing/jaeger/thrift-gen/zipkincore" @@ -16,9 +19,13 @@ import( // (needed to ensure safety because of naive import list construction.) var _ = thrift.ZERO var _ = fmt.Printf +var _ = errors.New var _ = context.Background var _ = time.Now var _ = bytes.Equal +// (needed by validator.) +var _ = strings.Contains +var _ = regexp.MatchString var _ = jaeger.GoUnusedProtection__ var _ = zipkincore.GoUnusedProtection__ @@ -139,8 +146,7 @@ type agentProcessorEmitZipkinBatch struct { func (p *agentProcessorEmitZipkinBatch) Process(ctx context.Context, seqId int32, iprot, oprot thrift.TProtocol) (success bool, err thrift.TException) { args := AgentEmitZipkinBatchArgs{} - var err2 error - if err2 = args.Read(ctx, iprot); err2 != nil { + if err2 := args.Read(ctx, iprot); err2 != nil { iprot.ReadMessageEnd(ctx) return false, thrift.WrapTException(err2) } @@ -149,12 +155,12 @@ func (p *agentProcessorEmitZipkinBatch) Process(ctx context.Context, seqId int32 tickerCancel := func() {} _ = tickerCancel - if err2 = p.handler.EmitZipkinBatch(ctx, args.Spans); err2 != nil { + if err2 := p.handler.EmitZipkinBatch(ctx, args.Spans); err2 != nil { tickerCancel() - return true, thrift.WrapTException(err2) + err = thrift.WrapTException(err2) } tickerCancel() - return true, nil + return true, err } type agentProcessorEmitBatch struct { @@ -163,8 +169,7 @@ type agentProcessorEmitBatch struct { func (p *agentProcessorEmitBatch) Process(ctx context.Context, seqId int32, iprot, oprot thrift.TProtocol) (success bool, err thrift.TException) { args := AgentEmitBatchArgs{} - var err2 error - if err2 = args.Read(ctx, iprot); err2 != nil { + if err2 := args.Read(ctx, iprot); err2 != nil { iprot.ReadMessageEnd(ctx) return false, thrift.WrapTException(err2) } @@ -173,12 +178,12 @@ func (p *agentProcessorEmitBatch) Process(ctx context.Context, seqId int32, ipro tickerCancel := func() {} _ = tickerCancel - if err2 = p.handler.EmitBatch(ctx, args.Batch); err2 != nil { + if err2 := p.handler.EmitBatch(ctx, args.Batch); err2 != nil { tickerCancel() - return true, thrift.WrapTException(err2) + err = thrift.WrapTException(err2) } tickerCancel() - return true, nil + return true, err } diff --git a/thrift-gen/baggage/GoUnusedProtection__.go b/thrift-gen/baggage/GoUnusedProtection__.go index 712b6a9da4c..2a12aadf771 100644 --- a/thrift-gen/baggage/GoUnusedProtection__.go +++ b/thrift-gen/baggage/GoUnusedProtection__.go @@ -1,4 +1,4 @@ -// Code generated by Thrift Compiler (0.14.1). DO NOT EDIT. +// Code generated by Thrift Compiler (0.19.0). DO NOT EDIT. package baggage diff --git a/thrift-gen/baggage/baggage-consts.go b/thrift-gen/baggage/baggage-consts.go index 0eeb8239f97..ddc1c2702d2 100644 --- a/thrift-gen/baggage/baggage-consts.go +++ b/thrift-gen/baggage/baggage-consts.go @@ -1,21 +1,28 @@ -// Code generated by Thrift Compiler (0.14.1). DO NOT EDIT. +// Code generated by Thrift Compiler (0.19.0). DO NOT EDIT. package baggage -import( +import ( "bytes" "context" + "errors" "fmt" "time" - "github.com/apache/thrift/lib/go/thrift" + thrift "github.com/apache/thrift/lib/go/thrift" + "strings" + "regexp" ) // (needed to ensure safety because of naive import list construction.) var _ = thrift.ZERO var _ = fmt.Printf +var _ = errors.New var _ = context.Background var _ = time.Now var _ = bytes.Equal +// (needed by validator.) +var _ = strings.Contains +var _ = regexp.MatchString func init() { diff --git a/thrift-gen/baggage/baggage.go b/thrift-gen/baggage/baggage.go index 40134450580..3d5db071478 100644 --- a/thrift-gen/baggage/baggage.go +++ b/thrift-gen/baggage/baggage.go @@ -1,21 +1,28 @@ -// Code generated by Thrift Compiler (0.14.1). DO NOT EDIT. +// Code generated by Thrift Compiler (0.19.0). DO NOT EDIT. package baggage -import( +import ( "bytes" "context" + "errors" "fmt" "time" - "github.com/apache/thrift/lib/go/thrift" + thrift "github.com/apache/thrift/lib/go/thrift" + "strings" + "regexp" ) // (needed to ensure safety because of naive import list construction.) var _ = thrift.ZERO var _ = fmt.Printf +var _ = errors.New var _ = context.Background var _ = time.Now var _ = bytes.Equal +// (needed by validator.) +var _ = strings.Contains +var _ = regexp.MatchString // Attributes: // - BaggageKey @@ -165,6 +172,9 @@ func (p *BaggageRestriction) String() string { return fmt.Sprintf("BaggageRestriction(%+v)", *p) } +func (p *BaggageRestriction) Validate() error { + return nil +} type BaggageRestrictionManager interface { // getBaggageRestrictions retrieves the baggage restrictions for a specific service. // Usually, baggageRestrictions apply to all services however there may be situations @@ -276,9 +286,9 @@ type baggageRestrictionManagerProcessorGetBaggageRestrictions struct { } func (p *baggageRestrictionManagerProcessorGetBaggageRestrictions) Process(ctx context.Context, seqId int32, iprot, oprot thrift.TProtocol) (success bool, err thrift.TException) { + var _write_err5 error args := BaggageRestrictionManagerGetBaggageRestrictionsArgs{} - var err2 error - if err2 = args.Read(ctx, iprot); err2 != nil { + if err2 := args.Read(ctx, iprot); err2 != nil { iprot.ReadMessageEnd(ctx) x := thrift.NewTApplicationException(thrift.PROTOCOL_ERROR, err2.Error()) oprot.WriteMessageBegin(ctx, "getBaggageRestrictions", thrift.EXCEPTION, seqId) @@ -292,13 +302,13 @@ func (p *baggageRestrictionManagerProcessorGetBaggageRestrictions) Process(ctx c tickerCancel := func() {} // Start a goroutine to do server side connectivity check. if thrift.ServerConnectivityCheckInterval > 0 { - var cancel context.CancelFunc - ctx, cancel = context.WithCancel(ctx) - defer cancel() + var cancel context.CancelCauseFunc + ctx, cancel = context.WithCancelCause(ctx) + defer cancel(nil) var tickerCtx context.Context tickerCtx, tickerCancel = context.WithCancel(context.Background()) defer tickerCancel() - go func(ctx context.Context, cancel context.CancelFunc) { + go func(ctx context.Context, cancel context.CancelCauseFunc) { ticker := time.NewTicker(thrift.ServerConnectivityCheckInterval) defer ticker.Stop() for { @@ -307,7 +317,7 @@ func (p *baggageRestrictionManagerProcessorGetBaggageRestrictions) Process(ctx c return case <-ticker.C: if !iprot.Transport().IsOpen() { - cancel() + cancel(thrift.ErrAbandonRequest) return } } @@ -316,36 +326,52 @@ func (p *baggageRestrictionManagerProcessorGetBaggageRestrictions) Process(ctx c } result := BaggageRestrictionManagerGetBaggageRestrictionsResult{} - var retval []*BaggageRestriction - if retval, err2 = p.handler.GetBaggageRestrictions(ctx, args.ServiceName); err2 != nil { + if retval, err2 := p.handler.GetBaggageRestrictions(ctx, args.ServiceName); err2 != nil { tickerCancel() - if err2 == thrift.ErrAbandonRequest { + err = thrift.WrapTException(err2) + if errors.Is(err2, thrift.ErrAbandonRequest) { return false, thrift.WrapTException(err2) } - x := thrift.NewTApplicationException(thrift.INTERNAL_ERROR, "Internal error processing getBaggageRestrictions: " + err2.Error()) - oprot.WriteMessageBegin(ctx, "getBaggageRestrictions", thrift.EXCEPTION, seqId) - x.Write(ctx, oprot) - oprot.WriteMessageEnd(ctx) - oprot.Flush(ctx) - return true, thrift.WrapTException(err2) + if errors.Is(err2, context.Canceled) { + if err := context.Cause(ctx); errors.Is(err, thrift.ErrAbandonRequest) { + return false, thrift.WrapTException(err) + } + } + _exc6 := thrift.NewTApplicationException(thrift.INTERNAL_ERROR, "Internal error processing getBaggageRestrictions: " + err2.Error()) + if err2 := oprot.WriteMessageBegin(ctx, "getBaggageRestrictions", thrift.EXCEPTION, seqId); err2 != nil { + _write_err5 = thrift.WrapTException(err2) + } + if err2 := _exc6.Write(ctx, oprot); _write_err5 == nil && err2 != nil { + _write_err5 = thrift.WrapTException(err2) + } + if err2 := oprot.WriteMessageEnd(ctx); _write_err5 == nil && err2 != nil { + _write_err5 = thrift.WrapTException(err2) + } + if err2 := oprot.Flush(ctx); _write_err5 == nil && err2 != nil { + _write_err5 = thrift.WrapTException(err2) + } + if _write_err5 != nil { + return false, thrift.WrapTException(_write_err5) + } + return true, err } else { result.Success = retval } tickerCancel() - if err2 = oprot.WriteMessageBegin(ctx, "getBaggageRestrictions", thrift.REPLY, seqId); err2 != nil { - err = thrift.WrapTException(err2) + if err2 := oprot.WriteMessageBegin(ctx, "getBaggageRestrictions", thrift.REPLY, seqId); err2 != nil { + _write_err5 = thrift.WrapTException(err2) } - if err2 = result.Write(ctx, oprot); err == nil && err2 != nil { - err = thrift.WrapTException(err2) + if err2 := result.Write(ctx, oprot); _write_err5 == nil && err2 != nil { + _write_err5 = thrift.WrapTException(err2) } - if err2 = oprot.WriteMessageEnd(ctx); err == nil && err2 != nil { - err = thrift.WrapTException(err2) + if err2 := oprot.WriteMessageEnd(ctx); _write_err5 == nil && err2 != nil { + _write_err5 = thrift.WrapTException(err2) } - if err2 = oprot.Flush(ctx); err == nil && err2 != nil { - err = thrift.WrapTException(err2) + if err2 := oprot.Flush(ctx); _write_err5 == nil && err2 != nil { + _write_err5 = thrift.WrapTException(err2) } - if err != nil { - return + if _write_err5 != nil { + return false, thrift.WrapTException(_write_err5) } return true, err } @@ -509,11 +535,11 @@ func (p *BaggageRestrictionManagerGetBaggageRestrictionsResult) ReadField0(ctx tSlice := make([]*BaggageRestriction, 0, size) p.Success = tSlice for i := 0; i < size; i ++ { - _elem5 := &BaggageRestriction{} - if err := _elem5.Read(ctx, iprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", _elem5), err) + _elem7 := &BaggageRestriction{} + if err := _elem7.Read(ctx, iprot); err != nil { + return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", _elem7), err) } - p.Success = append(p.Success, _elem5) + p.Success = append(p.Success, _elem7) } if err := iprot.ReadListEnd(ctx); err != nil { return thrift.PrependError("error reading list end: ", err) diff --git a/thrift-gen/jaeger/GoUnusedProtection__.go b/thrift-gen/jaeger/GoUnusedProtection__.go index fe45a9f9ad2..23ebe84140f 100644 --- a/thrift-gen/jaeger/GoUnusedProtection__.go +++ b/thrift-gen/jaeger/GoUnusedProtection__.go @@ -1,4 +1,4 @@ -// Code generated by Thrift Compiler (0.14.1). DO NOT EDIT. +// Code generated by Thrift Compiler (0.19.0). DO NOT EDIT. package jaeger diff --git a/thrift-gen/jaeger/jaeger-consts.go b/thrift-gen/jaeger/jaeger-consts.go index ca723e29f1a..ad004c114bf 100644 --- a/thrift-gen/jaeger/jaeger-consts.go +++ b/thrift-gen/jaeger/jaeger-consts.go @@ -1,21 +1,28 @@ -// Code generated by Thrift Compiler (0.14.1). DO NOT EDIT. +// Code generated by Thrift Compiler (0.19.0). DO NOT EDIT. package jaeger -import( +import ( "bytes" "context" + "errors" "fmt" "time" - "github.com/apache/thrift/lib/go/thrift" + thrift "github.com/apache/thrift/lib/go/thrift" + "strings" + "regexp" ) // (needed to ensure safety because of naive import list construction.) var _ = thrift.ZERO var _ = fmt.Printf +var _ = errors.New var _ = context.Background var _ = time.Now var _ = bytes.Equal +// (needed by validator.) +var _ = strings.Contains +var _ = regexp.MatchString func init() { diff --git a/thrift-gen/jaeger/jaeger.go b/thrift-gen/jaeger/jaeger.go index 9a55459f33f..4c087622586 100644 --- a/thrift-gen/jaeger/jaeger.go +++ b/thrift-gen/jaeger/jaeger.go @@ -1,23 +1,29 @@ -// Code generated by Thrift Compiler (0.14.1). DO NOT EDIT. +// Code generated by Thrift Compiler (0.19.0). DO NOT EDIT. package jaeger -import( +import ( "bytes" "context" "database/sql/driver" "errors" "fmt" "time" - "github.com/apache/thrift/lib/go/thrift" + thrift "github.com/apache/thrift/lib/go/thrift" + "strings" + "regexp" ) // (needed to ensure safety because of naive import list construction.) var _ = thrift.ZERO var _ = fmt.Printf +var _ = errors.New var _ = context.Background var _ = time.Now var _ = bytes.Equal +// (needed by validator.) +var _ = strings.Contains +var _ = regexp.MatchString type TagType int64 const ( @@ -531,6 +537,9 @@ func (p *Tag) String() string { return fmt.Sprintf("Tag(%+v)", *p) } +func (p *Tag) Validate() error { + return nil +} // Attributes: // - Timestamp // - Fields @@ -703,6 +712,9 @@ func (p *Log) String() string { return fmt.Sprintf("Log(%+v)", *p) } +func (p *Log) Validate() error { + return nil +} // Attributes: // - RefType // - TraceIdLow @@ -936,6 +948,9 @@ func (p *SpanRef) String() string { return fmt.Sprintf("SpanRef(%+v)", *p) } +func (p *SpanRef) Validate() error { + return nil +} // Attributes: // - TraceIdLow // - TraceIdHigh @@ -1540,6 +1555,9 @@ func (p *Span) String() string { return fmt.Sprintf("Span(%+v)", *p) } +func (p *Span) Validate() error { + return nil +} // Attributes: // - ServiceName // - Tags @@ -1714,6 +1732,9 @@ func (p *Process) String() string { return fmt.Sprintf("Process(%+v)", *p) } +func (p *Process) Validate() error { + return nil +} // Attributes: // - FullQueueDroppedSpans // - TooLargeDroppedSpans @@ -1904,6 +1925,9 @@ func (p *ClientStats) String() string { return fmt.Sprintf("ClientStats(%+v)", *p) } +func (p *ClientStats) Validate() error { + return nil +} // Attributes: // - Process // - Spans @@ -2180,6 +2204,9 @@ func (p *Batch) String() string { return fmt.Sprintf("Batch(%+v)", *p) } +func (p *Batch) Validate() error { + return nil +} // Attributes: // - Ok type BatchSubmitResponse struct { @@ -2286,6 +2313,9 @@ func (p *BatchSubmitResponse) String() string { return fmt.Sprintf("BatchSubmitResponse(%+v)", *p) } +func (p *BatchSubmitResponse) Validate() error { + return nil +} type Collector interface { // Parameters: // - Batches @@ -2389,9 +2419,9 @@ type collectorProcessorSubmitBatches struct { } func (p *collectorProcessorSubmitBatches) Process(ctx context.Context, seqId int32, iprot, oprot thrift.TProtocol) (success bool, err thrift.TException) { + var _write_err17 error args := CollectorSubmitBatchesArgs{} - var err2 error - if err2 = args.Read(ctx, iprot); err2 != nil { + if err2 := args.Read(ctx, iprot); err2 != nil { iprot.ReadMessageEnd(ctx) x := thrift.NewTApplicationException(thrift.PROTOCOL_ERROR, err2.Error()) oprot.WriteMessageBegin(ctx, "submitBatches", thrift.EXCEPTION, seqId) @@ -2405,13 +2435,13 @@ func (p *collectorProcessorSubmitBatches) Process(ctx context.Context, seqId int tickerCancel := func() {} // Start a goroutine to do server side connectivity check. if thrift.ServerConnectivityCheckInterval > 0 { - var cancel context.CancelFunc - ctx, cancel = context.WithCancel(ctx) - defer cancel() + var cancel context.CancelCauseFunc + ctx, cancel = context.WithCancelCause(ctx) + defer cancel(nil) var tickerCtx context.Context tickerCtx, tickerCancel = context.WithCancel(context.Background()) defer tickerCancel() - go func(ctx context.Context, cancel context.CancelFunc) { + go func(ctx context.Context, cancel context.CancelCauseFunc) { ticker := time.NewTicker(thrift.ServerConnectivityCheckInterval) defer ticker.Stop() for { @@ -2420,7 +2450,7 @@ func (p *collectorProcessorSubmitBatches) Process(ctx context.Context, seqId int return case <-ticker.C: if !iprot.Transport().IsOpen() { - cancel() + cancel(thrift.ErrAbandonRequest) return } } @@ -2429,36 +2459,52 @@ func (p *collectorProcessorSubmitBatches) Process(ctx context.Context, seqId int } result := CollectorSubmitBatchesResult{} - var retval []*BatchSubmitResponse - if retval, err2 = p.handler.SubmitBatches(ctx, args.Batches); err2 != nil { + if retval, err2 := p.handler.SubmitBatches(ctx, args.Batches); err2 != nil { tickerCancel() - if err2 == thrift.ErrAbandonRequest { + err = thrift.WrapTException(err2) + if errors.Is(err2, thrift.ErrAbandonRequest) { return false, thrift.WrapTException(err2) } - x := thrift.NewTApplicationException(thrift.INTERNAL_ERROR, "Internal error processing submitBatches: " + err2.Error()) - oprot.WriteMessageBegin(ctx, "submitBatches", thrift.EXCEPTION, seqId) - x.Write(ctx, oprot) - oprot.WriteMessageEnd(ctx) - oprot.Flush(ctx) - return true, thrift.WrapTException(err2) + if errors.Is(err2, context.Canceled) { + if err := context.Cause(ctx); errors.Is(err, thrift.ErrAbandonRequest) { + return false, thrift.WrapTException(err) + } + } + _exc18 := thrift.NewTApplicationException(thrift.INTERNAL_ERROR, "Internal error processing submitBatches: " + err2.Error()) + if err2 := oprot.WriteMessageBegin(ctx, "submitBatches", thrift.EXCEPTION, seqId); err2 != nil { + _write_err17 = thrift.WrapTException(err2) + } + if err2 := _exc18.Write(ctx, oprot); _write_err17 == nil && err2 != nil { + _write_err17 = thrift.WrapTException(err2) + } + if err2 := oprot.WriteMessageEnd(ctx); _write_err17 == nil && err2 != nil { + _write_err17 = thrift.WrapTException(err2) + } + if err2 := oprot.Flush(ctx); _write_err17 == nil && err2 != nil { + _write_err17 = thrift.WrapTException(err2) + } + if _write_err17 != nil { + return false, thrift.WrapTException(_write_err17) + } + return true, err } else { result.Success = retval } tickerCancel() - if err2 = oprot.WriteMessageBegin(ctx, "submitBatches", thrift.REPLY, seqId); err2 != nil { - err = thrift.WrapTException(err2) + if err2 := oprot.WriteMessageBegin(ctx, "submitBatches", thrift.REPLY, seqId); err2 != nil { + _write_err17 = thrift.WrapTException(err2) } - if err2 = result.Write(ctx, oprot); err == nil && err2 != nil { - err = thrift.WrapTException(err2) + if err2 := result.Write(ctx, oprot); _write_err17 == nil && err2 != nil { + _write_err17 = thrift.WrapTException(err2) } - if err2 = oprot.WriteMessageEnd(ctx); err == nil && err2 != nil { - err = thrift.WrapTException(err2) + if err2 := oprot.WriteMessageEnd(ctx); _write_err17 == nil && err2 != nil { + _write_err17 = thrift.WrapTException(err2) } - if err2 = oprot.Flush(ctx); err == nil && err2 != nil { - err = thrift.WrapTException(err2) + if err2 := oprot.Flush(ctx); _write_err17 == nil && err2 != nil { + _write_err17 = thrift.WrapTException(err2) } - if err != nil { - return + if _write_err17 != nil { + return false, thrift.WrapTException(_write_err17) } return true, err } @@ -2526,11 +2572,11 @@ func (p *CollectorSubmitBatchesArgs) ReadField1(ctx context.Context, iprot thri tSlice := make([]*Batch, 0, size) p.Batches = tSlice for i := 0; i < size; i ++ { - _elem17 := &Batch{} - if err := _elem17.Read(ctx, iprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", _elem17), err) + _elem19 := &Batch{} + if err := _elem19.Read(ctx, iprot); err != nil { + return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", _elem19), err) } - p.Batches = append(p.Batches, _elem17) + p.Batches = append(p.Batches, _elem19) } if err := iprot.ReadListEnd(ctx); err != nil { return thrift.PrependError("error reading list end: ", err) @@ -2642,11 +2688,11 @@ func (p *CollectorSubmitBatchesResult) ReadField0(ctx context.Context, iprot th tSlice := make([]*BatchSubmitResponse, 0, size) p.Success = tSlice for i := 0; i < size; i ++ { - _elem18 := &BatchSubmitResponse{} - if err := _elem18.Read(ctx, iprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", _elem18), err) + _elem20 := &BatchSubmitResponse{} + if err := _elem20.Read(ctx, iprot); err != nil { + return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", _elem20), err) } - p.Success = append(p.Success, _elem18) + p.Success = append(p.Success, _elem20) } if err := iprot.ReadListEnd(ctx); err != nil { return thrift.PrependError("error reading list end: ", err) diff --git a/thrift-gen/sampling/GoUnusedProtection__.go b/thrift-gen/sampling/GoUnusedProtection__.go index 015ad4b0674..662b3694a71 100644 --- a/thrift-gen/sampling/GoUnusedProtection__.go +++ b/thrift-gen/sampling/GoUnusedProtection__.go @@ -1,4 +1,4 @@ -// Code generated by Thrift Compiler (0.14.1). DO NOT EDIT. +// Code generated by Thrift Compiler (0.19.0). DO NOT EDIT. package sampling diff --git a/thrift-gen/sampling/sampling-consts.go b/thrift-gen/sampling/sampling-consts.go index 9899b278c72..decd5c32bb6 100644 --- a/thrift-gen/sampling/sampling-consts.go +++ b/thrift-gen/sampling/sampling-consts.go @@ -1,21 +1,28 @@ -// Code generated by Thrift Compiler (0.14.1). DO NOT EDIT. +// Code generated by Thrift Compiler (0.19.0). DO NOT EDIT. package sampling -import( +import ( "bytes" "context" + "errors" "fmt" "time" - "github.com/apache/thrift/lib/go/thrift" + thrift "github.com/apache/thrift/lib/go/thrift" + "strings" + "regexp" ) // (needed to ensure safety because of naive import list construction.) var _ = thrift.ZERO var _ = fmt.Printf +var _ = errors.New var _ = context.Background var _ = time.Now var _ = bytes.Equal +// (needed by validator.) +var _ = strings.Contains +var _ = regexp.MatchString func init() { diff --git a/thrift-gen/sampling/sampling.go b/thrift-gen/sampling/sampling.go index f251540656d..c28891055e6 100644 --- a/thrift-gen/sampling/sampling.go +++ b/thrift-gen/sampling/sampling.go @@ -1,23 +1,29 @@ -// Code generated by Thrift Compiler (0.14.1). DO NOT EDIT. +// Code generated by Thrift Compiler (0.19.0). DO NOT EDIT. package sampling -import( +import ( "bytes" "context" "database/sql/driver" "errors" "fmt" "time" - "github.com/apache/thrift/lib/go/thrift" + thrift "github.com/apache/thrift/lib/go/thrift" + "strings" + "regexp" ) // (needed to ensure safety because of naive import list construction.) var _ = thrift.ZERO var _ = fmt.Printf +var _ = errors.New var _ = context.Background var _ = time.Now var _ = bytes.Equal +// (needed by validator.) +var _ = strings.Contains +var _ = regexp.MatchString type SamplingStrategyType int64 const ( @@ -178,6 +184,9 @@ func (p *ProbabilisticSamplingStrategy) String() string { return fmt.Sprintf("ProbabilisticSamplingStrategy(%+v)", *p) } +func (p *ProbabilisticSamplingStrategy) Validate() error { + return nil +} // Attributes: // - MaxTracesPerSecond type RateLimitingSamplingStrategy struct { @@ -284,6 +293,9 @@ func (p *RateLimitingSamplingStrategy) String() string { return fmt.Sprintf("RateLimitingSamplingStrategy(%+v)", *p) } +func (p *RateLimitingSamplingStrategy) Validate() error { + return nil +} // Attributes: // - Operation // - ProbabilisticSampling @@ -439,6 +451,9 @@ func (p *OperationSamplingStrategy) String() string { return fmt.Sprintf("OperationSamplingStrategy(%+v)", *p) } +func (p *OperationSamplingStrategy) Validate() error { + return nil +} // Attributes: // - DefaultSamplingProbability // - DefaultLowerBoundTracesPerSecond @@ -704,6 +719,9 @@ func (p *PerOperationSamplingStrategies) String() string { return fmt.Sprintf("PerOperationSamplingStrategies(%+v)", *p) } +func (p *PerOperationSamplingStrategies) Validate() error { + return nil +} // Attributes: // - StrategyType // - ProbabilisticSampling @@ -949,6 +967,9 @@ func (p *SamplingStrategyResponse) String() string { return fmt.Sprintf("SamplingStrategyResponse(%+v)", *p) } +func (p *SamplingStrategyResponse) Validate() error { + return nil +} type SamplingManager interface { // Parameters: // - ServiceName @@ -1002,7 +1023,10 @@ func (p *SamplingManagerClient) GetSamplingStrategy(ctx context.Context, service if _err != nil { return } - return _result4.GetSuccess(), nil + if _ret5 := _result4.GetSuccess(); _ret5 != nil { + return _ret5, nil + } + return nil, thrift.NewTApplicationException(thrift.MISSING_RESULT, "getSamplingStrategy failed: unknown result") } type SamplingManagerProcessor struct { @@ -1025,9 +1049,9 @@ func (p *SamplingManagerProcessor) ProcessorMap() map[string]thrift.TProcessorFu func NewSamplingManagerProcessor(handler SamplingManager) *SamplingManagerProcessor { - self5 := &SamplingManagerProcessor{handler:handler, processorMap:make(map[string]thrift.TProcessorFunction)} - self5.processorMap["getSamplingStrategy"] = &samplingManagerProcessorGetSamplingStrategy{handler:handler} -return self5 + self6 := &SamplingManagerProcessor{handler:handler, processorMap:make(map[string]thrift.TProcessorFunction)} + self6.processorMap["getSamplingStrategy"] = &samplingManagerProcessorGetSamplingStrategy{handler:handler} +return self6 } func (p *SamplingManagerProcessor) Process(ctx context.Context, iprot, oprot thrift.TProtocol) (success bool, err thrift.TException) { @@ -1038,12 +1062,12 @@ func (p *SamplingManagerProcessor) Process(ctx context.Context, iprot, oprot thr } iprot.Skip(ctx, thrift.STRUCT) iprot.ReadMessageEnd(ctx) - x6 := thrift.NewTApplicationException(thrift.UNKNOWN_METHOD, "Unknown function " + name) + x7 := thrift.NewTApplicationException(thrift.UNKNOWN_METHOD, "Unknown function " + name) oprot.WriteMessageBegin(ctx, name, thrift.EXCEPTION, seqId) - x6.Write(ctx, oprot) + x7.Write(ctx, oprot) oprot.WriteMessageEnd(ctx) oprot.Flush(ctx) - return false, x6 + return false, x7 } @@ -1052,9 +1076,9 @@ type samplingManagerProcessorGetSamplingStrategy struct { } func (p *samplingManagerProcessorGetSamplingStrategy) Process(ctx context.Context, seqId int32, iprot, oprot thrift.TProtocol) (success bool, err thrift.TException) { + var _write_err8 error args := SamplingManagerGetSamplingStrategyArgs{} - var err2 error - if err2 = args.Read(ctx, iprot); err2 != nil { + if err2 := args.Read(ctx, iprot); err2 != nil { iprot.ReadMessageEnd(ctx) x := thrift.NewTApplicationException(thrift.PROTOCOL_ERROR, err2.Error()) oprot.WriteMessageBegin(ctx, "getSamplingStrategy", thrift.EXCEPTION, seqId) @@ -1068,13 +1092,13 @@ func (p *samplingManagerProcessorGetSamplingStrategy) Process(ctx context.Contex tickerCancel := func() {} // Start a goroutine to do server side connectivity check. if thrift.ServerConnectivityCheckInterval > 0 { - var cancel context.CancelFunc - ctx, cancel = context.WithCancel(ctx) - defer cancel() + var cancel context.CancelCauseFunc + ctx, cancel = context.WithCancelCause(ctx) + defer cancel(nil) var tickerCtx context.Context tickerCtx, tickerCancel = context.WithCancel(context.Background()) defer tickerCancel() - go func(ctx context.Context, cancel context.CancelFunc) { + go func(ctx context.Context, cancel context.CancelCauseFunc) { ticker := time.NewTicker(thrift.ServerConnectivityCheckInterval) defer ticker.Stop() for { @@ -1083,7 +1107,7 @@ func (p *samplingManagerProcessorGetSamplingStrategy) Process(ctx context.Contex return case <-ticker.C: if !iprot.Transport().IsOpen() { - cancel() + cancel(thrift.ErrAbandonRequest) return } } @@ -1092,36 +1116,52 @@ func (p *samplingManagerProcessorGetSamplingStrategy) Process(ctx context.Contex } result := SamplingManagerGetSamplingStrategyResult{} - var retval *SamplingStrategyResponse - if retval, err2 = p.handler.GetSamplingStrategy(ctx, args.ServiceName); err2 != nil { + if retval, err2 := p.handler.GetSamplingStrategy(ctx, args.ServiceName); err2 != nil { tickerCancel() - if err2 == thrift.ErrAbandonRequest { + err = thrift.WrapTException(err2) + if errors.Is(err2, thrift.ErrAbandonRequest) { return false, thrift.WrapTException(err2) } - x := thrift.NewTApplicationException(thrift.INTERNAL_ERROR, "Internal error processing getSamplingStrategy: " + err2.Error()) - oprot.WriteMessageBegin(ctx, "getSamplingStrategy", thrift.EXCEPTION, seqId) - x.Write(ctx, oprot) - oprot.WriteMessageEnd(ctx) - oprot.Flush(ctx) - return true, thrift.WrapTException(err2) + if errors.Is(err2, context.Canceled) { + if err := context.Cause(ctx); errors.Is(err, thrift.ErrAbandonRequest) { + return false, thrift.WrapTException(err) + } + } + _exc9 := thrift.NewTApplicationException(thrift.INTERNAL_ERROR, "Internal error processing getSamplingStrategy: " + err2.Error()) + if err2 := oprot.WriteMessageBegin(ctx, "getSamplingStrategy", thrift.EXCEPTION, seqId); err2 != nil { + _write_err8 = thrift.WrapTException(err2) + } + if err2 := _exc9.Write(ctx, oprot); _write_err8 == nil && err2 != nil { + _write_err8 = thrift.WrapTException(err2) + } + if err2 := oprot.WriteMessageEnd(ctx); _write_err8 == nil && err2 != nil { + _write_err8 = thrift.WrapTException(err2) + } + if err2 := oprot.Flush(ctx); _write_err8 == nil && err2 != nil { + _write_err8 = thrift.WrapTException(err2) + } + if _write_err8 != nil { + return false, thrift.WrapTException(_write_err8) + } + return true, err } else { result.Success = retval } tickerCancel() - if err2 = oprot.WriteMessageBegin(ctx, "getSamplingStrategy", thrift.REPLY, seqId); err2 != nil { - err = thrift.WrapTException(err2) + if err2 := oprot.WriteMessageBegin(ctx, "getSamplingStrategy", thrift.REPLY, seqId); err2 != nil { + _write_err8 = thrift.WrapTException(err2) } - if err2 = result.Write(ctx, oprot); err == nil && err2 != nil { - err = thrift.WrapTException(err2) + if err2 := result.Write(ctx, oprot); _write_err8 == nil && err2 != nil { + _write_err8 = thrift.WrapTException(err2) } - if err2 = oprot.WriteMessageEnd(ctx); err == nil && err2 != nil { - err = thrift.WrapTException(err2) + if err2 := oprot.WriteMessageEnd(ctx); _write_err8 == nil && err2 != nil { + _write_err8 = thrift.WrapTException(err2) } - if err2 = oprot.Flush(ctx); err == nil && err2 != nil { - err = thrift.WrapTException(err2) + if err2 := oprot.Flush(ctx); _write_err8 == nil && err2 != nil { + _write_err8 = thrift.WrapTException(err2) } - if err != nil { - return + if _write_err8 != nil { + return false, thrift.WrapTException(_write_err8) } return true, err } diff --git a/thrift-gen/zipkincore/GoUnusedProtection__.go b/thrift-gen/zipkincore/GoUnusedProtection__.go index ebf43018fe7..440071d1c4b 100644 --- a/thrift-gen/zipkincore/GoUnusedProtection__.go +++ b/thrift-gen/zipkincore/GoUnusedProtection__.go @@ -1,4 +1,4 @@ -// Code generated by Thrift Compiler (0.14.1). DO NOT EDIT. +// Code generated by Thrift Compiler (0.19.0). DO NOT EDIT. package zipkincore diff --git a/thrift-gen/zipkincore/zipkincore-consts.go b/thrift-gen/zipkincore/zipkincore-consts.go index 8b6e02cd2d8..47cdd5ab52d 100644 --- a/thrift-gen/zipkincore/zipkincore-consts.go +++ b/thrift-gen/zipkincore/zipkincore-consts.go @@ -1,21 +1,28 @@ -// Code generated by Thrift Compiler (0.14.1). DO NOT EDIT. +// Code generated by Thrift Compiler (0.19.0). DO NOT EDIT. package zipkincore -import( +import ( "bytes" "context" + "errors" "fmt" "time" - "github.com/apache/thrift/lib/go/thrift" + thrift "github.com/apache/thrift/lib/go/thrift" + "strings" + "regexp" ) // (needed to ensure safety because of naive import list construction.) var _ = thrift.ZERO var _ = fmt.Printf +var _ = errors.New var _ = context.Background var _ = time.Now var _ = bytes.Equal +// (needed by validator.) +var _ = strings.Contains +var _ = regexp.MatchString const CLIENT_SEND = "cs" const CLIENT_RECV = "cr" diff --git a/thrift-gen/zipkincore/zipkincore.go b/thrift-gen/zipkincore/zipkincore.go index 71e89125c7b..aff9edfed41 100644 --- a/thrift-gen/zipkincore/zipkincore.go +++ b/thrift-gen/zipkincore/zipkincore.go @@ -1,23 +1,29 @@ -// Code generated by Thrift Compiler (0.14.1). DO NOT EDIT. +// Code generated by Thrift Compiler (0.19.0). DO NOT EDIT. package zipkincore -import( +import ( "bytes" "context" "database/sql/driver" "errors" "fmt" "time" - "github.com/apache/thrift/lib/go/thrift" + thrift "github.com/apache/thrift/lib/go/thrift" + "strings" + "regexp" ) // (needed to ensure safety because of naive import list construction.) var _ = thrift.ZERO var _ = fmt.Printf +var _ = errors.New var _ = context.Background var _ = time.Now var _ = bytes.Equal +// (needed by validator.) +var _ = strings.Contains +var _ = regexp.MatchString type AnnotationType int64 const ( @@ -322,6 +328,9 @@ func (p *Endpoint) String() string { return fmt.Sprintf("Endpoint(%+v)", *p) } +func (p *Endpoint) Validate() error { + return nil +} // An annotation is similar to a log statement. It includes a host field which // allows these events to be attributed properly, and also aggregatable. // @@ -513,6 +522,9 @@ func (p *Annotation) String() string { return fmt.Sprintf("Annotation(%+v)", *p) } +func (p *Annotation) Validate() error { + return nil +} // Binary annotations are tags applied to a Span to give it context. For // example, a binary annotation of "http.uri" could the path to a resource in a // RPC call. @@ -754,6 +766,9 @@ func (p *BinaryAnnotation) String() string { return fmt.Sprintf("BinaryAnnotation(%+v)", *p) } +func (p *BinaryAnnotation) Validate() error { + return nil +} // A trace is a series of spans (often RPC calls) which form a latency tree. // // The root span is where trace_id = id and parent_id = Nil. The root span is @@ -1335,6 +1350,9 @@ func (p *Span) String() string { return fmt.Sprintf("Span(%+v)", *p) } +func (p *Span) Validate() error { + return nil +} // Attributes: // - Ok type Response struct { @@ -1441,6 +1459,9 @@ func (p *Response) String() string { return fmt.Sprintf("Response(%+v)", *p) } +func (p *Response) Validate() error { + return nil +} type ZipkinCollector interface { // Parameters: // - Spans @@ -1544,9 +1565,9 @@ type zipkinCollectorProcessorSubmitZipkinBatch struct { } func (p *zipkinCollectorProcessorSubmitZipkinBatch) Process(ctx context.Context, seqId int32, iprot, oprot thrift.TProtocol) (success bool, err thrift.TException) { + var _write_err9 error args := ZipkinCollectorSubmitZipkinBatchArgs{} - var err2 error - if err2 = args.Read(ctx, iprot); err2 != nil { + if err2 := args.Read(ctx, iprot); err2 != nil { iprot.ReadMessageEnd(ctx) x := thrift.NewTApplicationException(thrift.PROTOCOL_ERROR, err2.Error()) oprot.WriteMessageBegin(ctx, "submitZipkinBatch", thrift.EXCEPTION, seqId) @@ -1560,13 +1581,13 @@ func (p *zipkinCollectorProcessorSubmitZipkinBatch) Process(ctx context.Context, tickerCancel := func() {} // Start a goroutine to do server side connectivity check. if thrift.ServerConnectivityCheckInterval > 0 { - var cancel context.CancelFunc - ctx, cancel = context.WithCancel(ctx) - defer cancel() + var cancel context.CancelCauseFunc + ctx, cancel = context.WithCancelCause(ctx) + defer cancel(nil) var tickerCtx context.Context tickerCtx, tickerCancel = context.WithCancel(context.Background()) defer tickerCancel() - go func(ctx context.Context, cancel context.CancelFunc) { + go func(ctx context.Context, cancel context.CancelCauseFunc) { ticker := time.NewTicker(thrift.ServerConnectivityCheckInterval) defer ticker.Stop() for { @@ -1575,7 +1596,7 @@ func (p *zipkinCollectorProcessorSubmitZipkinBatch) Process(ctx context.Context, return case <-ticker.C: if !iprot.Transport().IsOpen() { - cancel() + cancel(thrift.ErrAbandonRequest) return } } @@ -1584,36 +1605,52 @@ func (p *zipkinCollectorProcessorSubmitZipkinBatch) Process(ctx context.Context, } result := ZipkinCollectorSubmitZipkinBatchResult{} - var retval []*Response - if retval, err2 = p.handler.SubmitZipkinBatch(ctx, args.Spans); err2 != nil { + if retval, err2 := p.handler.SubmitZipkinBatch(ctx, args.Spans); err2 != nil { tickerCancel() - if err2 == thrift.ErrAbandonRequest { + err = thrift.WrapTException(err2) + if errors.Is(err2, thrift.ErrAbandonRequest) { return false, thrift.WrapTException(err2) } - x := thrift.NewTApplicationException(thrift.INTERNAL_ERROR, "Internal error processing submitZipkinBatch: " + err2.Error()) - oprot.WriteMessageBegin(ctx, "submitZipkinBatch", thrift.EXCEPTION, seqId) - x.Write(ctx, oprot) - oprot.WriteMessageEnd(ctx) - oprot.Flush(ctx) - return true, thrift.WrapTException(err2) + if errors.Is(err2, context.Canceled) { + if err := context.Cause(ctx); errors.Is(err, thrift.ErrAbandonRequest) { + return false, thrift.WrapTException(err) + } + } + _exc10 := thrift.NewTApplicationException(thrift.INTERNAL_ERROR, "Internal error processing submitZipkinBatch: " + err2.Error()) + if err2 := oprot.WriteMessageBegin(ctx, "submitZipkinBatch", thrift.EXCEPTION, seqId); err2 != nil { + _write_err9 = thrift.WrapTException(err2) + } + if err2 := _exc10.Write(ctx, oprot); _write_err9 == nil && err2 != nil { + _write_err9 = thrift.WrapTException(err2) + } + if err2 := oprot.WriteMessageEnd(ctx); _write_err9 == nil && err2 != nil { + _write_err9 = thrift.WrapTException(err2) + } + if err2 := oprot.Flush(ctx); _write_err9 == nil && err2 != nil { + _write_err9 = thrift.WrapTException(err2) + } + if _write_err9 != nil { + return false, thrift.WrapTException(_write_err9) + } + return true, err } else { result.Success = retval } tickerCancel() - if err2 = oprot.WriteMessageBegin(ctx, "submitZipkinBatch", thrift.REPLY, seqId); err2 != nil { - err = thrift.WrapTException(err2) + if err2 := oprot.WriteMessageBegin(ctx, "submitZipkinBatch", thrift.REPLY, seqId); err2 != nil { + _write_err9 = thrift.WrapTException(err2) } - if err2 = result.Write(ctx, oprot); err == nil && err2 != nil { - err = thrift.WrapTException(err2) + if err2 := result.Write(ctx, oprot); _write_err9 == nil && err2 != nil { + _write_err9 = thrift.WrapTException(err2) } - if err2 = oprot.WriteMessageEnd(ctx); err == nil && err2 != nil { - err = thrift.WrapTException(err2) + if err2 := oprot.WriteMessageEnd(ctx); _write_err9 == nil && err2 != nil { + _write_err9 = thrift.WrapTException(err2) } - if err2 = oprot.Flush(ctx); err == nil && err2 != nil { - err = thrift.WrapTException(err2) + if err2 := oprot.Flush(ctx); _write_err9 == nil && err2 != nil { + _write_err9 = thrift.WrapTException(err2) } - if err != nil { - return + if _write_err9 != nil { + return false, thrift.WrapTException(_write_err9) } return true, err } @@ -1681,11 +1718,11 @@ func (p *ZipkinCollectorSubmitZipkinBatchArgs) ReadField1(ctx context.Context, tSlice := make([]*Span, 0, size) p.Spans = tSlice for i := 0; i < size; i ++ { - _elem9 := &Span{} - if err := _elem9.Read(ctx, iprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", _elem9), err) + _elem11 := &Span{} + if err := _elem11.Read(ctx, iprot); err != nil { + return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", _elem11), err) } - p.Spans = append(p.Spans, _elem9) + p.Spans = append(p.Spans, _elem11) } if err := iprot.ReadListEnd(ctx); err != nil { return thrift.PrependError("error reading list end: ", err) @@ -1797,11 +1834,11 @@ func (p *ZipkinCollectorSubmitZipkinBatchResult) ReadField0(ctx context.Context tSlice := make([]*Response, 0, size) p.Success = tSlice for i := 0; i < size; i ++ { - _elem10 := &Response{} - if err := _elem10.Read(ctx, iprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", _elem10), err) + _elem12 := &Response{} + if err := _elem12.Read(ctx, iprot); err != nil { + return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", _elem12), err) } - p.Success = append(p.Success, _elem10) + p.Success = append(p.Success, _elem12) } if err := iprot.ReadListEnd(ctx); err != nil { return thrift.PrependError("error reading list end: ", err)