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

Generalize User-Agent header in receiver requests #2730

Merged
merged 1 commit into from
Oct 18, 2021
Merged

Generalize User-Agent header in receiver requests #2730

merged 1 commit into from
Oct 18, 2021

Conversation

theag3nt
Copy link
Contributor

@theag3nt theag3nt commented Oct 1, 2021

The request helper functions in the notify package now set the user agent for all requests. All applicable receivers were transitioned to these helpers, except opsgenie. In the case of opsgenie where requests are pre-generated the user agent is set before sending each request.

Resolves #2722

Copy link
Contributor

@jan--f jan--f left a comment

Choose a reason for hiding this comment

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

Nice this lgtm! Maybe a changelog entry would be good for this?

cc @simonpasquier @roidelapluie

@roidelapluie
Copy link
Member

Nice this lgtm! Maybe a changelog entry would be good for this?

cc @simonpasquier @roidelapluie

We do changelogs at release time.

Copy link
Member

@roidelapluie roidelapluie left a comment

Choose a reason for hiding this comment

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

Somehow I forgot to send my review.

Thanks!

return true, err
}

req.Header.Set("Content-Type", "application/json")
Copy link
Member

Choose a reason for hiding this comment

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

We still need this, right?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

As I understand for GET requests there is no need for a Content-Type header. I've also tried to check other libraries targeting the WeChat API and the API documentation, and I wasn't able to find any mention of this. Unfortunately I cannot test this in practice myself.

But I'd gladly restore the old approach in this case if you think it's too risky to remove.

Copy link
Member

Choose a reason for hiding this comment

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

You are probably right, but we should confirm this by an manual test against wechat.

Copy link
Contributor

Choose a reason for hiding this comment

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

I think @theag3nt is right, the Content-Type header does not apply to GET requests. Its a bit convoluted but according to [1] the header applies to a requests body, which GET doesn't have. I'd argue setting the header before was probably a bug, the header is probably ignored.
Furthermore, this request is only for refreshing the access token. The actual alert requests happens further down, is a POST requests and sets the Content-Type.

So I'd be 👍 to move forward.

Copy link
Contributor

Choose a reason for hiding this comment

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

Copy link
Member

Choose a reason for hiding this comment

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

Thanks for the comments!

@roidelapluie
Copy link
Member

Thanks!

@roidelapluie roidelapluie merged commit 78fdd6f into prometheus:main Oct 18, 2021
@theag3nt theag3nt deleted the receiver-user-agent branch October 18, 2021 12:45
markoposavec pushed a commit to markoposavec/alertmanager that referenced this pull request Nov 4, 2021
markoposavec pushed a commit to markoposavec/alertmanager that referenced this pull request Nov 4, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

generalize user-agent in receivers.
3 participants