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

Return consumererror.Permanent in the Prometheus remote write exporter #1734

Closed
wants to merge 1 commit into from

Conversation

huyan0
Copy link
Member

@huyan0 huyan0 commented Sep 3, 2020

This PR changes the Prometheus remote write to return error of consumererror.permanent type when a invalid metric is encountered or a non-5xx HTTP status code is received from the backend.

linked issue: resolves #1733

cc: @bogdandrutu @alolita @jmacd @huyan0

@codecov
Copy link

codecov bot commented Sep 3, 2020

Codecov Report

Merging #1734 into master will increase coverage by 0.03%.
The diff coverage is 94.44%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #1734      +/-   ##
==========================================
+ Coverage   92.39%   92.42%   +0.03%     
==========================================
  Files         257      257              
  Lines       18184    18214      +30     
==========================================
+ Hits        16801    16835      +34     
+ Misses        969      967       -2     
+ Partials      414      412       -2     
Impacted Files Coverage Δ
exporter/prometheusremotewriteexporter/exporter.go 93.38% <87.50%> (+0.58%) ⬆️
processor/resourceprocessor/factory.go 100.00% <100.00%> (ø)
processor/resourceprocessor/resource_processor.go 100.00% <100.00%> (ø)
translator/internaldata/resource_to_oc.go 92.59% <0.00%> (+3.70%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 315e96e...01f65d4. Read the comment docs.

@huyan0 huyan0 marked this pull request as draft September 3, 2020 16:19
@huyan0 huyan0 marked this pull request as ready for review September 3, 2020 16:47
if httpResp.StatusCode/100 != 2 {
scanner := bufio.NewScanner(io.LimitReader(httpResp.Body, 256))
line := ""
if scanner.Scan() {
line = scanner.Text()
}
errMsg := "server returned HTTP status " + httpResp.Status + ": " + line
return errors.New(errMsg)
if httpResp.StatusCode >= 500 && httpResp.StatusCode < 600 {
return errors.New(errMsg)
Copy link
Member

Choose a reason for hiding this comment

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

I think you want permanent in this case not the other, can you add test?

Copy link
Member Author

Choose a reason for hiding this comment

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

I thought we should retry if its a 503 or other 500 errors. This is the Prometheus implementation I referenced.

I don't know how I can make the proto buf marshal fail or the construction of a http request return error.

Copy link
Member

Choose a reason for hiding this comment

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

Ok, if you want to retry on 5xx add a comment to the code that this is expected based on link to prom implementation.

Copy link
Member Author

Choose a reason for hiding this comment

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

Cool. I have added comments from 259 - 262

@bogdandrutu
Copy link
Member

Please also rebase.

}

if dropped != 0 {
if permanent {
Copy link
Member

Choose a reason for hiding this comment

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

Instead of doing this hack here, can you consider to change componenterror.CombineErrors to do this? you just need to check the type and if any error is permanent return permanent?

Probably a separate PR :)

Copy link
Member Author

Choose a reason for hiding this comment

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

yeah. I was hesitant on doing that because i'm not sure if its good to introduce the idea of "conusmer" in component error. I have the code already haha. Will file a PR tomorrow then.

Copy link
Member

Choose a reason for hiding this comment

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

Components already depend on consumer. The other way around is not expected

Copy link
Member

Choose a reason for hiding this comment

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

This needs now to be removed, the CombineErrors handles this.

@bogdandrutu
Copy link
Member

@huyan0 are you going to work on this? @alolita or @anuraaga can you finish this?

@github-actions
Copy link
Contributor

This PR was marked stale due to lack of activity. It will be closed in 7 days.

@github-actions github-actions bot added the Stale label Sep 23, 2020
@github-actions
Copy link
Contributor

Closed as inactive. Feel free to reopen if this PR is still being worked on.

@github-actions github-actions bot closed this Sep 30, 2020
MovieStoreGuy pushed a commit to atlassian-forks/opentelemetry-collector that referenced this pull request Nov 11, 2021
According to the [community
charter](https://github.com/open-telemetry/community/blob/main/community-membership.md#responsibilities-and-privileges-2):

> Expected to be responsive to review requests (inactivity for more than
> 1 month may result in suspension until active again)

Given @paivagustavo has returned to an active state, this reinstates
their status as an Approver.
hughesjj pushed a commit to hughesjj/opentelemetry-collector that referenced this pull request Apr 27, 2023
Troels51 pushed a commit to Troels51/opentelemetry-collector that referenced this pull request Jul 5, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Return consumererror.Permanent in the Prometheus remote write exporter
3 participants