GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — feat(go): Implement metrics and tracing for http and grpc servers by luisazofracabify · Pull Request #5925 · feast-dev/feast

feat(go): Implement metrics and tracing for http and grpc servers #5925

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

Sign up for GitHub

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
shuchu merged 7 commits into feast-dev:master from luisazofracabify:feat/go-server-observability
Feb 19, 2026

Uh oh!

There was an error while loading. Please reload this page.

Merged

feat(go): Implement metrics and tracing for http and grpc servers #5925

Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
7 commits
Select commit Hold shift + click to select a range
22a253b
feat(go): implement metrics and tracing for http and grpc servers
luisazofracabify Jan 30, 2026
1664ae5
fix(server): improve metrics, config, and shutdown logic
luisazofracabify Feb 11, 2026
1bf7277
chore: update go.sum after rebase
luisazofracabify Feb 11, 2026
816423b
docs: improve README instructions for metrics and tracing
luisazofracabify Feb 11, 2026
41d58e2
fix(server): resolve potential deadlock during shutdown
luisazofracabify Feb 11, 2026
f3b7021
Merge branch 'master' into feat/go-server-observability
luisazofracabify Feb 18, 2026
0bb51fc
Merge branch 'master' into feat/go-server-observability
luisazofracabify Feb 19, 2026
File filter
Filter by extension


Clear filters
Conversations
Failed to load comments.
Loading

Uh oh!

There was an error while loading. Please reload this page.

Jump to
Jump to file
Failed to load files.
Loading

Uh oh!

There was an error while loading. Please reload this page.

Diff view
Diff view

Some comments aren't visible on the classic Files Changed page.

There are no files selected for viewing

10 changes: 10 additions & 0 deletions 10 go.mod
Show comments
View file
Open in desktop
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,15 @@ require (
github.com/aws/aws-sdk-go-v2/config v1.29.14
github.com/aws/aws-sdk-go-v2/service/dynamodb v1.43.3
github.com/aws/aws-sdk-go-v2/service/s3 v1.79.3
github.com/cabify/gotoprom v1.1.0
github.com/ghodss/yaml v1.0.0
github.com/go-sql-driver/mysql v1.8.1
github.com/golang/protobuf v1.5.4
github.com/google/uuid v1.6.0
github.com/grpc-ecosystem/go-grpc-middleware/providers/prometheus v1.1.0
github.com/mattn/go-sqlite3 v1.14.23
github.com/pkg/errors v0.9.1
github.com/prometheus/client_golang v1.23.2
github.com/redis/go-redis/v9 v9.6.1
github.com/roberson-io/mmh3 v0.0.0-20190729202758-fdfce3ba6225
github.com/rs/zerolog v1.33.0
Expand Down Expand Up @@ -64,6 +67,7 @@ require (
github.com/aws/aws-sdk-go-v2/service/ssooidc v1.30.1 // indirect
github.com/aws/aws-sdk-go-v2/service/sts v1.33.19 // indirect
github.com/aws/smithy-go v1.22.2 // indirect
github.com/beorn7/perks v1.0.1 // indirect
github.com/cenkalti/backoff/v5 v5.0.3 // indirect
github.com/cespare/xxhash/v2 v2.3.0 // indirect
github.com/cncf/xds/go v0.0.0-20250501225837-2ac532fd4443 // indirect
Expand All @@ -81,6 +85,7 @@ require (
github.com/google/s2a-go v0.1.9 // indirect
github.com/googleapis/enterprise-certificate-proxy v0.3.7 // indirect
github.com/googleapis/gax-go/v2 v2.15.0 // indirect
github.com/grpc-ecosystem/go-grpc-middleware/v2 v2.1.0 // indirect
github.com/grpc-ecosystem/grpc-gateway/v2 v2.27.2 // indirect
github.com/jackc/pgpassfile v1.0.0 // indirect
github.com/jackc/pgservicefile v0.0.0-20240606120523-5a60cdf6a761 // indirect
Expand All @@ -93,9 +98,13 @@ require (
github.com/mattn/go-isatty v0.0.20 // indirect
github.com/minio/asm2plan9s v0.0.0-20200509001527-cdd76441f9d8 // indirect
github.com/minio/c2goasm v0.0.0-20190812172519-36a3d3bbc4f3 // indirect
github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 // indirect
github.com/pierrec/lz4/v4 v4.1.21 // indirect
github.com/planetscale/vtprotobuf v0.6.1-0.20240319094008-0393e58bdf10 // indirect
github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 // indirect
github.com/prometheus/client_model v0.6.2 // indirect
github.com/prometheus/common v0.66.1 // indirect
github.com/prometheus/procfs v0.16.1 // indirect
github.com/spiffe/go-spiffe/v2 v2.5.0 // indirect
github.com/stretchr/objx v0.5.2 // indirect
github.com/zeebo/errs v1.4.0 // indirect
Expand All @@ -107,6 +116,7 @@ require (
go.opentelemetry.io/otel/metric v1.38.0 // indirect
go.opentelemetry.io/otel/sdk/metric v1.38.0 // indirect
go.opentelemetry.io/proto/otlp v1.7.1 // indirect
go.yaml.in/yaml/v2 v2.4.2 // indirect
golang.org/x/crypto v0.45.0 // indirect
golang.org/x/exp v0.0.0-20240909161429-701f63a606c0 // indirect
golang.org/x/mod v0.29.0 // indirect
Expand Down
70 changes: 61 additions & 9 deletions 70 go.sum
Show comments
View file
Open in desktop

Large diffs are not rendered by default.

Oops, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

19 changes: 16 additions & 3 deletions 19 go/README.md
Show comments
View file
Open in desktop
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,27 @@ To build and run the Go Feature Server locally, create a feature_store.yaml file

```bash
go build -o feast-go ./go/main.go
# start the http server
./feast-go --type=http --port=8080
# start the http server (metrics on port 9090 by default)
./feast-go --type=http --port=8080 --metrics-port=9090
# or start the gRPC server
#./feast-go --type=grpc --port=[your-choice]
#./feast-go --type=grpc --port=[your-choice] --metrics-port=9091
```
## Prometheus Metrics
The server exposes Prometheus metrics at the `/metrics` endpoint on a dedicated port (default `:9090`).
- **HTTP Mode**: Metrics server runs on port `9090` (configurable via `-metrics-port`).
- **gRPC Mode**: Metrics server runs on port `9090` (configurable via `-metrics-port`).

Key metrics include:
- `http_request_duration_seconds`: Histogram of response latency.
- `http_requests_total`: Counter of HTTP requests by status, method, and path.
- Standard Go and Process metrics.

A `/health` endpoint is available on the main application port (default `:8080`) for readiness probes.


## OTEL based observability
The OS level env variable `ENABLE_OTEL_TRACING=="true"/"false"` (string type) is used to enable/disable this service (with Tracing only).
You can also configure the service name using `OTEL_SERVICE_NAME` env variable (defaults to "FeastGoFeatureServer").

The default exporter URL is "http://localhost:4318". The default schema of sending data to collector is **HTTP**. Please refer the following two docs about the configuration of the OTEL exporter:
1. https://opentelemetry.io/docs/languages/sdk-configuration/otlp-exporter/
Expand Down
66 changes: 66 additions & 0 deletions 66 go/internal/feast/metrics/metrics.go
Show comments
View file
Open in desktop
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
package metrics

import (
"reflect"
"time"

"github.com/cabify/gotoprom"
"github.com/cabify/gotoprom/prometheusvanilla"
"github.com/prometheus/client_golang/prometheus"
)

var HttpMetrics struct {
Duration func(HttpLabels) TimeHistogram `name:"http_request_duration_seconds" help:"Time taken to serve HTTP requests" buckets:".005,.01,.025,.05,.1,.25,.5,1,2.5,5,10"`

RequestsTotal func(HttpLabels) prometheus.Counter `name:"http_requests_total" help:"Total number of HTTP requests"`
}

type HttpLabels struct {
Method string `label:"method"`
Status int `label:"status"`
Path string `label:"path"`
}

func init() {
gotoprom.MustAddBuilder(TimeHistogramType, RegisterTimeHistogram)
gotoprom.MustInit(&HttpMetrics, "feast")
}

var (
TimeHistogramType = reflect.TypeOf((*TimeHistogram)(nil)).Elem()
)


func RegisterTimeHistogram(name, help, namespace string, labelNames []string, tag reflect.StructTag) (func(prometheus.Labels) interface{}, prometheus.Collector, error) {
f, collector, err := prometheusvanilla.BuildHistogram(name, help, namespace, labelNames, tag)
if err != nil {
return nil, nil, err
}

return func(labels prometheus.Labels) interface{} {
return timeHistogramAdapter{Histogram: f(labels).(prometheus.Histogram)}
}, collector, nil
}

// TimeHistogram offers the basic prometheus.Histogram functionality
type TimeHistogram interface {
prometheus.Histogram
// Duration observes the duration in seconds
Duration(duration time.Duration)
// Since observes the duration in seconds since the time point provided
Since(time.Time)
}

type timeHistogramAdapter struct {
prometheus.Histogram
}

// Duration observes the duration in seconds
func (to timeHistogramAdapter) Duration(duration time.Duration) {
to.Observe(duration.Seconds())
}

// Since observes the duration in seconds since the time point provided
func (to timeHistogramAdapter) Since(duration time.Time) {
to.Duration(time.Since(duration))
}
51 changes: 49 additions & 2 deletions 51 go/internal/feast/server/http_server.go
Show comments
View file
Open in desktop
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ import (
prototypes "github.com/feast-dev/feast/go/protos/feast/types"
"github.com/feast-dev/feast/go/types"
"github.com/rs/zerolog/log"

"github.com/feast-dev/feast/go/internal/feast/metrics"
)

type httpServer struct {
Expand Down Expand Up @@ -335,10 +337,55 @@ func recoverMiddleware(next http.Handler) http.Handler {
})
}

type statusWriter struct {
http.ResponseWriter
status int
}

func (w *statusWriter) WriteHeader(status int) {
if w.status == 0 {
w.status = status
}
w.ResponseWriter.WriteHeader(status)
}

func (w *statusWriter) Write(b []byte) (int, error) {
if w.status == 0 {
w.status = 200
}
n, err := w.ResponseWriter.Write(b)
return n, err
}

func metricsMiddleware(next http.Handler) http.Handler {
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
t0 := time.Now()
sw := &statusWriter{ResponseWriter: w}
next.ServeHTTP(sw, r)
duration := time.Since(t0)

if sw.status == 0 {
sw.status = 200
}

metrics.HttpMetrics.Duration(metrics.HttpLabels{
Method: r.Method,
Status: sw.status,
Path: r.URL.Path,
}).Duration(duration)

metrics.HttpMetrics.RequestsTotal(metrics.HttpLabels{
Method: r.Method,
Status: sw.status,
Path: r.URL.Path,
}).Inc()
})
}

func (s *httpServer) Serve(host string, port int) error {
mux := http.NewServeMux()
mux.Handle("/get-online-features", recoverMiddleware(http.HandlerFunc(s.getOnlineFeatures)))
mux.HandleFunc("/health", healthCheckHandler)
mux.Handle("/get-online-features", metricsMiddleware(recoverMiddleware(http.HandlerFunc(s.getOnlineFeatures))))
mux.Handle("/health", metricsMiddleware(http.HandlerFunc(healthCheckHandler)))
s.server = &http.Server{Addr: fmt.Sprintf("%s:%d", host, port), Handler: mux, ReadTimeout: 5 * time.Second, WriteTimeout: 10 * time.Second, IdleTimeout: 15 * time.Second}
err := s.server.ListenAndServe()
// Don't return the error if it's caused by graceful shutdown using Stop()
Expand Down
Loading
Oops, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

Loading
Oops, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

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.
You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.