Skip to content

Commit

Permalink
Add auth_providers
Browse files Browse the repository at this point in the history
  • Loading branch information
fantix committed Nov 10, 2023
1 parent 41f7795 commit cafdfa3
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 0 deletions.
3 changes: 3 additions & 0 deletions docs/reference/http.rst
Expand Up @@ -171,6 +171,9 @@ Auth Extension
``auth_ui_renders_total``
**Counter.** Number of UI pages rendered by the Auth extension.

``auth_providers``
**Histogram.** Number of Auth providers configured.

Errors
^^^^^^

Expand Down
1 change: 1 addition & 0 deletions edb/server/dbview/dbview.pxd
Expand Up @@ -98,6 +98,7 @@ cdef class Database:
cdef _cache_compiled_query(self, key, query_unit)
cdef _new_view(self, query_cache, protocol_version)
cdef _remove_view(self, view)
cdef _observe_auth_ext_config(self)
cdef _update_backend_ids(self, new_types)
cdef _set_and_signal_new_user_schema(
self,
Expand Down
20 changes: 20 additions & 0 deletions edb/server/dbview/dbview.pyx
Expand Up @@ -184,6 +184,7 @@ cdef class Database:
self.reflection_cache = reflection_cache
self.backend_ids = backend_ids
self.extensions = extensions
self._observe_auth_ext_config()

@property
def server(self):
Expand Down Expand Up @@ -220,8 +221,27 @@ cdef class Database:
self.reflection_cache = reflection_cache
if db_config is not None:
self.db_config = db_config
self._observe_auth_ext_config()
self._invalidate_caches()

cdef _observe_auth_ext_config(self):
key = "ext::auth::AuthConfig::providers"
if (
self.db_config is not None and
self.user_config_spec is not None and
key in self.user_config_spec
):
providers = config.lookup(
key,
self.db_config,
spec=self.user_config_spec,
)
metrics.auth_providers.set(
len(providers),
self.tenant.get_instance_name(),
self.name,
)

cdef _update_backend_ids(self, new_types):
self.backend_ids.update(new_types)

Expand Down
6 changes: 6 additions & 0 deletions edb/server/metrics.py
Expand Up @@ -187,3 +187,9 @@
"Number of UI pages rendered by the Auth extension.",
labels=("tenant",),
)

auth_providers = registry.new_labeled_gauge(
'auth_providers',
'Number of Auth providers configured.',
labels=('tenant', 'database'),
)

0 comments on commit cafdfa3

Please sign in to comment.