Skip to content
This repository was archived by the owner on Sep 30, 2024. It is now read-only.

Commit 8a0b342

Browse files
authored
gitserver: grpc: create exhaustive logger for repository service (#62158)
This PR builds on https://github.com/sourcegraph/sourcegraph/pull/61270, and adds the request logging funcionality to the repository grpc server in gitserver. ## Test plan Local testing: Ran `env SRC_GITSERVER_EXHAUSTIVE_LOGGING_ENABLED=true SRC_LOG_SCOPE_LEVEL=gitserver.gRPCRequestLogger=debug sg start` locally, and saw the following output from the logger in my terminal (note that specifically the repository service is mentioned): ``` [ gitserver-0] DEBUG gitserver.gRPCRequestLogger internal/server_grpc_logger.go:46 Handled FetchRepository RPC {"server": "gitserver.v1.GitserverRepositoryService", "method": "FetchRepository", "status": "OK", "traceID": "67f1aa837367fa7ea72b164e70a67419", "duration": "1.068438833s", "request": {"repoName": "github.com/sgtest/megarepo"}} ```
1 parent 7e2f77f commit 8a0b342

File tree

4 files changed

+146
-40
lines changed

4 files changed

+146
-40
lines changed

CHANGELOG.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,8 @@ All notable changes to Sourcegraph are documented in this file.
2121
- Added syntax highlighting for the [Pkl](https://pkl-lang.org/) configuration language. [#61478](https://github.com/sourcegraph/sourcegraph/pull/61478)
2222
- New `rev:at.time()` search filter that allows you to search a branch at a point in time. [#61513](https://github.com/sourcegraph/sourcegraph/pull/61513)
2323
- "cody.contextFilters" field to the site config. Admins can set include and exclude rules to define which repositories Cody can use as context in its requests to third-party LLMs. [#61101](https://github.com/sourcegraph/sourcegraph/pull/61101), [#61641](https://github.com/sourcegraph/sourcegraph/pull/61641)
24-
- Added exhaustive logging for all gRPC requests sent to gitserver. This feature is off by default, and can be enabled by setting the `SRC_GITSERVER_EXHAUSTIVE_LOGGING_ENABLED` environment variable to `true`. [#61270](https://github.com/sourcegraph/sourcegraph/pull/61270)
24+
- Added exhaustive logging for all gRPC requests sent to gitserver service gitserver. This feature is off by default, and can be enabled by setting the `SRC_GITSERVER_EXHAUSTIVE_LOGGING_ENABLED` environment variable to `true`. [#61270](https://github.com/sourcegraph/sourcegraph/pull/61270)
25+
- Added exhaustive logging for all gRPC requests sent to the repository service in gitserver. This feature is off by default, and can be enabled by setting the `SRC_GITSERVER_EXHAUSTIVE_LOGGING_ENABLED` environment variable to `true`. [#62158](https://github.com/sourcegraph/sourcegraph/pull/62158)
2526

2627
### Changed
2728

cmd/gitserver/internal/repositoryservice.go

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,14 +15,29 @@ import (
1515
"github.com/sourcegraph/sourcegraph/lib/errors"
1616
)
1717

18-
func NewRepositoryServiceServer(server *Server) proto.GitserverRepositoryServiceServer {
19-
return &repositoryServiceServer{
18+
type GRPCRepositoryServiceConfig struct {
19+
ExhaustiveRequestLoggingEnabled bool
20+
}
21+
22+
func NewRepositoryServiceServer(server *Server, config *GRPCRepositoryServiceConfig) proto.GitserverRepositoryServiceServer {
23+
var srv proto.GitserverRepositoryServiceServer = &repositoryServiceServer{
2024
logger: server.logger,
2125
db: server.db,
2226
hostname: server.hostname,
2327
svc: server,
2428
fs: server.fs,
2529
}
30+
31+
if config.ExhaustiveRequestLoggingEnabled {
32+
logger := server.logger.Scoped("gRPCRequestLogger")
33+
34+
srv = &loggingRepositoryServiceServer{
35+
base: srv,
36+
logger: logger,
37+
}
38+
}
39+
40+
return srv
2641
}
2742

2843
type repositoryServiceServer struct {

0 commit comments

Comments
 (0)