Replace constants from trace with equivalents defined in teleport (#39307)

* Remove logging from circuit breaker

The logging is never output, and if it was would be very verbose.
Instead of dropping the level down to trace the logger is removed
entirely.

* Add constants from trace library

The logging functionality in trace is being removed in an upcoming
release. To prepare the logging component keys are copied from trace
into teleport.

* Convert trace.ComponentFields to teleport.ComponentFields

* Replace trace.Component with teleport.ComponentKey

* Replace trace logging constants
This commit is contained in:
rosstimothy
2024-03-14 13:04:29 +00:00
committed by GitHub
parent 640e88b6ba
commit 1aec5414f1
217 changed files with 498 additions and 402 deletions
-13
View File
@@ -22,7 +22,6 @@ import (
"github.com/gravitational/trace"
"github.com/jonboulle/clockwork"
"github.com/sirupsen/logrus"
"google.golang.org/grpc/codes"
"google.golang.org/grpc/status"
@@ -132,8 +131,6 @@ type Config struct {
OnStandBy func()
// IsSuccessful is used by the CircuitBreaker to determine if the executed function was successful or not
IsSuccessful func(v interface{}, err error) bool
// Logger is the logger
Logger logrus.FieldLogger
// TrippedErrorMessage is an optional message to use as the error message when the CircuitBreaker
// is tripped. Defaults to ErrStateTripped if not provided.
TrippedErrorMessage string
@@ -260,12 +257,6 @@ func (c *Config) CheckAndSetDefaults() error {
c.IsSuccessful = NonNilErrorIsSuccess
}
if c.Logger == nil {
c.Logger = logrus.New().WithFields(logrus.Fields{
trace.Component: "breaker",
})
}
c.TrippedPeriod = retryutils.NewSeventhJitter()(c.TrippedPeriod)
return nil
@@ -359,10 +350,8 @@ func (c *CircuitBreaker) afterExecution(prior uint64, v interface{}, err error)
}
if c.cfg.IsSuccessful(v, err) {
c.cfg.Logger.Debugf("successful execution, %s", c.metrics.String())
c.success(state, now)
} else {
c.cfg.Logger.Debugf("failed execution, %s", c.metrics.String())
c.failure(state, now)
}
}
@@ -407,8 +396,6 @@ func (c *CircuitBreaker) setState(s State, t time.Time) {
return
}
c.cfg.Logger.Debugf("state is transition from %s -> %s", c.state, s)
c.state = s
c.nextGeneration(t)
}
+6
View File
@@ -69,6 +69,12 @@ const (
)
const (
// ComponentKey is a field that represents a component - e.g. service or
// function
ComponentKey = "teleport.ComponentKey"
// ComponentFields is a fields component
ComponentFields = "trace.fields"
// ComponentMemory is a memory backend
ComponentMemory = "memory"
+2 -1
View File
@@ -26,6 +26,7 @@ import (
"github.com/sirupsen/logrus"
"google.golang.org/protobuf/types/known/emptypb"
"github.com/gravitational/teleport"
"github.com/gravitational/teleport/api/defaults"
"github.com/gravitational/teleport/api/gen/proto/go/assist/v1"
"github.com/gravitational/teleport/api/types"
@@ -90,7 +91,7 @@ func NewService(cfg *ServiceConfig) (*Service, error) {
case cfg.ResourceGetter == nil:
return nil, trace.BadParameter("resource getter is required")
case cfg.Logger == nil:
cfg.Logger = logrus.WithField(trace.Component, "assist.service")
cfg.Logger = logrus.WithField(teleport.ComponentKey, "assist.service")
}
// Embedder can be nil is the OpenAI API key is not set.
@@ -25,6 +25,7 @@ import (
"github.com/sirupsen/logrus"
"google.golang.org/protobuf/types/known/emptypb"
"github.com/gravitational/teleport"
pb "github.com/gravitational/teleport/api/gen/proto/go/teleport/dbobjectimportrule/v1"
"github.com/gravitational/teleport/api/types"
"github.com/gravitational/teleport/api/types/databaseobjectimportrule"
@@ -54,7 +55,7 @@ func NewDatabaseObjectImportRuleService(cfg DatabaseObjectImportRuleServiceConfi
return nil, trace.BadParameter("backend service is required")
}
if cfg.Logger == nil {
cfg.Logger = logrus.WithField(trace.Component, "db_obj_import_rule")
cfg.Logger = logrus.WithField(teleport.ComponentKey, "db_obj_import_rule")
}
return &DatabaseObjectImportRuleService{
logger: cfg.Logger,
@@ -26,6 +26,7 @@ import (
"github.com/sirupsen/logrus"
"google.golang.org/protobuf/types/known/emptypb"
"github.com/gravitational/teleport"
discoveryconfigv1 "github.com/gravitational/teleport/api/gen/proto/go/teleport/discoveryconfig/v1"
"github.com/gravitational/teleport/api/types"
conv "github.com/gravitational/teleport/api/types/discoveryconfig/convert/v1"
@@ -60,7 +61,7 @@ func (s *ServiceConfig) CheckAndSetDefaults() error {
}
if s.Logger == nil {
s.Logger = logrus.New().WithField(trace.Component, "discoveryconfig_crud_service")
s.Logger = logrus.New().WithField(teleport.ComponentKey, "discoveryconfig_crud_service")
}
if s.Clock == nil {
+4 -4
View File
@@ -141,7 +141,7 @@ func (a *Server) CreateGithubAuthRequest(ctx context.Context, req types.GithubAu
return nil, trace.Wrap(err)
}
req.RedirectURL = client.AuthCodeURL(req.StateToken, "", "")
log.WithFields(logrus.Fields{trace.Component: "github"}).Debugf(
log.WithFields(logrus.Fields{teleport.ComponentKey: "github"}).Debugf(
"Redirect URL: %v.", req.RedirectURL)
req.SetExpiry(a.GetClock().Now().UTC().Add(defaults.GithubAuthRequestTTL))
err = a.Services.CreateGithubAuthRequest(ctx, req)
@@ -578,7 +578,7 @@ func (a *Server) getGithubOAuth2Client(connector types.GithubConnector) (*oauth2
// ValidateGithubAuthCallback validates Github auth callback redirect
func (a *Server) validateGithubAuthCallback(ctx context.Context, diagCtx *SSODiagContext, q url.Values) (*GithubAuthResponse, error) {
logger := log.WithFields(logrus.Fields{trace.Component: "github"})
logger := log.WithFields(logrus.Fields{teleport.ComponentKey: "github"})
if errParam := q.Get("error"); errParam != "" {
// try to find request so the error gets logged against it.
@@ -860,7 +860,7 @@ func (a *Server) calculateGithubUser(ctx context.Context, diagCtx *SSODiagContex
}
func (a *Server) createGithubUser(ctx context.Context, p *CreateUserParams, dryRun bool) (types.User, error) {
log.WithFields(logrus.Fields{trace.Component: "github"}).Debugf(
log.WithFields(logrus.Fields{teleport.ComponentKey: "github"}).Debugf(
"Generating dynamic GitHub identity %v/%v with roles: %v. Dry run: %v.",
p.ConnectorName, p.Username, p.Roles, dryRun)
@@ -941,7 +941,7 @@ func populateGithubClaims(user *userResponse, teams []teamResponse) (*types.Gith
OrganizationToTeams: orgToTeams,
Teams: teamList,
}
log.WithFields(logrus.Fields{trace.Component: "github"}).Debugf(
log.WithFields(logrus.Fields{teleport.ComponentKey: "github"}).Debugf(
"Claims: %#v.", claims)
return claims, nil
}
+1 -1
View File
@@ -5278,7 +5278,7 @@ func NewGRPCServer(cfg GRPCServerConfig) (*GRPCServer, error) {
authServer := &GRPCServer{
APIConfig: cfg.APIConfig,
Entry: logrus.WithFields(logrus.Fields{
trace.Component: teleport.Component(teleport.ComponentAuth, teleport.ComponentGRPC),
teleport.ComponentKey: teleport.Component(teleport.ComponentAuth, teleport.ComponentGRPC),
}),
server: server,
usersService: usersService,
+1 -1
View File
@@ -70,7 +70,7 @@ import (
)
var log = logrus.WithFields(logrus.Fields{
trace.Component: teleport.ComponentAuth,
teleport.ComponentKey: teleport.ComponentAuth,
})
// InitConfig is auth server init config
@@ -26,6 +26,7 @@ import (
"github.com/jonboulle/clockwork"
"github.com/sirupsen/logrus"
"github.com/gravitational/teleport"
integrationpb "github.com/gravitational/teleport/api/gen/proto/go/teleport/integration/v1"
"github.com/gravitational/teleport/api/types"
"github.com/gravitational/teleport/lib/authz"
@@ -138,7 +139,7 @@ func (s *AWSOIDCServiceConfig) CheckAndSetDefaults() error {
}
if s.Logger == nil {
s.Logger = logrus.WithField(trace.Component, "integrations.awsoidc.service")
s.Logger = logrus.WithField(teleport.ComponentKey, "integrations.awsoidc.service")
}
return nil
@@ -27,6 +27,7 @@ import (
"github.com/sirupsen/logrus"
"google.golang.org/protobuf/types/known/emptypb"
"github.com/gravitational/teleport"
integrationpb "github.com/gravitational/teleport/api/gen/proto/go/teleport/integration/v1"
"github.com/gravitational/teleport/api/types"
"github.com/gravitational/teleport/lib/authz"
@@ -87,7 +88,7 @@ func (s *ServiceConfig) CheckAndSetDefaults() error {
}
if s.Logger == nil {
s.Logger = logrus.WithField(trace.Component, "integrations.service")
s.Logger = logrus.WithField(teleport.ComponentKey, "integrations.service")
}
if s.Clock == nil {
+2 -1
View File
@@ -36,6 +36,7 @@ import (
"github.com/sirupsen/logrus"
"google.golang.org/api/iterator"
"github.com/gravitational/teleport"
"github.com/gravitational/teleport/api/types"
"github.com/gravitational/teleport/lib/auth/keystore/internal/faketime"
)
@@ -122,7 +123,7 @@ func newGCPKMSKeyStore(ctx context.Context, cfg *GCPKMSConfig, logger logrus.Fie
clock = cfg.clockOverride
}
logger = logger.WithFields(logrus.Fields{trace.Component: "GCPKMSKeyStore"})
logger = logger.WithFields(logrus.Fields{teleport.ComponentKey: "GCPKMSKeyStore"})
return &gcpKMSKeyStore{
hostUUID: cfg.HostUUID,
+2 -1
View File
@@ -33,6 +33,7 @@ import (
"github.com/miekg/pkcs11"
"github.com/sirupsen/logrus"
"github.com/gravitational/teleport"
"github.com/gravitational/teleport/api/constants"
"github.com/gravitational/teleport/api/types"
)
@@ -91,7 +92,7 @@ func newPKCS11KeyStore(config *PKCS11Config, logger logrus.FieldLogger) (*pkcs11
return nil, trace.Wrap(err, "getting PKCS#11 module info")
}
logger = logger.WithFields(logrus.Fields{trace.Component: "PKCS11KeyStore"})
logger = logger.WithFields(logrus.Fields{teleport.ComponentKey: "PKCS11KeyStore"})
return &pkcs11KeyStore{
ctx: ctx,
@@ -30,6 +30,7 @@ import (
"github.com/sirupsen/logrus"
"google.golang.org/protobuf/types/known/emptypb"
"github.com/gravitational/teleport"
headerv1 "github.com/gravitational/teleport/api/gen/proto/go/teleport/header/v1"
pb "github.com/gravitational/teleport/api/gen/proto/go/teleport/machineid/v1"
"github.com/gravitational/teleport/api/types"
@@ -125,7 +126,7 @@ func NewBotService(cfg BotServiceConfig) (*BotService, error) {
}
if cfg.Logger == nil {
cfg.Logger = logrus.WithField(trace.Component, "bot.service")
cfg.Logger = logrus.WithField(teleport.ComponentKey, "bot.service")
}
if cfg.Clock == nil {
cfg.Clock = clockwork.NewRealClock()
@@ -33,6 +33,7 @@ import (
"github.com/jonboulle/clockwork"
"github.com/sirupsen/logrus"
"github.com/gravitational/teleport"
pb "github.com/gravitational/teleport/api/gen/proto/go/teleport/machineid/v1"
"github.com/gravitational/teleport/api/types"
apievents "github.com/gravitational/teleport/api/types/events"
@@ -86,7 +87,7 @@ func NewWorkloadIdentityService(
}
if cfg.Logger == nil {
cfg.Logger = logrus.WithField(trace.Component, "workload-identity.service")
cfg.Logger = logrus.WithField(teleport.ComponentKey, "workload-identity.service")
}
if cfg.Clock == nil {
cfg.Clock = clockwork.NewRealClock()
+1 -1
View File
@@ -210,7 +210,7 @@ func NewTLSServer(ctx context.Context, cfg TLSServerConfig) (*TLSServer, error)
},
},
log: logrus.WithFields(logrus.Fields{
trace.Component: cfg.Component,
teleport.ComponentKey: cfg.Component,
}),
}
server.cfg.TLS.GetConfigForClient = server.GetConfigForClient
+1 -1
View File
@@ -52,7 +52,7 @@ func withMigrations(m []migration) func(c *applyConfig) {
}
var log = logrus.WithFields(logrus.Fields{
trace.Component: teleport.ComponentAuth,
teleport.ComponentKey: teleport.ComponentAuth,
})
var tracer = tracing.NewTracer("migrations")
+1 -1
View File
@@ -39,7 +39,7 @@ import (
)
var log = logrus.WithFields(logrus.Fields{
trace.Component: teleport.ComponentKeyGen,
teleport.ComponentKey: teleport.ComponentKeyGen,
})
// precomputedKeys is a queue of cached keys ready for usage.
+2 -1
View File
@@ -25,6 +25,7 @@ import (
"github.com/sirupsen/logrus"
"google.golang.org/protobuf/types/known/emptypb"
"github.com/gravitational/teleport"
oktapb "github.com/gravitational/teleport/api/gen/proto/go/teleport/okta/v1"
"github.com/gravitational/teleport/api/types"
"github.com/gravitational/teleport/lib/authz"
@@ -57,7 +58,7 @@ func (c *ServiceConfig) CheckAndSetDefaults() error {
}
if c.Logger == nil {
c.Logger = logrus.New().WithField(trace.Component, "okta_crud_service")
c.Logger = logrus.New().WithField(teleport.ComponentKey, "okta_crud_service")
}
if c.Authorizer == nil {
+2 -1
View File
@@ -26,6 +26,7 @@ import (
"github.com/sirupsen/logrus"
"google.golang.org/protobuf/types/known/emptypb"
"github.com/gravitational/teleport"
trustpb "github.com/gravitational/teleport/api/gen/proto/go/teleport/trust/v1"
"github.com/gravitational/teleport/api/types"
"github.com/gravitational/teleport/lib/authz"
@@ -77,7 +78,7 @@ func NewService(cfg *ServiceConfig) (*Service, error) {
case cfg.AuthServer == nil:
return nil, trace.BadParameter("authServer is required")
case cfg.Logger == nil:
cfg.Logger = logrus.WithField(trace.Component, "trust.service")
cfg.Logger = logrus.WithField(teleport.ComponentKey, "trust.service")
}
return &Service{
+2 -1
View File
@@ -26,6 +26,7 @@ import (
"github.com/sirupsen/logrus"
"google.golang.org/protobuf/types/known/emptypb"
"github.com/gravitational/teleport"
userloginstatev1 "github.com/gravitational/teleport/api/gen/proto/go/teleport/userloginstate/v1"
"github.com/gravitational/teleport/api/types"
conv "github.com/gravitational/teleport/api/types/userloginstate/convert/v1"
@@ -58,7 +59,7 @@ func (c *ServiceConfig) checkAndSetDefaults() error {
}
if c.Logger == nil {
c.Logger = logrus.WithField(trace.Component, "user_login_state_crud_service")
c.Logger = logrus.WithField(teleport.ComponentKey, "user_login_state_crud_service")
}
if c.Clock == nil {
@@ -25,6 +25,7 @@ import (
"github.com/sirupsen/logrus"
"google.golang.org/protobuf/types/known/emptypb"
"github.com/gravitational/teleport"
userpreferences "github.com/gravitational/teleport/api/gen/proto/go/userpreferences/v1"
"github.com/gravitational/teleport/lib/authz"
"github.com/gravitational/teleport/lib/services"
@@ -54,7 +55,7 @@ func NewService(cfg *ServiceConfig) (*Service, error) {
case cfg.Authorizer == nil:
return nil, trace.BadParameter("authorizer is required")
case cfg.Logger == nil:
cfg.Logger = logrus.WithField(trace.Component, "userpreferences.service")
cfg.Logger = logrus.WithField(teleport.ComponentKey, "userpreferences.service")
}
return &Service{
+2 -1
View File
@@ -26,6 +26,7 @@ import (
"github.com/sirupsen/logrus"
"google.golang.org/protobuf/types/known/emptypb"
"github.com/gravitational/teleport"
"github.com/gravitational/teleport/api/constants"
apidefaults "github.com/gravitational/teleport/api/defaults"
userspb "github.com/gravitational/teleport/api/gen/proto/go/teleport/users/v1"
@@ -103,7 +104,7 @@ func NewService(cfg ServiceConfig) (*Service, error) {
}
if cfg.Logger == nil {
cfg.Logger = logrus.WithField(trace.Component, "users.service")
cfg.Logger = logrus.WithField(teleport.ComponentKey, "users.service")
}
if cfg.Clock == nil {
cfg.Clock = clockwork.NewRealClock()
+1 -1
View File
@@ -98,7 +98,7 @@ func NewAuthorizer(opts AuthorizerOpts) (Authorizer, error) {
}
logger := opts.Logger
if logger == nil {
logger = logrus.WithFields(logrus.Fields{trace.Component: "authorizer"})
logger = logrus.WithFields(logrus.Fields{teleport.ComponentKey: "authorizer"})
}
return &authorizer{
+1 -1
View File
@@ -92,7 +92,7 @@ func NewCircularBuffer(opts ...BufferOption) *CircularBuffer {
}
return &CircularBuffer{
Entry: log.WithFields(log.Fields{
trace.Component: teleport.ComponentBuffer,
teleport.ComponentKey: teleport.ComponentBuffer,
}),
cfg: cfg,
watchers: newWatcherTree(),
+2 -1
View File
@@ -44,6 +44,7 @@ import (
"github.com/jonboulle/clockwork"
log "github.com/sirupsen/logrus"
"github.com/gravitational/teleport"
"github.com/gravitational/teleport/api/utils"
"github.com/gravitational/teleport/lib/backend"
"github.com/gravitational/teleport/lib/defaults"
@@ -220,7 +221,7 @@ var _ backend.Backend = &Backend{}
// New returns new instance of DynamoDB backend.
// It's an implementation of backend API's NewFunc
func New(ctx context.Context, params backend.Params) (*Backend, error) {
l := log.WithFields(log.Fields{trace.Component: BackendName})
l := log.WithFields(log.Fields{teleport.ComponentKey: BackendName})
var cfg *Config
err := utils.ObjectToStruct(params, &cfg)
+1 -1
View File
@@ -279,7 +279,7 @@ func New(ctx context.Context, params backend.Params, opts ...Option) (*EtcdBacke
}
b := &EtcdBackend{
Entry: log.WithFields(log.Fields{trace.Component: GetName()}),
Entry: log.WithFields(log.Fields{teleport.ComponentKey: GetName()}),
cfg: cfg,
nodes: cfg.Nodes,
cancelC: make(chan bool, 1),
+3 -2
View File
@@ -40,6 +40,7 @@ import (
"google.golang.org/grpc/credentials/insecure"
"google.golang.org/grpc/status"
"github.com/gravitational/teleport"
"github.com/gravitational/teleport/api/types"
apiutils "github.com/gravitational/teleport/api/utils"
"github.com/gravitational/teleport/api/utils/retryutils"
@@ -328,7 +329,7 @@ func (opts *Options) checkAndSetDefaults() error {
// New returns new instance of Firestore backend.
// It's an implementation of backend API's NewFunc
func New(ctx context.Context, params backend.Params, options Options) (*Backend, error) {
l := log.WithFields(log.Fields{trace.Component: BackendName})
l := log.WithFields(log.Fields{teleport.ComponentKey: BackendName})
var cfg *backendConfig
err := apiutils.ObjectToStruct(params, &cfg)
if err != nil {
@@ -1083,7 +1084,7 @@ type indexTask struct {
// EnsureIndexes is a function used by Firestore events and backend to generate indexes and will block until
// indexes are reported as created
func EnsureIndexes(ctx context.Context, adminSvc *apiv1.FirestoreAdminClient, tuples IndexList, indexParent string) error {
l := log.WithFields(log.Fields{trace.Component: BackendName})
l := log.WithFields(log.Fields{teleport.ComponentKey: BackendName})
var tasks []indexTask
// create the indexes
+2 -1
View File
@@ -47,6 +47,7 @@ import (
"google.golang.org/protobuf/proto"
"google.golang.org/protobuf/types/known/timestamppb"
"github.com/gravitational/teleport"
"github.com/gravitational/teleport/lib/backend"
"github.com/gravitational/teleport/lib/backend/test"
"github.com/gravitational/teleport/lib/utils"
@@ -328,7 +329,7 @@ func TestDeleteDocuments(t *testing.T) {
b := &Backend{
svc: client,
Entry: utils.NewLoggerForTests().WithFields(logrus.Fields{trace.Component: BackendName}),
Entry: utils.NewLoggerForTests().WithFields(logrus.Fields{teleport.ComponentKey: BackendName}),
clock: clockwork.NewFakeClock(),
clientContext: ctx,
clientCancel: cancel,
+2 -1
View File
@@ -38,6 +38,7 @@ import (
"github.com/mattn/go-sqlite3"
log "github.com/sirupsen/logrus"
"github.com/gravitational/teleport"
"github.com/gravitational/teleport/api/types"
"github.com/gravitational/teleport/api/utils"
"github.com/gravitational/teleport/lib/backend"
@@ -249,7 +250,7 @@ func NewWithConfig(ctx context.Context, cfg Config) (*Backend, error) {
l := &Backend{
Config: cfg,
db: db,
Entry: log.WithFields(log.Fields{trace.Component: BackendName}),
Entry: log.WithFields(log.Fields{teleport.ComponentKey: BackendName}),
clock: cfg.Clock,
buf: buf,
ctx: closeCtx,
+1 -1
View File
@@ -101,7 +101,7 @@ func New(cfg Config) (*Memory, error) {
m := &Memory{
Mutex: &sync.Mutex{},
Entry: log.WithFields(log.Fields{
trace.Component: teleport.ComponentMemory,
teleport.ComponentKey: teleport.ComponentMemory,
}),
Config: cfg,
tree: btree.NewG(cfg.BTreeDegree, func(a, b *btreeItem) bool {
+2 -1
View File
@@ -32,6 +32,7 @@ import (
"github.com/jonboulle/clockwork"
"github.com/sirupsen/logrus"
"github.com/gravitational/teleport"
"github.com/gravitational/teleport/api/types"
"github.com/gravitational/teleport/api/utils"
"github.com/gravitational/teleport/lib/backend"
@@ -171,7 +172,7 @@ func NewWithConfig(ctx context.Context, cfg Config) (*Backend, error) {
return nil, trace.Wrap(err)
}
log := logrus.WithField(trace.Component, componentName)
log := logrus.WithField(teleport.ComponentKey, componentName)
if cfg.AuthMode == AzureADAuth {
bc, err := pgcommon.AzureBeforeConnect(log)
+1 -1
View File
@@ -36,7 +36,7 @@ import (
)
var log = logrus.WithFields(logrus.Fields{
trace.Component: teleport.ComponentBPF,
teleport.ComponentKey: teleport.ComponentBPF,
})
const (
+1 -1
View File
@@ -942,7 +942,7 @@ func New(config Config) (*Cache, error) {
eventsFanout: fanout,
lowVolumeEventsFanout: utils.NewRoundRobin(lowVolumeFanouts),
Logger: log.WithFields(log.Fields{
trace.Component: config.Component,
teleport.ComponentKey: config.Component,
}),
}
collections, err := setupCollections(cs, config.Watches)
+1 -1
View File
@@ -47,7 +47,7 @@ import (
)
var log = logrus.WithFields(logrus.Fields{
trace.Component: teleport.ComponentCgroup,
teleport.ComponentKey: teleport.ComponentCgroup,
})
// Config holds configuration for the cgroup service.
+1 -1
View File
@@ -129,7 +129,7 @@ const (
)
var log = logrus.WithFields(logrus.Fields{
trace.Component: teleport.ComponentClient,
teleport.ComponentKey: teleport.ComponentClient,
})
// ForwardedPort specifies local tunnel to remote
+2 -2
View File
@@ -53,7 +53,7 @@ type Store struct {
func NewFSClientStore(dirPath string) *Store {
dirPath = profile.FullProfilePath(dirPath)
return &Store{
log: logrus.WithField(trace.Component, teleport.ComponentKeyStore),
log: logrus.WithField(teleport.ComponentKey, teleport.ComponentKeyStore),
KeyStore: NewFSKeyStore(dirPath),
TrustedCertsStore: NewFSTrustedCertsStore(dirPath),
ProfileStore: NewFSProfileStore(dirPath),
@@ -63,7 +63,7 @@ func NewFSClientStore(dirPath string) *Store {
// NewMemClientStore initializes a new in-memory client store.
func NewMemClientStore() *Store {
return &Store{
log: logrus.WithField(trace.Component, teleport.ComponentKeyStore),
log: logrus.WithField(teleport.ComponentKey, teleport.ComponentKeyStore),
KeyStore: NewMemKeyStore(),
TrustedCertsStore: NewMemTrustedCertsStore(),
ProfileStore: NewMemProfileStore(),
+1 -1
View File
@@ -121,7 +121,7 @@ func NewLocalAgent(conf LocalAgentConfig) (a *LocalKeyAgent, err error) {
}
a = &LocalKeyAgent{
log: logrus.WithFields(logrus.Fields{
trace.Component: teleport.ComponentKeyAgent,
teleport.ComponentKey: teleport.ComponentKeyAgent,
}),
ExtendedAgent: conf.Agent,
clientStore: conf.ClientStore,
+1 -1
View File
@@ -97,7 +97,7 @@ type FSKeyStore struct {
func NewFSKeyStore(dirPath string) *FSKeyStore {
dirPath = profile.FullProfilePath(dirPath)
return &FSKeyStore{
log: logrus.WithField(trace.Component, teleport.ComponentKeyStore),
log: logrus.WithField(teleport.ComponentKey, teleport.ComponentKeyStore),
KeyDir: dirPath,
}
}
+1 -1
View File
@@ -117,7 +117,7 @@ func canPruneOldHostsEntry(oldEntry *knownHostEntry, newEntries []*knownHostEntr
// duplicate entry exists. This may modify order of host keys, but will not
// change their content.
func pruneOldHostKeys(output []string) []string {
log := logrus.WithField(trace.Component, teleport.ComponentMigrate)
log := logrus.WithField(teleport.ComponentKey, teleport.ComponentMigrate)
var (
oldEntries = make([]*knownHostEntry, 0)
+1 -1
View File
@@ -26,7 +26,7 @@ import (
)
var log = logrus.WithFields(logrus.Fields{
trace.Component: teleport.ComponentKubeClient,
teleport.ComponentKey: teleport.ComponentKubeClient,
})
// CheckIfCertsAreAllowedToAccessCluster evaluates if the new cert created by the user
+1 -1
View File
@@ -121,7 +121,7 @@ type FSProfileStore struct {
func NewFSProfileStore(dirPath string) *FSProfileStore {
dirPath = profile.FullProfilePath(dirPath)
return &FSProfileStore{
log: logrus.WithField(trace.Component, teleport.ComponentKeyStore),
log: logrus.WithField(teleport.ComponentKey, teleport.ComponentKeyStore),
Dir: dirPath,
}
}
+1 -1
View File
@@ -29,7 +29,7 @@ import (
)
var log = logrus.WithFields(logrus.Fields{
trace.Component: teleport.ComponentClient,
teleport.ComponentKey: teleport.ComponentClient,
})
// ResizeEvent is emitted when a terminal window is resized.
+1 -1
View File
@@ -171,7 +171,7 @@ type FSTrustedCertsStore struct {
func NewFSTrustedCertsStore(dirPath string) *FSTrustedCertsStore {
dirPath = profile.FullProfilePath(dirPath)
return &FSTrustedCertsStore{
log: logrus.WithField(trace.Component, teleport.ComponentKeyStore),
log: logrus.WithField(teleport.ComponentKey, teleport.ComponentKeyStore),
Dir: dirPath,
}
}
+1 -1
View File
@@ -341,7 +341,7 @@ type TOTPRegisterChallenge struct {
// initClient creates a new client to the HTTPS web proxy.
func initClient(proxyAddr string, insecure bool, pool *x509.CertPool, extraHeaders map[string]string, opts ...roundtrip.ClientParam) (*WebClient, *url.URL, error) {
log := logrus.WithFields(logrus.Fields{
trace.Component: teleport.ComponentClient,
teleport.ComponentKey: teleport.ComponentClient,
})
log.Debugf("HTTPS client init(proxyAddr=%v, insecure=%v, extraHeaders=%v)", proxyAddr, insecure, extraHeaders)
+1 -1
View File
@@ -267,7 +267,7 @@ func (cfg *Config) CheckAndSetDefaults(ctx context.Context) error {
if cfg.LogEntry == nil {
cfg.LogEntry = log.WithFields(log.Fields{
trace.Component: teleport.ComponentAthena,
teleport.ComponentKey: teleport.ComponentAthena,
})
}
+1 -1
View File
@@ -391,7 +391,7 @@ func (cfg *sqsCollectConfig) CheckAndSetDefaults() error {
}
if cfg.logger == nil {
cfg.logger = log.WithFields(log.Fields{
trace.Component: teleport.ComponentAthena,
teleport.ComponentKey: teleport.ComponentAthena,
})
}
if cfg.errHandlingFn == nil {
+2 -1
View File
@@ -44,6 +44,7 @@ import (
"github.com/segmentio/parquet-go"
"github.com/stretchr/testify/require"
"github.com/gravitational/teleport"
apievents "github.com/gravitational/teleport/api/types/events"
"github.com/gravitational/teleport/lib/backend/memory"
"github.com/gravitational/teleport/lib/events"
@@ -576,7 +577,7 @@ func TestErrHandlingFnFromSQS(t *testing.T) {
require.NoError(t, err)
cfg := &Config{
LogEntry: log.WithField(trace.Component, "test"),
LogEntry: log.WithField(teleport.ComponentKey, "test"),
metrics: metrics,
}
+1 -1
View File
@@ -113,7 +113,7 @@ func (cfg *querierConfig) CheckAndSetDefaults() error {
if cfg.logger == nil {
cfg.logger = log.WithFields(log.Fields{
trace.Component: teleport.ComponentAthena,
teleport.ComponentKey: teleport.ComponentAthena,
})
}
if cfg.clock == nil {
+1 -1
View File
@@ -302,7 +302,7 @@ func NewAuditLog(cfg AuditLogConfig) (*AuditLog, error) {
playbackDir: filepath.Join(cfg.DataDir, PlaybackDir, SessionLogsDir, apidefaults.Namespace),
AuditLogConfig: cfg,
log: log.WithFields(log.Fields{
trace.Component: teleport.ComponentAuditLog,
teleport.ComponentKey: teleport.ComponentAuditLog,
}),
activeDownloads: make(map[string]context.Context),
ctx: ctx,
+1 -1
View File
@@ -160,7 +160,7 @@ func (c *Config) CheckAndSetDefaults() error {
}
if c.Log == nil {
c.Log = logrus.WithField(trace.Component, "azblob")
c.Log = logrus.WithField(teleport.ComponentKey, "azblob")
}
return nil
+1 -1
View File
@@ -97,7 +97,7 @@ func NewUploadCompleter(cfg UploadCompleterConfig) (*UploadCompleter, error) {
u := &UploadCompleter{
cfg: cfg,
log: log.WithFields(log.Fields{
trace.Component: teleport.Component(cfg.Component, "completer"),
teleport.ComponentKey: teleport.Component(cfg.Component, "completer"),
}),
closeC: make(chan struct{}),
}
+1 -1
View File
@@ -251,7 +251,7 @@ const (
// It's an implementation of backend API's NewFunc
func New(ctx context.Context, cfg Config) (*Log, error) {
l := log.WithFields(log.Fields{
trace.Component: teleport.Component(teleport.ComponentDynamoDB),
teleport.ComponentKey: teleport.Component(teleport.ComponentDynamoDB),
})
l.Info("Initializing event backend.")
+1 -1
View File
@@ -273,7 +273,7 @@ func (*LoggingEmitter) EmitAuditEvent(ctx context.Context, event apievents.Audit
if err != nil {
return trace.Wrap(err)
}
fields[trace.Component] = teleport.Component(teleport.ComponentAuditLog)
fields[teleport.ComponentKey] = teleport.Component(teleport.ComponentAuditLog)
log.WithFields(fields).Infof(event.GetType())
return nil
+3 -3
View File
@@ -21,9 +21,9 @@ package eventstest
import (
"context"
"github.com/gravitational/trace"
"github.com/sirupsen/logrus"
"github.com/gravitational/teleport"
apievents "github.com/gravitational/teleport/api/types/events"
"github.com/gravitational/teleport/lib/session"
)
@@ -37,7 +37,7 @@ type ChannelEmitter struct {
// NewChannelEmitter returns a new instance of test emitter.
func NewChannelEmitter(capacity int) *ChannelEmitter {
return &ChannelEmitter{
log: logrus.WithField(trace.Component, "channel_emitter"),
log: logrus.WithField(teleport.ComponentKey, "channel_emitter"),
events: make(chan apievents.AuditEvent, capacity),
}
}
@@ -65,7 +65,7 @@ type ChannelRecorder struct {
// NewChannelRecorder returns a new instance of test recorder.
func NewChannelRecorder(capacity int) *ChannelRecorder {
return &ChannelRecorder{
log: logrus.WithField(trace.Component, "channel_recorder"),
log: logrus.WithField(teleport.ComponentKey, "channel_recorder"),
events: make(chan apievents.AuditEvent, capacity),
}
}
+1 -1
View File
@@ -102,7 +102,7 @@ func NewFileLog(cfg FileLogConfig) (*FileLog, error) {
f := &FileLog{
FileLogConfig: cfg,
Entry: log.WithFields(log.Fields{
trace.Component: teleport.ComponentAuditLog,
teleport.ComponentKey: teleport.ComponentAuditLog,
}),
}
return f, nil
+1 -1
View File
@@ -105,7 +105,7 @@ func NewUploader(cfg UploaderConfig) (*Uploader, error) {
uploader := &Uploader{
cfg: cfg,
log: logrus.WithFields(logrus.Fields{
trace.Component: cfg.Component,
teleport.ComponentKey: cfg.Component,
}),
closeC: make(chan struct{}),
semaphore: make(chan struct{}, cfg.ConcurrentUploads),
+1 -1
View File
@@ -74,7 +74,7 @@ func NewHandler(cfg Config) (*Handler, error) {
h := &Handler{
Entry: log.WithFields(log.Fields{
trace.Component: teleport.Component(teleport.SchemeFile),
teleport.ComponentKey: teleport.Component(teleport.SchemeFile),
}),
Config: cfg,
}
@@ -275,7 +275,7 @@ func New(cfg EventsConfig) (*Log, error) {
}
l := log.WithFields(log.Fields{
trace.Component: teleport.Component(teleport.ComponentFirestore),
teleport.ComponentKey: teleport.Component(teleport.ComponentFirestore),
})
l.Info("Initializing event backend.")
closeCtx, cancel := context.WithCancel(context.Background())
+1 -1
View File
@@ -200,7 +200,7 @@ func NewHandler(ctx context.Context, cancelFunc context.CancelFunc, cfg Config,
}
h := &Handler{
Entry: log.WithFields(log.Fields{
trace.Component: teleport.Component(teleport.SchemeGCS),
teleport.ComponentKey: teleport.Component(teleport.SchemeGCS),
}),
Config: cfg,
gcsClient: client,
+2 -1
View File
@@ -33,6 +33,7 @@ import (
"github.com/jackc/pgx/v5/pgxpool"
"github.com/sirupsen/logrus"
"github.com/gravitational/teleport"
"github.com/gravitational/teleport/api/types"
apievents "github.com/gravitational/teleport/api/types/events"
pgcommon "github.com/gravitational/teleport/lib/backend/pgbk/common"
@@ -175,7 +176,7 @@ func (c *Config) CheckAndSetDefaults() error {
}
if c.Log == nil {
c.Log = logrus.WithField(trace.Component, componentName)
c.Log = logrus.WithField(teleport.ComponentKey, componentName)
}
return nil
+1 -1
View File
@@ -210,7 +210,7 @@ func NewHandler(ctx context.Context, cfg Config) (*Handler, error) {
h := &Handler{
Entry: log.WithFields(log.Fields{
trace.Component: teleport.Component(teleport.SchemeS3),
teleport.ComponentKey: teleport.Component(teleport.SchemeS3),
}),
Config: cfg,
uploader: uploader,
+2 -1
View File
@@ -30,6 +30,7 @@ import (
"github.com/jonboulle/clockwork"
logrus "github.com/sirupsen/logrus"
"github.com/gravitational/teleport"
apievents "github.com/gravitational/teleport/api/types/events"
"github.com/gravitational/teleport/api/utils/retryutils"
"github.com/gravitational/teleport/lib/session"
@@ -51,7 +52,7 @@ func NewSessionWriter(cfg SessionWriterConfig) (*SessionWriter, error) {
cfg: cfg,
stream: stream,
log: logrus.WithFields(logrus.Fields{
trace.Component: cfg.Component,
teleport.ComponentKey: cfg.Component,
}),
cancel: cancel,
closeCtx: ctx,
+1 -2
View File
@@ -21,7 +21,6 @@ package usageevents
import (
"context"
"github.com/gravitational/trace"
"github.com/sirupsen/logrus"
"github.com/gravitational/teleport"
@@ -84,7 +83,7 @@ func New(reporter usagereporter.UsageReporter, log logrus.FieldLogger, inner api
return &UsageLogger{
Entry: log.WithField(
trace.Component,
teleport.ComponentKey,
teleport.Component(teleport.ComponentUsageReporting),
),
reporter: reporter,
@@ -33,6 +33,7 @@ import (
"github.com/jonboulle/clockwork"
"github.com/sirupsen/logrus"
"github.com/gravitational/teleport"
"github.com/gravitational/teleport/api/types"
"github.com/gravitational/teleport/api/types/externalauditstorage"
"github.com/gravitational/teleport/lib/modules"
@@ -322,7 +323,7 @@ func newCredentialsCache(ctx context.Context, region, roleARN string, options *O
gotFirstCredsOrErr := make(chan struct{})
return &credentialsCache{
roleARN: roleARN,
log: logrus.WithField(trace.Component, "ExternalAuditStorage.CredentialsCache"),
log: logrus.WithField(teleport.ComponentKey, "ExternalAuditStorage.CredentialsCache"),
initialized: initialized,
closeInitialized: sync.OnceFunc(func() { close(initialized) }),
gotFirstCredsOrErr: gotFirstCredsOrErr,
@@ -31,6 +31,7 @@ import (
"github.com/jonboulle/clockwork"
"github.com/sirupsen/logrus"
"github.com/gravitational/teleport"
"github.com/gravitational/teleport/api/types"
apievents "github.com/gravitational/teleport/api/types/events"
"github.com/gravitational/teleport/lib/events"
@@ -50,7 +51,7 @@ const (
syncInterval = 30 * time.Second
)
var log = logrus.WithField(trace.Component, "ExternalAuditStorage")
var log = logrus.WithField(teleport.ComponentKey, "ExternalAuditStorage")
// ClusterAlertService abstracts a service providing Upsert and Delete
// operations for cluster alerts.
+2 -1
View File
@@ -28,6 +28,7 @@ import (
"github.com/sirupsen/logrus"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"github.com/gravitational/teleport"
"github.com/gravitational/teleport/api/defaults"
proto "github.com/gravitational/teleport/api/gen/proto/go/teleport/kube/v1"
"github.com/gravitational/teleport/api/types"
@@ -118,7 +119,7 @@ func (c *Config) CheckAndSetDefaults() error {
if c.Log == nil {
c.Log = logrus.New()
}
c.Log = c.Log.WithFields(logrus.Fields{trace.Component: c.Component})
c.Log = c.Log.WithFields(logrus.Fields{teleport.ComponentKey: c.Component})
return nil
}
+1 -1
View File
@@ -39,7 +39,7 @@ import (
)
var log = logrus.WithFields(logrus.Fields{
trace.Component: teleport.ComponentKubeClient,
teleport.ComponentKey: teleport.ComponentKubeClient,
})
const (
+2 -2
View File
@@ -92,8 +92,8 @@ func runPortForwardingHTTPStreams(req portForwardRequest) error {
h := &portForwardProxy{
Entry: log.WithFields(log.Fields{
trace.Component: teleport.Component(teleport.ComponentProxyKube),
events.RemoteAddr: req.httpRequest.RemoteAddr,
teleport.ComponentKey: teleport.Component(teleport.ComponentProxyKube),
events.RemoteAddr: req.httpRequest.RemoteAddr,
}),
portForwardRequest: req,
sourceConn: conn,
+2 -2
View File
@@ -144,8 +144,8 @@ func runPortForwardingWebSocket(req portForwardRequest) error {
targetConn: targetConn,
onPortForward: req.onPortForward,
FieldLogger: logrus.WithFields(logrus.Fields{
trace.Component: teleport.Component(teleport.ComponentProxyKube),
events.RemoteAddr: req.httpRequest.RemoteAddr,
teleport.ComponentKey: teleport.Component(teleport.ComponentProxyKube),
events.RemoteAddr: req.httpRequest.RemoteAddr,
}),
context: req.context,
}
+1 -1
View File
@@ -192,7 +192,7 @@ func NewTLSServer(cfg TLSServerConfig) (*TLSServer, error) {
return nil, trace.Wrap(err)
}
log := cfg.Log.WithFields(logrus.Fields{
trace.Component: cfg.Component,
teleport.ComponentKey: cfg.Component,
})
// limiter limits requests by frequency and amount of simultaneous
// connections per client
+2 -1
View File
@@ -39,6 +39,7 @@ import (
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/client-go/tools/remotecommand"
"github.com/gravitational/teleport"
"github.com/gravitational/teleport/api/types"
apievents "github.com/gravitational/teleport/api/types/events"
"github.com/gravitational/teleport/lib/auth"
@@ -242,7 +243,7 @@ func Test_session_trackSession(t *testing.T) {
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
sess := &session{
log: logrus.New().WithField(trace.Component, "test"),
log: logrus.New().WithField(teleport.ComponentKey, "test"),
id: uuid.New(),
req: &http.Request{
URL: &url.URL{},
+2 -1
View File
@@ -29,6 +29,7 @@ import (
"github.com/jonboulle/clockwork"
"github.com/sirupsen/logrus"
"github.com/gravitational/teleport"
"github.com/gravitational/teleport/api/types"
"github.com/gravitational/teleport/lib/cloud"
)
@@ -66,7 +67,7 @@ func (conf *CloudConfig) checkAndSetDefaults() error {
conf.Clock = clockwork.NewRealClock()
}
if conf.Log == nil {
conf.Log = logrus.WithField(trace.Component, "cloudlabels")
conf.Log = logrus.WithField(teleport.ComponentKey, "cloudlabels")
}
return nil
}
+1 -1
View File
@@ -155,7 +155,7 @@ func New(cfg Config) (*Mux, error) {
waitContext, waitCancel := context.WithCancel(context.TODO())
return &Mux{
Entry: log.WithFields(log.Fields{
trace.Component: teleport.Component("mx", cfg.ID),
teleport.ComponentKey: teleport.Component("mx", cfg.ID),
}),
Config: cfg,
context: ctx,
+2 -1
View File
@@ -25,6 +25,7 @@ import (
"github.com/gravitational/trace"
"github.com/sirupsen/logrus"
"github.com/gravitational/teleport"
"github.com/gravitational/teleport/lib/utils"
)
@@ -49,7 +50,7 @@ func NewTestProxy(target string, v2 bool) (*TestProxy, error) {
listener: listener,
target: target,
closeCh: make(chan struct{}),
log: logrus.WithField(trace.Component, "test:proxy"),
log: logrus.WithField(teleport.ComponentKey, "test:proxy"),
v2: v2,
}, nil
}
+1 -1
View File
@@ -74,7 +74,7 @@ func NewTLSListener(cfg TLSListenerConfig) (*TLSListener, error) {
context, cancel := context.WithCancel(context.TODO())
return &TLSListener{
log: log.WithFields(log.Fields{
trace.Component: teleport.Component("mxtls", cfg.ID),
teleport.ComponentKey: teleport.Component("mxtls", cfg.ID),
}),
cfg: cfg,
http2Listener: newListener(context, cfg.Listener.Addr()),
+2 -1
View File
@@ -30,6 +30,7 @@ import (
"github.com/jonboulle/clockwork"
"github.com/sirupsen/logrus"
"github.com/gravitational/teleport"
"github.com/gravitational/teleport/lib/defaults"
dbcommon "github.com/gravitational/teleport/lib/srv/db/dbutils"
"github.com/gravitational/teleport/lib/utils"
@@ -66,7 +67,7 @@ func NewWebListener(cfg WebListenerConfig) (*WebListener, error) {
}
context, cancel := context.WithCancel(context.Background())
return &WebListener{
log: logrus.WithField(trace.Component, "mxweb"),
log: logrus.WithField(teleport.ComponentKey, "mxweb"),
cfg: cfg,
webListener: newListener(context, cfg.Listener.Addr()),
dbListener: newListener(context, cfg.Listener.Addr()),
+1 -1
View File
@@ -99,7 +99,7 @@ func (c *Config) CheckAndSetDefaults() error {
}
if c.Logger == nil {
c.Logger = logrus.WithField(trace.Component, teleport.ComponentTracing)
c.Logger = logrus.WithField(teleport.ComponentKey, teleport.ComponentTracing)
}
if c.Client != nil {
+1 -1
View File
@@ -102,7 +102,7 @@ func init() {
}
var log = logrus.WithFields(logrus.Fields{
trace.Component: teleport.ComponentPAM,
teleport.ComponentKey: teleport.ComponentPAM,
})
const (
+2 -1
View File
@@ -30,6 +30,7 @@ import (
"github.com/jonboulle/clockwork"
"github.com/sirupsen/logrus"
"github.com/gravitational/teleport"
"github.com/gravitational/teleport/api/types/events"
"github.com/gravitational/teleport/lib/session"
)
@@ -108,7 +109,7 @@ func New(cfg *Config) (*Player, error) {
var log logrus.FieldLogger = cfg.Log
if log == nil {
log = logrus.New().WithField(trace.Component, "player")
log = logrus.New().WithField(teleport.ComponentKey, "player")
}
p := &Player{
+1 -1
View File
@@ -103,7 +103,7 @@ func (c *ClientConfig) checkAndSetDefaults() error {
}
c.Log = c.Log.WithField(
trace.Component,
teleport.ComponentKey,
teleport.Component(teleport.ComponentProxyPeer),
)
+1 -1
View File
@@ -68,7 +68,7 @@ func (c *ServerConfig) checkAndSetDefaults() error {
c.Log = logrus.New()
}
c.Log = c.Log.WithField(
trace.Component,
teleport.ComponentKey,
teleport.Component(teleport.ComponentProxy, "peer"),
)
+1 -1
View File
@@ -136,7 +136,7 @@ type RouterConfig struct {
// CheckAndSetDefaults ensures the required items were populated
func (c *RouterConfig) CheckAndSetDefaults() error {
if c.Log == nil {
c.Log = logrus.WithField(trace.Component, "Router")
c.Log = logrus.WithField(teleport.ComponentKey, "Router")
}
if c.ClusterName == "" {
+2 -2
View File
@@ -480,7 +480,7 @@ type fakeConn struct {
func TestRouter_DialHost(t *testing.T) {
t.Parallel()
logger := utils.NewLoggerForTests().WithField(trace.Component, "test")
logger := utils.NewLoggerForTests().WithField(teleport.ComponentKey, "test")
srv := &types.ServerV2{
Kind: types.KindNode,
@@ -654,7 +654,7 @@ func TestRouter_DialSite(t *testing.T) {
t.Parallel()
const cluster = "test"
logger := utils.NewLoggerForTests().WithField(trace.Component, cluster)
logger := utils.NewLoggerForTests().WithField(teleport.ComponentKey, cluster)
cases := []struct {
name string
+2 -1
View File
@@ -29,6 +29,7 @@ import (
"github.com/gravitational/trace"
"github.com/sirupsen/logrus"
"github.com/gravitational/teleport"
"github.com/gravitational/teleport/lib/multiplexer"
"github.com/gravitational/teleport/lib/sshutils"
"github.com/gravitational/teleport/lib/utils"
@@ -79,7 +80,7 @@ type SSHServerWrapperConfig struct {
// NewSSHServerWrapper creates a [SSHServerWrapper].
func NewSSHServerWrapper(cfg SSHServerWrapperConfig) *SSHServerWrapper {
if cfg.Log == nil {
cfg.Log = logrus.WithField(trace.Component, Component)
cfg.Log = logrus.WithField(teleport.ComponentKey, Component)
}
return &SSHServerWrapper{
+2 -2
View File
@@ -202,8 +202,8 @@ func NewAgentPool(ctx context.Context, config AgentPoolConfig) (*AgentPool, erro
events: make(chan Agent),
backoff: retry,
log: logrus.WithFields(logrus.Fields{
trace.Component: teleport.ComponentReverseTunnelAgent,
trace.ComponentFields: logrus.Fields{
teleport.ComponentKey: teleport.ComponentReverseTunnelAgent,
teleport.ComponentFields: logrus.Fields{
"targetCluster": config.Cluster,
"localCluster": config.LocalCluster,
},
+2 -1
View File
@@ -31,6 +31,7 @@ import (
"github.com/sirupsen/logrus"
"golang.org/x/crypto/ssh"
"github.com/gravitational/teleport"
"github.com/gravitational/teleport/api/types"
"github.com/gravitational/teleport/api/utils/sshutils"
)
@@ -109,7 +110,7 @@ type connConfig struct {
func newRemoteConn(cfg *connConfig) *remoteConn {
c := &remoteConn{
log: logrus.WithFields(logrus.Fields{
trace.Component: "discovery",
teleport.ComponentKey: "discovery",
}),
connConfig: cfg,
clock: clockwork.NewRealClock(),
+2 -2
View File
@@ -102,8 +102,8 @@ func newLocalSite(srv *server, domainName string, authServers []string, opts ...
remoteConns: make(map[connKey][]*remoteConn),
clock: srv.Clock,
log: log.WithFields(log.Fields{
trace.Component: teleport.ComponentReverseTunnelServer,
trace.ComponentFields: map[string]string{
teleport.ComponentKey: teleport.ComponentReverseTunnelServer,
teleport.ComponentFields: map[string]string{
"cluster": domainName,
},
}),
+2 -2
View File
@@ -157,8 +157,8 @@ func newClusterPeer(srv *server, connInfo types.TunnelConnection, offlineThresho
srv: srv,
connInfo: connInfo,
log: log.WithFields(log.Fields{
trace.Component: teleport.ComponentReverseTunnelServer,
trace.ComponentFields: map[string]string{
teleport.ComponentKey: teleport.ComponentReverseTunnelServer,
teleport.ComponentFields: map[string]string{
"cluster": connInfo.GetClusterName(),
},
}),
+3 -3
View File
@@ -269,7 +269,7 @@ func (cfg *Config) CheckAndSetDefaults() error {
logger = log.StandardLogger()
}
cfg.Log = logger.WithFields(log.Fields{
trace.Component: cfg.Component,
teleport.ComponentKey: cfg.Component,
})
if cfg.LockWatcher == nil {
return trace.BadParameter("missing parameter LockWatcher")
@@ -1181,8 +1181,8 @@ func newRemoteSite(srv *server, domainName string, sconn ssh.Conn) (*remoteSite,
domainName: domainName,
connInfo: connInfo,
logger: log.WithFields(log.Fields{
trace.Component: teleport.ComponentReverseTunnelServer,
trace.ComponentFields: log.Fields{
teleport.ComponentKey: teleport.ComponentReverseTunnelServer,
teleport.ComponentFields: log.Fields{
"cluster": domainName,
},
}),
+2 -2
View File
@@ -83,7 +83,7 @@ func (process *TeleportProcess) initAWSOIDCDeployServiceUpdater() error {
}
updater, err := NewDeployServiceUpdater(AWSOIDCDeployServiceUpdaterConfig{
Log: process.log.WithField(trace.Component, teleport.Component(teleport.ComponentProxy, "aws_oidc_deploy_service_updater")),
Log: process.log.WithField(teleport.ComponentKey, teleport.Component(teleport.ComponentProxy, "aws_oidc_deploy_service_updater")),
AuthClient: authClient,
Clock: process.Clock,
TeleportClusterName: clusterNameConfig.GetClusterName(),
@@ -129,7 +129,7 @@ func (cfg *AWSOIDCDeployServiceUpdaterConfig) CheckAndSetDefaults() error {
}
if cfg.Log == nil {
cfg.Log = logrus.WithField(trace.Component, teleport.Component(teleport.ComponentProxy, "aws_oidc_deploy_service_updater"))
cfg.Log = logrus.WithField(teleport.ComponentKey, teleport.Component(teleport.ComponentProxy, "aws_oidc_deploy_service_updater"))
}
if cfg.Clock == nil {
+1 -1
View File
@@ -58,7 +58,7 @@ type CertReloader struct {
func NewCertReloader(cfg CertReloaderConfig) *CertReloader {
return &CertReloader{
Entry: log.WithFields(log.Fields{
trace.Component: teleport.Component(teleport.ComponentProxy, "certreloader"),
teleport.ComponentKey: teleport.Component(teleport.ComponentProxy, "certreloader"),
}),
cfg: cfg,
}
+3 -3
View File
@@ -47,7 +47,7 @@ func (process *TeleportProcess) initDatabases() {
}
func (process *TeleportProcess) initDatabaseService() (retErr error) {
logger := process.logger.With(trace.Component, teleport.Component(teleport.ComponentDatabase, process.id))
logger := process.logger.With(teleport.ComponentKey, teleport.Component(teleport.ComponentDatabase, process.id))
conn, err := process.WaitForConnector(DatabasesIdentityEvent, logger)
if conn == nil {
@@ -87,7 +87,7 @@ func (process *TeleportProcess) initDatabaseService() (retErr error) {
lockWatcher, err := services.NewLockWatcher(process.ExitContext(), services.LockWatcherConfig{
ResourceWatcherConfig: services.ResourceWatcherConfig{
Component: teleport.ComponentDatabase,
Log: process.log.WithField(trace.Component, teleport.Component(teleport.ComponentDatabase, process.id)),
Log: process.log.WithField(teleport.ComponentKey, teleport.Component(teleport.ComponentDatabase, process.id)),
Client: conn.Client,
},
})
@@ -100,7 +100,7 @@ func (process *TeleportProcess) initDatabaseService() (retErr error) {
ClusterName: clusterName,
AccessPoint: accessPoint,
LockWatcher: lockWatcher,
Logger: process.log.WithField(trace.Component, teleport.Component(teleport.ComponentDatabase, process.id)),
Logger: process.log.WithField(teleport.ComponentKey, teleport.Component(teleport.ComponentDatabase, process.id)),
})
if err != nil {
return trace.Wrap(err)
+4 -4
View File
@@ -45,7 +45,7 @@ import (
)
func (process *TeleportProcess) initWindowsDesktopService() {
logger := process.logger.With(trace.Component, teleport.Component(teleport.ComponentWindowsDesktop, process.id))
logger := process.logger.With(teleport.ComponentKey, teleport.Component(teleport.ComponentWindowsDesktop, process.id))
process.RegisterWithAuthServer(types.RoleWindowsDesktop, WindowsDesktopIdentityEvent)
process.RegisterCriticalFunc("windows_desktop.init", func() error {
conn, err := process.WaitForConnector(WindowsDesktopIdentityEvent, logger)
@@ -144,7 +144,7 @@ func (process *TeleportProcess) initWindowsDesktopServiceRegistered(logger *slog
lockWatcher, err := services.NewLockWatcher(process.ExitContext(), services.LockWatcherConfig{
ResourceWatcherConfig: services.ResourceWatcherConfig{
Component: teleport.ComponentWindowsDesktop,
Log: process.log.WithField(trace.Component, teleport.Component(teleport.ComponentWindowsDesktop, process.id)),
Log: process.log.WithField(teleport.ComponentKey, teleport.Component(teleport.ComponentWindowsDesktop, process.id)),
Clock: cfg.Clock,
Client: conn.Client,
},
@@ -159,7 +159,7 @@ func (process *TeleportProcess) initWindowsDesktopServiceRegistered(logger *slog
ClusterName: clusterName,
AccessPoint: accessPoint,
LockWatcher: lockWatcher,
Logger: process.log.WithField(trace.Component, teleport.Component(teleport.ComponentWindowsDesktop, process.id)),
Logger: process.log.WithField(teleport.ComponentKey, teleport.Component(teleport.ComponentWindowsDesktop, process.id)),
// Device authorization breaks browser-based access.
DeviceAuthorization: authz.DeviceAuthorizationOpts{
DisableGlobalMode: true,
@@ -212,7 +212,7 @@ func (process *TeleportProcess) initWindowsDesktopServiceRegistered(logger *slog
srv, err := desktop.NewWindowsService(desktop.WindowsServiceConfig{
DataDir: process.Config.DataDir,
Log: process.log.WithField(trace.Component, teleport.Component(teleport.ComponentWindowsDesktop, process.id)),
Log: process.log.WithField(teleport.ComponentKey, teleport.Component(teleport.ComponentWindowsDesktop, process.id)),
Clock: process.Clock,
Authorizer: authorizer,
Emitter: conn.Client,
+1 -1
View File
@@ -37,7 +37,7 @@ func (process *TeleportProcess) initDiscovery() {
}
func (process *TeleportProcess) initDiscoveryService() error {
logger := process.logger.With(trace.Component, teleport.Component(teleport.ComponentDiscovery, process.id))
logger := process.logger.With(teleport.ComponentKey, teleport.Component(teleport.ComponentDiscovery, process.id))
conn, err := process.WaitForConnector(DiscoveryIdentityEvent, logger)
if conn == nil {
+5 -5
View File
@@ -39,7 +39,7 @@ import (
)
func (process *TeleportProcess) initKubernetes() {
logger := process.logger.With(trace.Component, teleport.Component(teleport.ComponentKube, process.id))
logger := process.logger.With(teleport.ComponentKey, teleport.Component(teleport.ComponentKube, process.id))
process.RegisterWithAuthServer(types.RoleKube, KubeIdentityEvent)
process.RegisterCriticalFunc("kube.init", func() error {
@@ -152,7 +152,7 @@ func (process *TeleportProcess) initKubernetesService(logger *slog.Logger, conn
if len(cfg.Kube.DynamicLabels) != 0 {
dynLabels, err = labels.NewDynamic(process.ExitContext(), &labels.DynamicConfig{
Labels: cfg.Kube.DynamicLabels,
Log: process.log.WithField(trace.Component, teleport.Component(teleport.ComponentKube, process.id)),
Log: process.log.WithField(teleport.ComponentKey, teleport.Component(teleport.ComponentKube, process.id)),
})
if err != nil {
return trace.Wrap(err)
@@ -169,7 +169,7 @@ func (process *TeleportProcess) initKubernetesService(logger *slog.Logger, conn
lockWatcher, err := services.NewLockWatcher(process.ExitContext(), services.LockWatcherConfig{
ResourceWatcherConfig: services.ResourceWatcherConfig{
Component: teleport.ComponentKube,
Log: process.log.WithField(trace.Component, teleport.Component(teleport.ComponentKube, process.id)),
Log: process.log.WithField(teleport.ComponentKey, teleport.Component(teleport.ComponentKube, process.id)),
Client: conn.Client,
},
})
@@ -182,7 +182,7 @@ func (process *TeleportProcess) initKubernetesService(logger *slog.Logger, conn
ClusterName: teleportClusterName,
AccessPoint: accessPoint,
LockWatcher: lockWatcher,
Logger: process.log.WithField(trace.Component, teleport.Component(teleport.ComponentKube, process.id)),
Logger: process.log.WithField(teleport.ComponentKey, teleport.Component(teleport.ComponentKube, process.id)),
})
if err != nil {
return trace.Wrap(err)
@@ -236,7 +236,7 @@ func (process *TeleportProcess) initKubernetesService(logger *slog.Logger, conn
StaticLabels: cfg.Kube.StaticLabels,
DynamicLabels: dynLabels,
CloudLabels: process.cloudLabels,
Log: process.log.WithField(trace.Component, teleport.Component(teleport.ComponentKube, process.id)),
Log: process.log.WithField(teleport.ComponentKey, teleport.Component(teleport.ComponentKube, process.id)),
PROXYProtocolMode: multiplexer.PROXYProtocolOff, // Kube service doesn't need to process unsigned PROXY headers.
})
if err != nil {
+43 -43
View File
@@ -830,11 +830,11 @@ func NewTeleport(cfg *servicecfg.Config) (*TeleportProcess, error) {
processID := fmt.Sprintf("%v", nextProcessID())
cfg.Log = utils.WrapLogger(cfg.Log.WithFields(logrus.Fields{
trace.Component: teleport.Component(teleport.ComponentProcess, processID),
"pid": fmt.Sprintf("%v.%v", os.Getpid(), processID),
teleport.ComponentKey: teleport.Component(teleport.ComponentProcess, processID),
"pid": fmt.Sprintf("%v.%v", os.Getpid(), processID),
}))
cfg.Logger = cfg.Logger.With(
trace.Component, teleport.Component(teleport.ComponentProcess, processID),
teleport.ComponentKey, teleport.Component(teleport.ComponentProcess, processID),
"pid", fmt.Sprintf("%v.%v", os.Getpid(), processID),
)
@@ -1792,7 +1792,7 @@ func (process *TeleportProcess) initAuthService() error {
if err != nil {
return trace.Wrap(err)
}
traceConf.Logger = process.log.WithField(trace.Component, teleport.ComponentTracing)
traceConf.Logger = process.log.WithField(teleport.ComponentKey, teleport.ComponentTracing)
clt, err := tracing.NewStartedClient(process.ExitContext(), *traceConf)
if err != nil {
@@ -1895,12 +1895,12 @@ func (process *TeleportProcess) initAuthService() error {
return trace.Wrap(err)
}
logger := process.logger.With(trace.Component, teleport.Component(teleport.ComponentAuth, process.id))
logger := process.logger.With(teleport.ComponentKey, teleport.Component(teleport.ComponentAuth, process.id))
lockWatcher, err := services.NewLockWatcher(process.ExitContext(), services.LockWatcherConfig{
ResourceWatcherConfig: services.ResourceWatcherConfig{
Component: teleport.ComponentAuth,
Log: process.log.WithField(trace.Component, teleport.Component(teleport.ComponentAuth, process.id)),
Log: process.log.WithField(teleport.ComponentKey, teleport.Component(teleport.ComponentAuth, process.id)),
Client: authServer.Services,
},
})
@@ -1917,7 +1917,7 @@ func (process *TeleportProcess) initAuthService() error {
ResourceWatcherConfig: services.ResourceWatcherConfig{
QueueSize: defaults.UnifiedResourcesQueueSize,
Component: teleport.ComponentUnifiedResource,
Log: process.log.WithField(trace.Component, teleport.ComponentUnifiedResource),
Log: process.log.WithField(teleport.ComponentKey, teleport.ComponentUnifiedResource),
Client: authServer,
MaxStaleness: time.Minute,
},
@@ -1946,7 +1946,7 @@ func (process *TeleportProcess) initAuthService() error {
EmbeddingsRetriever: embeddingsRetriever,
EmbeddingSrv: authServer,
NodeSrv: authServer.UnifiedResourceCache,
Log: process.log.WithField(trace.Component, teleport.Component(teleport.ComponentAuth, process.id)),
Log: process.log.WithField(teleport.ComponentKey, teleport.Component(teleport.ComponentAuth, process.id)),
Jitter: retryutils.NewFullJitter(),
})
@@ -2013,7 +2013,7 @@ func (process *TeleportProcess) initAuthService() error {
AccessPoint: authServer,
MFAAuthenticator: authServer,
LockWatcher: lockWatcher,
Logger: process.log.WithField(trace.Component, teleport.Component(teleport.ComponentAuth, process.id)),
Logger: process.log.WithField(teleport.ComponentKey, teleport.Component(teleport.ComponentAuth, process.id)),
// Auth Server does explicit device authorization.
// Various Auth APIs must allow access to unauthorized devices, otherwise it
// is not possible to acquire device-aware certificates in the first place.
@@ -2488,7 +2488,7 @@ func (process *TeleportProcess) initInstance() error {
}
process.RegisterWithAuthServer(types.RoleInstance, InstanceIdentityEvent)
logger := process.logger.With(trace.Component, teleport.Component(teleport.ComponentInstance, process.id))
logger := process.logger.With(teleport.ComponentKey, teleport.Component(teleport.ComponentInstance, process.id))
process.RegisterCriticalFunc("instance.init", func() error {
conn, err := process.WaitForConnector(InstanceIdentityEvent, logger)
@@ -2509,7 +2509,7 @@ func (process *TeleportProcess) initInstance() error {
func (process *TeleportProcess) initSSH() error {
process.RegisterWithAuthServer(types.RoleNode, SSHIdentityEvent)
logger := process.logger.With(trace.Component, teleport.Component(teleport.ComponentNode, process.id))
logger := process.logger.With(teleport.ComponentKey, teleport.Component(teleport.ComponentNode, process.id))
proxyGetter := reversetunnel.NewConnectedProxyGetter()
@@ -2618,7 +2618,7 @@ func (process *TeleportProcess) initSSH() error {
lockWatcher, err := services.NewLockWatcher(process.ExitContext(), services.LockWatcherConfig{
ResourceWatcherConfig: services.ResourceWatcherConfig{
Component: teleport.ComponentNode,
Log: process.log.WithField(trace.Component, teleport.Component(teleport.ComponentNode, process.id)),
Log: process.log.WithField(teleport.ComponentKey, teleport.Component(teleport.ComponentNode, process.id)),
Client: conn.Client,
},
})
@@ -2640,7 +2640,7 @@ func (process *TeleportProcess) initSSH() error {
LockEnforcer: lockWatcher,
Emitter: &events.StreamerAndEmitter{Emitter: asyncEmitter, Streamer: conn.Client},
Component: teleport.ComponentNode,
Logger: process.log.WithField(trace.Component, teleport.Component(teleport.ComponentNode, process.id)).WithField(trace.Component, "sessionctrl"),
Logger: process.log.WithField(teleport.ComponentKey, teleport.Component(teleport.ComponentNode, process.id)).WithField(teleport.ComponentKey, "sessionctrl"),
TracerProvider: process.TracingProvider,
ServerID: serverID,
})
@@ -2694,7 +2694,7 @@ func (process *TeleportProcess) initSSH() error {
var resumableServer *resumption.SSHServerWrapper
if os.Getenv("TELEPORT_UNSTABLE_DISABLE_SSH_RESUMPTION") == "" {
resumableServer = resumption.NewSSHServerWrapper(resumption.SSHServerWrapperConfig{
Log: process.log.WithField(trace.Component, teleport.Component(teleport.ComponentNode, resumption.Component)),
Log: process.log.WithField(teleport.ComponentKey, teleport.Component(teleport.ComponentNode, resumption.Component)),
SSHServer: s.HandleConnection,
HostID: serverID,
@@ -2875,7 +2875,7 @@ func waitForInstanceConnector(process *TeleportProcess, log *slog.Logger) (*Conn
func (process *TeleportProcess) initUploaderService() error {
component := teleport.Component(teleport.ComponentUpload, process.id)
logger := process.logger.With(trace.Component, component)
logger := process.logger.With(teleport.ComponentKey, component)
var clusterName string
@@ -3017,7 +3017,7 @@ func (process *TeleportProcess) initMetricsService() error {
mux := http.NewServeMux()
mux.Handle("/metrics", promhttp.Handler())
logger := process.logger.With(trace.Component, teleport.Component(teleport.ComponentMetrics, process.id))
logger := process.logger.With(teleport.ComponentKey, teleport.Component(teleport.ComponentMetrics, process.id))
listener, err := process.importOrCreateListener(ListenerMetrics, process.Config.Metrics.ListenAddr.Addr)
if err != nil {
@@ -3126,7 +3126,7 @@ func (process *TeleportProcess) initDiagnosticService() error {
roundtrip.ReplyJSON(w, http.StatusOK, map[string]interface{}{"status": "ok"})
})
logger := process.logger.With(trace.Component, teleport.Component(teleport.ComponentDiagnostic, process.id))
logger := process.logger.With(teleport.ComponentKey, teleport.Component(teleport.ComponentDiagnostic, process.id))
// Create a state machine that will process and update the internal state of
// Teleport based off Events. Use this state machine to return return the
@@ -3219,7 +3219,7 @@ func (process *TeleportProcess) initDiagnosticService() error {
}
func (process *TeleportProcess) initTracingService() error {
logger := process.logger.With(trace.Component, teleport.Component(teleport.ComponentTracing, process.id))
logger := process.logger.With(teleport.ComponentKey, teleport.Component(teleport.ComponentTracing, process.id))
logger.InfoContext(process.ExitContext(), "Initializing tracing provider and exporter.")
attrs := []attribute.KeyValue{
@@ -3232,7 +3232,7 @@ func (process *TeleportProcess) initTracingService() error {
if err != nil {
return trace.Wrap(err)
}
traceConf.Logger = process.log.WithField(trace.Component, teleport.Component(teleport.ComponentTracing, process.id))
traceConf.Logger = process.log.WithField(teleport.ComponentKey, teleport.Component(teleport.ComponentTracing, process.id))
provider, err := tracing.NewTraceProvider(process.ExitContext(), *traceConf)
if err != nil {
@@ -3840,7 +3840,7 @@ func (process *TeleportProcess) initProxyEndpoint(conn *Connector) error {
proxySSHAddr.Addr = listeners.ssh.Addr().String()
}
logger := process.logger.With(trace.Component, teleport.Component(teleport.ComponentReverseTunnelServer, process.id))
logger := process.logger.With(teleport.ComponentKey, teleport.Component(teleport.ComponentReverseTunnelServer, process.id))
// asyncEmitter makes sure that sessions do not block
// in case if connections are slow
@@ -3856,7 +3856,7 @@ func (process *TeleportProcess) initProxyEndpoint(conn *Connector) error {
lockWatcher, err := services.NewLockWatcher(process.ExitContext(), services.LockWatcherConfig{
ResourceWatcherConfig: services.ResourceWatcherConfig{
Component: teleport.ComponentProxy,
Log: process.log.WithField(trace.Component, teleport.ComponentProxy),
Log: process.log.WithField(teleport.ComponentKey, teleport.ComponentProxy),
Client: conn.Client,
},
})
@@ -3867,7 +3867,7 @@ func (process *TeleportProcess) initProxyEndpoint(conn *Connector) error {
nodeWatcher, err := services.NewNodeWatcher(process.ExitContext(), services.NodeWatcherConfig{
ResourceWatcherConfig: services.ResourceWatcherConfig{
Component: teleport.ComponentProxy,
Log: process.log.WithField(trace.Component, teleport.ComponentProxy),
Log: process.log.WithField(teleport.ComponentKey, teleport.ComponentProxy),
Client: accessPoint,
MaxStaleness: time.Minute,
},
@@ -3880,7 +3880,7 @@ func (process *TeleportProcess) initProxyEndpoint(conn *Connector) error {
caWatcher, err := services.NewCertAuthorityWatcher(process.ExitContext(), services.CertAuthorityWatcherConfig{
ResourceWatcherConfig: services.ResourceWatcherConfig{
Component: teleport.ComponentProxy,
Log: process.log.WithField(trace.Component, teleport.ComponentProxy),
Log: process.log.WithField(teleport.ComponentKey, teleport.ComponentProxy),
Client: accessPoint,
},
AuthorityGetter: accessPoint,
@@ -3996,7 +3996,7 @@ func (process *TeleportProcess) initProxyEndpoint(conn *Connector) error {
if !process.Config.Proxy.DisableReverseTunnel {
router, err := proxy.NewRouter(proxy.RouterConfig{
ClusterName: clusterName,
Log: process.log.WithField(trace.Component, "router"),
Log: process.log.WithField(teleport.ComponentKey, "router"),
RemoteClusterGetter: accessPoint,
SiteGetter: tsrv,
TracerProvider: process.TracingProvider,
@@ -4020,7 +4020,7 @@ func (process *TeleportProcess) initProxyEndpoint(conn *Connector) error {
LockEnforcer: lockWatcher,
Emitter: asyncEmitter,
Component: teleport.ComponentProxy,
Logger: process.log.WithField(trace.Component, "sessionctrl"),
Logger: process.log.WithField(teleport.ComponentKey, "sessionctrl"),
TracerProvider: process.TracingProvider,
ServerID: serverID,
})
@@ -4059,7 +4059,7 @@ func (process *TeleportProcess) initProxyEndpoint(conn *Connector) error {
if err != nil {
return trace.Wrap(err)
}
traceConf.Logger = process.log.WithField(trace.Component, teleport.ComponentTracing)
traceConf.Logger = process.log.WithField(teleport.ComponentKey, teleport.ComponentTracing)
clt, err := tracing.NewStartedClient(process.ExitContext(), *traceConf)
if err != nil {
@@ -4157,7 +4157,7 @@ func (process *TeleportProcess) initProxyEndpoint(conn *Connector) error {
},
},
Handler: webHandler,
Log: process.log.WithField(trace.Component, teleport.Component(teleport.ComponentReverseTunnelServer, process.id)),
Log: process.log.WithField(teleport.ComponentKey, teleport.Component(teleport.ComponentReverseTunnelServer, process.id)),
})
if err != nil {
return trace.Wrap(err)
@@ -4175,7 +4175,7 @@ func (process *TeleportProcess) initProxyEndpoint(conn *Connector) error {
})
if listeners.reverseTunnelMux != nil {
if minimalWebServer, err = process.initMinimalReverseTunnel(listeners, tlsConfigWeb, cfg, webConfig, process.log.WithField(trace.Component, teleport.Component(teleport.ComponentReverseTunnelServer, process.id))); err != nil {
if minimalWebServer, err = process.initMinimalReverseTunnel(listeners, tlsConfigWeb, cfg, webConfig, process.log.WithField(teleport.ComponentKey, teleport.Component(teleport.ComponentReverseTunnelServer, process.id))); err != nil {
return trace.Wrap(err)
}
}
@@ -4205,7 +4205,7 @@ func (process *TeleportProcess) initProxyEndpoint(conn *Connector) error {
Listener: listeners.proxyPeer,
TLSConfig: serverTLSConfig,
ClusterDialer: clusterdial.NewClusterDialer(tsrv),
Log: process.log.WithField(trace.Component, teleport.Component(teleport.ComponentReverseTunnelServer, process.id)),
Log: process.log.WithField(teleport.ComponentKey, teleport.Component(teleport.ComponentReverseTunnelServer, process.id)),
ClusterName: clusterName,
})
if err != nil {
@@ -4280,7 +4280,7 @@ func (process *TeleportProcess) initProxyEndpoint(conn *Connector) error {
ClusterName: clusterName,
AccessPoint: accessPoint,
LockWatcher: lockWatcher,
Logger: process.log.WithField(trace.Component, teleport.Component(teleport.ComponentReverseTunnelServer, process.id)),
Logger: process.log.WithField(teleport.ComponentKey, teleport.Component(teleport.ComponentReverseTunnelServer, process.id)),
})
if err != nil {
return trace.Wrap(err)
@@ -4299,7 +4299,7 @@ func (process *TeleportProcess) initProxyEndpoint(conn *Connector) error {
tlscfg.InsecureSkipVerify = true
tlscfg.ClientAuth = tls.RequireAnyClientCert
}
tlscfg.GetConfigForClient = auth.WithClusterCAs(tlscfg, accessPoint, clusterName, process.log.WithField(trace.Component, teleport.Component(teleport.ComponentReverseTunnelServer, process.id)))
tlscfg.GetConfigForClient = auth.WithClusterCAs(tlscfg, accessPoint, clusterName, process.log.WithField(teleport.ComponentKey, teleport.Component(teleport.ComponentReverseTunnelServer, process.id)))
creds, err := auth.NewTransportCredentials(auth.TransportCredentialsConfig{
TransportCredentials: credentials.NewTLS(tlscfg),
@@ -4342,7 +4342,7 @@ func (process *TeleportProcess) initProxyEndpoint(conn *Connector) error {
transportService, err := transportv1.NewService(transportv1.ServerConfig{
FIPS: cfg.FIPS,
Logger: process.log.WithField(trace.Component, "transport"),
Logger: process.log.WithField(teleport.ComponentKey, "transport"),
Dialer: proxyRouter,
SignerFn: func(authzCtx *authz.Context, clusterName string) agentless.SignerCreator {
return agentless.SignerFromAuthzContext(authzCtx, accessPoint, clusterName)
@@ -4382,7 +4382,7 @@ func (process *TeleportProcess) initProxyEndpoint(conn *Connector) error {
})
rcWatchLog := logrus.WithFields(logrus.Fields{
trace.Component: teleport.Component(teleport.ComponentReverseTunnelAgent, process.id),
teleport.ComponentKey: teleport.Component(teleport.ComponentReverseTunnelAgent, process.id),
})
// Create and register reverse tunnel AgentPool.
@@ -4421,7 +4421,7 @@ func (process *TeleportProcess) initProxyEndpoint(conn *Connector) error {
ClusterName: clusterName,
AccessPoint: accessPoint,
LockWatcher: lockWatcher,
Logger: process.log.WithField(trace.Component, teleport.Component(teleport.ComponentReverseTunnelServer, process.id)),
Logger: process.log.WithField(teleport.ComponentKey, teleport.Component(teleport.ComponentReverseTunnelServer, process.id)),
})
if err != nil {
return trace.Wrap(err)
@@ -4443,7 +4443,7 @@ func (process *TeleportProcess) initProxyEndpoint(conn *Connector) error {
kubeServerWatcher, err := services.NewKubeServerWatcher(process.ExitContext(), services.KubeServerWatcherConfig{
ResourceWatcherConfig: services.ResourceWatcherConfig{
Component: component,
Log: process.log.WithField(trace.Component, teleport.Component(teleport.ComponentReverseTunnelServer, process.id)),
Log: process.log.WithField(teleport.ComponentKey, teleport.Component(teleport.ComponentReverseTunnelServer, process.id)),
Client: accessPoint,
},
})
@@ -4483,7 +4483,7 @@ func (process *TeleportProcess) initProxyEndpoint(conn *Connector) error {
AccessPoint: accessPoint,
GetRotation: process.GetRotation,
OnHeartbeat: process.OnHeartbeat(component),
Log: process.log.WithField(trace.Component, teleport.Component(teleport.ComponentReverseTunnelServer, process.id)),
Log: process.log.WithField(teleport.ComponentKey, teleport.Component(teleport.ComponentReverseTunnelServer, process.id)),
IngressReporter: ingressReporter,
KubernetesServersWatcher: kubeServerWatcher,
PROXYProtocolMode: cfg.Proxy.PROXYProtocolMode,
@@ -4492,7 +4492,7 @@ func (process *TeleportProcess) initProxyEndpoint(conn *Connector) error {
return trace.Wrap(err)
}
process.RegisterCriticalFunc("proxy.kube", func() error {
logger := process.logger.With(trace.Component, component)
logger := process.logger.With(teleport.ComponentKey, component)
kubeListenAddr := listeners.kube.Addr().String()
if cfg.Proxy.Kube.ListenAddr.Addr != "" {
@@ -4522,7 +4522,7 @@ func (process *TeleportProcess) initProxyEndpoint(conn *Connector) error {
ClusterName: clusterName,
AccessPoint: accessPoint,
LockWatcher: lockWatcher,
Logger: process.log.WithField(trace.Component, teleport.Component(teleport.ComponentReverseTunnelServer, process.id)),
Logger: process.log.WithField(teleport.ComponentKey, teleport.Component(teleport.ComponentReverseTunnelServer, process.id)),
})
if err != nil {
return trace.Wrap(err)
@@ -4592,7 +4592,7 @@ func (process *TeleportProcess) initProxyEndpoint(conn *Connector) error {
})
}
logger := process.logger.With(trace.Component, teleport.Component(teleport.ComponentDatabase))
logger := process.logger.With(teleport.ComponentKey, teleport.Component(teleport.ComponentDatabase))
if listeners.db.postgres != nil {
process.RegisterCriticalFunc("proxy.db.postgres", func() error {
logger.InfoContext(process.ExitContext(), "Starting Database Postgres proxy server.", "listen_address", listeners.db.postgres.Addr())
@@ -5204,7 +5204,7 @@ func (process *TeleportProcess) initApps() {
// Define logger to prefix log lines with the name of the component and PID.
component := teleport.Component(teleport.ComponentApp, process.id)
logger := process.logger.With(trace.Component, component)
logger := process.logger.With(teleport.ComponentKey, component)
process.RegisterCriticalFunc("apps.start", func() error {
conn, err := process.WaitForConnector(AppsIdentityEvent, logger)
@@ -5327,7 +5327,7 @@ func (process *TeleportProcess) initApps() {
lockWatcher, err := services.NewLockWatcher(process.ExitContext(), services.LockWatcherConfig{
ResourceWatcherConfig: services.ResourceWatcherConfig{
Component: teleport.ComponentApp,
Log: process.log.WithField(trace.Component, component),
Log: process.log.WithField(teleport.ComponentKey, component),
Client: conn.Client,
},
})
@@ -5338,7 +5338,7 @@ func (process *TeleportProcess) initApps() {
ClusterName: clusterName,
AccessPoint: accessPoint,
LockWatcher: lockWatcher,
Logger: process.log.WithField(trace.Component, component),
Logger: process.log.WithField(teleport.ComponentKey, component),
DeviceAuthorization: authz.DeviceAuthorizationOpts{
// Ignore the global device_trust.mode toggle, but allow role-based
// settings to be applied.
@@ -5992,7 +5992,7 @@ func (process *TeleportProcess) initSecureGRPCServer(cfg initSecureGRPCServerCfg
AccessPoint: cfg.accessPoint,
LockWatcher: cfg.lockWatcher,
Logger: process.log.WithFields(logrus.Fields{
trace.Component: teleport.Component(teleport.ComponentProxySecureGRPC, process.id),
teleport.ComponentKey: teleport.Component(teleport.ComponentProxySecureGRPC, process.id),
}),
})
if err != nil {
+1 -1
View File
@@ -203,7 +203,7 @@ func NewSupervisor(id string, parentLog logrus.FieldLogger) Supervisor {
reloadContext: reloadContext,
signalReload: signalReload,
log: parentLog.WithField(trace.Component, teleport.Component(teleport.ComponentProcess, id)),
log: parentLog.WithField(teleport.ComponentKey, teleport.Component(teleport.ComponentProcess, id)),
}
go srv.fanOut()
return srv
+2 -1
View File
@@ -27,6 +27,7 @@ import (
"github.com/gravitational/trace"
"github.com/sirupsen/logrus"
"github.com/gravitational/teleport"
"github.com/gravitational/teleport/api/client/proto"
apidefaults "github.com/gravitational/teleport/api/defaults"
"github.com/gravitational/teleport/api/types"
@@ -44,7 +45,7 @@ type AccessService struct {
func NewAccessService(backend backend.Backend) *AccessService {
return &AccessService{
Backend: backend,
log: logrus.WithFields(logrus.Fields{trace.Component: "AccessService"}),
log: logrus.WithFields(logrus.Fields{teleport.ComponentKey: "AccessService"}),
}
}
+2 -1
View File
@@ -29,6 +29,7 @@ import (
"github.com/jonboulle/clockwork"
"github.com/sirupsen/logrus"
"github.com/gravitational/teleport"
accesslistv1 "github.com/gravitational/teleport/api/gen/proto/go/teleport/accesslist/v1"
"github.com/gravitational/teleport/api/types"
"github.com/gravitational/teleport/api/types/accesslist"
@@ -110,7 +111,7 @@ func NewAccessListService(backend backend.Backend, clock clockwork.Clock) (*Acce
}
return &AccessListService{
log: logrus.WithFields(logrus.Fields{trace.Component: "access-list:local-service"}),
log: logrus.WithFields(logrus.Fields{teleport.ComponentKey: "access-list:local-service"}),
clock: clock,
service: service,
memberService: memberService,
+2 -1
View File
@@ -29,6 +29,7 @@ import (
"github.com/sirupsen/logrus"
"google.golang.org/protobuf/types/known/timestamppb"
"github.com/gravitational/teleport"
"github.com/gravitational/teleport/api/gen/proto/go/assist/v1"
"github.com/gravitational/teleport/lib/backend"
)
@@ -50,7 +51,7 @@ type AssistService struct {
func NewAssistService(backend backend.Backend) *AssistService {
return &AssistService{
Backend: backend,
log: logrus.WithField(trace.Component, "assist"),
log: logrus.WithField(teleport.ComponentKey, "assist"),
}
}

Some files were not shown because too many files have changed in this diff Show More