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
82 changes: 82 additions & 0 deletions Cargo.lock

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

25 changes: 17 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -97,14 +97,23 @@ with a few deliberate differences:
reports the function as serving.
- **Graceful shutdown is built in.** The server drains in-flight requests on
SIGTERM and SIGINT.
- **No Prometheus metrics yet.** function-sdk-go serves gRPC server metrics
on `:8080` (`WithMetricsServer`). As of August 2026 there is no maintained
tonic-compatible Prometheus layer: the only purpose-built crate,
[tonic-prometheus-layer], is pinned to tonic 0.13 and lags tonic majors,
so depending on it would hold this SDK back. When metrics are needed the
plan is to hand-roll a small tower layer on [prometheus-client] (the
actively maintained official Rust client) with a `/metrics` endpoint,
rather than take that dependency.
- **Metrics are Go-compatible, served as OpenMetrics first.** Like
function-sdk-go, the server serves the gRPC server series on `:8080` at
`/metrics` (`--metrics-address`, empty disables):
`grpc_server_started_total`, `grpc_server_handled_total` (with
`grpc_code`), `grpc_server_msg_received_total` and
`grpc_server_msg_sent_total`, with the interceptor's exact names, labels
and help strings - dashboards built for Go functions work unchanged. As
in the Go SDK, only unary calls are counted (streaming reflection and
health `Watch` exist as permanently zero series), every served method is
pre-created at zero, and there is no handling-time histogram. The
exposition differs deliberately: OpenMetrics 1.0 is the main format
(readable beyond Prometheus), with the classic Prometheus text format
served to an `Accept` header that asks for it. Built on
[prometheus-client], the official OpenMetrics-native client - the only
purpose-built alternative, [tonic-prometheus-layer], is pinned to tonic
0.13 and would hold this SDK back. Since this SDK serves no v1beta1, the
v1beta1 series the Go SDK pre-created do not exist here.

[crossplane]: https://www.crossplane.io
[functions]: https://docs.crossplane.io/latest/composition/compositions/
Expand Down
6 changes: 6 additions & 0 deletions sdk/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@ keywords = ["crossplane", "kubernetes", "grpc"]
categories = ["api-bindings"]

[dependencies]
bytes = "1"
http = "1"
http-body = "1"
prometheus-client = "0.25"
tonic = { version = "0.14", features = ["tls-aws-lc"] }
tonic-prost = "0.14"
tonic-health = "0.14"
Expand All @@ -22,6 +26,8 @@ serde_json = "1"
tokio = { version = "1", features = ["rt-multi-thread", "macros", "signal"] }
clap = { version = "4", features = ["derive", "env"] }
tracing = "0.1"
tower-layer = "0.3"
tower-service = "0.3"
tracing-subscriber = { version = "0.3", features = ["json"] }
sha2 = "0.11"
thiserror = "2"
Expand Down
2 changes: 2 additions & 0 deletions sdk/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@
//!
//! [`FunctionRunnerService`]: proto::v1::function_runner_service_server::FunctionRunnerService

mod metrics;

pub mod context;
pub mod logging;
pub mod proto;
Expand Down
Loading
Loading