logging and otel

This commit is contained in:
Tim Möhlmann
2023-11-05 13:58:22 +02:00
parent 66f91cdc4e
commit 96a53aa130
6 changed files with 116 additions and 65 deletions

View File

@@ -4,6 +4,9 @@ import (
"context"
"net/http"
"golang.org/x/exp/slog"
"github.com/zitadel/logging"
"github.com/zitadel/oidc/v3/pkg/oidc"
"github.com/zitadel/oidc/v3/pkg/op"
"github.com/zitadel/zitadel/internal/crypto"
@@ -15,7 +18,8 @@ type Server struct {
storage *OPStorage
*op.LegacyServer
hashAlg crypto.HashAlgorithm
fallbackLogger *slog.Logger
hashAlg crypto.HashAlgorithm
}
func endpoints(endpointConfig *EndpointConfig) op.Endpoints {
@@ -61,6 +65,13 @@ func endpoints(endpointConfig *EndpointConfig) op.Endpoints {
return endpoints
}
func (s *Server) getLogger(ctx context.Context) *slog.Logger {
if logger, ok := logging.FromContext(ctx); ok {
return logger
}
return s.fallbackLogger
}
func (s *Server) IssuerFromRequest(r *http.Request) string {
return s.Provider().IssuerFromRequest(r)
}