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

[exporter/datadog] Do not read response if nil on logs error #16390

Merged
merged 1 commit into from
Nov 21, 2022

Conversation

mx-psi
Copy link
Member

@mx-psi mx-psi commented Nov 21, 2022

Description:

Do not try to read the response body if nil. The SubmitLogs method returns an error when failing to submit (e.g. 4xx or 5xx) but also in other cases where there is no response. The latter are classified as permanent errors to avoid unnecessary retries.

Link to tracking Issue: Fixes #16077

@github-actions github-actions bot added the exporter/datadog Datadog components label Nov 21, 2022
@mx-psi mx-psi marked this pull request as ready for review November 21, 2022 14:58
@mx-psi mx-psi requested review from a team and dashpole November 21, 2022 14:58
if r != nil {
b := make([]byte, 1024) // 1KB message max
n, _ := r.Body.Read(b) // ignore any error
s.logger.Error("Failed to send logs", zap.Error(err), zap.String("msg", string(b[:n])), zap.String("status_code", r.Status))
Copy link
Contributor

Choose a reason for hiding this comment

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

Do you still want to log the error if r is nil?

Copy link
Member Author

Choose a reason for hiding this comment

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

Do you still want to log the error if r is nil?

It will be logged by the exporterhelper since we bubble up the error :)

I think the real question is if we should be double logging when r is not nil, I feel like it's justified because we are adding some extra fields here, and it's hard to pass these as fields to the exporterhelper


// If response is nil assume permanent error.
// The error will be logged by the exporter helper.
return consumererror.NewPermanent(err)
Copy link
Member

Choose a reason for hiding this comment

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

If the server is unreachable , i would expect this code to get hit. Shouldn't we retry in that case ?

Copy link
Member

@dineshg13 dineshg13 left a comment

Choose a reason for hiding this comment

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

👍

@bogdandrutu bogdandrutu merged commit a21144b into open-telemetry:main Nov 21, 2022
shalper2 pushed a commit to shalper2/opentelemetry-collector-contrib that referenced this pull request Dec 6, 2022
@plantfansam plantfansam mentioned this pull request Jul 21, 2023
@iSignal
Copy link

iSignal commented Jul 22, 2023

@dineshg13 @bogdandrutu : is it intentional behavior that any other error other than specific http codes from the datadog server are considered permanent? If there are temporary network blips that cause connectivity issues to datadog, that wouldn't result in a http error code, it would result in a connect error - but those should be retried in case network comes back up later. Could you please clarify your thinking about intermittent network blips / temporary network partition?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
exporter/datadog Datadog components
Projects
None yet
Development

Successfully merging this pull request may close these issues.

'invalid memory address or nil pointer dereference' error in Datadog Logs exporter
6 participants