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

RSDK-9326 - log important viam env variables #4602

Merged

Conversation

Kschappacher
Copy link
Contributor

Overview

Small pr to add logging of some viam env variables

Review Request

  • Looking for any additional variables people would like logged

@viambot viambot added the safe to test This pull request is marked safe to test from a trusted zone label Dec 4, 2024
@viambot viambot added safe to test This pull request is marked safe to test from a trusted zone and removed safe to test This pull request is marked safe to test from a trusted zone labels Dec 4, 2024
Copy link
Member

@benjirewis benjirewis left a comment

Choose a reason for hiding this comment

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

Could we do a single Info level log with Infow using fields for each of the env vars?

@viambot viambot added safe to test This pull request is marked safe to test from a trusted zone and removed safe to test This pull request is marked safe to test from a trusted zone labels Dec 4, 2024
@viambot viambot added safe to test This pull request is marked safe to test from a trusted zone and removed safe to test This pull request is marked safe to test from a trusted zone labels Dec 4, 2024
@Kschappacher
Copy link
Contributor Author

Could we do a single Info level log with Infow using fields for each of the env vars?

good call, just tested and it looks really clean 👍

@@ -57,6 +57,22 @@ type robotServer struct {
registry *logging.Registry
}

func logViamEnvVariables(logger logging.Logger) {
var viamEnvVariables []interface{}
Copy link
Member

@dgottlieb dgottlieb Dec 4, 2024

Choose a reason for hiding this comment

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

Let's also grab the home directory via PlatformHomeDir here.

(and looking at that function -- it should be using Go's stdlib os.UserHomeDir() because maybe windows one day -- not a required change for this PR)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

added

@viambot viambot added safe to test This pull request is marked safe to test from a trusted zone and removed safe to test This pull request is marked safe to test from a trusted zone labels Dec 4, 2024
@@ -99,6 +118,8 @@ func RunServer(ctx context.Context, args []string, _ logging.Logger) (err error)
return
}

logViamEnvVariables(logger)
Copy link
Member

Choose a reason for hiding this comment

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

move this so that this gets logged to cloud as well

Copy link
Contributor Author

Choose a reason for hiding this comment

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

good catch. moved it to after the remote logging is initialized

web/server/entrypoint.go Outdated Show resolved Hide resolved
Co-authored-by: Cheuk <90270663+cheukt@users.noreply.github.com>
@viambot viambot added safe to test This pull request is marked safe to test from a trusted zone and removed safe to test This pull request is marked safe to test from a trusted zone labels Dec 4, 2024
@viambot viambot removed the safe to test This pull request is marked safe to test from a trusted zone label Dec 4, 2024
@viambot viambot added the safe to test This pull request is marked safe to test from a trusted zone label Dec 4, 2024
Copy link
Member

@benjirewis benjirewis left a comment

Choose a reason for hiding this comment

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

Nice! Thanks.

@@ -164,6 +183,8 @@ func RunServer(ctx context.Context, args []string, _ logging.Logger) (err error)
logVersion(logger)
versionLogged = true

logViamEnvVariables(logger)
Copy link
Member

Choose a reason for hiding this comment

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

can we put this in the logVersion method or slightly refactor the flow so that logViamEnvVariables is also tracked by the defer statement above? maybe change versionLogged to startupInfoLogged or something

@viambot viambot added safe to test This pull request is marked safe to test from a trusted zone and removed safe to test This pull request is marked safe to test from a trusted zone labels Dec 5, 2024
@viambot viambot added safe to test This pull request is marked safe to test from a trusted zone and removed safe to test This pull request is marked safe to test from a trusted zone labels Dec 5, 2024
@Kschappacher Kschappacher merged commit 2117ac3 into viamrobotics:main Dec 5, 2024
16 checks passed
@Kschappacher Kschappacher deleted the RSDK-9326-viam-startup-env-logs branch December 5, 2024 20:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
safe to test This pull request is marked safe to test from a trusted zone
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants