rpc: add DRPC Logger integration routing to DEV channel#169813
Draft
cthumuluru-crdb wants to merge 2 commits intocockroachdb:masterfrom
Draft
rpc: add DRPC Logger integration routing to DEV channel#169813cthumuluru-crdb wants to merge 2 commits intocockroachdb:masterfrom
cthumuluru-crdb wants to merge 2 commits intocockroachdb:masterfrom
Conversation
Implement a `drpcLogger` that satisfies the new `drpc.Logger` interface (added upstream in cockroachdb/drpc) and routes DRPC library log messages to CockroachDB's DEV logging channel — the same channel used for gRPC library logs. `Debugf` is routed through `log.Dev.VEventfDepth` at verbosity level 2, so debug messages (buffer flushes, stream lifecycle, pool operations) are suppressed by default and only appear when an operator enables verbose logging via `--verbosity` or `--vmodule`. `Infof`, `Errorf`, and `Fatalf` are routed to their standard `log.Dev` counterparts with proper call depth so that file:line metadata points to the DRPC callsite. The logger is injected into both `NewDRPCServer` (server-side) and `DialDRPC` (client-side pool), and propagated through the entire DRPC stack (manager, stream, wire writer, pool) via DRPC's new options plumbing. Epic: none Release note: None Co-Authored-By: roachdev-claude <roachdev-claude-bot@cockroachlabs.com>
Contributor
|
Merging to
After your PR is submitted to the merge queue, this comment will be automatically updated with its status. If the PR fails, failure details will also be posted here |
|
It looks like your PR touches production code but doesn't add or edit any test code. Did you consider adding tests to your PR? 🦉 Hoot! I am a Blathers, a bot for CockroachDB. My owner is dev-inf. |
Member
Pick up the squashed commit that removes redundant logger fields from Manager, Stream, and Pool (opts.Logger used directly). Co-Authored-By: roachdev-claude <roachdev-claude-bot@cockroachlabs.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Motivation
cockroachdb/drpc#57 adds a structured
drpc.Loggerinterface to replace the oldLog func(error)callback. This PR implements a CockroachDB-side logger that satisfies that interface, routing DRPC library log messages into CockroachDB's logging infrastructure.Changes
drpcLoggerimplementationA
drpcLoggerstruct inpkg/rpcthat satisfiesdrpc.Loggerand routes all output to the DEV logging channel:Debugflog.Dev.VEventfDepth(verbosity 2)--verbosity>=2or--vmoduleInfoflog.Dev.InfofDepthErrorflog.Dev.ErrorfDepthFatalflog.Dev.FatalfDepthThe logger carries a
depthfield so that*Depthcalls report the correct DRPC callsite, not the logger wrapper.Logger injection
The logger is injected at both entry points into the DRPC stack:
NewDRPCServer— server-side, viadrpcserver.Options.LoggerDialDRPC— client-side, viadrpcpool.Options.LoggerFrom there, DRPC propagates the logger internally through the manager, streams, and wire writer.
Linter registration
drpcLoggermethods are registered in thefmtsafelinter allowlist (pkg/testutils/lint/passes/fmtsafe/functions.go) so the format-string safety checker recognizes them as printf-like functions.Design decisions
grpcLoggerinpkg/util/grpcutil/grpc_log.go. Library-internal logs go to DEV; RPC health events go to Health.Debugf— same threshold used for other verbose internal tracing. Keeps default logs clean while allowing operators to enable DRPC debug output for troubleshooting.Debug logging is off by default
The DRPC
drpcdebugbuild tag is not added to CockroachDB's default Bazel tags. Debug-level DRPC logs (buffer flushes, stream lifecycle, pool operations) are compiled out entirely — zero overhead on hot RPC paths.To create a build with DRPC debug logging enabled:
With a debug build, DRPC debug messages can be enabled at runtime via
--verbosity=2or--vmodule="drpc*=2".Infof,Errorf, andFatalfare always active regardless of the build tag — onlyDebugfcallsites are gated.Depends on
drpc.Loggerinterface, replacesLogcallback, removes the deaddrpcdebugpackage, adds compile-time debug guard.Epic: none
Release note: None