| Crates.io | xbp-monitoring |
| lib.rs | xbp-monitoring |
| version | 0.9.48 |
| created_at | 2025-12-11 19:03:18.650201+00 |
| updated_at | 2025-12-11 19:03:18.650201+00 |
| description | XBP-Monitoring is a synthetic monitoring framework that simplifies and automates the entire process. Optionally used in conjuction as plugin to XBP base |
| homepage | |
| repository | |
| max_upload_size | |
| id | 1980325 |
| size | 235,962 |
axum for HTTP, tokio runtime, reqwest for outbound calls, tracing for logs, and OpenTelemetry for traces/metrics. It exposes a JSON API and optionally a Prometheus endpoint.cargo fmt and cargo clippy -D warnings on edits.axum 0.7; return axum::Json<T> for JSON responses; inject shared state via Extension<Arc<AppState>>.tokio 1.x; never block the runtime (no std::thread::sleep).reqwest 0.11 with a single reused client via lazy_static!. Reuse the existing client(s) instead of creating new ones.opentelemetry, opentelemetry-otlp, opentelemetry-prometheus, tracing, tracing-subscriber.Result<T, Box<dyn std::error::Error + Send>> (or Box<dyn Error + Send> for errors) to preserve sendability.MapToSendError (see errors.rs) rather than .unwrap() or .expect()..unwrap() in tests or truly infallible contexts; otherwise bubble errors up.std::fmt::Display and std::error::Error.tracing macros (trace!, debug!, info!, warn!, error!), not println!.opentelemetry_http::HeaderInjector; attach attributes:
http.method, http.url, http.status_codename, type (probe|story|step), and story_name on step spanssensitive, do not log or attach response body; use “Redacted”.Metrics in src/otel/metrics.rs:
runs (Counter<u64>)duration (Histogram<u64>, milliseconds)errors (Counter<u64>)status (Gauge<u64>, 0=OK, 1=Error)http_status_code (Gauge<u64>, 0 if HTTP call failed)name and type (probe|story|step). Steps also include story_name.Copy .env.example to .env and configure as needed:
OTEL_EXPORTER_OTLP_ENDPOINT (default: http://localhost:4317)
OTEL_EXPORTER_OTLP_PROTOCOL (default: grpc)
grpc, http/protobuf, http/jsonOTEL_EXPORTER_OTLP_TIMEOUT (default: 10)
OTEL_METRICS_EXPORTER (optional)
otlp, stdout, prometheusprometheus to enable Prometheus metrics endpointOTEL_TRACES_EXPORTER (optional)
otlp, stdoutstdout for local development to print spans to consoleOTEL_EXPORTER_PROMETHEUS_HOST (default: localhost)
OTEL_METRICS_EXPORTER=prometheus)OTEL_EXPORTER_PROMETHEUS_PORT (default: 9464)
OTEL_METRICS_EXPORTER=prometheus)OTEL_RESOURCE_ATTRIBUTES (optional)
service.name=xbp-monitoring,service.version=1.0.0Any custom environment variables can be referenced in xbp.yaml config files using:
url: https://api.example.com/${{ env.API_KEY }}
See .env.example.github for detailed documentation of all GitHub workflow environment variables and secrets.
.github/workflows/docker.yaml)REGISTRY (default: ghcr.io)
IMAGE_NAME (default: ${{ github.repository }})
GITHUB_TOKEN (GitHub secret, auto-provided)
.github/workflows/test.yaml)CARGO_TERM_COLOR (set to always)
.github/workflows/release.yaml)GITHUB_TOKEN (GitHub secret, auto-provided)
.github/workflows/lint.yaml)reqwest::Client singletons (via lazy_static!) with user-agent:
XBP Probe/0.9.4XBP Alert/0.9.4AppState guarded by RwLocks. Do not hold locks across .await points.Arc<AppState> when spawning tasks; ensure spawned tasks are Send.tokio::spawn with the provided probing_loop pattern.tokio::time.src/web_server. Follow existing route structure and response types.Json<T> with serializable DTOs from src/web_server/model.rs..unwrap() with graceful error responses and proper status codes.show_response query param: if false, strip bodies before returning.serde_yaml; top-level shape is Config { probes, stories }.${{steps.<step-name>.response.body}} → entire body${{steps.<step-name>.response.body.<field>}} → JSON field${{generate.uuid}} → new UUID${{ env.VAR_NAME }} → environment variable (logs a warning if missing; substitutes empty string)#[serde(default)] for optional vectors/fields and #[serde(skip_serializing_if = "Option::is_none")] for optional outputs.StatusCode, BodyEquals, NotEquals, Contains, NotContains, Matches (regex), IsOneOf (pipe-separated)probe::expectations while keeping pure, testable functions.#[tokio::test] with wiremock for HTTP mocking. Avoid real network calls.sensitive: bool on probes/steps:
src/probe, telemetry under src/otel, web under src/web_server, alerts under src/alerts.cargo run -- --file xbp.ymlcargo fmt --allcargo clippy -D warningscargo testOTEL_TRACES_EXPORTER=stdout to print spans to stdout locally.OTEL_METRICS_EXPORTER=prometheus.OTEL_EXPORTER_PROMETHEUS_HOST (default localhost) and OTEL_EXPORTER_PROMETHEUS_PORT (default 9464)./metrics.src/probe/http_probe.rs (user-agent XBP Probe/0.9.4).src/alerts/outbound_webhook.rs (user-agent XBP Alert/0.9.4).lazy_static!; do not introduce new clients—reuse these.DEFAULT_REQUEST_TIMEOUT_SECS in src/probe/http_probe.rs).with.timeout_seconds (ProbeInputParameters.timeout_seconds).REQUEST_TIMEOUT_SECS in src/alerts/outbound_webhook.rs).//probes/probes/:name/results/probes/:name/trigger/stories/stories/:name/results/stories/:name/trigger/metrics (only when Prometheus metrics are enabled)xbp.yml. Override via CLI: --file <path>.src/config.rs.opentelemetry_http::HeaderInjector.http.method, http.url, and http.status_code.sensitive: true, do not attach response bodies to spans; otherwise, truncate bodies to <= 500 chars.wiremock for HTTP; avoid real network calls.