From 3d4d2428334959c915215640d611a140fdf5ca07 Mon Sep 17 00:00:00 2001 From: Sebastian Choren Date: Wed, 4 Sep 2024 16:16:15 -0300 Subject: [PATCH] chore(agent): add debug logs for otlp connection tester (#4011) --- agent/client/workflow_listen_for_otlp_connection_tests.go | 2 ++ agent/runner/session.go | 8 ++++++++ 2 files changed, 10 insertions(+) diff --git a/agent/client/workflow_listen_for_otlp_connection_tests.go b/agent/client/workflow_listen_for_otlp_connection_tests.go index cfc579266b..e01ae4d115 100644 --- a/agent/client/workflow_listen_for_otlp_connection_tests.go +++ b/agent/client/workflow_listen_for_otlp_connection_tests.go @@ -51,11 +51,13 @@ func (c *Client) startOTLPConnectionTestListener(ctx context.Context) error { // we want a new context per request, not to reuse the one from the stream ctx := telemetry.InjectMetadataIntoContext(context.Background(), req.Metadata) go func() { + logger.Debug("handling otlp connection test request") err = c.otlpConnectionTestListener(ctx, &req) if err != nil { logger.Error("could not handle otlp connection test request", zap.Error(err)) fmt.Println(err.Error()) } + logger.Debug("otlp connection test request handled") }() } }() diff --git a/agent/runner/session.go b/agent/runner/session.go index 6f49812006..a1e4a03af7 100644 --- a/agent/runner/session.go +++ b/agent/runner/session.go @@ -4,6 +4,7 @@ import ( "context" "errors" "fmt" + "time" "github.com/kubeshop/tracetest/agent/client" "github.com/kubeshop/tracetest/agent/collector" @@ -69,12 +70,19 @@ func StartSession(ctx context.Context, cfg config.Config, observer event.Observe } controlPlaneClient.OnOTLPConnectionTest(func(ctx context.Context, otr *proto.OTLPConnectionTestRequest) error { + logger.Debug("Received OTLP connection test request", zap.Bool("resetCounter", otr.ResetCounter)) if otr.ResetCounter { + logger.Debug("Resetting statistics") agentCollector.ResetStatistics() return nil } statistics := agentCollector.Statistics() + logger.Debug("Sending OTLP connection test response", + zap.Int64("spanCount", statistics.SpanCount), + zap.Int64("lastSpanTimestamp", time.Since(statistics.LastSpanTimestamp).Milliseconds()), + ) + controlPlaneClient.SendOTLPConnectionResult(ctx, &proto.OTLPConnectionTestResponse{ RequestID: otr.RequestID, SpanCount: int64(statistics.SpanCount),