From 1073fa7bd00b7a070caca612d716ac115409cc60 Mon Sep 17 00:00:00 2001 From: bryan newbold Date: Mon, 16 Sep 2024 12:49:04 -0700 Subject: [PATCH] don't use 'host' as structured logging field --- automod/rules/identity.go | 2 +- bgs/bgs.go | 10 +++++----- bgs/fedmgr.go | 14 +++++++------- cmd/athome/handlers.go | 2 +- cmd/hepa/server.go | 4 ++-- 5 files changed, 16 insertions(+), 16 deletions(-) diff --git a/automod/rules/identity.go b/automod/rules/identity.go index 377b923ac..365d63f95 100644 --- a/automod/rules/identity.go +++ b/automod/rules/identity.go @@ -32,7 +32,7 @@ func NewAccountRule(c *automod.AccountContext) error { // new PDS host if existingAccounts == 0 { - c.Logger.Info("new PDS instance", "host", pdsHost) + c.Logger.Info("new PDS instance", "pdsHost", pdsHost) c.Increment("host", "new") c.AddAccountFlag("host-first-account") c.Notify("slack") diff --git a/bgs/bgs.go b/bgs/bgs.go index c0224cbad..192f4ee3d 100644 --- a/bgs/bgs.go +++ b/bgs/bgs.go @@ -800,7 +800,7 @@ func (bgs *BGS) handleFedEvent(ctx context.Context, host *models.PDS, env *event case env.RepoCommit != nil: repoCommitsReceivedCounter.WithLabelValues(host.Host).Add(1) evt := env.RepoCommit - log.Debugw("bgs got repo append event", "seq", evt.Seq, "host", host.Host, "repo", evt.Repo) + log.Debugw("bgs got repo append event", "seq", evt.Seq, "pdsHost", host.Host, "repo", evt.Repo) u, err := bgs.lookupUserByDid(ctx, evt.Repo) if err != nil { if !errors.Is(err, gorm.ErrRecordNotFound) { @@ -822,17 +822,17 @@ func (bgs *BGS) handleFedEvent(ctx context.Context, host *models.PDS, env *event if u.TakenDown || u.UpstreamStatus == events.AccountStatusTakendown { span.SetAttributes(attribute.Bool("taken_down_by_relay_admin", u.TakenDown)) - log.Debugw("dropping commit event from taken down user", "did", evt.Repo, "seq", evt.Seq, "host", host.Host) + log.Debugw("dropping commit event from taken down user", "did", evt.Repo, "seq", evt.Seq, "pdsHost", host.Host) return nil } if u.UpstreamStatus == events.AccountStatusSuspended { - log.Debugw("dropping commit event from suspended user", "did", evt.Repo, "seq", evt.Seq, "host", host.Host) + log.Debugw("dropping commit event from suspended user", "did", evt.Repo, "seq", evt.Seq, "pdsHost", host.Host) return nil } if u.UpstreamStatus == events.AccountStatusDeactivated { - log.Debugw("dropping commit event from deactivated user", "did", evt.Repo, "seq", evt.Seq, "host", host.Host) + log.Debugw("dropping commit event from deactivated user", "did", evt.Repo, "seq", evt.Seq, "pdsHost", host.Host) return nil } @@ -891,7 +891,7 @@ func (bgs *BGS) handleFedEvent(ctx context.Context, host *models.PDS, env *event } if err := bgs.repoman.HandleExternalUserEvent(ctx, host.ID, u.ID, u.Did, evt.Since, evt.Rev, evt.Blocks, evt.Ops); err != nil { - log.Warnw("failed handling event", "err", err, "host", host.Host, "seq", evt.Seq, "repo", u.Did, "prev", stringLink(evt.Prev), "commit", evt.Commit.String()) + log.Warnw("failed handling event", "err", err, "pdsHost", host.Host, "seq", evt.Seq, "repo", u.Did, "prev", stringLink(evt.Prev), "commit", evt.Commit.String()) if errors.Is(err, carstore.ErrRepoBaseMismatch) || ipld.IsNotFound(err) { ai, lerr := bgs.Index.LookupUser(ctx, u.ID) diff --git a/bgs/fedmgr.go b/bgs/fedmgr.go index dca05f5ab..42ce7407c 100644 --- a/bgs/fedmgr.go +++ b/bgs/fedmgr.go @@ -481,12 +481,12 @@ func (s *Slurper) subscribeWithRedialer(ctx context.Context, host *models.PDS, s url := fmt.Sprintf("%s://%s/xrpc/com.atproto.sync.subscribeRepos?cursor=%d", protocol, host.Host, cursor) con, res, err := d.DialContext(ctx, url, nil) if err != nil { - log.Warnw("dialing failed", "host", host.Host, "err", err, "backoff", backoff) + log.Warnw("dialing failed", "pdsHost", host.Host, "err", err, "backoff", backoff) time.Sleep(sleepForBackoff(backoff)) backoff++ if backoff > 15 { - log.Warnw("pds does not appear to be online, disabling for now", "host", host.Host) + log.Warnw("pds does not appear to be online, disabling for now", "pdsHost", host.Host) if err := s.db.Model(&models.PDS{}).Where("id = ?", host.ID).Update("registered", false).Error; err != nil { log.Errorf("failed to unregister failing pds: %w", err) } @@ -536,7 +536,7 @@ func (s *Slurper) handleConnection(ctx context.Context, host *models.PDS, con *w rsc := &events.RepoStreamCallbacks{ RepoCommit: func(evt *comatproto.SyncSubscribeRepos_Commit) error { - log.Debugw("got remote repo event", "host", host.Host, "repo", evt.Repo, "seq", evt.Seq) + log.Debugw("got remote repo event", "pdsHost", host.Host, "repo", evt.Repo, "seq", evt.Seq) if err := s.cb(context.TODO(), host, &events.XRPCStreamEvent{ RepoCommit: evt, }); err != nil { @@ -551,7 +551,7 @@ func (s *Slurper) handleConnection(ctx context.Context, host *models.PDS, con *w return nil }, RepoHandle: func(evt *comatproto.SyncSubscribeRepos_Handle) error { - log.Infow("got remote handle update event", "host", host.Host, "did", evt.Did, "handle", evt.Handle) + log.Infow("got remote handle update event", "pdsHost", host.Host, "did", evt.Did, "handle", evt.Handle) if err := s.cb(context.TODO(), host, &events.XRPCStreamEvent{ RepoHandle: evt, }); err != nil { @@ -566,7 +566,7 @@ func (s *Slurper) handleConnection(ctx context.Context, host *models.PDS, con *w return nil }, RepoMigrate: func(evt *comatproto.SyncSubscribeRepos_Migrate) error { - log.Infow("got remote repo migrate event", "host", host.Host, "did", evt.Did, "migrateTo", evt.MigrateTo) + log.Infow("got remote repo migrate event", "pdsHost", host.Host, "did", evt.Did, "migrateTo", evt.MigrateTo) if err := s.cb(context.TODO(), host, &events.XRPCStreamEvent{ RepoMigrate: evt, }); err != nil { @@ -581,7 +581,7 @@ func (s *Slurper) handleConnection(ctx context.Context, host *models.PDS, con *w return nil }, RepoTombstone: func(evt *comatproto.SyncSubscribeRepos_Tombstone) error { - log.Infow("got remote repo tombstone event", "host", host.Host, "did", evt.Did) + log.Infow("got remote repo tombstone event", "pdsHost", host.Host, "did", evt.Did) if err := s.cb(context.TODO(), host, &events.XRPCStreamEvent{ RepoTombstone: evt, }); err != nil { @@ -596,7 +596,7 @@ func (s *Slurper) handleConnection(ctx context.Context, host *models.PDS, con *w return nil }, RepoInfo: func(info *comatproto.SyncSubscribeRepos_Info) error { - log.Infow("info event", "name", info.Name, "message", info.Message, "host", host.Host) + log.Infow("info event", "name", info.Name, "message", info.Message, "pdsHost", host.Host) return nil }, RepoIdentity: func(ident *comatproto.SyncSubscribeRepos_Identity) error { diff --git a/cmd/athome/handlers.go b/cmd/athome/handlers.go index d4f246fde..6c13d9b0d 100644 --- a/cmd/athome/handlers.go +++ b/cmd/athome/handlers.go @@ -17,7 +17,7 @@ func (srv *Server) reqHandle(c echo.Context) syntax.Handle { host = strings.SplitN(host, ":", 2)[0] handle, err := syntax.ParseHandle(host) if err != nil { - slog.Warn("host is not a valid handle, fallback to default", "host", host) + slog.Warn("host is not a valid handle, fallback to default", "hostname", host) handle = srv.defaultHandle } return handle diff --git a/cmd/hepa/server.go b/cmd/hepa/server.go index 89e4134d0..55ebf49f2 100644 --- a/cmd/hepa/server.go +++ b/cmd/hepa/server.go @@ -95,7 +95,7 @@ func NewServer(dir identity.Directory, config Config) (*Server, error) { return nil, fmt.Errorf("ozone account DID supplied was not valid: %v", err) } ozoneClient.Auth.Did = od.String() - logger.Info("configured ozone admin client", "did", od.String(), "host", config.OzoneHost) + logger.Info("configured ozone admin client", "did", od.String(), "ozoneHost", config.OzoneHost) } else { logger.Info("did not configure ozone client") } @@ -112,7 +112,7 @@ func NewServer(dir identity.Directory, config Config) (*Server, error) { adminClient.Headers = make(map[string]string) adminClient.Headers["x-ratelimit-bypass"] = config.RatelimitBypass } - logger.Info("configured PDS admin client", "host", config.PDSHost) + logger.Info("configured PDS admin client", "pdsHost", config.PDSHost) } else { logger.Info("did not configure PDS admin client") }