Skip to content

Commit

Permalink
raft: add a raft tracing library
Browse files Browse the repository at this point in the history
This change adds a tracing library for raft messages. Specifically it
allows registering an entry either directly or due to a remote raft
message and then possibly tracing the message at various key points.
When the message is finally unregistered, it will dump the trace to the
log. Additionally, on a local message, it will add the trace to the
context that is passed in.

Fixes: #104035

Release note: None
  • Loading branch information
andrewbaptist committed Oct 18, 2024
1 parent 01213eb commit fc7487e
Show file tree
Hide file tree
Showing 5 changed files with 864 additions and 0 deletions.
3 changes: 3 additions & 0 deletions pkg/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -269,6 +269,7 @@ ALL_TESTS = [
"//pkg/kv/kvserver/protectedts:protectedts_test",
"//pkg/kv/kvserver/raftentry:raftentry_test",
"//pkg/kv/kvserver/raftlog:raftlog_test",
"//pkg/kv/kvserver/rafttrace:rafttrace_test",
"//pkg/kv/kvserver/raftutil:raftutil_test",
"//pkg/kv/kvserver/rangefeed:rangefeed_test",
"//pkg/kv/kvserver/rangelog:rangelog_test",
Expand Down Expand Up @@ -1513,6 +1514,8 @@ GO_TARGETS = [
"//pkg/kv/kvserver/raftentry:raftentry_test",
"//pkg/kv/kvserver/raftlog:raftlog",
"//pkg/kv/kvserver/raftlog:raftlog_test",
"//pkg/kv/kvserver/rafttrace:rafttrace",
"//pkg/kv/kvserver/rafttrace:rafttrace_test",
"//pkg/kv/kvserver/raftutil:raftutil",
"//pkg/kv/kvserver/raftutil:raftutil_test",
"//pkg/kv/kvserver/rangefeed:rangefeed",
Expand Down
38 changes: 38 additions & 0 deletions pkg/kv/kvserver/rafttrace/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test")

go_library(
name = "rafttrace",
srcs = ["rafttrace.go"],
importpath = "github.com/cockroachdb/cockroach/pkg/kv/kvserver/rafttrace",
visibility = ["//visibility:public"],
deps = [
"//pkg/kv/kvpb",
"//pkg/kv/kvserver/kvserverpb",
"//pkg/raft",
"//pkg/raft/raftpb",
"//pkg/settings",
"//pkg/settings/cluster",
"//pkg/util/log",
"//pkg/util/syncutil",
"//pkg/util/tracing",
"//pkg/util/tracing/tracingpb",
"@com_github_cockroachdb_logtags//:logtags",
"@com_github_cockroachdb_redact//:redact",
],
)

go_test(
name = "rafttrace_test",
srcs = ["rafttrace_test.go"],
embed = [":rafttrace"],
deps = [
"//pkg/kv/kvpb",
"//pkg/kv/kvserver/kvserverpb",
"//pkg/raft/raftpb",
"//pkg/settings/cluster",
"//pkg/testutils",
"//pkg/util/tracing",
"//pkg/util/tracing/tracingpb",
"@com_github_stretchr_testify//require",
],
)
Loading

0 comments on commit fc7487e

Please sign in to comment.