@@ -574,7 +574,7 @@ func (r *topicStreamReaderImpl) checkCommitRange(commitRange topicreadercommon.C
574
574
func (r * topicStreamReaderImpl ) send (msg rawtopicreader.ClientMessage ) error {
575
575
err := r .stream .Send (msg )
576
576
if err != nil {
577
- trace .TopicOnReaderError (r .cfg .Trace , r .readConnectionID , err )
577
+ trace .TopicOnReaderError (r .cfg .Trace , & r . ctx , r .readConnectionID , err )
578
578
_ = r .CloseWithError (r .ctx , err )
579
579
}
580
580
@@ -613,7 +613,7 @@ func (r *topicStreamReaderImpl) setStarted() error {
613
613
func (r * topicStreamReaderImpl ) initSession () (err error ) {
614
614
initMessage := topicreadercommon .CreateInitMessage (r .cfg .Consumer , r .cfg .ReadSelectors )
615
615
616
- onDone := trace .TopicOnReaderInit (r .cfg .Trace , r .readConnectionID , initMessage )
616
+ onDone := trace .TopicOnReaderInit (r .cfg .Trace , & r . ctx , r .readConnectionID , initMessage )
617
617
defer func () {
618
618
onDone (r .readConnectionID , err )
619
619
}()
@@ -664,9 +664,9 @@ func (r *topicStreamReaderImpl) readMessagesLoop(ctx context.Context) {
664
664
for {
665
665
serverMessage , err := r .stream .Recv ()
666
666
if err != nil {
667
- trace .TopicOnReaderError (r .cfg .Trace , r .readConnectionID , err )
667
+ trace .TopicOnReaderError (r .cfg .Trace , & ctx , r .readConnectionID , err )
668
668
if errors .Is (err , rawtopicreader .ErrUnexpectedMessageType ) {
669
- trace .TopicOnReaderUnknownGrpcMessage (r .cfg .Trace , r .readConnectionID , err )
669
+ trace .TopicOnReaderUnknownGrpcMessage (r .cfg .Trace , & ctx , r .readConnectionID , err )
670
670
// new messages can be added to protocol, it must be backward compatible to old programs
671
671
// and skip message is safe
672
672
continue
@@ -687,7 +687,7 @@ func (r *topicStreamReaderImpl) readMessagesLoop(ctx context.Context) {
687
687
688
688
switch m := serverMessage .(type ) {
689
689
case * rawtopicreader.ReadResponse :
690
- if err = r .onReadResponse (m ); err != nil {
690
+ if err = r .onReadResponse (ctx , m ); err != nil {
691
691
_ = r .CloseWithError (ctx , err )
692
692
}
693
693
case * rawtopicreader.StartPartitionSessionRequest :
@@ -703,7 +703,7 @@ func (r *topicStreamReaderImpl) readMessagesLoop(ctx context.Context) {
703
703
return
704
704
}
705
705
case * rawtopicreader.CommitOffsetResponse :
706
- if err = r .onCommitResponse (m ); err != nil {
706
+ if err = r .onCommitResponse (ctx , m ); err != nil {
707
707
_ = r .CloseWithError (ctx , err )
708
708
709
709
return
@@ -714,6 +714,7 @@ func (r *topicStreamReaderImpl) readMessagesLoop(ctx context.Context) {
714
714
default :
715
715
trace .TopicOnReaderUnknownGrpcMessage (
716
716
r .cfg .Trace ,
717
+ & ctx ,
717
718
r .readConnectionID ,
718
719
xerrors .WithStackTrace (xerrors .Wrap (fmt .Errorf (
719
720
"ydb: unexpected message type in stream reader: %v" ,
@@ -753,7 +754,7 @@ func (r *topicStreamReaderImpl) dataRequestLoop(ctx context.Context) {
753
754
}
754
755
755
756
resCapacity := r .addRestBufferBytes (sum )
756
- trace .TopicOnReaderSentDataRequest (r .cfg .Trace , r .readConnectionID , sum , resCapacity )
757
+ trace .TopicOnReaderSentDataRequest (r .cfg .Trace , & ctx , r .readConnectionID , sum , resCapacity )
757
758
if err := r .sendDataRequest (sum ); err != nil {
758
759
return
759
760
}
@@ -791,9 +792,9 @@ func (r *topicStreamReaderImpl) updateTokenLoop(ctx context.Context) {
791
792
}
792
793
}
793
794
794
- func (r * topicStreamReaderImpl ) onReadResponse (msg * rawtopicreader.ReadResponse ) (err error ) {
795
+ func (r * topicStreamReaderImpl ) onReadResponse (ctx context. Context , msg * rawtopicreader.ReadResponse ) (err error ) {
795
796
resCapacity := r .addRestBufferBytes (- msg .BytesSize )
796
- onDone := trace .TopicOnReaderReceiveDataResponse (r .cfg .Trace , r .readConnectionID , resCapacity , msg )
797
+ onDone := trace .TopicOnReaderReceiveDataResponse (r .cfg .Trace , & ctx , r .readConnectionID , resCapacity , msg )
797
798
defer func () {
798
799
onDone (err )
799
800
}()
@@ -813,7 +814,7 @@ func (r *topicStreamReaderImpl) onReadResponse(msg *rawtopicreader.ReadResponse)
813
814
}
814
815
815
816
func (r * topicStreamReaderImpl ) CloseWithError (ctx context.Context , reason error ) (closeErr error ) {
816
- onDone := trace .TopicOnReaderClose (r .cfg .Trace , r .readConnectionID , reason )
817
+ onDone := trace .TopicOnReaderClose (r .cfg .Trace , & ctx , r .readConnectionID , reason )
817
818
defer onDone (closeErr )
818
819
819
820
isFirstClose := false
@@ -853,7 +854,7 @@ func (r *topicStreamReaderImpl) CloseWithError(ctx context.Context, reason error
853
854
return closeErr
854
855
}
855
856
856
- func (r * topicStreamReaderImpl ) onCommitResponse (msg * rawtopicreader.CommitOffsetResponse ) error {
857
+ func (r * topicStreamReaderImpl ) onCommitResponse (ctx context. Context , msg * rawtopicreader.CommitOffsetResponse ) error {
857
858
for i := range msg .PartitionsCommittedOffsets {
858
859
commit := & msg .PartitionsCommittedOffsets [i ]
859
860
partition , err := r .sessionController .Get (commit .PartitionSessionID )
@@ -864,6 +865,7 @@ func (r *topicStreamReaderImpl) onCommitResponse(msg *rawtopicreader.CommitOffse
864
865
865
866
trace .TopicOnReaderCommittedNotify (
866
867
r .cfg .Trace ,
868
+ & ctx ,
867
869
r .readConnectionID ,
868
870
partition .Topic ,
869
871
partition .PartitionID ,
@@ -880,10 +882,11 @@ func (r *topicStreamReaderImpl) onCommitResponse(msg *rawtopicreader.CommitOffse
880
882
func (r * topicStreamReaderImpl ) updateToken (ctx context.Context ) {
881
883
onUpdateToken := trace .TopicOnReaderUpdateToken (
882
884
r .cfg .Trace ,
885
+ & ctx ,
883
886
r .readConnectionID ,
884
887
)
885
888
token , err := r .cfg .Cred .Token (ctx )
886
- onSent := onUpdateToken (len (token ), err )
889
+ onSent := onUpdateToken (& ctx , len (token ), err )
887
890
if err != nil {
888
891
return
889
892
}
0 commit comments