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 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
11 changes: 4 additions & 7 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 @@ -597,11 +597,10 @@ func (gw *Handle) getPayloadFromRequest(r *http.Request) ([]byte, error) {
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),
)
return payload, errors.New(response.RequestBodyReadFailed)
}
Expand Down Expand Up @@ -723,7 +722,6 @@ func (gw *Handle) internalBatchHandlerFunc() http.HandlerFunc {
logger.NewStringField("path", r.URL.Path),
logger.NewIntField("status", int64(status)),
logger.NewStringField("body", responseBody),
logger.NewStringField("request", string(body)),
)
http.Error(w, responseBody, status)
}
Expand Down Expand Up @@ -1016,7 +1014,6 @@ func (gw *Handle) storeJobs(ctx context.Context, jobs []*jobsdb.JobT) error {
gw.logger.Errorn(
"Store into gateway db failed with error",
obskit.Error(err),
logger.NewField("jobs", jobs),
)
return err
}
Expand Down
14 changes: 3 additions & 11 deletions router/transformer/transformer.go
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@
// Call remote transformation
rawJSON, err := jsonrs.Marshal(&transformMessageCopy)
if err != nil {
trans.logger.Errorf("problematic input for marshalling: %#v", transformMessage)
trans.logger.Errorw("problematic input for marshalling", "error", err)
panic(err)
}

Expand Down Expand Up @@ -290,8 +290,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 = jsonrs.Unmarshal(respData, &destinationJobs)
Expand Down Expand Up @@ -341,8 +339,6 @@
}

if invalidResponseReason != "" {

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

Expand Down Expand Up @@ -615,7 +610,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 @@ -678,7 +672,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))
return httpProxyResponse{
respData: []byte{},
statusCode: http.StatusInternalServerError,
Expand All @@ -690,17 +684,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 687 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))
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