File tree Expand file tree Collapse file tree 1 file changed +20
-1
lines changed Expand file tree Collapse file tree 1 file changed +20
-1
lines changed Original file line number Diff line number Diff line change @@ -2,6 +2,9 @@ package query
22
33import (
44 "context"
5+ "os"
6+ "runtime/pprof"
7+ "strconv"
58 "sync/atomic"
69 "time"
710
@@ -22,6 +25,9 @@ import (
2225 "github.com/ydb-platform/ydb-go-sdk/v3/trace"
2326)
2427
28+ // Internals: https://github.com/ydb-platform/ydb-go-sdk/blob/master/VERSIONING.md#internals
29+ var setGoroutineLabelForAttachStream = os .Getenv ("YDB_QUERY_SESSION_ATTACH_STREAM_GOROUTINE_LABEL" ) == "1"
30+
2531type (
2632 Core interface {
2733 query.SessionInfo
@@ -110,6 +116,7 @@ func WithTrace(t *trace.Query) Option {
110116 }
111117}
112118
119+ //nolint:funlen
113120func Open (
114121 ctx context.Context , client Ydb_Query_V1.QueryServiceClient , opts ... Option ,
115122) (_ * sessionCore , finalErr error ) {
@@ -152,7 +159,19 @@ func Open(
152159 core .id = response .GetSessionId ()
153160 core .nodeID = uint32 (response .GetNodeId ())
154161
155- err = core .attach (ctx )
162+ if setGoroutineLabelForAttachStream {
163+ attachRes := make (chan error )
164+ pprof .Do (ctx , pprof .Labels (
165+ "node_id" , strconv .Itoa (int (core .NodeID ())),
166+ ), func (ctx context.Context ) {
167+ go func () {
168+ attachRes <- core .attach (ctx )
169+ }()
170+ })
171+ err = <- attachRes
172+ } else {
173+ err = core .attach (ctx )
174+ }
156175 if err != nil {
157176 _ = core .deleteSession (ctx )
158177
You can’t perform that action at this time.
0 commit comments