Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
name: CI

on:
push:
pull_request:

permissions:
Expand Down Expand Up @@ -70,4 +69,4 @@ jobs:
- uses: actions/checkout@v3
with:
fetch-depth: 1
- run: go run github.com/vkcom/statshouse/cmd/statshouse-client-test@master
- run: go run github.com/VKCOM/statshouse/cmd/statshouse-client-test@master
20 changes: 2 additions & 18 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 5 additions & 4 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,12 @@ opt-level = 2
opt-level = 1

[workspace.package]
version = "0.1.0"
version = "0.1.1"
authors = ["V Kontakte LLC"]
homepage = "https://github.com/vkcom/statshouse-rs"
repository = "https://github.com/vkcom/statshouse-rs"
homepage = "https://github.com/VKCOM/statshouse-rs"
repository = "https://github.com/VKCOM/statshouse-rs"
description = "Rust client library for StatsHouse metrics collection system"
keywords = ["statshouse", "observability", "metrics", "monitoring", "telemetry"]
categories = [
"statshouse",
"observability",
Expand All @@ -36,4 +38,3 @@ unwrap_used = "forbid"

[workspace.dependencies]
lexopt = "0.3.0"
xshell = "0.2.6"
39 changes: 39 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
# StatsHouse Rust Client

A Rust client library for the [StatsHouse](https://github.com/VKCOM/statshouse) metrics collection system.

## Features

- Efficient metrics collection and batching
- Thread-safe client implementation
- Configurable batch sizes and timeouts
- Support for various metric types

## Usage

Add this to your `Cargo.toml`:

```toml
[dependencies]
statshouse = "0.1.1"
```

Basic usage example:

```rust
use statshouse::Client;

// Create a client
let client = Client::new("localhost:13337")?;

// Send metrics
client.send_metric("my_metric", 42.0)?;
```

## License

This project is licensed under the Mozilla Public License 2.0 - see the [LICENSE](LICENSE) file for details.

## Contributing

Contributions are welcome! Please feel free to submit a Pull Request.
2 changes: 2 additions & 0 deletions statshouse/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ version.workspace = true
authors.workspace = true
homepage.workspace = true
repository.workspace = true
description.workspace = true
keywords.workspace = true
categories.workspace = true
license.workspace = true
edition.workspace = true
Expand Down
4 changes: 2 additions & 2 deletions statshouse/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2024 V Kontakte LLC
// Copyright 2025 V Kontakte LLC
//
// This Source Code Form is subject to the terms of the Mozilla Public
// License, v. 2.0. If a copy of the MPL was not distributed with this
Expand Down Expand Up @@ -282,7 +282,7 @@ impl MetricBuilder {
m.tl_buffer_overflow = !m.tl_buffer.write_u32(0);
} else {
m.tl_buffer_overflow = true;
};
}
m
}

Expand Down
1 change: 0 additions & 1 deletion xtask/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,3 @@ workspace = true

[dependencies]
lexopt.workspace = true
xshell.workspace = true
84 changes: 62 additions & 22 deletions xtask/src/main.rs
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
// Copyright 2024 V Kontakte LLC
// Copyright 2025 V Kontakte LLC
//
// This Source Code Form is subject to the terms of the Mozilla Public
// License, v. 2.0. If a copy of the MPL was not distributed with this
// file, You can obtain one at https://mozilla.org/MPL/2.0/.

use lexopt::Parser;
use xshell::{cmd, Shell};
use std::process::Command;

type BoxedError = Box<dyn std::error::Error + Send + Sync>;

Expand All @@ -19,10 +19,9 @@ fn main() -> Result<(), BoxedError> {
None
};

let sh = Shell::new()?;
match subcommand.as_deref() {
Some("bench") => run_bench(&mut parser, &sh),
Some("ci") => run_ci(&mut parser, &sh),
Some("bench") => run_bench(&mut parser),
Some("ci") => run_ci(&mut parser),
Some(cmd) => Err(format!("unexpected subcommand: {cmd}").into()),
None => Err("subcommand expected".into()),
}
Expand All @@ -34,35 +33,76 @@ fn assert_no_more_args(parser: &mut Parser) -> Result<(), BoxedError> {
match parser.next()? {
Some(Short(c)) => Err(format!("unexpected option: -{c}").into()),
Some(Long(s)) => Err(format!("unexpected option: --{s}").into()),
Some(Value(v)) => Err(format!("unexpected value: {v:?}").into()),
Some(Value(v)) => Err(format!("unexpected value: {}", v.display()).into()),
None => Ok(()),
}
}

fn run_bench(parser: &mut Parser, sh: &Shell) -> Result<(), BoxedError> {
fn run_bench(parser: &mut Parser) -> Result<(), BoxedError> {
assert_no_more_args(parser)?;

cmd!(
sh,
"cargo +nightly bench --features=_bench --quiet -- benches"
)
.run()?;
let status = Command::new("rustup")
.args([
"run",
"nightly",
"cargo",
"bench",
"--features=_bench",
"--quiet",
"--",
"benches",
])
.status()?;

if !status.success() {
return Err(format!("bench command failed with status: {status}").into());
}

Ok(())
}

fn run_ci(parser: &mut Parser, sh: &Shell) -> Result<(), BoxedError> {
fn run_ci(parser: &mut Parser) -> Result<(), BoxedError> {
assert_no_more_args(parser)?;

cmd!(
sh,
"go run github.com/vkcom/statshouse/cmd/statshouse-client-test@master"
)
.run()?;
cmd!(sh, "cargo fmt --check").run()?;
cmd!(sh, "cargo clippy -- -D warnings").run()?;
cmd!(sh, "cargo test --quiet").run()?;
cmd!(sh, "cargo +nightly bench --no-run --quiet").run()?;
// Run Go test
let status = Command::new("go")
.args([
"run",
"github.com/VKCOM/statshouse/cmd/statshouse-client-test@master",
])
.status()?;

if !status.success() {
return Err(format!("go test command failed with status: {status}").into());
}
// Run cargo fmt check
let status = Command::new("cargo").args(["fmt", "--check"]).status()?;

if !status.success() {
return Err(format!("cargo fmt check failed with status: {status}").into());
}
// Run cargo clippy with warnings as errors
let status = Command::new("cargo")
.args(["clippy", "--", "-D", "warnings"])
.status()?;

if !status.success() {
return Err(format!("cargo clippy failed with status: {status}").into());
}
// Run cargo test
let status = Command::new("cargo").args(["test", "--quiet"]).status()?;

if !status.success() {
return Err(format!("cargo test failed with status: {status}").into());
}
// Run nightly bench (compile only)
let status = Command::new("rustup")
.args(["run", "nightly", "cargo", "bench", "--no-run", "--quiet"])
.status()?;

if !status.success() {
return Err(format!("nightly bench command failed with status: {status}").into());
}

Ok(())
}
Loading