From 57052ae56e8213a2b2b628255dfd9eeff2f323ba Mon Sep 17 00:00:00 2001 From: Christian Simon Date: Tue, 13 Sep 2022 16:43:18 +0100 Subject: [PATCH] Implement a fake debuginfo server --- pkg/debuginfo/fake.go | 47 +++++++++++++++++++++++++++++++++++++++++++ pkg/fire/modules.go | 3 +++ 2 files changed, 50 insertions(+) create mode 100644 pkg/debuginfo/fake.go diff --git a/pkg/debuginfo/fake.go b/pkg/debuginfo/fake.go new file mode 100644 index 000000000..4515c339c --- /dev/null +++ b/pkg/debuginfo/fake.go @@ -0,0 +1,47 @@ +package debuginfo + +import ( + "context" + + "github.com/go-kit/log" + "github.com/go-kit/log/level" + + parcadebuginfov1 "github.com/parca-dev/parca/gen/proto/go/parca/debuginfo/v1alpha1" +) + +type fakeDebugInfo struct { + parcadebuginfov1.UnimplementedDebugInfoServiceServer + + logger log.Logger +} + +func New(logger log.Logger) parcadebuginfov1.DebugInfoServiceServer { + return &fakeDebugInfo{ + logger: logger, + } +} + +// Exists returns true if the given build_id has debug info uploaded for it. +func (f *fakeDebugInfo) Exists(ctx context.Context, req *parcadebuginfov1.ExistsRequest) (*parcadebuginfov1.ExistsResponse, error) { + level.Warn(f.logger).Log("msg", "received exists request", "buildid", req.GetBuildId(), "hash", req.GetHash()) + + return &parcadebuginfov1.ExistsResponse{ + Exists: false, + }, nil +} + +// Upload ingests debug info for a given build_id +func (f *fakeDebugInfo) Upload(u parcadebuginfov1.DebugInfoService_UploadServer) error { + req, err := u.Recv() + if err != nil { + return err + } + level.Warn(f.logger).Log("msg", "received upload", "buildid", req.GetInfo().GetBuildId(), "hash", req.GetInfo().GetHash()) + + return nil +} + +// Download returns the debug info for a given build_id. +func (_ *fakeDebugInfo) Download(*parcadebuginfov1.DownloadRequest, parcadebuginfov1.DebugInfoService_DownloadServer) error { + return nil +} diff --git a/pkg/fire/modules.go b/pkg/fire/modules.go index fe8452016..b72cd3828 100644 --- a/pkg/fire/modules.go +++ b/pkg/fire/modules.go @@ -13,6 +13,7 @@ import ( "github.com/grafana/dskit/ring" "github.com/grafana/dskit/services" grpcgw "github.com/grpc-ecosystem/grpc-gateway/v2/runtime" + parcadebuginfov1 "github.com/parca-dev/parca/gen/proto/go/parca/debuginfo/v1alpha1" parcastorev1 "github.com/parca-dev/parca/gen/proto/go/parca/profilestore/v1alpha1" "github.com/pkg/errors" "github.com/prometheus/client_golang/prometheus" @@ -24,6 +25,7 @@ import ( "golang.org/x/net/http2/h2c" "github.com/grafana/fire/pkg/agent" + "github.com/grafana/fire/pkg/debuginfo" "github.com/grafana/fire/pkg/distributor" "github.com/grafana/fire/pkg/firedb" agentv1 "github.com/grafana/fire/pkg/gen/agent/v1" @@ -112,6 +114,7 @@ func (f *Fire) initDistributor() (services.Service, error) { // register parca compatible profile store parcastorev1.RegisterProfileStoreServiceServer(f.Server.GRPC, d.ParcaProfileStore()) + parcadebuginfov1.RegisterDebugInfoServiceServer(f.Server.GRPC, debuginfo.New(f.logger)) return d, nil }