diff options
author | Patrick Bajao <ebajao@gitlab.com> | 2021-07-23 04:33:49 +0000 |
---|---|---|
committer | Patrick Bajao <ebajao@gitlab.com> | 2021-07-23 04:33:49 +0000 |
commit | 1eadd3a61f3955354b4041fd284ba50e2a17864a (patch) | |
tree | 3357d32d99d9185faf8056ea4662a82b72855122 /internal/handler/exec.go | |
parent | 05ae5680633c1de1cc369c592f3bbcce13ee7375 (diff) | |
parent | fb7b9417842c66e12466e658e861e19619dfcd9a (diff) | |
download | gitlab-shell-1eadd3a61f3955354b4041fd284ba50e2a17864a.tar.gz |
Merge branch 'id-switch-logging-to-labkit' into 'main'
Switch to labkit/log for logging functionality
See merge request gitlab-org/gitlab-shell!498
Diffstat (limited to 'internal/handler/exec.go')
-rw-r--r-- | internal/handler/exec.go | 18 |
1 files changed, 9 insertions, 9 deletions
diff --git a/internal/handler/exec.go b/internal/handler/exec.go index fd0ea89..89856f7 100644 --- a/internal/handler/exec.go +++ b/internal/handler/exec.go @@ -8,19 +8,20 @@ import ( grpc_middleware "github.com/grpc-ecosystem/go-grpc-middleware" grpc_prometheus "github.com/grpc-ecosystem/go-grpc-prometheus" - log "github.com/sirupsen/logrus" "google.golang.org/grpc" "google.golang.org/grpc/metadata" - gitalyauth "gitlab.com/gitlab-org/gitaly/v14/auth" - "gitlab.com/gitlab-org/gitaly/v14/client" - pb "gitlab.com/gitlab-org/gitaly/v14/proto/go/gitalypb" "gitlab.com/gitlab-org/gitlab-shell/internal/config" "gitlab.com/gitlab-org/gitlab-shell/internal/gitlabnet/accessverifier" "gitlab.com/gitlab-org/gitlab-shell/internal/sshenv" - "gitlab.com/gitlab-org/labkit/correlation" + + gitalyauth "gitlab.com/gitlab-org/gitaly/v14/auth" + "gitlab.com/gitlab-org/gitaly/v14/client" + pb "gitlab.com/gitlab-org/gitaly/v14/proto/go/gitalypb" grpccorrelation "gitlab.com/gitlab-org/labkit/correlation/grpc" grpctracing "gitlab.com/gitlab-org/labkit/tracing/grpc" + "gitlab.com/gitlab-org/labkit/correlation" + "gitlab.com/gitlab-org/labkit/log" ) // GitalyHandlerFunc implementations are responsible for making @@ -75,7 +76,6 @@ func (gc *GitalyCommand) PrepareContext(ctx context.Context, repository *pb.Repo func (gc *GitalyCommand) LogExecution(ctx context.Context, repository *pb.Repository, response *accessverifier.Response, env sshenv.Env) { fields := log.Fields{ "command": gc.ServiceName, - "correlation_id": correlation.ExtractFromContext(ctx), "gl_project_path": repository.GlProjectPath, "gl_repository": repository.GlRepository, "user_id": response.UserId, @@ -86,7 +86,7 @@ func (gc *GitalyCommand) LogExecution(ctx context.Context, repository *pb.Reposi "gl_key_id": response.KeyId, } - log.WithFields(fields).Info("executing git command") + log.WithContextFields(ctx, fields).Info("executing git command") } func withOutgoingMetadata(ctx context.Context, features map[string]string) context.Context { @@ -108,9 +108,9 @@ func getConn(ctx context.Context, gc *GitalyCommand) (*grpc.ClientConn, error) { serviceName := correlation.ExtractClientNameFromContext(ctx) if serviceName == "" { - log.Warn("No gRPC service name specified, defaulting to gitlab-shell-unknown") - serviceName = "gitlab-shell-unknown" + + log.WithFields(log.Fields{"service_name": serviceName}).Warn("No gRPC service name specified, defaulting to gitlab-shell-unknown") } serviceName = fmt.Sprintf("%s-%s", serviceName, gc.ServiceName) |