From 5f735a415d63fac09c4aa159a55658f01457d43f Mon Sep 17 00:00:00 2001 From: Saket Chaudhary <118331906+chaudharysaket@users.noreply.github.com> Date: Wed, 7 Aug 2024 16:24:32 +0530 Subject: [PATCH] Extension debug (#227) * modify debug messages & add payload size in log --- main.go | 2 +- telemetry/client.go | 10 +++++----- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/main.go b/main.go index f9b9b51..cedfb23 100644 --- a/main.go +++ b/main.go @@ -198,7 +198,7 @@ func mainLoop(ctx context.Context, invocationClient *client.InvocationClient, ba return eventCounter default: // Our call to next blocks. It is likely that the container is frozen immediately after we call NextEvent. - util.Debugln("mainLoop: blocking while awaiting next invocation event...") + util.Debugln("mainLoop: waiting for next lambda invocation event...") event, err := invocationClient.NextEvent(ctx) // We've thawed. diff --git a/telemetry/client.go b/telemetry/client.go index fb53cd8..8b41647 100644 --- a/telemetry/client.go +++ b/telemetry/client.go @@ -131,7 +131,7 @@ func (c *Client) SendTelemetry(ctx context.Context, invokedFunctionARN string, t totalTime := end.Sub(start) transmissionTime := end.Sub(transmitStart) util.Logf( - "Sent %d/%d New Relic payload batches with %d log events successfully with certainty in %.3fms (%dms to transmit %.1fkB).\n", + "Sent %d/%d New Relic Telemetry payload batches with %d log events successfully with certainty in %.3fms (%dms to transmit %.1fkB).\n", successCount, len(compressedPayloads), len(telemetry), @@ -150,7 +150,8 @@ func (c *Client) sendPayloads(compressedPayloads []*bytes.Buffer, builder reques sentBytes = 0 sendPayloadsStartTime := time.Now() for _, p := range compressedPayloads { - sentBytes += p.Len() + payloadSize := p.Len() + sentBytes += payloadSize currentPayloadBytes := p.Bytes() var response AttemptData @@ -169,8 +170,8 @@ func (c *Client) sendPayloads(compressedPayloads []*bytes.Buffer, builder reques } if response.Error != nil { - util.Logf("Telemetry client error: %s", response.Error) - sentBytes -= p.Len() + util.Logf("Telemetry client error: %s, payload size: %d bytes", response.Error, payloadSize) + sentBytes -= payloadSize } else if response.Response.StatusCode >= 300 { util.Logf("Telemetry client response: [%s] %s", response.Response.Status, response.ResponseBody) } else { @@ -330,7 +331,6 @@ func (c *Client) buildLogPayloads(ctx context.Context, invokedFunctionARN string traceId = c.batch.RetrieveTraceID(l.RequestID) } logMessages = append(logMessages, NewFunctionLogMessage(ts, l.RequestID, traceId, string(l.Content))) - util.Debugf("Sending function logs for request %s", l.RequestID) } // The Log API expects an array logData := []DetailedFunctionLog{NewDetailedFunctionLog(common, logMessages)}