From b272282b1fc13838bde65cd85885fba174c98158 Mon Sep 17 00:00:00 2001 From: matst80 Date: Fri, 7 Nov 2025 14:44:15 +0100 Subject: [PATCH] better metrics --- pkg/actor/grpc_server.go | 23 ++++++++++++++++------- pkg/proxy/remotehost.go | 1 + 2 files changed, 17 insertions(+), 7 deletions(-) diff --git a/pkg/actor/grpc_server.go b/pkg/actor/grpc_server.go index 2a262ac..06bd8a1 100644 --- a/pkg/actor/grpc_server.go +++ b/pkg/actor/grpc_server.go @@ -81,6 +81,7 @@ func (s *ControlServer[V]) AnnounceOwnership(ctx context.Context, req *messages. ctx, span := tracer.Start(ctx, "grpc_announce_ownership") defer span.End() span.SetAttributes( + attribute.String("component", "controlplane"), attribute.String("host", req.Host), attribute.Int("id_count", len(req.Ids)), ) @@ -107,6 +108,7 @@ func (s *ControlServer[V]) AnnounceExpiry(ctx context.Context, req *messages.Exp ctx, span := tracer.Start(ctx, "grpc_announce_expiry") defer span.End() span.SetAttributes( + attribute.String("component", "controlplane"), attribute.String("host", req.Host), attribute.Int("id_count", len(req.Ids)), ) @@ -125,11 +127,9 @@ func (s *ControlServer[V]) AnnounceExpiry(ctx context.Context, req *messages.Exp // ControlPlane: Ping func (s *ControlServer[V]) Ping(ctx context.Context, _ *messages.Empty) (*messages.PingReply, error) { - ctx, span := tracer.Start(ctx, "grpc_ping") - defer span.End() + host := s.pool.Hostname() - span.SetAttributes(attribute.String("host", host)) - logger.InfoContext(ctx, "ping received", "host", host) + pingCalls.Add(ctx, 1, metric.WithAttributes(attribute.String("host", host))) // log.Printf("got ping") @@ -143,7 +143,10 @@ func (s *ControlServer[V]) Ping(ctx context.Context, _ *messages.Empty) (*messag func (s *ControlServer[V]) Negotiate(ctx context.Context, req *messages.NegotiateRequest) (*messages.NegotiateReply, error) { ctx, span := tracer.Start(ctx, "grpc_negotiate") defer span.End() - span.SetAttributes(attribute.Int("known_hosts_count", len(req.KnownHosts))) + span.SetAttributes( + attribute.String("component", "controlplane"), + attribute.Int("known_hosts_count", len(req.KnownHosts)), + ) logger.InfoContext(ctx, "negotiate", "known_hosts_count", len(req.KnownHosts)) negotiateCalls.Add(ctx, 1) @@ -156,7 +159,10 @@ func (s *ControlServer[V]) GetLocalActorIds(ctx context.Context, _ *messages.Emp ctx, span := tracer.Start(ctx, "grpc_get_local_actor_ids") defer span.End() ids := s.pool.GetLocalIds() - span.SetAttributes(attribute.Int("id_count", len(ids))) + span.SetAttributes( + attribute.String("component", "controlplane"), + attribute.Int("id_count", len(ids)), + ) logger.InfoContext(ctx, "get local actor ids", "id_count", len(ids)) getLocalActorIdsCalls.Add(ctx, 1) @@ -168,7 +174,10 @@ func (s *ControlServer[V]) Closing(ctx context.Context, req *messages.ClosingNot ctx, span := tracer.Start(ctx, "grpc_closing") defer span.End() host := req.GetHost() - span.SetAttributes(attribute.String("host", host)) + span.SetAttributes( + attribute.String("component", "controlplane"), + attribute.String("host", host), + ) logger.InfoContext(ctx, "closing notice", "host", host) closingCalls.Add(ctx, 1, metric.WithAttributes(attribute.String("host", host))) diff --git a/pkg/proxy/remotehost.go b/pkg/proxy/remotehost.go index 7445bb8..cfc9ab3 100644 --- a/pkg/proxy/remotehost.go +++ b/pkg/proxy/remotehost.go @@ -162,6 +162,7 @@ func (h *RemoteHost) Proxy(id uint64, w http.ResponseWriter, r *http.Request) (b ctx, span := tracer.Start(r.Context(), "remote_proxy") defer span.End() span.SetAttributes( + attribute.String("component", "proxy"), attribute.String("cartid", fmt.Sprintf("%d", id)), attribute.String("host", h.host), attribute.String("method", r.Method),