Skip to content

Draft: Implement a log server for subprocess logging

Sami Hiltunen requested to merge smh-log-server into master

Gitaly's spawns subprocesses such as gitaly-hooks and gitaly-lfs-smudge. Their logs are not currently output through Gitaly's stdout like all other logs but they rather log into separate log files. This hampers observability as now some logs are in different place than others, and they need separate solutions for log rotation and collection.

This commit implements a log server that solve the above problems by writing the subprocesses' logs through Gitaly's stdout as all other logs. The log server is listening on a Unix socket placed in the runtime directory. The subprocesses will receive the socket's location through an environment variable. They'll then connect to the socket and setup a logger that writes its output into the socket. The log server reads the fully formatted log lines from the connections and outputs them into Gitaly's stdout. This way all of the logs are in the same place and can be handled all the same.

When the feature flag is set, logs from gitaly-hooks for example are printed through Gitaly's stdout and look like

{"component":"gitaly_hooks.log","correlation_id":"01J30HGTP324HSWWFCB2YG02FT","level":"info","msg":"LOG OUTPUT FROM GITALY HOOKS","pid":89220,"time":"2024-07-17T14:28:42.654Z"}

Closes Centralize logging strategy to avoid individual... (#3275)

Merge request reports