Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Convert lib/reversetunnel to use slog #50362

Merged
merged 1 commit into from
Dec 18, 2024
Merged

Conversation

rosstimothy
Copy link
Contributor

No description provided.

@rosstimothy rosstimothy added the no-changelog Indicates that a PR does not require a changelog entry label Dec 17, 2024
@rosstimothy rosstimothy marked this pull request as ready for review December 17, 2024 21:57
lib/reversetunnel/agent.go Outdated Show resolved Hide resolved
for {
select {
case <-s.ctx.Done():
s.logger.WithError(s.ctx.Err()).Debug("Context is closing.")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we check the s.ctx.Err() != nil log if true?

Comment on lines 803 to +807
log := logger
if roundtrip != 0 {
log = logger.WithField("latency", roundtrip.String())
log = logger.With("latency", logutils.StringerAttr(roundtrip))
}
log.Debugf("Ping <- %v", rconn.conn.RemoteAddr())
log.DebugContext(ctx, "Received ping request", "remote_addr", logutils.StringerAttr(rconn.conn.RemoteAddr()))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there a better way to do conditional fields in slog?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The only other option I can think of is to use a slice and only append attributes if they should be included in the output.

@@ -788,9 +802,9 @@ func (s *localSite) handleHeartbeat(rconn *remoteConn, ch ssh.Channel, reqC <-ch

log := logger
if roundtrip != 0 {
log = logger.WithField("latency", roundtrip.String())
log = logger.With("latency", logutils.StringerAttr(roundtrip))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sould we add special handling for time.Duration to our handlers so we don't have to do this every time, kinda like we do for error?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Possibly, the other option is to use slog.Duration("latency", roundtrip).

@public-teleport-github-review-bot public-teleport-github-review-bot bot removed the request for review from camscale December 18, 2024 11:00
@rosstimothy rosstimothy force-pushed the tross/reversetunnel_slog branch from 1708df7 to 2444661 Compare December 18, 2024 14:03
@rosstimothy rosstimothy force-pushed the tross/reversetunnel_slog branch from 2444661 to c37d452 Compare December 18, 2024 14:03
@rosstimothy rosstimothy added this pull request to the merge queue Dec 18, 2024
Merged via the queue into master with commit 3550c4d Dec 18, 2024
41 checks passed
@rosstimothy rosstimothy deleted the tross/reversetunnel_slog branch December 18, 2024 15:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
no-changelog Indicates that a PR does not require a changelog entry size/sm
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants