Repository: MystenLabs/sui
File: crates/sui-indexer-alt-graphql/src/main.rs (Rust)

Code before:
use sui_indexer_alt_graphql::config::RpcLayer;
use sui_indexer_alt_graphql::start_rpc;
use sui_indexer_alt_graphql::telemetry_config_for_graphql;
use sui_indexer_alt_metrics::MetricsService;
use sui_indexer_alt_metrics::uptime;
use tokio::fs;

// Define the `GIT_REVISION` const
bin_version::git_revision!();

static VERSION: &str = const_str::concat!(
    env!("CARGO_PKG_VERSION_MAJOR"),
    ".",
    env!("CARGO_PKG_VERSION_MINOR"),
    ".",
    env!("CARGO_PKG_VERSION_PATCH"),
    "-",
    GIT_REVISION
);

#[tokio::main]
async fn main() -> anyhow::Result<()> {
    let args = Args::parse();

    // Enable tracing, configured by environment variables.
    let _guard = telemetry_config_for_graphql().with_env().init();

    rustls::crypto::ring::default_provider()
        .install_default()
        .expect("Failed to install CryptoProvider");

    match args.command {
        Command::Rpc {
            database_url,
            fullnode_args,
            db_args,
            kv_args,
            consistent_reader_args,
            rpc_args,
            system_package_task_args,
            metrics_args,
            config,
            indexer_config,
        } => {
            let rpc_config = if let Some(path) = config {
                let contents = fs::read_to_string(path)
                    .await
                    .context("Failed to read configuration TOML file")?;

                toml::from_str(&contents).context("Failed to parse configuration TOML file")?
            } else {

Review comment (refactor):
IMO, abstracting this with a function is making it harder to follow, let's just write the config inline -- the function seems to imply that GraphQL must be started with tracing set a certain way which is not the case.

```suggestion
    let _guard = telemetry_subscribers::TelemetryConfig::new()
        .with_enable_error_layer(true)
        .with_env()
        .init();
```

Code after:
use sui_indexer_alt_graphql::config::RpcLayer;
use sui_indexer_alt_graphql::start_rpc;
use sui_indexer_alt_metrics::MetricsService;
use sui_indexer_alt_metrics::uptime;
use telemetry_subscribers::TelemetryConfig;
use tokio::fs;

// Define the `GIT_REVISION` const
bin_version::git_revision!();

static VERSION: &str = const_str::concat!(
    env!("CARGO_PKG_VERSION_MAJOR"),
    ".",
    env!("CARGO_PKG_VERSION_MINOR"),
    ".",
    env!("CARGO_PKG_VERSION_PATCH"),
    "-",
    GIT_REVISION
);

#[tokio::main]
async fn main() -> anyhow::Result<()> {
    let args = Args::parse();

    // Enable tracing, configured by environment variables.
    let _guard = TelemetryConfig::new()
        // ErrorLayer is disabled by default in TelemetryConfig, but enabled by default in GraphQL
        // to give useful error output for debugging request timeouts.
        .with_enable_error_layer(true)
        .with_env()
        .init();

    rustls::crypto::ring::default_provider()
        .install_default()
        .expect("Failed to install CryptoProvider");

    match args.command {
        Command::Rpc {
            database_url,
            fullnode_args,
            db_args,
            kv_args,
            consistent_reader_args,
            rpc_args,
            system_package_task_args,
            metrics_args,
            config,
            indexer_config,
        } => {
            let rpc_config = if let Some(path) = config {
                let contents = fs::read_to_string(path)