Skip to content

Commit 7ffe8c4

Browse files
New Example: Monitoring Data Pipelines (#230)
1 parent 72ae286 commit 7ffe8c4

File tree

7 files changed

+746
-0
lines changed

7 files changed

+746
-0
lines changed
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
[package]
2+
name = "polars-otel-shuttle"
3+
version = "0.1.0"
4+
edition = "2021"
5+
6+
[features]
7+
bench-cli = [] # local CLI binary
8+
otel-otlp = ["opentelemetry-otlp"] # enable real OTLP exporter when you want it
9+
10+
[dependencies]
11+
anyhow = "1"
12+
serde = { version = "1", features = ["derive"] }
13+
serde_json = "1"
14+
15+
# Web (for Shuttle build)
16+
axum = { version = "0.8", features = ["json"] }
17+
tower = "0.5"
18+
tower-http = { version = "0.6", features = ["cors", "trace"] }
19+
20+
# Tracing
21+
tracing = "0.1"
22+
tracing-subscriber = { version = "0.3", features = ["env-filter", "fmt", "json", "time"] }
23+
time = { version = "0.3", features = ["formatting", "macros"] }
24+
tracing-opentelemetry = "0.31"
25+
26+
# OpenTelemetry (core + SDK; OTLP exporter is optional via feature)
27+
opentelemetry = { version = "0.30", features = ["trace"] }
28+
opentelemetry_sdk = { version = "0.30", features = ["trace", "rt-tokio"] }
29+
opentelemetry-otlp = { version = "0.30", features = ["http-proto", "tls"], optional = true }
30+
31+
# Runtime (new enough to satisfy shuttle-runtime)
32+
tokio = { version = "1.47.0", features = ["rt-multi-thread", "macros"] }
33+
34+
# ETL
35+
polars = { version = "0.49", features = [
36+
"lazy", "csv", "parquet", "fmt", "strings", "dtype-date", "dtype-datetime"
37+
] }
38+
chrono = { version = "0.4", features = ["clock"] }
39+
comfy-table = "7"
40+
41+
# Shuttle (only used on deploy)
42+
shuttle-runtime = { version = "0.56", features = ["setup-otel-exporter"] }
43+
shuttle-axum = "0.56"

axum/polars-otel-shuttle/README.md

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
# Polars ETL with OpenTelemetry
2+
3+
An ETL pipeline using Polars for data processing and OpenTelemetry for observability, deployable on Shuttle.
4+
5+
## What it does
6+
7+
- Processes CSV data with Polars (load → clean → aggregate → filter/sort → save)
8+
- Exposes HTTP endpoints via Axum
9+
- Emits metrics and traces via OpenTelemetry
10+
- Integrates with Better Stack for monitoring (when deployed on Shuttle)
11+
12+
## Running locally
13+
14+
**ETL benchmark:**
15+
```bash
16+
RUST_LOG=info cargo run --release --features bench-cli
17+
```
18+
19+
**Web service:**
20+
```bash
21+
cargo run --release
22+
```
23+
24+
Place your CSV file at `./data/yellow_tripdata_2015-01.csv` or set `DATA_PATH=/path/to/file.csv`.
25+
26+
## Deploy to Shuttle
27+
28+
```bash
29+
shuttle deploy
30+
```
31+
32+
## Endpoints
33+
34+
- `GET /` - Health check
35+
- `GET /health` - Health check with metrics
36+
- `GET /benchmark` - Returns ETL metrics and emits telemetry events
37+
38+
## Observability
39+
40+
The service emits OpenTelemetry metrics:
41+
- `monotonic_counter.http_requests_total` - Request counts
42+
- `histogram.request_duration_ms` - Request latency
43+
- `histogram.*_time_ms` - ETL stage timings
44+
- `monotonic_counter.rows_processed` - Data throughput
45+
46+
When deployed on Shuttle with Better Stack integration enabled, these automatically appear in your telemetry dashboard.
47+
48+
## Configuration
49+
50+
**Environment variables:**
51+
- `DATA_PATH` - Path to CSV file (default: `data/yellow_tripdata_2015-01.csv`)
52+
53+
**Features:**
54+
- `bench-cli` - Enables local ETL benchmark
55+
- `otel-otlp` - Enables OTLP export (for non-Shuttle deployments)
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
name = "polars-otel-shuttle"
2+
# Shuttle uses your #[shuttle_runtime::main] entry point in src/main.rs

0 commit comments

Comments
 (0)