You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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
Missing Logging The initialization of the RpcServerConfig is missing logging for the configuration details. Ensure that the initialization logs all relevant configurations.
Missing Error Handling The load_dotenv_file and load_env_aliases functions do not handle potential errors from environment variable operations. Consider adding error handling to improve robustness.
-init_metrics_exporter(self.metrics_exporter_address);+static INIT_METRICS_EXPORTER: Once = Once::new();+INIT_METRICS_EXPORTER.call_once(|| {+ init_metrics_exporter(self.metrics_exporter_address);+});
Suggestion importance[1-10]: 9
Why: This suggestion addresses a potential issue by ensuring that the metrics exporter is only initialized once, which is crucial for preventing conflicts or multiple initializations.
9
Replace unwrap calls with expect to provide descriptive error messages
The unwrap calls in the opentelemetry_tracer function can cause the program to panic if the MetadataKey or value parsing fails. Consider using expect with a descriptive error message or handling the error more gracefully.
Why: This suggestion improves error handling by providing more context in case of failure, which is crucial for debugging and maintaining robust code. The existing code can cause the program to panic without a clear reason, so this change is highly beneficial.
9
Handle potential errors from console_server.serve().await more explicitly by logging and returning a result
The spawn_named function call inside the tokio_console_layer match arm should handle potential errors from the console_server.serve().await call more explicitly, possibly by logging the error and returning a result.
spawn_named("console::grpc-server", async move {
if let Err(e) = console_server.serve().await {
tracing::error!(reason = ?e, address = %tokio_console_address, "failed to create tokio-console server");
+ return Err(e);
};
+ Ok(())
});
Suggestion importance[1-10]: 8
Why: Explicitly handling potential errors from console_server.serve().await improves the robustness of the code by ensuring that errors are logged and propagated correctly. This change enhances error visibility and handling.
8
Performance
Clone the config once and reuse the cloned instance to improve performance and readability
Instead of cloning the config multiple times, consider cloning it once and reusing the cloned instance. This can improve performance and readability.
Why: Using constants for environment variable keys is a best practice that can help avoid potential issues with variable names and improve code maintainability.
7
Use structured logging for errors in tracing_subscriber::registry().try_init()
The tracing_subscriber::registry().try_init() call can fail, and the error is currently only printed. Consider logging this error using a more structured logging approach or handling it more gracefully.
-println!("failed to create tracing registry | reason={:?}", e);+tracing::error!(reason = ?e, "failed to create tracing registry");
Err(e.into())
Suggestion importance[1-10]: 7
Why: Using structured logging for errors provides better context and integration with logging systems, making it easier to diagnose issues. This is a good practice for maintaining clear and informative logs.
7
Maintainability
Extract the configuration of the RpcServer into a separate function to improve readability and maintainability
To improve readability and maintainability, consider extracting the configuration of the RpcServer into a separate function.
Why: Simplifying redundant clone calls improves code readability and efficiency. While this is a minor enhancement, it contributes to cleaner and more maintainable code.
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.
PR Type
Enhancement, Bug fix
Description
MetricsConfig
andSentryConfig
structs and their implementations.RpcServerConfig
fields to includerpc_
prefix and adjusted related code.Changes walkthrough 📝
16 files
run_with_importer.rs
Update RPC server address field name
src/bin/run_with_importer.rs
config.rpc_server.address
toconfig.rpc_server.rpc_address
.config.rs
Refactor configuration loading and initialization
src/config.rs
MetricsConfig
andSentryConfig
.load_dotenv
toload_dotenv_file
.load_env_aliases
function.SentryConfig
andMetricsConfig
.init_runtime
toinit_tokio_runtime
.rpc_config.rs
Rename RPC server configuration fields
src/eth/rpc/rpc_config.rs
RpcServerConfig
to includerpc_
prefix.rpc_server.rs
Update RPC server field usage
src/eth/rpc/rpc_server.rs
RpcServerConfig
.globals.rs
Refactor global initialization
src/globals.rs
config::load_dotenv_file
andconfig::load_env_aliases
.SentryConfig
andMetricsConfig
.metrics_config.rs
Add MetricsConfig struct
src/infra/metrics/metrics_config.rs
MetricsConfig
struct and its implementation.metrics_init.rs
Remove metrics_init.rs
src/infra/metrics/metrics_init.rs
metrics_init.rs
and moved its functionality tometrics_config.rs
.mod.rs
Update metrics module
src/infra/metrics/mod.rs
MetricsConfig
.mod.rs
Clean up infra module
src/infra/mod.rs
sentry.rs
Remove sentry.rs
src/infra/sentry.rs
sentry.rs
and moved its functionality tosentry_config.rs
.mod.rs
Add SentryConfig module
src/infra/sentry/mod.rs
sentry_config
module and updated exports.sentry_config.rs
Add SentryConfig struct
src/infra/sentry/sentry_config.rs
SentryConfig
struct and its implementation.mod.rs
Refactor tracing module
src/infra/tracing/mod.rs
tracing_config.rs
Enhance TracingConfig and initialization
src/infra/tracing/tracing_config.rs
TracingConfig
.tracing_services.rs
Refactor tracing services
src/infra/tracing/tracing_services.rs
implementations.
main.rs
Update RPC server address field name in main
src/main.rs
config.rpc_server.address
toconfig.rpc_server.rpc_address
.