Repository navigation
feat: initialize binding logging from environment #691
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
Merged
rapids-bot
merged 7 commits into
NVIDIA:release/0.7
from
willkill07:wkk_feat/default-binding-logging
Aug 4, 2026
Merged
Changes from 1 commit
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
3687140
feat: initialize binding logging from environment
willkill07 a6c4c07
fix: drain binding logging during shutdown
willkill07 5bde739
fix: synchronize Node logging lifecycle
willkill07 281018f
fix: defer unconfigured logging to host facade
willkill07 203c17b
fix: preserve host logging during binding startup
willkill07 d045bb3
test: restore logging proxy after assertion
willkill07 6eb20b4
fix: preserve Relay logging receiver
willkill07 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
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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 |
|---|---|---|
| @@ -0,0 +1,42 @@ | ||
| // SPDX-FileCopyrightText: Copyright (c) 2026, NVIDIA CORPORATION & AFFILIATES. All rights reserved. | ||
| // SPDX-License-Identifier: Apache-2.0 | ||
|
|
||
| import { describe, it } from 'node:test'; | ||
| import assert from 'node:assert/strict'; | ||
| import { spawnSync } from 'node:child_process'; | ||
| import { fileURLToPath } from 'node:url'; | ||
|
|
||
| const packageDirectory = fileURLToPath(new URL('..', import.meta.url)); | ||
| const loggingEnvironmentNames = ['NEMO_RELAY_LOG', 'NEMO_RELAY_LOG_STDERR_FORMAT', 'NEMO_RELAY_LOG_CONFIG_PATH']; | ||
|
|
||
| function requireBinding(loggingEnvironment) { | ||
| const environment = { ...process.env }; | ||
| for (const name of loggingEnvironmentNames) { | ||
| delete environment[name]; | ||
| } | ||
| Object.assign(environment, loggingEnvironment); | ||
| return spawnSync(process.execPath, ['-e', "require('./index.js')"], { | ||
| cwd: packageDirectory, | ||
| encoding: 'utf8', | ||
| env: environment, | ||
| }); | ||
| } | ||
|
|
||
| describe('operational logging', () => { | ||
| it('initializes from the logging environment', () => { | ||
| const result = requireBinding({ | ||
| NEMO_RELAY_LOG: 'info', | ||
| NEMO_RELAY_LOG_STDERR_FORMAT: 'jsonl', | ||
| }); | ||
|
|
||
| assert.equal(result.status, 0, result.stderr); | ||
| assert.match(result.stderr, /"event":"logging_initialized"/); | ||
| }); | ||
|
|
||
| it('rejects an invalid logging environment', () => { | ||
| const result = requireBinding({ NEMO_RELAY_LOG: '' }); | ||
|
|
||
| assert.notEqual(result.status, 0); | ||
| assert.match(result.stderr, /NEMO_RELAY_LOG must not be empty/); | ||
| }); | ||
| }); |
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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 |
|---|---|---|
| @@ -0,0 +1,67 @@ | ||
| // SPDX-FileCopyrightText: Copyright (c) 2026, NVIDIA CORPORATION & AFFILIATES. All rights reserved. | ||
| // SPDX-License-Identifier: Apache-2.0 | ||
|
|
||
| package nemo_relay | ||
|
|
||
| import ( | ||
| "os" | ||
| "os/exec" | ||
| "strings" | ||
| "testing" | ||
| ) | ||
|
|
||
| const loggingHelperEnvironment = "NEMO_RELAY_TEST_LOGGING_HELPER" | ||
|
|
||
| var loggingEnvironmentNames = map[string]struct{}{ | ||
| "NEMO_RELAY_LOG": {}, | ||
| "NEMO_RELAY_LOG_STDERR_FORMAT": {}, | ||
| "NEMO_RELAY_LOG_CONFIG_PATH": {}, | ||
| } | ||
|
|
||
| func loggingTestEnvironment(values ...string) []string { | ||
| environment := make([]string, 0, len(os.Environ())+len(values)) | ||
| for _, value := range os.Environ() { | ||
| name, _, _ := strings.Cut(value, "=") | ||
| if _, isLoggingEnvironment := loggingEnvironmentNames[name]; !isLoggingEnvironment { | ||
| environment = append(environment, value) | ||
| } | ||
| } | ||
| return append(environment, values...) | ||
| } | ||
|
|
||
| func TestBindingLoggingEnvironment(t *testing.T) { | ||
| if os.Getenv(loggingHelperEnvironment) == "1" { | ||
| return | ||
| } | ||
|
|
||
| t.Run("initializes from environment", func(t *testing.T) { | ||
| command := exec.Command(os.Args[0], "-test.run=TestBindingLoggingEnvironment") | ||
| command.Env = loggingTestEnvironment( | ||
| loggingHelperEnvironment+"=1", | ||
| "NEMO_RELAY_LOG=info", | ||
| "NEMO_RELAY_LOG_STDERR_FORMAT=jsonl", | ||
| ) | ||
| output, err := command.CombinedOutput() | ||
| if err != nil { | ||
| t.Fatalf("binding import failed: %v\n%s", err, output) | ||
| } | ||
| if !strings.Contains(string(output), `"event":"logging_initialized"`) { | ||
| t.Fatalf("logging initialization event missing from output:\n%s", output) | ||
| } | ||
| }) | ||
|
|
||
| t.Run("rejects invalid environment", func(t *testing.T) { | ||
| command := exec.Command(os.Args[0], "-test.run=TestBindingLoggingEnvironment") | ||
| command.Env = loggingTestEnvironment( | ||
| loggingHelperEnvironment+"=1", | ||
| "NEMO_RELAY_LOG=", | ||
| ) | ||
| output, err := command.CombinedOutput() | ||
| if err == nil { | ||
| t.Fatalf("binding initialization unexpectedly succeeded:\n%s", output) | ||
| } | ||
| if !strings.Contains(string(output), "NEMO_RELAY_LOG must not be empty") { | ||
| t.Fatalf("logging initialization error missing from output:\n%s", output) | ||
| } | ||
| }) | ||
| } |
This file contains hidden or 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
This file contains hidden or 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 |
|---|---|---|
| @@ -0,0 +1,43 @@ | ||
| # SPDX-FileCopyrightText: Copyright (c) 2026, NVIDIA CORPORATION & AFFILIATES. All rights reserved. | ||
| # SPDX-License-Identifier: Apache-2.0 | ||
|
|
||
| import os | ||
| import subprocess | ||
| import sys | ||
|
|
||
| _LOG_ENVIRONMENT = ( | ||
| "NEMO_RELAY_LOG", | ||
| "NEMO_RELAY_LOG_STDERR_FORMAT", | ||
| "NEMO_RELAY_LOG_CONFIG_PATH", | ||
| ) | ||
|
|
||
|
|
||
| def _import_nemo_relay(**logging_environment: str) -> subprocess.CompletedProcess[str]: | ||
| environment = os.environ.copy() | ||
| for name in _LOG_ENVIRONMENT: | ||
| environment.pop(name, None) | ||
| environment.update(logging_environment) | ||
| return subprocess.run( | ||
| [sys.executable, "-c", "import nemo_relay"], | ||
| check=False, | ||
| capture_output=True, | ||
| text=True, | ||
| env=environment, | ||
| ) | ||
|
|
||
|
|
||
| def test_binding_initializes_logging_from_environment(): | ||
| completed = _import_nemo_relay( | ||
| NEMO_RELAY_LOG="info", | ||
| NEMO_RELAY_LOG_STDERR_FORMAT="jsonl", | ||
| ) | ||
|
|
||
| assert completed.returncode == 0, completed.stderr | ||
| assert '"event":"logging_initialized"' in completed.stderr | ||
|
|
||
|
|
||
| def test_binding_rejects_invalid_logging_environment(): | ||
| completed = _import_nemo_relay(NEMO_RELAY_LOG="") | ||
|
|
||
| assert completed.returncode != 0 | ||
| assert "NEMO_RELAY_LOG must not be empty" in completed.stderr |
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.
Uh oh!
There was an error while loading. Please reload this page.