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

Commit

Permalink
zoekt: update to 3ce1f2b24c80b3dea89d237600d2b0879342ed1b (#56525)
Browse files Browse the repository at this point in the history
(cherry picked from commit b32587f)

 Conflicts:
	internal/search/backend/zoekt.go
  • Loading branch information
ggilmore committed Sep 12, 2023
1 parent a08566b commit 8de0421
Show file tree
Hide file tree
Showing 14 changed files with 580 additions and 70 deletions.
4 changes: 2 additions & 2 deletions deps.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -6241,8 +6241,8 @@ def go_dependencies():
name = "com_github_sourcegraph_zoekt",
build_file_proto_mode = "disable_global",
importpath = "github.com/sourcegraph/zoekt",
sum = "h1:kqYHOCtMTKwkM2F6AbpelFE+Olt2qqJyxBCNps1oIjQ=",
version = "v0.0.0-20230825171831-40a9a23bb04b",
sum = "h1:jz6dUd7NKcULoGoC0KcsdWw1dh58S8/cM50rl1K2b00=",
version = "v0.0.0-20230912152407-3ce1f2b24c80",
)

go_repository(
Expand Down
571 changes: 517 additions & 54 deletions doc/admin/observability/dashboards.md

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -538,7 +538,7 @@ require (
github.com/sourcegraph/conc v0.2.0
github.com/sourcegraph/mountinfo v0.0.0-20230106004439-7026e28cef67
github.com/sourcegraph/sourcegraph/monitoring v0.0.0-20230124144931-b2d81b1accb6
github.com/sourcegraph/zoekt v0.0.0-20230825171831-40a9a23bb04b
github.com/sourcegraph/zoekt v0.0.0-20230912152407-3ce1f2b24c80
github.com/spf13/cobra v1.7.0 // indirect
github.com/spf13/pflag v1.0.5 // indirect
github.com/stretchr/objx v0.5.0 // indirect
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -2026,8 +2026,8 @@ github.com/sourcegraph/scip v0.3.1-0.20230627154934-45df7f6d33fc h1:o+eq0cjVV3B5
github.com/sourcegraph/scip v0.3.1-0.20230627154934-45df7f6d33fc/go.mod h1:7ZKAtLIUmiMvOIgG5LMcBxdtBXVa0v2GWC4Hm1ASYQ0=
github.com/sourcegraph/yaml v1.0.1-0.20200714132230-56936252f152 h1:z/MpntplPaW6QW95pzcAR/72Z5TWDyDnSo0EOcyij9o=
github.com/sourcegraph/yaml v1.0.1-0.20200714132230-56936252f152/go.mod h1:GIjDIg/heH5DOkXY3YJ/wNhfHsQHoXGjl8G8amsYQ1I=
github.com/sourcegraph/zoekt v0.0.0-20230825171831-40a9a23bb04b h1:kqYHOCtMTKwkM2F6AbpelFE+Olt2qqJyxBCNps1oIjQ=
github.com/sourcegraph/zoekt v0.0.0-20230825171831-40a9a23bb04b/go.mod h1:3rlMtZdLxkc7P1R14qWq20fWDDyRQwL6TmAqH81WQ4M=
github.com/sourcegraph/zoekt v0.0.0-20230912152407-3ce1f2b24c80 h1:jz6dUd7NKcULoGoC0KcsdWw1dh58S8/cM50rl1K2b00=
github.com/sourcegraph/zoekt v0.0.0-20230912152407-3ce1f2b24c80/go.mod h1:49Y2VVQuWxaSUXeFphZnZX+/zVy2G/sqd+cg/oqQTBk=
github.com/spaolacci/murmur3 v0.0.0-20180118202830-f09979ecbc72/go.mod h1:JwIasOWyU6f++ZhiEuf87xNszmSA2myDM2Kzu9HwQUA=
github.com/spaolacci/murmur3 v1.1.0/go.mod h1:JwIasOWyU6f++ZhiEuf87xNszmSA2myDM2Kzu9HwQUA=
github.com/spf13/afero v0.0.0-20170901052352-ee1bd8ee15a1/go.mod h1:j4pytiNVoe2o6bmDsKpLACNPDBIoEAkihy7loJ1B0CQ=
Expand Down
2 changes: 1 addition & 1 deletion internal/search/backend/BUILD.bazel

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

18 changes: 10 additions & 8 deletions internal/search/backend/grpc.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import (
"io"

"github.com/sourcegraph/zoekt"
v1 "github.com/sourcegraph/zoekt/grpc/v1"
proto "github.com/sourcegraph/zoekt/grpc/protos/zoekt/webserver/v1"
"github.com/sourcegraph/zoekt/query"
"google.golang.org/grpc/codes"
"google.golang.org/grpc/status"
Expand Down Expand Up @@ -55,7 +55,7 @@ func (c *switchableZoektGRPCClient) String() string {
// zoektGRPCClient is a zoekt.Streamer that uses gRPC for its RPC layer
type zoektGRPCClient struct {
endpoint string
client v1.WebserverServiceClient
client proto.WebserverServiceClient

// We capture the dial error to return it lazily.
// This allows us to treat Dial as infallible, which is
Expand All @@ -70,9 +70,11 @@ func (z *zoektGRPCClient) StreamSearch(ctx context.Context, q query.Q, opts *zoe
return z.dialErr
}

req := &v1.SearchRequest{
Query: query.QToProto(q),
Opts: opts.ToProto(),
req := &proto.StreamSearchRequest{
Request: &proto.SearchRequest{
Query: query.QToProto(q),
Opts: opts.ToProto(),
},
}

ss, err := z.client.StreamSearch(ctx, req)
Expand All @@ -89,7 +91,7 @@ func (z *zoektGRPCClient) StreamSearch(ctx context.Context, q query.Q, opts *zoe
var repoURLS map[string]string // We don't use repoURLs in Sourcegraph
var lineFragments map[string]string // We don't use lineFragments in Sourcegraph

sender.Send(zoekt.SearchResultFromProto(msg, repoURLS, lineFragments))
sender.Send(zoekt.SearchResultFromProto(msg.GetResponseChunk(), repoURLS, lineFragments))
}
}

Expand All @@ -98,7 +100,7 @@ func (z *zoektGRPCClient) Search(ctx context.Context, q query.Q, opts *zoekt.Sea
return nil, z.dialErr
}

req := &v1.SearchRequest{
req := &proto.SearchRequest{
Query: query.QToProto(q),
Opts: opts.ToProto(),
}
Expand All @@ -121,7 +123,7 @@ func (z *zoektGRPCClient) List(ctx context.Context, q query.Q, opts *zoekt.ListO
return nil, z.dialErr
}

req := &v1.ListRequest{
req := &proto.ListRequest{
Query: query.QToProto(q),
Opts: opts.ToProto(),
}
Expand Down
4 changes: 2 additions & 2 deletions internal/search/backend/zoekt.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import (

"github.com/sourcegraph/log"
"github.com/sourcegraph/zoekt"
"github.com/sourcegraph/zoekt/grpc/v1"
proto "github.com/sourcegraph/zoekt/grpc/protos/zoekt/webserver/v1"
"github.com/sourcegraph/zoekt/rpc"
zoektstream "github.com/sourcegraph/zoekt/stream"
"google.golang.org/grpc"
Expand Down Expand Up @@ -125,7 +125,7 @@ func ZoektDialGRPC(endpoint string) zoekt.Streamer {
)
return NewMeteredSearcher(endpoint, &zoektGRPCClient{
endpoint: endpoint,
client: v1.NewWebserverServiceClient(conn),
client: proto.NewWebserverServiceClient(conn),
dialErr: err,
})
}
Expand Down
1 change: 1 addition & 0 deletions monitoring/definitions/frontend.go
Original file line number Diff line number Diff line change
Expand Up @@ -418,6 +418,7 @@ func Frontend() *monitoring.Dashboard {
shared.GRPCInternalErrorMetricsOptions{
HumanServiceName: "frontend",
RawGRPCServiceName: grpcZoektConfigurationServiceName,
Namespace: "", // intentionally empty

MethodFilterRegex: fmt.Sprintf("${%s:regex}", grpcMethodVariable.Name),
}, monitoring.ObservableOwnerSearchCore),
Expand Down
1 change: 1 addition & 0 deletions monitoring/definitions/git_server.go
Original file line number Diff line number Diff line change
Expand Up @@ -560,6 +560,7 @@ func GitServer() *monitoring.Dashboard {
shared.GRPCInternalErrorMetricsOptions{
HumanServiceName: "gitserver",
RawGRPCServiceName: grpcServiceName,
Namespace: "src",

MethodFilterRegex: fmt.Sprintf("${%s:regex}", grpcMethodVariable.Name),
}, monitoring.ObservableOwnerSearchCore),
Expand Down
1 change: 1 addition & 0 deletions monitoring/definitions/repo_updater.go
Original file line number Diff line number Diff line change
Expand Up @@ -588,6 +588,7 @@ func RepoUpdater() *monitoring.Dashboard {
shared.GRPCInternalErrorMetricsOptions{
HumanServiceName: "repo_updater",
RawGRPCServiceName: grpcServiceName,
Namespace: "src",

MethodFilterRegex: fmt.Sprintf("${%s:regex}", grpcMethodVariable.Name),
}, monitoring.ObservableOwnerRepoManagement),
Expand Down
1 change: 1 addition & 0 deletions monitoring/definitions/searcher.go
Original file line number Diff line number Diff line change
Expand Up @@ -235,6 +235,7 @@ regularly above 0 it is a sign for further investigation.`,
shared.GRPCInternalErrorMetricsOptions{
HumanServiceName: "searcher",
RawGRPCServiceName: grpcServiceName,
Namespace: "src",

MethodFilterRegex: fmt.Sprintf("${%s:regex}", grpcMethodVariable.Name),
}, monitoring.ObservableOwnerSearchCore),
Expand Down
7 changes: 7 additions & 0 deletions monitoring/definitions/shared/grpc.go
Original file line number Diff line number Diff line change
Expand Up @@ -289,13 +289,20 @@ type GRPCInternalErrorMetricsOptions struct {
//
// Example: (Search | Exec)
MethodFilterRegex string

// Namespace is the Prometheus metrics namespace for metrics emitted by this service.
Namespace string
}

// NewGRPCInternalErrorMetricsGroup creates a Group containing metrics that track "internal" gRPC errors.
func NewGRPCInternalErrorMetricsGroup(opts GRPCInternalErrorMetricsOptions, owner monitoring.ObservableOwner) monitoring.Group {
metric := func(base string, labelFilters ...string) string {
m := base

if opts.Namespace != "" {
m = fmt.Sprintf("%s_%s", opts.Namespace, m)
}

if len(labelFilters) > 0 {
m = fmt.Sprintf("%s{%s}", m, strings.Join(labelFilters, ","))
}
Expand Down
1 change: 1 addition & 0 deletions monitoring/definitions/symbols.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ func Symbols() *monitoring.Dashboard {
shared.GRPCInternalErrorMetricsOptions{
HumanServiceName: containerName,
RawGRPCServiceName: grpcServiceName,
Namespace: "src",

MethodFilterRegex: fmt.Sprintf("${%s:regex}", grpcMethodVariable.Name),
}, monitoring.ObservableOwnerCodeIntel),
Expand Down
33 changes: 33 additions & 0 deletions monitoring/definitions/zoekt.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,11 @@ func Zoekt() *monitoring.Dashboard {
indexServerContainerName = "zoekt-indexserver"
webserverContainerName = "zoekt-webserver"
bundledContainerName = "indexed-search"
grpcServiceName = "zoekt.webserver.v1.WebserverService"
)

grpcMethodVariable := shared.GRPCMethodVariable(grpcServiceName)

return &monitoring.Dashboard{
Name: "zoekt",
Title: "Zoekt",
Expand All @@ -33,6 +36,17 @@ func Zoekt() *monitoring.Dashboard {
},
Multi: true,
},
{
Label: "Webserver Instance",
Name: "webserver_instance",
OptionsLabelValues: monitoring.ContainerVariableOptionsLabelValues{
Query: "zoekt_webserver_watchdog_errors",
LabelName: "instance",
ExampleOption: "zoekt-webserver-0:6072",
},
Multi: true,
},
grpcMethodVariable,
},
Groups: []monitoring.Group{
{
Expand Down Expand Up @@ -1055,6 +1069,25 @@ func Zoekt() *monitoring.Dashboard {
},
},
},

shared.NewGRPCServerMetricsGroup(
shared.GRPCServerMetricsOptions{
HumanServiceName: "zoekt-webserver",
RawGRPCServiceName: grpcServiceName,

MethodFilterRegex: fmt.Sprintf("${%s:regex}", grpcMethodVariable.Name),
InstanceFilterRegex: `${webserver_instance:regex}`,
}, monitoring.ObservableOwnerSearchCore),

shared.NewGRPCInternalErrorMetricsGroup(
shared.GRPCInternalErrorMetricsOptions{
HumanServiceName: "zoekt-webserver",
RawGRPCServiceName: grpcServiceName,
Namespace: "", // deliberately empty

MethodFilterRegex: fmt.Sprintf("${%s:regex}", grpcMethodVariable.Name),
}, monitoring.ObservableOwnerSearchCore),

shared.NewDiskMetricsGroup(
shared.DiskMetricsGroupOptions{
DiskTitle: "data",
Expand Down

0 comments on commit 8de0421

Please sign in to comment.