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

Add malformed response to log metadata in dtclient #685

Merged
merged 4 commits into from
Apr 1, 2022
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
5 changes: 2 additions & 3 deletions src/dtclient/activegate_tenant_info.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ func (dtc *dynatraceClient) GetActiveGateTenantInfo() (*ActiveGateTenantInfo, er

tenantInfo, err := dtc.readResponseForActiveGateTenantInfo(data)
if err != nil {
log.Error(err, err.Error())
return nil, err
}
if len(tenantInfo.Endpoints) == 0 {
Expand All @@ -49,8 +48,8 @@ func (dtc *dynatraceClient) readResponseForActiveGateTenantInfo(response []byte)
agTenantInfo := &ActiveGateTenantInfo{}
err := json.Unmarshal(response, agTenantInfo)
if err != nil {
log.Error(err, "error unmarshalling json response")
return nil, errors.WithStack(err)
log.Error(err, "error unmarshalling activegate tenant info", "response", string(response))
return nil, err
}

return agTenantInfo, nil
Expand Down
5 changes: 2 additions & 3 deletions src/dtclient/agent_tenant_info.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ func (dtc *dynatraceClient) GetAgentTenantInfo() (*AgentTenantInfo, error) {

tenantInfo, err := dtc.readResponseForTenantInfo(data)
if err != nil {
log.Error(err, err.Error())
return nil, errors.WithStack(err)
}
if len(tenantInfo.Endpoints) <= 0 {
Expand All @@ -57,8 +56,8 @@ func (dtc *dynatraceClient) readResponseForTenantInfo(response []byte) (*AgentTe
jr := &jsonResponse{}
err := json.Unmarshal(response, jr)
if err != nil {
log.Error(err, "error unmarshalling json response")
return nil, errors.WithStack(err)
log.Error(err, "unable to unmarshal tenant info response")
return nil, err
}

return &AgentTenantInfo{
Expand Down
2 changes: 1 addition & 1 deletion src/dtclient/agent_version.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ func (dtc *dynatraceClient) readResponseForLatestVersion(response []byte) (strin
jr := &jsonResponse{}
err := json.Unmarshal(response, jr)
if err != nil {
log.Error(err, "error unmarshalling json response")
log.Error(err, "error unmarshalling latest agent version response", "response", string(response))
return "", err
}

Expand Down
2 changes: 1 addition & 1 deletion src/dtclient/communication_hosts.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ func (dtc *dynatraceClient) readResponseForConnectionInfo(response []byte) (Conn
resp := jsonResponse{}
err := json.Unmarshal(response, &resp)
if err != nil {
log.Error(err, "error unmarshalling json response")
log.Error(err, "error unmarshalling connection info response", "response", string(response))
return ConnectionInfo{}, err
}

Expand Down
2 changes: 1 addition & 1 deletion src/dtclient/dynatrace_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@ func (dtc *dynatraceClient) setHostCacheFromResponse(response []byte) error {
var hostInfoResponses []hostInfoResponse
err := json.Unmarshal(response, &hostInfoResponses)
if err != nil {
log.Error(err, "error unmarshalling json response")
log.Error(err, "error unmarshalling json response", "response", string(response))
return errors.WithStack(err)
}

Expand Down
4 changes: 2 additions & 2 deletions src/dtclient/processmoduleconfig.go
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ func (dtc *dynatraceClient) GetProcessModuleConfig(prevRevision uint) (*ProcessM
return &ProcessModuleConfig{}, nil
}
if err != nil {
return nil, fmt.Errorf("error making get request to dynatrace api: %w", err)
return nil, fmt.Errorf("error while requesting process module config: %v", err)
}
defer func() {
//Swallow error, nothing has to be done at this point
Expand Down Expand Up @@ -131,7 +131,7 @@ func (dtc *dynatraceClient) readResponseForProcessModuleConfig(response []byte)
resp := ProcessModuleConfig{}
err := json.Unmarshal(response, &resp)
if err != nil {
log.Error(err, "error unmarshalling json response")
log.Error(err, "error unmarshalling processmoduleconfig response", "response", string(response))
return nil, err
}

Expand Down
3 changes: 2 additions & 1 deletion src/dtclient/token.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,8 @@ func (dtc *dynatraceClient) readResponseForTokenScopes(response []byte) (TokenSc
}

if err := json.Unmarshal(response, &jr); err != nil {
return nil, fmt.Errorf("error unmarshalling json response: %w", err)
log.Error(err, "unable to unmarshal token scopes response", "response", string(response))
return nil, err
}

return jr.Scopes, nil
Expand Down