diff --git a/cmd/cart/pool-server.go b/cmd/cart/pool-server.go index a6822a7..2d8ec6e 100644 --- a/cmd/cart/pool-server.go +++ b/cmd/cart/pool-server.go @@ -23,6 +23,7 @@ import ( "go.opentelemetry.io/otel" "go.opentelemetry.io/otel/attribute" + "go.opentelemetry.io/otel/metric" "go.opentelemetry.io/otel/trace" ) @@ -456,10 +457,11 @@ func CartIdHandler(fn func(cartId cart.CartId, w http.ResponseWriter, r *http.Re func (s *PoolServer) ProxyHandler(fn func(w http.ResponseWriter, r *http.Request, cartId cart.CartId) error) func(cartId cart.CartId, w http.ResponseWriter, r *http.Request) error { return func(cartId cart.CartId, w http.ResponseWriter, r *http.Request) error { if ownerHost, ok := s.OwnerHost(uint64(cartId)); ok { - _, span := tracer.Start(r.Context(), "proxy") + ctx, span := tracer.Start(r.Context(), "proxy") defer span.End() - - span.SetAttributes(attribute.String("other host", ownerHost.Name())) + hostAttr := attribute.String("other host", ownerHost.Name()) + span.SetAttributes(hostAttr) + proxyCalls.Add(ctx, 1, metric.WithAttributes(hostAttr)) handled, err := ownerHost.Proxy(uint64(cartId), w, r) grainLookups.Inc() @@ -477,8 +479,9 @@ func (s *PoolServer) ProxyHandler(fn func(w http.ResponseWriter, r *http.Request var ( tracer = otel.Tracer(name) - // meter = otel.Meter(name) - logger = otelslog.NewLogger(name) + meter = otel.Meter(name) + logger = otelslog.NewLogger(name) + proxyCalls metric.Int64Counter // rollCnt metric.Int64Counter ) diff --git a/deployment/deployment.yaml b/deployment/deployment.yaml index cffe16b..46c2ab6 100644 --- a/deployment/deployment.yaml +++ b/deployment/deployment.yaml @@ -60,14 +60,14 @@ spec: path: /livez port: web failureThreshold: 1 - periodSeconds: 10 + periodSeconds: 30 readinessProbe: httpGet: path: /readyz port: web failureThreshold: 2 initialDelaySeconds: 2 - periodSeconds: 10 + periodSeconds: 30 volumeMounts: - mountPath: "/data" name: data @@ -152,14 +152,14 @@ spec: path: /livez port: web failureThreshold: 1 - periodSeconds: 10 + periodSeconds: 30 readinessProbe: httpGet: path: /readyz port: web failureThreshold: 2 initialDelaySeconds: 2 - periodSeconds: 10 + periodSeconds: 50 volumeMounts: - mountPath: "/data" name: data @@ -260,14 +260,14 @@ spec: path: /livez port: web failureThreshold: 1 - periodSeconds: 10 + periodSeconds: 30 readinessProbe: httpGet: path: /readyz port: web failureThreshold: 2 initialDelaySeconds: 2 - periodSeconds: 10 + periodSeconds: 30 volumeMounts: - mountPath: "/data" name: data