1
1
package log
2
2
3
3
import (
4
- "context"
5
4
"time"
6
5
7
6
"github.com/ydb-platform/ydb-go-genproto/protos/Ydb_Topic"
@@ -25,7 +24,7 @@ func internalTopic(l Logger, d trace.Detailer) (t trace.Topic) {
25
24
if d .Details ()& trace .TopicReaderStreamLifeCycleEvents == 0 {
26
25
return nil
27
26
}
28
- ctx := with (context . Background () , TRACE , "ydb" , "topic" , "reader" , "reconnect" )
27
+ ctx := with (* info . Context , TRACE , "ydb" , "topic" , "reader" , "reconnect" )
29
28
start := time .Now ()
30
29
l .Log (ctx , "topic reader reconnect starting..." )
31
30
@@ -40,7 +39,7 @@ func internalTopic(l Logger, d trace.Detailer) (t trace.Topic) {
40
39
if d .Details ()& trace .TopicReaderStreamLifeCycleEvents == 0 {
41
40
return
42
41
}
43
- ctx := with (context . Background () , TRACE , "ydb" , "topic" , "reader" , "reconnect" , "request" )
42
+ ctx := with (* info . Context , TRACE , "ydb" , "topic" , "reader" , "reconnect" , "request" )
44
43
l .Log (ctx , "topic reader reconnect request" ,
45
44
kv .NamedError ("reason" , info .Reason ),
46
45
kv .Bool ("was_sent" , info .WasSent ),
@@ -52,7 +51,7 @@ func internalTopic(l Logger, d trace.Detailer) (t trace.Topic) {
52
51
if d .Details ()& trace .TopicReaderPartitionEvents == 0 {
53
52
return nil
54
53
}
55
- ctx := with (context . Background () , TRACE , "ydb" , "topic" , "reader" , "partition" , "read" , "start" , "response" )
54
+ ctx := with (* info . PartitionContext , TRACE , "ydb" , "topic" , "reader" , "partition" , "read" , "start" , "response" )
56
55
start := time .Now ()
57
56
l .Log (ctx , "topic reader start partition read response starting..." ,
58
57
kv .String ("topic" , info .Topic ),
@@ -97,7 +96,7 @@ func internalTopic(l Logger, d trace.Detailer) (t trace.Topic) {
97
96
if d .Details ()& trace .TopicReaderPartitionEvents == 0 {
98
97
return nil
99
98
}
100
- ctx := with (context . Background () , TRACE , "ydb" , "topic" , "reader" , "partition" , "read" , "stop" , "response" )
99
+ ctx := with (info . PartitionContext , TRACE , "ydb" , "topic" , "reader" , "partition" , "read" , "stop" , "response" )
101
100
start := time .Now ()
102
101
l .Log (ctx , "topic reader stop partition read response starting..." ,
103
102
kv .String ("reader_connection_id" , info .ReaderConnectionID ),
@@ -133,7 +132,7 @@ func internalTopic(l Logger, d trace.Detailer) (t trace.Topic) {
133
132
if d .Details ()& trace .TopicReaderStreamEvents == 0 {
134
133
return nil
135
134
}
136
- ctx := with (* info .RequestContext , TRACE , "ydb" , "topic" , "reader" , "commit" )
135
+ ctx := with (* info .Context , TRACE , "ydb" , "topic" , "reader" , "commit" )
137
136
start := time .Now ()
138
137
l .Log (ctx , "topic reader commit starting..." ,
139
138
kv .String ("topic" , info .Topic ),
@@ -170,7 +169,7 @@ func internalTopic(l Logger, d trace.Detailer) (t trace.Topic) {
170
169
if d .Details ()& trace .TopicReaderStreamEvents == 0 {
171
170
return nil
172
171
}
173
- ctx := with (context . Background () , TRACE , "ydb" , "topic" , "reader" , "send" , "commit" , "message" )
172
+ ctx := with (* info . Context , TRACE , "ydb" , "topic" , "reader" , "send" , "commit" , "message" )
174
173
start := time .Now ()
175
174
176
175
commitInfo := info .CommitsInfo .GetCommitsInfo ()
@@ -211,7 +210,7 @@ func internalTopic(l Logger, d trace.Detailer) (t trace.Topic) {
211
210
if d .Details ()& trace .TopicReaderStreamEvents == 0 {
212
211
return
213
212
}
214
- ctx := with (context . Background () , TRACE , "ydb" , "topic" , "reader" , "committed" , "notify" )
213
+ ctx := with (* info . Context , TRACE , "ydb" , "topic" , "reader" , "committed" , "notify" )
215
214
l .Log (ctx , "topic reader received commit ack" ,
216
215
kv .String ("reader_connection_id" , info .ReaderConnectionID ),
217
216
kv .String ("topic" , info .Topic ),
@@ -224,7 +223,7 @@ func internalTopic(l Logger, d trace.Detailer) (t trace.Topic) {
224
223
if d .Details ()& trace .TopicReaderStreamEvents == 0 {
225
224
return nil
226
225
}
227
- ctx := with (context . Background () , TRACE , "ydb" , "topic" , "reader" , "close" )
226
+ ctx := with (* info . Context , TRACE , "ydb" , "topic" , "reader" , "close" )
228
227
start := time .Now ()
229
228
l .Log (ctx , "topic reader close starting..." ,
230
229
kv .String ("reader_connection_id" , info .ReaderConnectionID ),
@@ -253,7 +252,7 @@ func internalTopic(l Logger, d trace.Detailer) (t trace.Topic) {
253
252
if d .Details ()& trace .TopicReaderStreamEvents == 0 {
254
253
return nil
255
254
}
256
- ctx := with (context . Background () , TRACE , "ydb" , "topic" , "reader" , "init" )
255
+ ctx := with (* info . Context , TRACE , "ydb" , "topic" , "reader" , "init" )
257
256
start := time .Now ()
258
257
l .Log (ctx , "topic reader init starting..." ,
259
258
kv .String ("pre_init_reader_connection_id" , info .PreInitReaderConnectionID ),
@@ -284,7 +283,7 @@ func internalTopic(l Logger, d trace.Detailer) (t trace.Topic) {
284
283
if d .Details ()& trace .TopicReaderStreamEvents == 0 {
285
284
return
286
285
}
287
- ctx := with (context . Background () , TRACE , "ydb" , "topic" , "reader" , "error" )
286
+ ctx := with (* info . Context , TRACE , "ydb" , "topic" , "reader" , "error" )
288
287
l .Log (WithLevel (ctx , INFO ), "topic reader has grpc stream error" ,
289
288
kv .Error (info .Error ),
290
289
kv .String ("reader_connection_id" , info .ReaderConnectionID ),
@@ -299,7 +298,7 @@ func internalTopic(l Logger, d trace.Detailer) (t trace.Topic) {
299
298
if d .Details ()& trace .TopicReaderStreamEvents == 0 {
300
299
return nil
301
300
}
302
- ctx := with (context . Background () , TRACE , "ydb" , "topic" , "reader" , "update" , "token" )
301
+ ctx := with (* info . Context , TRACE , "ydb" , "topic" , "reader" , "update" , "token" )
303
302
start := time .Now ()
304
303
l .Log (ctx , "topic reader token update starting..." ,
305
304
kv .String ("reader_connection_id" , info .ReaderConnectionID ),
@@ -347,7 +346,7 @@ func internalTopic(l Logger, d trace.Detailer) (t trace.Topic) {
347
346
if d .Details ()& trace .TopicReaderMessageEvents == 0 {
348
347
return
349
348
}
350
- ctx := with (context . Background () , TRACE , "ydb" , "topic" , "reader" , "sent" , "data" , "request" )
349
+ ctx := with (* info . Context , TRACE , "ydb" , "topic" , "reader" , "sent" , "data" , "request" )
351
350
l .Log (ctx , "topic reader sent data request" ,
352
351
kv .String ("reader_connection_id" , info .ReaderConnectionID ),
353
352
kv .Int ("request_bytes" , info .RequestBytes ),
@@ -360,7 +359,7 @@ func internalTopic(l Logger, d trace.Detailer) (t trace.Topic) {
360
359
if d .Details ()& trace .TopicReaderMessageEvents == 0 {
361
360
return nil
362
361
}
363
- ctx := with (context . Background () , TRACE , "ydb" , "topic" , "reader" , "receive" , "data" , "response" )
362
+ ctx := with (* info . Context , TRACE , "ydb" , "topic" , "reader" , "receive" , "data" , "response" )
364
363
start := time .Now ()
365
364
partitionsCount , batchesCount , messagesCount := info .DataResponse .GetPartitionBatchMessagesCounts ()
366
365
l .Log (ctx , "topic reader data response received, process starting..." ,
@@ -404,7 +403,7 @@ func internalTopic(l Logger, d trace.Detailer) (t trace.Topic) {
404
403
if d .Details ()& trace .TopicReaderMessageEvents == 0 {
405
404
return nil
406
405
}
407
- ctx := with (* info .RequestContext , TRACE , "ydb" , "topic" , "reader" , "read" , "messages" )
406
+ ctx := with (* info .Context , TRACE , "ydb" , "topic" , "reader" , "read" , "messages" )
408
407
start := time .Now ()
409
408
l .Log (ctx , "topic read messages, waiting..." ,
410
409
kv .Int ("min_count" , info .MinCount ),
@@ -436,7 +435,7 @@ func internalTopic(l Logger, d trace.Detailer) (t trace.Topic) {
436
435
if d .Details ()& trace .TopicReaderMessageEvents == 0 {
437
436
return
438
437
}
439
- ctx := with (context . Background () , TRACE , "ydb" , "topic" , "reader" , "unknown" , "grpc" , "message" )
438
+ ctx := with (* info . Context , TRACE , "ydb" , "topic" , "reader" , "unknown" , "grpc" , "message" )
440
439
l .Log (WithLevel (ctx , INFO ), "topic reader received unknown grpc message" ,
441
440
kv .Error (info .Error ),
442
441
kv .String ("reader_connection_id" , info .ReaderConnectionID ),
@@ -648,7 +647,7 @@ func internalTopic(l Logger, d trace.Detailer) (t trace.Topic) {
648
647
if d .Details ()& trace .TopicWriterStreamLifeCycleEvents == 0 {
649
648
return nil
650
649
}
651
- ctx := with (context . Background () , TRACE , "ydb" , "topic" , "writer" , "reconnect" )
650
+ ctx := with (* info . Context , TRACE , "ydb" , "topic" , "writer" , "reconnect" )
652
651
start := time .Now ()
653
652
l .Log (ctx , "connect to topic writer stream starting..." ,
654
653
kv .String ("topic" , info .Topic ),
@@ -694,7 +693,7 @@ func internalTopic(l Logger, d trace.Detailer) (t trace.Topic) {
694
693
if d .Details ()& trace .TopicWriterStreamLifeCycleEvents == 0 {
695
694
return nil
696
695
}
697
- ctx := with (context . Background () , TRACE , "ydb" , "topic" , "writer" , "stream" , "init" )
696
+ ctx := with (* info . Context , TRACE , "ydb" , "topic" , "writer" , "stream" , "init" )
698
697
start := time .Now ()
699
698
l .Log (ctx , "topic writer init stream starting..." ,
700
699
kv .String ("topic" , info .Topic ),
@@ -734,7 +733,7 @@ func internalTopic(l Logger, d trace.Detailer) (t trace.Topic) {
734
733
start := time .Now ()
735
734
736
735
return func (doneInfo trace.TopicOnWriterBeforeCommitTransactionDoneInfo ) {
737
- ctx := with (* info .Ctx , TRACE , "ydb" , "topic" , "writer" , "beforecommit" )
736
+ ctx := with (* info .Context , TRACE , "ydb" , "topic" , "writer" , "beforecommit" )
738
737
l .Log (ctx , "topic writer wait of flush messages before commit transaction" ,
739
738
kv .String ("kqp_session_id" , info .KqpSessionID ),
740
739
kv .String ("topic_session_id_start" , info .TopicSessionID ),
@@ -750,7 +749,7 @@ func internalTopic(l Logger, d trace.Detailer) (t trace.Topic) {
750
749
start := time .Now ()
751
750
752
751
return func (doneInfo trace.TopicOnWriterAfterFinishTransactionDoneInfo ) {
753
- ctx := with (context . Background () , TRACE , "ydb" , "topic" , "writer" , "beforecommit" )
752
+ ctx := with (* info . Context , TRACE , "ydb" , "topic" , "writer" , "beforecommit" )
754
753
l .Log (ctx , "topic writer close writer after transaction finished" ,
755
754
kv .String ("kqp_session_id" , info .SessionID ),
756
755
kv .String ("tx_id" , info .TransactionID ),
@@ -762,7 +761,7 @@ func internalTopic(l Logger, d trace.Detailer) (t trace.Topic) {
762
761
if d .Details ()& trace .TopicWriterStreamLifeCycleEvents == 0 {
763
762
return nil
764
763
}
765
- ctx := with (context . Background () , TRACE , "ydb" , "topic" , "writer" , "close" )
764
+ ctx := with (* info . Context , TRACE , "ydb" , "topic" , "writer" , "close" )
766
765
start := time .Now ()
767
766
l .Log (ctx , "topic writer close starting..." ,
768
767
kv .String ("writer_instance_id" , info .WriterInstanceID ),
@@ -793,7 +792,7 @@ func internalTopic(l Logger, d trace.Detailer) (t trace.Topic) {
793
792
if d .Details ()& trace .TopicWriterStreamEvents == 0 {
794
793
return nil
795
794
}
796
- ctx := with (context . Background () , TRACE , "ydb" , "topic" , "writer" , "compress" , "messages" )
795
+ ctx := with (* info . Context , TRACE , "ydb" , "topic" , "writer" , "compress" , "messages" )
797
796
start := time .Now ()
798
797
l .Log (ctx , "topic writer compress messages starting..." ,
799
798
kv .String ("writer_instance_id" , info .WriterInstanceID ),
@@ -836,7 +835,7 @@ func internalTopic(l Logger, d trace.Detailer) (t trace.Topic) {
836
835
if d .Details ()& trace .TopicWriterStreamEvents == 0 {
837
836
return nil
838
837
}
839
- ctx := with (context . Background () , TRACE , "ydb" , "topic" , "writer" , "send" , "messages" )
838
+ ctx := with (* info . Context , TRACE , "ydb" , "topic" , "writer" , "send" , "messages" )
840
839
start := time .Now ()
841
840
l .Log (ctx , "topic writer send messages starting..." ,
842
841
kv .String ("writer_instance_id" , info .WriterInstanceID ),
@@ -874,7 +873,7 @@ func internalTopic(l Logger, d trace.Detailer) (t trace.Topic) {
874
873
return
875
874
}
876
875
acks := info .Acks .GetAcks ()
877
- ctx := with (context . Background () , DEBUG , "ydb" , "topic" , "writer" , "receive" , "result" )
876
+ ctx := with (* info . Context , DEBUG , "ydb" , "topic" , "writer" , "receive" , "result" )
878
877
l .Log (ctx , "topic writer received result from server" ,
879
878
kv .String ("writer_instance_id" , info .WriterInstanceID ),
880
879
kv .String ("session_id" , info .SessionID ),
@@ -895,7 +894,7 @@ func internalTopic(l Logger, d trace.Detailer) (t trace.Topic) {
895
894
return
896
895
}
897
896
898
- ctx := with (context . Background () , TRACE , "ydb" , "topic" , "writer" , "grpc" )
897
+ ctx := with (* info . Context , TRACE , "ydb" , "topic" , "writer" , "grpc" )
899
898
l .Log (
900
899
ctx , "topic writer sent grpc message (message body and metadata are removed)" ,
901
900
kv .String ("topic_stream_internal_id" , info .TopicStreamInternalID ),
@@ -911,7 +910,7 @@ func internalTopic(l Logger, d trace.Detailer) (t trace.Topic) {
911
910
return
912
911
}
913
912
914
- ctx := with (context . Background () , TRACE , "ydb" , "topic" , "writer" , "grpc" )
913
+ ctx := with (* info . Context , TRACE , "ydb" , "topic" , "writer" , "grpc" )
915
914
l .Log (
916
915
ctx , "topic writer received grpc message (message body and metadata are removed)" ,
917
916
kv .String ("topic_stream_internal_id" , info .TopicStreamInternalID ),
@@ -926,7 +925,7 @@ func internalTopic(l Logger, d trace.Detailer) (t trace.Topic) {
926
925
if d .Details ()& trace .TopicWriterStreamEvents == 0 {
927
926
return
928
927
}
929
- ctx := with (context . Background () , DEBUG , "ydb" , "topic" , "writer" , "read" , "unknown" , "grpc" , "message" )
928
+ ctx := with (* info . Context , DEBUG , "ydb" , "topic" , "writer" , "read" , "unknown" , "grpc" , "message" )
930
929
l .Log (ctx , "topic writer receive unknown grpc message from server" ,
931
930
kv .Error (info .Error ),
932
931
kv .String ("writer_instance_id" , info .WriterInstanceID ),
0 commit comments