manual handler
This commit is contained in:
@@ -29,7 +29,7 @@ func (a *App) HandleCheckoutRequests(amqpUrl string, mux *http.ServeMux) {
|
|||||||
orderHandler := NewAmqpOrderHandler(conn)
|
orderHandler := NewAmqpOrderHandler(conn)
|
||||||
orderHandler.DefineTopics()
|
orderHandler.DefineTopics()
|
||||||
|
|
||||||
mux.HandleFunc("/push", func(w http.ResponseWriter, r *http.Request) {
|
mux.HandleFunc("POST /push", func(w http.ResponseWriter, r *http.Request) {
|
||||||
|
|
||||||
if r.Method != http.MethodPost {
|
if r.Method != http.MethodPost {
|
||||||
w.WriteHeader(http.StatusMethodNotAllowed)
|
w.WriteHeader(http.StatusMethodNotAllowed)
|
||||||
|
|||||||
@@ -19,8 +19,10 @@ import (
|
|||||||
"github.com/prometheus/client_golang/prometheus/promauto"
|
"github.com/prometheus/client_golang/prometheus/promauto"
|
||||||
"go.opentelemetry.io/contrib/bridges/otelslog"
|
"go.opentelemetry.io/contrib/bridges/otelslog"
|
||||||
"go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp"
|
"go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp"
|
||||||
|
"go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp/internal/semconv"
|
||||||
"go.opentelemetry.io/otel"
|
"go.opentelemetry.io/otel"
|
||||||
"go.opentelemetry.io/otel/attribute"
|
"go.opentelemetry.io/otel/attribute"
|
||||||
|
"go.opentelemetry.io/otel/trace"
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
@@ -574,9 +576,16 @@ func (s *PoolServer) Serve(mux *http.ServeMux) {
|
|||||||
// })
|
// })
|
||||||
|
|
||||||
handleFunc := func(pattern string, handlerFunc func(http.ResponseWriter, *http.Request)) {
|
handleFunc := func(pattern string, handlerFunc func(http.ResponseWriter, *http.Request)) {
|
||||||
// Configure the "http.route" for the HTTP instrumentation.
|
attr := semconv.NewHTTPServer(nil).Route(pattern)
|
||||||
handler := otelhttp.WithRouteTag(pattern, http.HandlerFunc(handlerFunc))
|
mux.HandleFunc(pattern, http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
||||||
mux.Handle(pattern, handler)
|
span := trace.SpanFromContext(r.Context())
|
||||||
|
span.SetAttributes(attr)
|
||||||
|
|
||||||
|
labeler, _ := otelhttp.LabelerFromContext(r.Context())
|
||||||
|
labeler.Add(attr)
|
||||||
|
|
||||||
|
handlerFunc(w, r)
|
||||||
|
}))
|
||||||
}
|
}
|
||||||
|
|
||||||
handleFunc("GET /cart", CookieCartIdHandler(s.ProxyHandler(s.GetCartHandler)))
|
handleFunc("GET /cart", CookieCartIdHandler(s.ProxyHandler(s.GetCartHandler)))
|
||||||
|
|||||||
Reference in New Issue
Block a user