Skip to content

Commit

Permalink
add stats
Browse files Browse the repository at this point in the history
  • Loading branch information
spikelu2016 committed Mar 19, 2024
1 parent 30d88a0 commit dafabcd
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions internal/authenticator/authenticator.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import (

"github.com/bricks-cloud/bricksllm/internal/encrypter"
internal_errors "github.com/bricks-cloud/bricksllm/internal/errors"
"github.com/bricks-cloud/bricksllm/internal/stats"

"github.com/bricks-cloud/bricksllm/internal/key"
"github.com/bricks-cloud/bricksllm/internal/provider"
Expand Down Expand Up @@ -171,6 +172,10 @@ func (a *Authenticator) AuthenticateHttpRequest(req *http.Request) (*key.Respons
hash := encrypter.Encrypt(raw)

key := a.kms.GetKey(hash)
if key != nil {
stats.Incr("bricksllm.authenticator.authenticate_http_request.found_key_from_memdb", nil, 1)
}

if key == nil {
key, err = a.ks.GetKeyByHash(hash)
if err != nil {
Expand All @@ -181,6 +186,10 @@ func (a *Authenticator) AuthenticateHttpRequest(req *http.Request) (*key.Respons

return nil, nil, err
}

if key != nil {
stats.Incr("bricksllm.authenticator.authenticate_http_request.found_key_from_db", nil, 1)
}
}

if key == nil {
Expand Down

0 comments on commit dafabcd

Please sign in to comment.