-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add separate flag for metrics (#1504)
* feat: adds metrics server address to config and sets localhost defaults * uses metrics-listen-addr for metrics server * sets default debug server api-listen-addr to 127.0.0.1:5183 * sets default metrics server metrics-listen-addr to 127.0.0.1:9100 * refactor: separates debug and metrics server * moves metrics to separate server * feat: changes the default metrics port to 5184 * refactor: removes address flags for debug and metrics server * removes address flags so config file is the source of truth for addresses * adds tests for flags to enable debug and metrics servers * adds tests for config file settings for addresses for debug and metrics servers * adjusts log messages * refactor: renames api-listen-addr to debug-listen-addr * feat: restores cli flags to set addresses for debug and metrics servers * restores address flags * renames `--debug-addr` to `--debug-listen-addr` to be consistent with config file setting `debug-listen-addr:` * renames `--metrics-addr` to `--metrics-listen-addr` to be consistent with config file setting `metrics-listen-addr:` * updates docs * feat: improves error reporting * chore: code cleanup * feat: rollbacks --debug-addr flag * feat: deprecates api-listen-addr * fix: closes body * fix: reformat log messages to follow styleguide
- Loading branch information
1 parent
6a22c2b
commit 2cd9062
Showing
13 changed files
with
699 additions
and
68 deletions.
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
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
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 |
---|---|---|
@@ -0,0 +1,64 @@ | ||
package cmd_test | ||
|
||
import ( | ||
"fmt" | ||
"os" | ||
"testing" | ||
|
||
"github.com/cosmos/relayer/v2/cmd" | ||
"github.com/cosmos/relayer/v2/internal/relayertest" | ||
"github.com/cosmos/relayer/v2/relayer/chains/cosmos" | ||
"github.com/stretchr/testify/require" | ||
) | ||
|
||
func TestDefaultConfig(t *testing.T) { | ||
t.Parallel() | ||
|
||
sys := relayertest.NewSystem(t) | ||
|
||
_ = sys.MustRun(t, "config", "init") | ||
|
||
sys.MustAddChain(t, "testChain", cmd.ProviderConfigWrapper{ | ||
Type: "cosmos", | ||
Value: cosmos.CosmosProviderConfig{ | ||
ChainID: "testcosmos", | ||
KeyringBackend: "test", | ||
Timeout: "10s", | ||
}, | ||
}) | ||
|
||
tests := []struct { | ||
setting string | ||
wantedPresent bool | ||
}{ | ||
{ | ||
"debug-listen-addr: 127.0.0.1:5183", | ||
true, | ||
}, | ||
{ | ||
"metrics-listen-addr: 127.0.0.1:5184", | ||
true, | ||
}, | ||
{ | ||
"api-listen-addr: 127.0.0.1:5184", | ||
false, | ||
}, | ||
} | ||
|
||
for _, tt := range tests { | ||
t.Run(tt.setting, func(t *testing.T) { | ||
sys := setupRelayer(t) | ||
|
||
configFile := fmt.Sprintf("%s/config/config.yaml", sys.HomeDir) | ||
data, err := os.ReadFile(configFile) | ||
require.NoError(t, err) | ||
config := string(data) | ||
|
||
if tt.wantedPresent { | ||
require.Contains(t, config, tt.setting) | ||
} else { | ||
require.NotContains(t, config, tt.setting) | ||
} | ||
}) | ||
} | ||
} |
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
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
Oops, something went wrong.