Skip to content
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.

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

[hotrod] Move metrics endpoints from route to frontend service #4720

Merged
merged 3 commits into from
Sep 4, 2023
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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ next release (yyyy-mm-dd)
* [SPM] Support spanmetrics connector by default ([@albertteoh](https://github.com/albertteoh) in [#4704](https://github.com/jaegertracing/jaeger/pull/4704))
* [tracegen] Stop supporting -trace-exporter=jaeger ([@yurishkuro](https://github.com/yurishkuro) in [#4717](https://github.com/jaegertracing/jaeger/pull/4717))
* [hotrod] Stop supporting -otel-exporter=jaeger ([@yurishkuro](https://github.com/yurishkuro) in [#4719](https://github.com/jaegertracing/jaeger/pull/4719))
* [hotrod] Metrics endpoints moved from route service (:8083) to frontend service (:8080) ([@yurishkuro](https://github.com/yurishkuro) in [#4720](https://github.com/jaegertracing/jaeger/pull/4720))

#### New Features

Expand Down
4 changes: 4 additions & 0 deletions examples/hotrod/services/frontend/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,12 @@ package frontend
import (
"embed"
"encoding/json"
"expvar"
"net/http"
"path"
"strconv"

"github.com/prometheus/client_golang/prometheus/promhttp"
"go.opentelemetry.io/otel/trace"
"go.uber.org/zap"

Expand Down Expand Up @@ -82,6 +84,8 @@ func (s *Server) createServeMux() http.Handler {
mux.Handle(p, http.StripPrefix(p, http.FileServer(s.assetFS)))
mux.Handle(path.Join(p, "/dispatch"), http.HandlerFunc(s.dispatch))
mux.Handle(path.Join(p, "/config"), http.HandlerFunc(s.config))
mux.Handle(path.Join(p, "/debug/vars"), expvar.Handler()) // expvar
mux.Handle(path.Join(p, "/metrics"), promhttp.Handler()) // Prometheus
return mux
}

Expand Down
10 changes: 6 additions & 4 deletions examples/hotrod/services/route/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,11 @@ package route
import (
"context"
"encoding/json"
"expvar"
"math"
"math/rand"
"net/http"
"time"

"github.com/prometheus/client_golang/prometheus/promhttp"
"go.opentelemetry.io/otel/trace"
"go.uber.org/zap"

Expand Down Expand Up @@ -61,11 +59,15 @@ func (s *Server) Run() error {
func (s *Server) createServeMux() http.Handler {
mux := tracing.NewServeMux(false, s.tracer, s.logger)
mux.Handle("/route", http.HandlerFunc(s.route))
mux.Handle("/debug/vars", expvar.Handler()) // expvar
mux.Handle("/metrics", promhttp.Handler()) // Prometheus
mux.Handle("/debug/vars", http.HandlerFunc(movedToFrontend))
mux.Handle("/metrics", http.HandlerFunc(movedToFrontend))
return mux
}

func movedToFrontend(w http.ResponseWriter, r *http.Request) {
http.Error(w, "endpoint moved to the frontend service", http.StatusNotFound)
}

func (s *Server) route(w http.ResponseWriter, r *http.Request) {
ctx := r.Context()
s.logger.For(ctx).Info("HTTP request received", zap.String("method", r.Method), zap.Stringer("url", r.URL))
Expand Down