Skip to content
Merged
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
12 changes: 6 additions & 6 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,13 @@ jobs:
- name: Check formatting (OTAP compatibility suite)
run: cargo fmt --manifest-path tests/otap-compat/Cargo.toml --all -- --check
- name: Run clippy
run: cargo clippy --all-targets --all-features -- -D warnings
run: cargo clippy --workspace --all-targets --all-features -- -D warnings
- name: Run clippy (no default features)
run: cargo clippy --all-targets --no-default-features -- -D warnings
run: cargo clippy --workspace --all-targets --no-default-features -- -D warnings
- name: Run tests (all features)
run: cargo test --all-features
run: cargo test --workspace --all-features
- name: Run tests (no default features)
run: cargo test --no-default-features
run: cargo test --workspace --no-default-features
- name: Run clippy (OTAP compatibility suite)
env:
CARGO_TARGET_DIR: target
Expand All @@ -53,9 +53,9 @@ jobs:
- uses: dtolnay/rust-toolchain@1.88
- uses: Swatinem/rust-cache@v2
- name: Check MSRV (all features)
run: cargo check --all-targets --all-features
run: cargo check --workspace --all-targets --all-features
- name: Check MSRV (no default features)
run: cargo check --all-targets --no-default-features
run: cargo check --workspace --all-targets --no-default-features

go-fixtures:
name: Go testdata sync check
Expand Down
77 changes: 77 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
name: Release

on:
release:
types: [published]
workflow_dispatch:
inputs:
dry_run:
description: "Run cargo publish --dry-run without uploading to crates.io"
required: true
type: boolean
default: true

permissions:
contents: read
id-token: write

concurrency:
group: release-${{ github.ref }}
cancel-in-progress: false

jobs:
publish:
name: Publish to crates.io
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
persist-credentials: false

- uses: dtolnay/rust-toolchain@stable

- name: Verify release tag matches workspace crate versions
if: github.event_name == 'release'
env:
TAG_NAME: ${{ github.event.release.tag_name }}
run: |
expected="${TAG_NAME#v}"
if [ "$expected" = "$TAG_NAME" ]; then
echo "Release tag '${TAG_NAME}' must start with 'v' (for example, v0.1.0)"
exit 1
fi
actual=$(cargo metadata --no-deps --format-version 1 \
| jq -r '.packages[] | select(.publish == null or (.publish | length > 0)) | "\(.name)@\(.version)"')
echo "Publishable crates:"
echo "$actual"
mismatched=$(cargo metadata --no-deps --format-version 1 \
| jq -r --arg expected "$expected" \
'.packages[] | select(.publish == null or (.publish | length > 0)) | select(.version != $expected) | "\(.name)@\(.version)"')
if [ -n "$mismatched" ]; then
echo "Release tag ${TAG_NAME} (version ${expected}) does not match crate versions:"
echo "$mismatched"
exit 1
fi

- name: Run workspace tests and doc checks
env:
RUSTDOCFLAGS: "--deny warnings"
run: |
cargo test --workspace --locked --all-features
cargo test --workspace --locked --no-default-features
cargo doc --workspace --locked --no-deps --all-features

- name: Dry-run workspace publish
if: github.event_name == 'workflow_dispatch' && inputs.dry_run
run: cargo publish --workspace --locked --dry-run

- name: Authenticate with crates.io (OIDC Trusted Publishing)
if: github.event_name == 'release' || (github.event_name == 'workflow_dispatch' && !inputs.dry_run)
id: crates-io-auth
uses: rust-lang/crates-io-auth-action@3268eb413133e2960fa4ae0e963ca76380c54cd9 # v1.0.6

- name: Publish workspace crates to crates.io
if: github.event_name == 'release' || (github.event_name == 'workflow_dispatch' && !inputs.dry_run)
env:
CARGO_REGISTRY_TOKEN: ${{ steps.crates-io-auth.outputs.token }}
run: cargo publish --workspace --locked
14 changes: 7 additions & 7 deletions AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,13 @@ Run these before you push. CI runs the same commands, see [.github/workflows/ci.

```sh
cargo fmt --all -- --check
cargo clippy --all-targets --all-features -- -D warnings
cargo clippy --all-targets --no-default-features -- -D warnings
cargo test --all-features
cargo test --no-default-features
cargo clippy --workspace --all-targets --all-features -- -D warnings
cargo clippy --workspace --all-targets --no-default-features -- -D warnings
cargo test --workspace --all-features
cargo test --workspace --no-default-features
```

If you touch `src/arrow`, also run the OTAP compatibility suite. It has its own manifest:
If you touch `crates/expfmt/src/arrow`, also run the OTAP compatibility suite. It has its own manifest:

```sh
cargo test --manifest-path tests/otap-compat/Cargo.toml
Expand All @@ -24,7 +24,7 @@ Do not use Rust language or std features newer than `rust-version` in `Cargo.tom

## Spec

[specs/SPEC.md](specs/SPEC.md) is the specification contract for `scrape.rs` (`expfmt`, `relabel`, and scrape pipeline integration). If you change behavior the spec describes, update the spec in the same PR.
[specs/SPEC.md](specs/SPEC.md) is the specification contract for `scrape.rs` (`prometheus-expfmt`, `prometheus-relabel`, and `prometheus-scrape-manager`). If you change behavior the spec describes, update the spec in the same PR.

## Test data

Expand All @@ -46,7 +46,7 @@ If Rust must differ from Go on purpose, explain each difference in the PR body w

- Write all benchmarks with [`benchfmt.rs`](https://github.com/bwplotka/benchfmt.rs) using `benchfmt::Suite` and `benchfmt::CountingAlloc` in `harness = false` `[[bench]]` targets so every benchmark emits Go [Benchmark Data Format](https://go.googlesource.com/proposal/+/master/design/14313-benchmark-format.md) lines with `ns/op`, `MB/s`, `B/op`, and `allocs/op` for [`benchstat`](https://pkg.go.dev/golang.org/x/perf/cmd/benchstat). Do not use Criterion or custom benchmark output formats.
- Name benchmarks with `/key=value` sub-benchmark dimensions such as `Decode/case=alltypes.237mfs/mode=decode`, call `b.report_allocs()` and `while b.keep_running()`, and include a `Recommended CLI invocation:` doc comment at the top of each benchmark file.
- Performance improvements and hot-path changes require running benchmarks before and after the change, for example `cargo bench --bench decode -- -bench '^BenchmarkDecode' -benchtime 1s -count 6 -cpu 2 -benchmem | tee ${bench}.txt`, and comparing with `benchstat before.txt after.txt`.
- Performance improvements and hot-path changes require running benchmarks before and after the change, for example `cargo bench -p prometheus-expfmt --bench decode -- -bench '^BenchmarkDecode' -benchtime 1s -count 6 -cpu 2 -benchmem | tee ${bench}.txt`, and comparing with `benchstat before.txt after.txt`.
- Always output benchmark results in raw `benchstat` format in the PR body and review comments, and always include links to the exact `before` and `after` commits that the benchmark refers to. Rerun benchmarks and update the commit links whenever addressing review comments that touch benchmarked code or benchmarks.
- If a subset of benchmark results shows a regression, address it or explain in the PR body why that case is not important.
- Reuse allocations in hot paths where possible, such as `Vec::clear`, scratch buffers, and interner arenas. When reusing buffers exposed through APIs or traits, document lifetime and copy requirements on the trait or type definition.
Expand Down
52 changes: 34 additions & 18 deletions Cargo.lock

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

61 changes: 24 additions & 37 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,52 +1,39 @@
[package]
name = "expfmt"
[workspace]
resolver = "3"
members = [
"crates/expfmt",
"crates/relabel",
"crates/scrape-manager",
]
exclude = ["tests/otap-compat"]

[workspace.package]
version = "0.1.0"
edition = "2024"
rust-version = "1.88"
description = "Prometheus and OpenMetrics wire exposition format decoders"
license = "Apache-2.0"
repository = "https://github.com/prometheus/expfmt-rs"
keywords = ["prometheus", "openmetrics", "metrics", "opentelemetry", "arrow"]
categories = ["parser-implementations", "encoding"]

[workspace]
exclude = ["tests/otap-compat"]
repository = "https://github.com/prometheus/scrape.rs"

[features]
default = ["arrow", "dto", "relabel"]
arrow = ["dep:arrow-array", "dep:arrow-buffer", "dep:arrow-schema"]
dto = ["dep:prost", "dep:prost-types"]
relabel = ["dep:regex", "dep:serde"]
[workspace.dependencies]
prometheus-expfmt = { version = "0.1.0", path = "crates/expfmt", default-features = false }
prometheus-relabel = { version = "0.1.0", path = "crates/relabel" }

[dependencies]
arrow-array = { version = "59", default-features = false, optional = true }
arrow-buffer = { version = "59", default-features = false, optional = true }
arrow-schema = { version = "59", default-features = false, optional = true }
prost = { version = "0.14", optional = true }
prost-types = { version = "0.14", optional = true }
regex = { version = "1", optional = true }
serde = { version = "1", features = ["derive"], optional = true }
thiserror = "2"

[dev-dependencies]
arrow-array = { version = "59", default-features = false }
arrow-buffer = { version = "59", default-features = false }
arrow-schema = { version = "59", default-features = false }
benchfmt = { git = "https://github.com/bwplotka/benchfmt.rs" }
prost = { version = "0.14" }
prost-build = "=0.14.4"
prost-types = { version = "0.14" }
protox = "0.10"
regex = { version = "1" }
serde = { version = "1", features = ["derive"] }
serde_json = "1"
thiserror = "2"

[[bench]]
name = "decode"
harness = false
required-features = ["arrow"]

[[bench]]
name = "relabel"
harness = false
required-features = ["relabel"]

[lints.rust]
[workspace.lints.rust]
missing_docs = "warn"
unsafe_code = "forbid"

[lints.clippy]
[workspace.lints.clippy]
all = "warn"
Loading
Loading