Repository navigation
feat(sdk): serve Go-compatible gRPC server metrics - #10
Merged
Merged
Conversation
The gRPC server series function-sdk-go serves, with the interceptor exact names, labels and help strings, so dashboards work across Go and Rust functions: a tower layer over the whole router (unary-only like the Go interceptor, InitializeMetrics-style zero series, no handling histogram - Go never enabled it), counted into a prometheus-client registry and served at /metrics on --metrics-address (the Go SDK default :8080, empty disables) - OpenMetrics 1.0 as the main format, the classic Prometheus text format for an Accept header that asks. Closes the last recorded Go-parity gap. Breaking for Args literals: the struct gains metrics_address.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes the last recorded Go-parity gap (README "Differences from function-sdk-go", the ABI research verdict): a function built with this SDK now serves the same gRPC server metrics a function-sdk-go function serves, so platform dashboards and alerts work across Go and Rust functions unchanged.
What changed
metricsmodule:grpc_server_started_total,grpc_server_handled_total(withgrpc_code),grpc_server_msg_received_total,grpc_server_msg_sent_total- Confirmed (function-sdk-go v0.7.1 source): the exact names, label sets and help strings ofgrpcprometheus.NewServerMetrics()with default options, which is what the Go SDK installs.Checkis counted like Go's server-wide interceptor), reading the unary status from thegrpc-statustrailer or header; a client that disappears mid-call counts asCanceled./metricsendpoint beside the gRPC server:Argsgainsmetrics_address(default:8080- the Go SDK'sDefaultMetricsAddress-METRICS_ADDRESSenv, empty disables), mirroring howServe()behaves in Go.prometheus-client0.25, per the recorded research verdict: the only purpose-built alternative,tonic-prometheus-layer, is pinned to tonic ^0.13 and would hold the SDK's tonic major back.Deliberate parity choices
metrics.UnaryServerInterceptor()- streaming methods (reflection, healthWatch) were never counted there and are not counted here.metrics.InitializeMetrics(srv): every served method exists as a zero series from startup, streaming methods included (permanently zero).grpc_server_handling_seconds: the Go SDK never enables the handling-time histogram.text/plain; version=0.0.4served to anAcceptheader that asks for it without accepting OpenMetrics - the series are what Go compatibility means, and both formats carry them identically. Registration compensates two prometheus-client behaviors verified in its source (it appends_totalto counter samples and a trailing.to help strings), so the served text matches the Go SDK's byte for byte.API surface
One new public field:
Args::metrics_address. The module itself is private - no layer, registry or encoder types are exported, per the keep-serve-alone surface decision (#4). Breaking forArgsstruct literals (downstream: function-wasm constructsArgsin tests and defines its own colliding--metrics-addressflag - it drops that flag and adopts the SDK's on its next version bump), so this is a 0.3.0.Testing
serveintegration test now drives the full flow: oneRunFunction+ one healthCheck, then asserts on the served/metrics- started/received/handled-OK/sent all exactly 1 forRunFunction, the healthCheckcounted,Watchpresent at zero, OpenMetrics content type +# EOF, and the classic rendering on an explicittext/plainAccept.cargo test --workspacegreen (6 suites);cargo clippy --workspace --all-targets -- -D warningsandcargo fmt --checkclean.Reference