Skip to content

Commit

Permalink
chore(agent): add debug logs for otlp connection tester (#4011)
Browse files Browse the repository at this point in the history
  • Loading branch information
schoren authored Sep 4, 2024
1 parent c082252 commit 3d4d242
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
2 changes: 2 additions & 0 deletions agent/client/workflow_listen_for_otlp_connection_tests.go
Original file line number Diff line number Diff line change
Expand Up @@ -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")
}()
}
}()
Expand Down
8 changes: 8 additions & 0 deletions agent/runner/session.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"context"
"errors"
"fmt"
"time"

"github.com/kubeshop/tracetest/agent/client"
"github.com/kubeshop/tracetest/agent/collector"
Expand Down Expand Up @@ -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),
Expand Down

0 comments on commit 3d4d242

Please sign in to comment.