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

fix: add correlationid & body to verbose logging #33

Merged
merged 1 commit into from
Jun 20, 2023
Merged
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
16 changes: 9 additions & 7 deletions pkg/clients/marketplace/metrics.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,10 +45,11 @@ type MarketplaceUsageResponseDetails struct {
}

type MarketplaceUsageResponse struct {
RequestID string `json:"requestId,omitempty"`
Status MktplStatus `json:"status,omitempty"`
Message string `json:"message,omitempty"`
ErrorCode string `json:"errorCode,omitempty"`
RequestID string `json:"requestId,omitempty"`
CorrelationID string `json:"correlationId,omitempty"`
Status MktplStatus `json:"status,omitempty"`
Message string `json:"message,omitempty"`
ErrorCode string `json:"errorCode,omitempty"`

Details *MarketplaceUsageResponseDetails `json:"details,omitempty"`
}
Expand Down Expand Up @@ -97,7 +98,7 @@ func (r *marketplaceMetricClient) Status(ctx context.Context, id string) (*Marke

jsonErr := json.Unmarshal(data, &status)

if err := checkError(resp, status, "failed to get status"); err != nil {
if err := checkError(resp, string(data), status, "failed to get status"); err != nil {
return &status, err
}

Expand All @@ -119,12 +120,13 @@ func isRetryable(err error) bool {
return false
}

func checkError(resp *http.Response, status MarketplaceUsageResponse, message string) error {
func checkError(resp *http.Response, body string, status MarketplaceUsageResponse, message string) error {
logger.Info("retrieved response",
"statusCode", resp.StatusCode,
"proto", resp.Proto,
"status", status,
"headers", resp.Header,
"body", body,
)

/*
Expand Down Expand Up @@ -209,7 +211,7 @@ func (r *marketplaceMetricClient) uploadFile(ctx context.Context, form []byte, f
status := MarketplaceUsageResponse{}
jsonErr := json.Unmarshal(body, &status)

if err := checkError(resp, status, "failed to upload"); err != nil {
if err := checkError(resp, string(body), status, "failed to upload"); err != nil {
return "", err
}

Expand Down