Skip to content

Add minimal but super verbose logging to gitserver

Warren Gifford requested to merge mrn/minimal-gitserver-logging into main

Created by: mrnugget

This makes gitserver log requests. And if it's an /exec request it also logs the cmd, repo, args:

[      gitserver] INFO server server/server.go:2827 request {"actor": 1, "path": "/exec", "params": {}, "repo": "github.com/sourcegraph/go-diff", "cmd": "rev-parse", "args": ["rev-parse", "9d1f353a285b3094bc33bdae277a19aedabe8b71^0"]}
[      gitserver] INFO server server/server.go:2827 request {"actor": 1, "path": "/exec", "params": {}, "repo": "github.com/sourcegraph/go-diff", "cmd": "ls-tree", "args": ["ls-tree", "--long", "--full-name", "-z", "9d1f353a285b3094bc33bdae277a19aedabe8b71", "--", "go.sum"]}
[      gitserver] INFO server server/server.go:2827 request {"actor": 1, "path": "/exec", "params": {}, "repo": "github.com/sourcegraph/go-diff", "cmd": "show", "args": ["show", "9d1f353a285b3094bc33bdae277a19aedabe8b71:go.sum"]}
[      gitserver] INFO server server/server.go:2827 request {"actor": 1, "path": "/exec", "params": {}, "repo": "github.com/sourcegraph/go-diff", "cmd": "rev-parse", "args": ["rev-parse", "HEAD"]}
[      gitserver] INFO server server/server.go:2827 request {"actor": 1, "path": "/exec", "params": {}, "repo": "github.com/sourcegraph/go-diff", "cmd": "rev-parse", "args": ["rev-parse", "master^0"]}
[      gitserver] INFO server server/server.go:2827 request {"actor": 1, "path": "/exec", "params": {}, "repo": "github.com/sourcegraph/go-diff", "cmd": "ls-tree", "args": ["ls-tree", "--long", "--full-name", "-z", "9d1f353a285b3094bc33bdae277a19aedabe8b71", "--", "go.sum"]}
[      gitserver] INFO server server/server.go:2827 request {"actor": 1, "path": "/exec", "params": {}, "repo": "github.com/sourcegraph/go-diff", "cmd": "ls-tree", "args": ["ls-tree", "--long", "--full-name", "-z", "9d1f353a285b3094bc33bdae277a19aedabe8b71", "--", "go.sum"]}
[      gitserver] INFO server server/server.go:2827 request {"actor": 1, "path": "/exec", "params": {}, "repo": "github.com/sourcegraph/go-diff", "cmd": "rev-parse", "args": ["rev-parse", "9d1f353a285b3094bc33bdae277a19aedabe8b71^0"]}
[      gitserver] INFO server server/server.go:2827 request {"actor": 1, "path": "/exec", "params": {}, "repo": "github.com/sourcegraph/go-diff", "cmd": "ls-tree", "args": ["ls-tree", "--long", "--full-name", "-z", "9d1f353a285b3094bc33bdae277a19aedabe8b71", "--", "go.sum"]}
[      gitserver] INFO server server/server.go:2827 request {"actor": 1, "path": "/exec", "params": {}, "repo": "github.com/sourcegraph/go-diff", "cmd": "blame", "args": ["blame", "-w", "--porcelain", "9d1f353a285b3094bc33bdae277a19aedabe8b71", "--", "go.sum"]}

This is SUPER HACKY: it duplicates the request body, it doesn't handles errors, ...

Test plan

Merge request reports

Loading