mirror of https://github.com/grafana/grafana.git
AuthZ-Service: Add traces to cache (#105718)
Actionlint / Lint GitHub Actions files (push) Waiting to run
Details
Backend Code Checks / Validate Backend Configs (push) Waiting to run
Details
Backend Unit Tests / Grafana (${{ matrix.shard }}) (1/8) (push) Waiting to run
Details
Backend Unit Tests / Grafana (${{ matrix.shard }}) (2/8) (push) Waiting to run
Details
Backend Unit Tests / Grafana (${{ matrix.shard }}) (3/8) (push) Waiting to run
Details
Backend Unit Tests / Grafana (${{ matrix.shard }}) (4/8) (push) Waiting to run
Details
Backend Unit Tests / Grafana (${{ matrix.shard }}) (5/8) (push) Waiting to run
Details
Backend Unit Tests / Grafana (${{ matrix.shard }}) (6/8) (push) Waiting to run
Details
Backend Unit Tests / Grafana (${{ matrix.shard }}) (7/8) (push) Waiting to run
Details
Backend Unit Tests / Grafana (${{ matrix.shard }}) (8/8) (push) Waiting to run
Details
Backend Unit Tests / Grafana Enterprise (${{ matrix.shard }}) (1/8) (push) Waiting to run
Details
Backend Unit Tests / Grafana Enterprise (${{ matrix.shard }}) (2/8) (push) Waiting to run
Details
Backend Unit Tests / Grafana Enterprise (${{ matrix.shard }}) (3/8) (push) Waiting to run
Details
Backend Unit Tests / Grafana Enterprise (${{ matrix.shard }}) (4/8) (push) Waiting to run
Details
Backend Unit Tests / Grafana Enterprise (${{ matrix.shard }}) (5/8) (push) Waiting to run
Details
Backend Unit Tests / Grafana Enterprise (${{ matrix.shard }}) (6/8) (push) Waiting to run
Details
Backend Unit Tests / Grafana Enterprise (${{ matrix.shard }}) (7/8) (push) Waiting to run
Details
Backend Unit Tests / Grafana Enterprise (${{ matrix.shard }}) (8/8) (push) Waiting to run
Details
CodeQL checks / Analyze (actions) (push) Waiting to run
Details
CodeQL checks / Analyze (go) (push) Waiting to run
Details
CodeQL checks / Analyze (javascript) (push) Waiting to run
Details
CodeQL checks / Analyze (python) (push) Waiting to run
Details
Lint Frontend / Verify i18n (push) Waiting to run
Details
Lint Frontend / Lint (push) Waiting to run
Details
Lint Frontend / Typecheck (push) Waiting to run
Details
Lint Frontend / Betterer (push) Waiting to run
Details
golangci-lint / lint-go (push) Waiting to run
Details
Crowdin Upload Action / upload-sources-to-crowdin (push) Waiting to run
Details
End-to-end tests / Build & Package Grafana (push) Waiting to run
Details
End-to-end tests / ${{ matrix.suite }} (dashboards-suite) (push) Blocked by required conditions
Details
End-to-end tests / ${{ matrix.suite }} (panels-suite) (push) Blocked by required conditions
Details
End-to-end tests / ${{ matrix.suite }} (smoke-tests-suite) (push) Blocked by required conditions
Details
End-to-end tests / ${{ matrix.suite }} (various-suite) (push) Blocked by required conditions
Details
End-to-end tests / ${{ matrix.suite }} (old arch) (old-arch/dashboards-suite) (push) Blocked by required conditions
Details
End-to-end tests / ${{ matrix.suite }} (old arch) (old-arch/panels-suite) (push) Blocked by required conditions
Details
End-to-end tests / ${{ matrix.suite }} (old arch) (old-arch/smoke-tests-suite) (push) Blocked by required conditions
Details
End-to-end tests / ${{ matrix.suite }} (old arch) (old-arch/various-suite) (push) Blocked by required conditions
Details
Frontend tests / Unit tests (${{ matrix.chunk }} / 8) (1) (push) Waiting to run
Details
Frontend tests / Unit tests (${{ matrix.chunk }} / 8) (2) (push) Waiting to run
Details
Frontend tests / Unit tests (${{ matrix.chunk }} / 8) (3) (push) Waiting to run
Details
Frontend tests / Unit tests (${{ matrix.chunk }} / 8) (4) (push) Waiting to run
Details
Frontend tests / Unit tests (${{ matrix.chunk }} / 8) (5) (push) Waiting to run
Details
Frontend tests / Unit tests (${{ matrix.chunk }} / 8) (6) (push) Waiting to run
Details
Frontend tests / Unit tests (${{ matrix.chunk }} / 8) (7) (push) Waiting to run
Details
Frontend tests / Unit tests (${{ matrix.chunk }} / 8) (8) (push) Waiting to run
Details
Integration Tests / Sqlite (${{ matrix.shard }}) (1/8) (push) Waiting to run
Details
Integration Tests / Sqlite (${{ matrix.shard }}) (2/8) (push) Waiting to run
Details
Integration Tests / Sqlite (${{ matrix.shard }}) (3/8) (push) Waiting to run
Details
Integration Tests / Sqlite (${{ matrix.shard }}) (4/8) (push) Waiting to run
Details
Integration Tests / Sqlite (${{ matrix.shard }}) (5/8) (push) Waiting to run
Details
Integration Tests / Sqlite (${{ matrix.shard }}) (6/8) (push) Waiting to run
Details
Integration Tests / Sqlite (${{ matrix.shard }}) (7/8) (push) Waiting to run
Details
Integration Tests / Sqlite (${{ matrix.shard }}) (8/8) (push) Waiting to run
Details
Integration Tests / MySQL (${{ matrix.shard }}) (1/8) (push) Waiting to run
Details
Integration Tests / MySQL (${{ matrix.shard }}) (2/8) (push) Waiting to run
Details
Integration Tests / MySQL (${{ matrix.shard }}) (3/8) (push) Waiting to run
Details
Integration Tests / MySQL (${{ matrix.shard }}) (4/8) (push) Waiting to run
Details
Integration Tests / MySQL (${{ matrix.shard }}) (5/8) (push) Waiting to run
Details
Integration Tests / MySQL (${{ matrix.shard }}) (6/8) (push) Waiting to run
Details
Integration Tests / MySQL (${{ matrix.shard }}) (7/8) (push) Waiting to run
Details
Integration Tests / MySQL (${{ matrix.shard }}) (8/8) (push) Waiting to run
Details
Integration Tests / Postgres (${{ matrix.shard }}) (1/8) (push) Waiting to run
Details
Integration Tests / Postgres (${{ matrix.shard }}) (2/8) (push) Waiting to run
Details
Integration Tests / Postgres (${{ matrix.shard }}) (3/8) (push) Waiting to run
Details
Integration Tests / Postgres (${{ matrix.shard }}) (4/8) (push) Waiting to run
Details
Integration Tests / Postgres (${{ matrix.shard }}) (5/8) (push) Waiting to run
Details
Integration Tests / Postgres (${{ matrix.shard }}) (6/8) (push) Waiting to run
Details
Integration Tests / Postgres (${{ matrix.shard }}) (7/8) (push) Waiting to run
Details
Integration Tests / Postgres (${{ matrix.shard }}) (8/8) (push) Waiting to run
Details
Reject GitHub secrets / reject-gh-secrets (push) Waiting to run
Details
Run dashboard schema v2 e2e / dashboard-schema-v2-e2e (push) Waiting to run
Details
Verify Storybook / Verify Storybook (push) Waiting to run
Details
Dispatch sync to mirror / dispatch-job (push) Waiting to run
Details
trigger-dashboard-search-e2e / trigger-search-e2e (push) Waiting to run
Details
Trivy Scan / trivy-scan (push) Waiting to run
Details
Actionlint / Lint GitHub Actions files (push) Waiting to run
Details
Backend Code Checks / Validate Backend Configs (push) Waiting to run
Details
Backend Unit Tests / Grafana (${{ matrix.shard }}) (1/8) (push) Waiting to run
Details
Backend Unit Tests / Grafana (${{ matrix.shard }}) (2/8) (push) Waiting to run
Details
Backend Unit Tests / Grafana (${{ matrix.shard }}) (3/8) (push) Waiting to run
Details
Backend Unit Tests / Grafana (${{ matrix.shard }}) (4/8) (push) Waiting to run
Details
Backend Unit Tests / Grafana (${{ matrix.shard }}) (5/8) (push) Waiting to run
Details
Backend Unit Tests / Grafana (${{ matrix.shard }}) (6/8) (push) Waiting to run
Details
Backend Unit Tests / Grafana (${{ matrix.shard }}) (7/8) (push) Waiting to run
Details
Backend Unit Tests / Grafana (${{ matrix.shard }}) (8/8) (push) Waiting to run
Details
Backend Unit Tests / Grafana Enterprise (${{ matrix.shard }}) (1/8) (push) Waiting to run
Details
Backend Unit Tests / Grafana Enterprise (${{ matrix.shard }}) (2/8) (push) Waiting to run
Details
Backend Unit Tests / Grafana Enterprise (${{ matrix.shard }}) (3/8) (push) Waiting to run
Details
Backend Unit Tests / Grafana Enterprise (${{ matrix.shard }}) (4/8) (push) Waiting to run
Details
Backend Unit Tests / Grafana Enterprise (${{ matrix.shard }}) (5/8) (push) Waiting to run
Details
Backend Unit Tests / Grafana Enterprise (${{ matrix.shard }}) (6/8) (push) Waiting to run
Details
Backend Unit Tests / Grafana Enterprise (${{ matrix.shard }}) (7/8) (push) Waiting to run
Details
Backend Unit Tests / Grafana Enterprise (${{ matrix.shard }}) (8/8) (push) Waiting to run
Details
CodeQL checks / Analyze (actions) (push) Waiting to run
Details
CodeQL checks / Analyze (go) (push) Waiting to run
Details
CodeQL checks / Analyze (javascript) (push) Waiting to run
Details
CodeQL checks / Analyze (python) (push) Waiting to run
Details
Lint Frontend / Verify i18n (push) Waiting to run
Details
Lint Frontend / Lint (push) Waiting to run
Details
Lint Frontend / Typecheck (push) Waiting to run
Details
Lint Frontend / Betterer (push) Waiting to run
Details
golangci-lint / lint-go (push) Waiting to run
Details
Crowdin Upload Action / upload-sources-to-crowdin (push) Waiting to run
Details
End-to-end tests / Build & Package Grafana (push) Waiting to run
Details
End-to-end tests / ${{ matrix.suite }} (dashboards-suite) (push) Blocked by required conditions
Details
End-to-end tests / ${{ matrix.suite }} (panels-suite) (push) Blocked by required conditions
Details
End-to-end tests / ${{ matrix.suite }} (smoke-tests-suite) (push) Blocked by required conditions
Details
End-to-end tests / ${{ matrix.suite }} (various-suite) (push) Blocked by required conditions
Details
End-to-end tests / ${{ matrix.suite }} (old arch) (old-arch/dashboards-suite) (push) Blocked by required conditions
Details
End-to-end tests / ${{ matrix.suite }} (old arch) (old-arch/panels-suite) (push) Blocked by required conditions
Details
End-to-end tests / ${{ matrix.suite }} (old arch) (old-arch/smoke-tests-suite) (push) Blocked by required conditions
Details
End-to-end tests / ${{ matrix.suite }} (old arch) (old-arch/various-suite) (push) Blocked by required conditions
Details
Frontend tests / Unit tests (${{ matrix.chunk }} / 8) (1) (push) Waiting to run
Details
Frontend tests / Unit tests (${{ matrix.chunk }} / 8) (2) (push) Waiting to run
Details
Frontend tests / Unit tests (${{ matrix.chunk }} / 8) (3) (push) Waiting to run
Details
Frontend tests / Unit tests (${{ matrix.chunk }} / 8) (4) (push) Waiting to run
Details
Frontend tests / Unit tests (${{ matrix.chunk }} / 8) (5) (push) Waiting to run
Details
Frontend tests / Unit tests (${{ matrix.chunk }} / 8) (6) (push) Waiting to run
Details
Frontend tests / Unit tests (${{ matrix.chunk }} / 8) (7) (push) Waiting to run
Details
Frontend tests / Unit tests (${{ matrix.chunk }} / 8) (8) (push) Waiting to run
Details
Integration Tests / Sqlite (${{ matrix.shard }}) (1/8) (push) Waiting to run
Details
Integration Tests / Sqlite (${{ matrix.shard }}) (2/8) (push) Waiting to run
Details
Integration Tests / Sqlite (${{ matrix.shard }}) (3/8) (push) Waiting to run
Details
Integration Tests / Sqlite (${{ matrix.shard }}) (4/8) (push) Waiting to run
Details
Integration Tests / Sqlite (${{ matrix.shard }}) (5/8) (push) Waiting to run
Details
Integration Tests / Sqlite (${{ matrix.shard }}) (6/8) (push) Waiting to run
Details
Integration Tests / Sqlite (${{ matrix.shard }}) (7/8) (push) Waiting to run
Details
Integration Tests / Sqlite (${{ matrix.shard }}) (8/8) (push) Waiting to run
Details
Integration Tests / MySQL (${{ matrix.shard }}) (1/8) (push) Waiting to run
Details
Integration Tests / MySQL (${{ matrix.shard }}) (2/8) (push) Waiting to run
Details
Integration Tests / MySQL (${{ matrix.shard }}) (3/8) (push) Waiting to run
Details
Integration Tests / MySQL (${{ matrix.shard }}) (4/8) (push) Waiting to run
Details
Integration Tests / MySQL (${{ matrix.shard }}) (5/8) (push) Waiting to run
Details
Integration Tests / MySQL (${{ matrix.shard }}) (6/8) (push) Waiting to run
Details
Integration Tests / MySQL (${{ matrix.shard }}) (7/8) (push) Waiting to run
Details
Integration Tests / MySQL (${{ matrix.shard }}) (8/8) (push) Waiting to run
Details
Integration Tests / Postgres (${{ matrix.shard }}) (1/8) (push) Waiting to run
Details
Integration Tests / Postgres (${{ matrix.shard }}) (2/8) (push) Waiting to run
Details
Integration Tests / Postgres (${{ matrix.shard }}) (3/8) (push) Waiting to run
Details
Integration Tests / Postgres (${{ matrix.shard }}) (4/8) (push) Waiting to run
Details
Integration Tests / Postgres (${{ matrix.shard }}) (5/8) (push) Waiting to run
Details
Integration Tests / Postgres (${{ matrix.shard }}) (6/8) (push) Waiting to run
Details
Integration Tests / Postgres (${{ matrix.shard }}) (7/8) (push) Waiting to run
Details
Integration Tests / Postgres (${{ matrix.shard }}) (8/8) (push) Waiting to run
Details
Reject GitHub secrets / reject-gh-secrets (push) Waiting to run
Details
Run dashboard schema v2 e2e / dashboard-schema-v2-e2e (push) Waiting to run
Details
Verify Storybook / Verify Storybook (push) Waiting to run
Details
Dispatch sync to mirror / dispatch-job (push) Waiting to run
Details
trigger-dashboard-search-e2e / trigger-search-e2e (push) Waiting to run
Details
Trivy Scan / trivy-scan (push) Waiting to run
Details
This commit is contained in:
parent
8caa62ede0
commit
cb3cd021b7
|
@ -7,8 +7,10 @@ import (
|
|||
"time"
|
||||
|
||||
"github.com/grafana/authlib/cache"
|
||||
"go.opentelemetry.io/otel/attribute"
|
||||
|
||||
"github.com/grafana/grafana/pkg/infra/log"
|
||||
"github.com/grafana/grafana/pkg/infra/tracing"
|
||||
)
|
||||
|
||||
func userIdentifierCacheKey(namespace, userUID string) string {
|
||||
|
@ -50,20 +52,24 @@ type cacheWrap[T any] interface {
|
|||
type cacheWrapImpl[T any] struct {
|
||||
cache cache.Cache
|
||||
logger log.Logger
|
||||
tracer tracing.Tracer
|
||||
ttl time.Duration
|
||||
}
|
||||
|
||||
// cacheWrap is a wrapper around the authlib Cache that provides typed Get and Set methods
|
||||
// it handles encoding/decoding for a specific type.
|
||||
func newCacheWrap[T any](cache cache.Cache, logger log.Logger, ttl time.Duration) cacheWrap[T] {
|
||||
func newCacheWrap[T any](cache cache.Cache, logger log.Logger, tracer tracing.Tracer, ttl time.Duration) cacheWrap[T] {
|
||||
if ttl == 0 {
|
||||
logger.Info("cache ttl is 0, using noop cache")
|
||||
return &noopCache[T]{}
|
||||
}
|
||||
return &cacheWrapImpl[T]{cache: cache, logger: logger, ttl: ttl}
|
||||
return &cacheWrapImpl[T]{cache: cache, logger: logger, tracer: tracer, ttl: ttl}
|
||||
}
|
||||
|
||||
func (c *cacheWrapImpl[T]) Get(ctx context.Context, key string) (T, bool) {
|
||||
ctx, span := c.tracer.Start(ctx, "cacheWrap.Get")
|
||||
defer span.End()
|
||||
span.SetAttributes(attribute.Bool("hit", false))
|
||||
logger := c.logger.FromContext(ctx)
|
||||
|
||||
var value T
|
||||
|
@ -81,10 +87,13 @@ func (c *cacheWrapImpl[T]) Get(ctx context.Context, key string) (T, bool) {
|
|||
return value, false
|
||||
}
|
||||
|
||||
span.SetAttributes(attribute.Bool("hit", true))
|
||||
return value, true
|
||||
}
|
||||
|
||||
func (c *cacheWrapImpl[T]) Set(ctx context.Context, key string, value T) {
|
||||
ctx, span := c.tracer.Start(ctx, "cacheWrap.Set")
|
||||
defer span.End()
|
||||
logger := c.logger.FromContext(ctx)
|
||||
|
||||
data, err := json.Marshal(value)
|
||||
|
|
|
@ -94,12 +94,12 @@ func NewService(
|
|||
tracer: tracer,
|
||||
metrics: newMetrics(reg),
|
||||
mapper: newMapper(),
|
||||
idCache: newCacheWrap[store.UserIdentifiers](cache, logger, longCacheTTL),
|
||||
permCache: newCacheWrap[map[string]bool](cache, logger, settings.CacheTTL),
|
||||
permDenialCache: newCacheWrap[bool](cache, logger, settings.CacheTTL),
|
||||
teamCache: newCacheWrap[[]int64](cache, logger, settings.CacheTTL),
|
||||
basicRoleCache: newCacheWrap[store.BasicRole](cache, logger, settings.CacheTTL),
|
||||
folderCache: newCacheWrap[folderTree](cache, logger, settings.CacheTTL),
|
||||
idCache: newCacheWrap[store.UserIdentifiers](cache, logger, tracer, longCacheTTL),
|
||||
permCache: newCacheWrap[map[string]bool](cache, logger, tracer, settings.CacheTTL),
|
||||
permDenialCache: newCacheWrap[bool](cache, logger, tracer, settings.CacheTTL),
|
||||
teamCache: newCacheWrap[[]int64](cache, logger, tracer, settings.CacheTTL),
|
||||
basicRoleCache: newCacheWrap[store.BasicRole](cache, logger, tracer, settings.CacheTTL),
|
||||
folderCache: newCacheWrap[folderTree](cache, logger, tracer, settings.CacheTTL),
|
||||
sf: new(singleflight.Group),
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1516,17 +1516,18 @@ func setupService() *Service {
|
|||
cache := cache.NewLocalCache(cache.Config{Expiry: 5 * time.Minute, CleanupInterval: 5 * time.Minute})
|
||||
logger := log.New("authz-rbac-service")
|
||||
fStore := &fakeStore{}
|
||||
tracer := tracing.NewNoopTracerService()
|
||||
return &Service{
|
||||
logger: logger,
|
||||
mapper: newMapper(),
|
||||
tracer: tracing.NewNoopTracerService(),
|
||||
tracer: tracer,
|
||||
metrics: newMetrics(nil),
|
||||
idCache: newCacheWrap[store.UserIdentifiers](cache, logger, longCacheTTL),
|
||||
permCache: newCacheWrap[map[string]bool](cache, logger, shortCacheTTL),
|
||||
permDenialCache: newCacheWrap[bool](cache, logger, shortCacheTTL),
|
||||
teamCache: newCacheWrap[[]int64](cache, logger, shortCacheTTL),
|
||||
basicRoleCache: newCacheWrap[store.BasicRole](cache, logger, longCacheTTL),
|
||||
folderCache: newCacheWrap[folderTree](cache, logger, shortCacheTTL),
|
||||
idCache: newCacheWrap[store.UserIdentifiers](cache, logger, tracer, longCacheTTL),
|
||||
permCache: newCacheWrap[map[string]bool](cache, logger, tracer, shortCacheTTL),
|
||||
permDenialCache: newCacheWrap[bool](cache, logger, tracer, shortCacheTTL),
|
||||
teamCache: newCacheWrap[[]int64](cache, logger, tracer, shortCacheTTL),
|
||||
basicRoleCache: newCacheWrap[store.BasicRole](cache, logger, tracer, longCacheTTL),
|
||||
folderCache: newCacheWrap[folderTree](cache, logger, tracer, shortCacheTTL),
|
||||
settings: Settings{AnonOrgRole: "Viewer"},
|
||||
store: fStore,
|
||||
permissionStore: fStore,
|
||||
|
|
Loading…
Reference in New Issue