about summary refs log tree commit diff
path: root/tvix/nar-bridge/pkg
diff options
context:
space:
mode:
authorConnor Brewster <cbrewster@hey.com>2024-01-21T20·52-0600
committerclbot <clbot@tvl.fyi>2024-01-23T15·50+0000
commitd0563294121a85ecddbcc44474373b9293c31e7f (patch)
tree021246b2b903485df2447b80b767cca7600d6757 /tvix/nar-bridge/pkg
parente8061fc6190fdeaadb9d8ebc8d8dba15c9c6f5c4 (diff)
feat(tvix/store/nar-bridge): Setup OpenTelemetry r/7442
Sets up OpenTelemetry integration for nar-bridge. Right now it will
export spans for HTTP server requests and all gRPC client requests.
Having the spans available will make performance work significantly
easier as it provides a high level overview of where time is being
spent.

In the future we can add application-specifc metrics and
integrate logrus.

Change-Id: Ie3860675d7ffc626a95673ba062c3c798d8bb2a7
Reviewed-on: https://cl.tvl.fyi/c/depot/+/10678
Reviewed-by: flokli <flokli@flokli.de>
Tested-by: BuildkiteCI
Autosubmit: Connor Brewster <cbrewster@hey.com>
Diffstat (limited to 'tvix/nar-bridge/pkg')
-rw-r--r--tvix/nar-bridge/pkg/http/server.go4
1 files changed, 4 insertions, 0 deletions
diff --git a/tvix/nar-bridge/pkg/http/server.go b/tvix/nar-bridge/pkg/http/server.go
index 500902f262f0..aecbd54aec16 100644
--- a/tvix/nar-bridge/pkg/http/server.go
+++ b/tvix/nar-bridge/pkg/http/server.go
@@ -12,6 +12,7 @@ import (
 	"github.com/go-chi/chi/middleware"
 	"github.com/go-chi/chi/v5"
 	log "github.com/sirupsen/logrus"
+	"go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp"
 )
 
 type Server struct {
@@ -46,6 +47,9 @@ func New(
 	priority int,
 ) *Server {
 	r := chi.NewRouter()
+	r.Use(func(h http.Handler) http.Handler {
+		return otelhttp.NewHandler(h, "http.request")
+	})
 
 	if enableAccessLog {
 		r.Use(middleware.Logger)