Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(agent): add debug logs for otlp connection tester #4011

Merged
merged 1 commit into from
Sep 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading