DEV Community

xbill for Google Developer Experts

Posted on • Originally published at xbill999.Medium on

Building a Rust Network Tool with Gemini CLI, and Cloud Run

This article leverages the Gemini CLI and the underlying Gemini LLM to develop native compiled code built in the Rust Language for long term network ping monitoring. A fully functional tool is developed in Rust and then deployed to Google Cloud Run.

What is Rust?

Rust is a high performance, memory safe, compiled language:

Rust

Rust provides memory safe operations beyond C/C++ and also can provide exceptional performance gains as it is compiled directly to native binaries.

Initial Environment Setup

The environment is meant to be run from a Bash like shell. You can run this from a Linux VM, ChromeOS Linux VM, Firebase Studio environment, or any environment that provides a basic shell.

Rust Setup

Instructions to install Rust are available here:

Getting started

For a Linux like environment the command looks like this:

curl — proto ‘=https’ — tlsv1.2 -sSf https://sh.rustup.rs | sh
Enter fullscreen mode Exit fullscreen mode

Clone the Samples Repo and Setup the Basic Environment

Now that the Gemini CLI and the Rust installation has been validated from the base shell — you can clone the GitHub Repo with support scripts:

cd ~
git clone https://github.com/xbill9/ltping-rust
Enter fullscreen mode Exit fullscreen mode

Then run set_env.sh from the cloned directory. The script will attempt to determine your shell environment and set the correct variables:

cd ltping-rust
source set_env.sh
Enter fullscreen mode Exit fullscreen mode

Debugging API Permission Errors

If you did not set your environment variables or your Google Cloud Authentication expires you will get an error. The workaround is to re-authenticate:

gcloud auth login
Enter fullscreen mode Exit fullscreen mode

Another common error is that the environment variables are not set correctly. Go the the root directory and re-run the set_env.sh to set the variables:

cd ~/ltping-rust
source set_env.sh
Enter fullscreen mode Exit fullscreen mode

Debugging and Logging with Rust

The environment variable RUST_LOG controls how verbose the logging from the Rust code will produce messages. Initially — set the variable to info:

export RUST_LOG=info
echo $RUST_LOG
info
Enter fullscreen mode Exit fullscreen mode

Rust Log Levels

These levels filter messages based on their severity, from most critical to least:

  • ERROR : Only error messages are logged.
  • WARN : Warning messages and higher (error) are logged.
  • INFO : Informational messages and higher (warn, error) are logged.
  • DEBUG : Debug messages and higher (info, warn, error) are logged.
  • TRACE : Trace messages and higher (debug, info, warn, error) are logged. This is the most verbose level.
  • OFF : Disables all logging.

Next Steps- Build Rust Sample Client Code

A basic native Rust client sample has been included in the GitHub repo. Change to the sample directory and validate the Cargo.toml file for the minimal sample:

cd xbill@penguin:~$ cd ltping-rust/
pxbill@penguin:~/ltping-rust$ pwd
/home/xbill/ltping-rust
Enter fullscreen mode Exit fullscreen mode

The Rust standard format file Cargo.toml contains details about the code:

[package]
name = "ltping"
version = "0.1.0"
edition = "2024"
description = "A long-term ping monitor with a web-based dashboard."
license = "MIT"
repository = "https://github.com/xbill/ltping-rust"
readme = "README.md"
keywords = ["ping", "icmp", "monitor", "latency", "axum"]
categories = ["network-programming", "command-line-utilities"]
Enter fullscreen mode Exit fullscreen mode

Lint the code:

xbill@penguin:~/ltping-rust$ make lint
Linting code...
    Finished `dev` profile [unoptimized + debuginfo] target(s) in 0.04s
Enter fullscreen mode Exit fullscreen mode

Test the final binary:

xbill@penguin:~/ltping-rust$ make test
Running tests...
    Finished `test` profile [unoptimized + debuginfo] target(s) in 0.06s
     Running unittests src/main.rs (target/debug/deps/ltping-066254f6ec4865cf)

running 2 tests
test tests::test_parse_window_spec ... ok
test tests::test_stats_window ... ok

test result: ok. 2 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in 0.00s

xbill@penguin:~/ltping-rust$ 
Enter fullscreen mode Exit fullscreen mode

Build the release version with the Makefile :

xbill@penguin:~/ltping-rust$ make release
Building Release...
    Finished `release` profile [optimized] target(s) in 0.11s
xbill@penguin:~/ltping-rust$ 
Enter fullscreen mode Exit fullscreen mode

Then run the generated release Rust binary:

xbill@penguin:~/ltping-rust$ make run
Running the Rust project...
    Finished `release` profile [optimized] target(s) in 0.05s
     Running `target/release/ltping`
{"timestamp":"2026-02-03T17:16:57.209192Z","level":"INFO","fields":{"message":"Listening on 0.0.0.0:8080"},"target":"ltping"}
Enter fullscreen mode Exit fullscreen mode

Verify the Tool Locally

Once the tool has been built and run- you can access a basic web interface from the local server.

Open the local URL:

http://localhost:8080/
Enter fullscreen mode Exit fullscreen mode

This will present a basic interface:

Deploying to Cloud Run

After the HTTP version of the tool has been tested locally — it can be deployed remotely to Google Cloud Run.

First- switch to the directory with the HTTP sample code:

cd ~/ltping-rust
Enter fullscreen mode Exit fullscreen mode

Deploy the project to Google Cloud Run with the pre-built cloudbuild.yaml and Dockerfile:

cd ~/ltping-rust
xbill@penguin:~/ltping-rust$ make deploy
Enter fullscreen mode Exit fullscreen mode

The Cloud Build will start:

xbill@penguin:~/ltping-rust$ make deploy
Submitting build to Google Cloud Build...
Creating temporary archive of 10 file(s) totalling 57.0 KiB before compression.
Some files were not included in the source upload.

Check the gcloud log [/home/xbill/.config/gcloud/logs/2026.02.03/12.31.12.493423.log] to see which files and the contents of the
default gcloudignore file used (see `$ gcloud topic gcloudignore` to learn
more).

Uploading tarball of [.] to [gs://comglitn_cloudbuild/source/1770139872.678096-8d57222eee4b49baa36ef93b918fcd8a.tgz]
Created [https://cloudbuild.googleapis.com/v1/projects/comglitn/locations/global/builds/e40da48d-064c-4613-b525-b05e599be647].
Logs are available at [https://console.cloud.google.com/cloud-build/builds/e40da48d-064c-4613-b525-b05e599be647?project=1056842563084].
Waiting for build to complete. Polling interval: 1 second(s).
------------------------------------------------------------ REMOTE BUILD OUTPUT -------------------------------------------------------------
starting build "e40da48d-064c-4613-b525-b05e599be647"

Enter fullscreen mode Exit fullscreen mode

It can take 15–30 minutes to complete the build.

The cloud build needs to pull in all the Rust libraries in the build environment and generate the entire package from scratch:

Starting Step #1
Step #1: Already have image (with digest): gcr.io/cloud-builders/gcloud
Step #1: Deploying container to Cloud Run service [ltping] in project [comglitn] region [us-central1]
Step #1: Deploying...
Step #1: Setting IAM Policy............done
Step #1: Creating Revision........................................................done
Step #1: Routing traffic.....done
Step #1: Done.
Step #1: Service [ltping] revision [ltping-00005-kcd] has been deployed and is serving 100 percent of traffic.
Step #1: Service URL: https://ltping-1056842563084.us-central1.run.app
Finished Step #1
PUSH
Enter fullscreen mode Exit fullscreen mode

When the build is complete- an endpoint will be returned. The service endpoint in this example is :

https://ltping-1056842563084.us-central1.run.app
Enter fullscreen mode Exit fullscreen mode

The actual endpoint will vary based on your project settings.

Review Service in Cloud Run

Navigate to the Google Cloud console and search for Cloud Run -

and then you can detailed information on the Cloud Run Service:

Cloud Logging

The remote server writes logs to stderr in standard JSON format. These logs are available from the deployed Cloud Run Service:

Validate HTTP connection

Once you have the Endpoint — you can attempt a connection- navigate to in your browser:

https://ltping-1056842563084.us-central1.run.app
Enter fullscreen mode Exit fullscreen mode

You will need to adjust the exact URL to match the URL returned from Cloud Build:

Code Review the Project

Gemini CLI was used to review the project:

> what does this package do?

╭────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮
│ ✓ ReadFile README.md │
│ │
│ │
│ ✓ ReadFile Cargo.toml │
│ │
╰────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯
✦ ltping (Long-term Ping) is a network monitoring tool written in Rust that tracks connection quality over time and visualizes it on a web
  dashboard.

  Unlike a standard command-line ping, it is designed to run continuously and aggregates statistics over sliding time windows (e.g., last 10
  seconds, 1 minute, 1 hour).

  Key Features:
   - Web Dashboard: Accessible at http://localhost:8080 to view real-time stats.
   - Metrics: Tracks Packet Loss, Round Trip Time (RTT), and Jitter.
   - Dynamic Control: Allows changing the target host and interval on the fly via the web UI.
   - No External Dependencies: Uses raw ICMP sockets directly rather than calling the system ping command.
Enter fullscreen mode Exit fullscreen mode

Package Information on crates.io

The complete ltping-rust package is available on the Rust crates.io site:

crates.io: Rust Package Registry

Summary

A complete Rust native long term ping — ltping- utility was built and testing using Gemini CLI along with Rust libraries. This compiled Rust code was then called directly from the local shell and performed long term ping operations from the local network.

Then, the tool was then wrapped in a container and deployed to Google Cloud Run. This cloud deployment was tested to test the network jitter for remote sites from the Cloud Run environment.

Top comments (0)