diff options
author | Pavlo Strokov <pstrokov@gitlab.com> | 2020-09-08 13:07:22 +0300 |
---|---|---|
committer | Zeger-Jan van de Weg <git@zjvandeweg.nl> | 2020-09-08 13:07:22 +0300 |
commit | d87f0757c880a28b20338fd9533495688eeece95 (patch) | |
tree | 35f26f53712adee29f8c92c36a57e00c0b249bcc /client/dial.go | |
parent | 785bebf7fb05c6c4457c75c011a01b1bede3f3a9 (diff) |
Pass correlation_id over to gitaly-ssh
When gitaly-ssh is called it doesn't receive correlation_id.
That is why it is hard to understand what to what chain of calls
this call is related.
correlation_id passed as env var 'CORRELATION_ID' to gitaly-ssh
process. So it would be picked by it and used in outgoing requests.
In order to cover other missing parts where correlation_id should
be passed the client.DialContext method includes interceptors for it
by default. If correlation_id is present in the context.Context used
to invoke the method it will be passed to the remote.
Part of: https://gitlab.com/gitlab-org/gitaly/-/issues/3047
Diffstat (limited to 'client/dial.go')
-rw-r--r-- | client/dial.go | 24 |
1 files changed, 18 insertions, 6 deletions
diff --git a/client/dial.go b/client/dial.go index 4fce2ac5b..d60138268 100644 --- a/client/dial.go +++ b/client/dial.go @@ -8,6 +8,8 @@ import ( "time" gitaly_x509 "gitlab.com/gitlab-org/gitaly/internal/x509" + grpccorrelation "gitlab.com/gitlab-org/labkit/correlation/grpc" + grpctracing "gitlab.com/gitlab-org/labkit/tracing/grpc" "google.golang.org/grpc" "google.golang.org/grpc/credentials" "google.golang.org/grpc/keepalive" @@ -74,12 +76,22 @@ func DialContext(ctx context.Context, rawAddress string, connOpts []grpc.DialOpt ) } - // grpc.KeepaliveParams must be specified at least as large as what is allowed by the - // server-side grpc.KeepaliveEnforcementPolicy - connOpts = append(connOpts, grpc.WithKeepaliveParams(keepalive.ClientParameters{ - Time: 20 * time.Second, - PermitWithoutStream: true, - })) + connOpts = append(connOpts, + // grpc.KeepaliveParams must be specified at least as large as what is allowed by the + // server-side grpc.KeepaliveEnforcementPolicy + grpc.WithKeepaliveParams(keepalive.ClientParameters{ + Time: 20 * time.Second, + PermitWithoutStream: true, + }), + grpc.WithChainUnaryInterceptor( + grpctracing.UnaryClientTracingInterceptor(), + grpccorrelation.UnaryClientCorrelationInterceptor(), + ), + grpc.WithChainStreamInterceptor( + grpctracing.StreamClientTracingInterceptor(), + grpccorrelation.StreamClientCorrelationInterceptor(), + ), + ) conn, err := grpc.DialContext(ctx, canonicalAddress, connOpts...) if err != nil { |