Skip to content

Commit

Permalink
Add auth_successful_logins_total
Browse files Browse the repository at this point in the history
  • Loading branch information
fantix committed Mar 8, 2024
1 parent b34ea84 commit 0b3057e
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 1 deletion.
3 changes: 3 additions & 0 deletions docs/reference/http.rst
Expand Up @@ -174,6 +174,9 @@ Auth Extension
``auth_providers``
**Histogram.** Number of Auth providers configured.

``auth_successful_logins_total``
**Counter.** Number of successful logins in the Auth extension.

Errors
^^^^^^

Expand Down
6 changes: 6 additions & 0 deletions edb/server/metrics.py
Expand Up @@ -193,3 +193,9 @@
'Number of Auth providers configured.',
labels=('tenant', 'branch'),
)

auth_successful_logins = registry.new_labeled_counter(
"auth_successful_logins_total",
"Number of successful logins in the Auth extension.",
labels=("tenant",),
)
5 changes: 4 additions & 1 deletion edb/server/protocol/auth_ext/http.py
Expand Up @@ -38,7 +38,7 @@
from edb.common import debug
from edb.common import markup
from edb.ir import statypes
from edb.server import tenant as edbtenant
from edb.server import tenant as edbtenant, metrics
from edb.server.config.types import CompositeConfigType

from . import (
Expand Down Expand Up @@ -1660,6 +1660,9 @@ def _make_session_token(self, identity_id: str) -> str:
claims=claims,
)
session_token.make_signed_token(signing_key)
metrics.auth_successful_logins.inc(
1.0, self.tenant.get_instance_name()
)
return session_token.serialize()

def _get_from_claims(self, state: str, key: str) -> str:
Expand Down

0 comments on commit 0b3057e

Please sign in to comment.