Skip to content
This repository has been archived by the owner on Jul 19, 2023. It is now read-only.

Commit

Permalink
Implement a fake debuginfo server
Browse files Browse the repository at this point in the history
  • Loading branch information
simonswine committed Sep 13, 2022
1 parent 05b4713 commit 57052ae
Show file tree
Hide file tree
Showing 2 changed files with 50 additions and 0 deletions.
47 changes: 47 additions & 0 deletions pkg/debuginfo/fake.go
Original file line number Diff line number Diff line change
@@ -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
}
3 changes: 3 additions & 0 deletions pkg/fire/modules.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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"
Expand Down Expand Up @@ -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
}
Expand Down

0 comments on commit 57052ae

Please sign in to comment.