diff --git a/satellite/metainfo/endpoint.go b/satellite/metainfo/endpoint.go index 85479f63f..a96696ff9 100644 --- a/satellite/metainfo/endpoint.go +++ b/satellite/metainfo/endpoint.go @@ -12,14 +12,12 @@ import ( "go.uber.org/zap" "storj.io/common/encryption" - "storj.io/common/eventstat" "storj.io/common/lrucache" "storj.io/common/macaroon" "storj.io/common/pb" "storj.io/common/rpc/rpcstatus" "storj.io/common/signing" "storj.io/common/storj" - "storj.io/private/debug" "storj.io/storj/satellite/accounting" "storj.io/storj/satellite/attribution" "storj.io/storj/satellite/buckets" @@ -80,15 +78,6 @@ type Endpoint struct { defaultRS *pb.RedundancyScheme config Config versionCollector *versionCollector - top endpointTop -} - -// endpointTop represents in-memory counter stats. -// Cached info can be retrieved from the /mon monitoring endpoint. -type endpointTop struct { - Project eventstat.Sink - Partner eventstat.Sink - UserAgent eventstat.Sink } // NewEndpoint creates new metainfo endpoint instance. @@ -139,11 +128,6 @@ func NewEndpoint(log *zap.Logger, buckets *buckets.Service, metabaseDB *metabase defaultRS: defaultRSScheme, config: config, versionCollector: newVersionCollector(log), - top: endpointTop{ - Project: debug.Top.NewTagCounter("auth_request_project", "project"), - Partner: debug.Top.NewTagCounter("auth_request_partner", "partner"), - UserAgent: debug.Top.NewTagCounter("auth_request_user_agent", "agent"), - }, }, nil } diff --git a/satellite/metainfo/validation.go b/satellite/metainfo/validation.go index a05bab9b6..bfc773c11 100644 --- a/satellite/metainfo/validation.go +++ b/satellite/metainfo/validation.go @@ -11,6 +11,7 @@ import ( "strconv" "time" + "github.com/jtolio/eventkit" "github.com/zeebo/errs" "go.uber.org/zap" "golang.org/x/time/rate" @@ -35,6 +36,8 @@ var ( ipRegexp = regexp.MustCompile(`^(([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\.){3}([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])$`) ) +var ek = eventkit.Package() + func getAPIKey(ctx context.Context, header *pb.RequestHeader) (key *macaroon.APIKey, err error) { defer mon.Task()(&ctx)(&err) if header != nil { @@ -128,11 +131,15 @@ func (endpoint *Endpoint) validateBasic(ctx context.Context, header *pb.RequestH return nil, nil, rpcstatus.Error(rpcstatus.PermissionDenied, "Unauthorized API credentials") } - endpoint.top.Project(keyInfo.ProjectID.String()) - endpoint.top.Partner(keyInfo.PartnerID.String()) + userAgent := "" if keyInfo.UserAgent != nil { - endpoint.top.UserAgent(string(keyInfo.UserAgent)) + userAgent = string(keyInfo.UserAgent) } + ek.Event("auth", + eventkit.String("user-agent", userAgent), + eventkit.String("project", keyInfo.ProjectID.String()), + eventkit.String("partner", keyInfo.PartnerID.String()), + ) if err = endpoint.checkRate(ctx, keyInfo.ProjectID); err != nil { endpoint.log.Debug("rate check failed", zap.Error(err)) diff --git a/satellite/metainfo/validation_test.go b/satellite/metainfo/validation_test.go index ac006f797..bed8cf1d6 100644 --- a/satellite/metainfo/validation_test.go +++ b/satellite/metainfo/validation_test.go @@ -48,11 +48,6 @@ func TestEndpoint_validateAuthN(t *testing.T) { endpoint := Endpoint{ log: zaptest.NewLogger(t), apiKeys: &mockAPIKeys{secret: secret}, - top: endpointTop{ - Project: func(name string) {}, - Partner: func(name string) {}, - UserAgent: func(name string) {}, - }, } now := time.Now()