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: remove payload logging #5447

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 3 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
9 changes: 4 additions & 5 deletions gateway/handle.go
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

gw.logger.Debugn("response",

we can remove from here also

Original file line number Diff line number Diff line change
Expand Up @@ -599,11 +599,10 @@
payload, err := io.ReadAll(r.Body)
_ = r.Body.Close()
if err != nil {
gw.logger.Errorf(
"Error reading request body, 'Content-Length': %s, partial payload:\n\t%s\n:%v",
r.Header.Get("Content-Length"),
string(payload),
err,
gw.logger.Errorn(
"Error reading request body",
logger.NewStringField("Content-Length", r.Header.Get("Content-Length")),
logger.NewErrorField(err),

Check warning on line 605 in gateway/handle.go

View check run for this annotation

Codecov / codecov/patch

gateway/handle.go#L602-L605

Added lines #L602 - L605 were not covered by tests
)
return payload, errors.New(response.RequestBodyReadFailed)
}
Expand Down
13 changes: 3 additions & 10 deletions router/transformer/transformer.go
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,6 @@
trans.logger.Errorf("problematic input for marshalling: %#v", transformMessage)
panic(err)
}
trans.logger.Debugf("[Router Transformer] :: input payload : %s", string(rawJSON))

retryCount := 0
var resp *http.Response
Expand Down Expand Up @@ -242,8 +241,6 @@
panic(fmt.Errorf("Incompatible transformer version: Expected: %d Received: %d, URL: %v", utilTypes.SupportedTransformerApiVersion, transformerAPIVersion, url))
}

trans.logger.Debugf("[Router Transfomrer] :: output payload : %s", string(respData))

if transformType == BATCH {
integrations.CollectIntgTransformErrorStats(respData)
err = jsonfast.Unmarshal(respData, &destinationJobs)
Expand Down Expand Up @@ -291,7 +288,7 @@

if invalidResponseReason != "" {

trans.logger.Error(invalidResponseError)
// trans.logger.Error(invalidResponseError)
stats.Default.NewTaggedStat(`router.transformer.invalid.response`, stats.CountType, stats.Tags{
"destType": transformMessage.DestType,
"reason": invalidResponseReason,
Expand Down Expand Up @@ -435,7 +432,6 @@
}
}
**/
trans.logger.Debugf("ProxyResponseData: %s\n", string(respData))
respData = []byte(gjson.GetBytes(respData, "output").Raw)
integrations.CollectDestErrorStats(respData)

Expand Down Expand Up @@ -532,7 +528,6 @@
func (trans *handle) doProxyRequest(ctx context.Context, proxyUrl string, proxyReqParams *ProxyRequestParams, payload []byte) httpProxyResponse {
var respData []byte
destName := proxyReqParams.DestName
trans.logger.Debugf(`[TransformerProxy] (Dest-%[1]v) Proxy Request payload - %[2]s`, destName, string(payload))
req, err := http.NewRequestWithContext(ctx, http.MethodPost, proxyUrl, bytes.NewReader(payload))
if err != nil {
trans.logger.Errorf(`[TransformerProxy] (Dest-%[1]v) NewRequestWithContext Failed for %[1]v, with %[3]v`, destName, err.Error())
Expand Down Expand Up @@ -595,7 +590,7 @@
// error handling if body is missing
if resp.Body == nil {
errStr := "empty response body"
trans.logger.Errorf(`[TransformerProxy] (Dest-%[1]v) Failed with statusCode: %[2]v, message: %[3]v`, destName, http.StatusInternalServerError, string(respData))
trans.logger.Errorn(`[TransformerProxy] empty response body`, logger.NewIntField("statusCode", http.StatusInternalServerError))

Check warning on line 593 in router/transformer/transformer.go

View check run for this annotation

Codecov / codecov/patch

router/transformer/transformer.go#L593

Added line #L593 was not covered by tests
return httpProxyResponse{
respData: []byte{},
statusCode: http.StatusInternalServerError,
Expand All @@ -607,17 +602,15 @@
defer func() { httputil.CloseResponse(resp) }()
// error handling while reading from resp.Body
if err != nil {
respData = []byte(fmt.Sprintf(`failed to read response body, Error:: %+v`, err))

Check failure on line 605 in router/transformer/transformer.go

View workflow job for this annotation

GitHub Actions / lint

SA4006: this value of `respData` is never used (staticcheck)
trans.logger.Errorf(`[TransformerProxy] (Dest-%[1]v) Failed with statusCode: %[2]v, message: %[3]v`, destName, http.StatusBadRequest, string(respData))
trans.logger.Errorn(`[TransformerProxy] Failure`, logger.NewIntField("statusCode", http.StatusBadRequest), logger.NewErrorField(err))

Check warning on line 606 in router/transformer/transformer.go

View check run for this annotation

Codecov / codecov/patch

router/transformer/transformer.go#L606

Added line #L606 was not covered by tests
return httpProxyResponse{
respData: []byte{}, // sending this as it is not getting sent at all
statusCode: http.StatusInternalServerError,
err: err,
}
}

trans.logger.Debugf(`[TransformerProxy] (Dest-%[1]v) Proxy Request response - %[2]s`, destName, string(respData))

return httpProxyResponse{
respData: respData,
statusCode: resp.StatusCode,
Expand Down
Loading