-
Notifications
You must be signed in to change notification settings - Fork 111
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
Kschappacher
merged 11 commits into
viamrobotics:main
from
Kschappacher:RSDK-9326-viam-startup-env-logs
Dec 5, 2024
Merged
Changes from 4 commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
fd5a80b
log important viam env variables
Kschappacher b275ba4
fix log
Kschappacher d15127b
use logger.infow and move log out of version log
Kschappacher bad0c98
update casing
Kschappacher 79517d4
add home variable
Kschappacher a6728a8
Update web/server/entrypoint.go
Kschappacher d093f17
move logger so it is captured on cloud
Kschappacher c9bbb7c
Merge remote-tracking branch 'upstream/main' into RSDK-9326-viam-star…
Kschappacher 8c8741a
Merge branch 'RSDK-9326-viam-startup-env-logs' of ssh://github.com/Ks…
Kschappacher 52fb336
refactor to couple log version and logViamEnvVariables
Kschappacher c907f2b
Merge remote-tracking branch 'upstream/main' into RSDK-9326-viam-star…
Kschappacher File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -57,6 +57,22 @@ type robotServer struct { | |
registry *logging.Registry | ||
} | ||
|
||
func logViamEnvVariables(logger logging.Logger) { | ||
var viamEnvVariables []interface{} | ||
if value, exists := os.LookupEnv("VIAM_MODULE_ROOT"); exists { | ||
viamEnvVariables = append(viamEnvVariables, "VIAM_MODULE_ROOT: ", value) | ||
} | ||
if value, exists := os.LookupEnv("VIAM_RESOURCE_CONFIGURATION_TIMEOUT"); exists { | ||
viamEnvVariables = append(viamEnvVariables, "VIAM_RESOURCE_CONFIGURATION_TIMEOUT: ", value) | ||
} | ||
if value, exists := os.LookupEnv("VIAM_MODULE_STARTUP_TIMEOUT"); exists { | ||
viamEnvVariables = append(viamEnvVariables, "VIAM_MODULE_STARTUP_TIMEOUT: ", value) | ||
} | ||
if len(viamEnvVariables) != 0 { | ||
logger.Infow("Viam env variables", viamEnvVariables...) | ||
Kschappacher marked this conversation as resolved.
Show resolved
Hide resolved
|
||
} | ||
} | ||
|
||
func logVersion(logger logging.Logger) { | ||
var versionFields []interface{} | ||
if config.Version != "" { | ||
|
@@ -99,6 +115,8 @@ func RunServer(ctx context.Context, args []string, _ logging.Logger) (err error) | |
return | ||
} | ||
|
||
logViamEnvVariables(logger) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. move this so that this gets logged to cloud as well There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. good catch. moved it to after the remote logging is initialized |
||
|
||
// log version locally if server fails and exits while attempting to start up | ||
var versionLogged bool | ||
defer func() { | ||
|
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
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)There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
added