-
Notifications
You must be signed in to change notification settings - Fork 90
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 disable_http_keep_alive option #1035
Add disable_http_keep_alive option #1035
Conversation
495b925
to
5c8c0d9
Compare
config/config.go
Outdated
Verbose bool | ||
Silent bool | ||
Diagnostic bool `toml:"diagnostic"` | ||
DisableKeepAlive bool `toml:"disable_keep_alive"` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added DisableKeepAlive
here
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Changed it to DisableHttpKeepAlive
mackerel-agent/config/config.go
Line 105 in 12e1b6e
DisableHttpKeepAlive bool `toml:"disable_http_keep_alive"` |
mackerel/api.go
Outdated
t := http.DefaultTransport.(*http.Transport).Clone() | ||
print(disableKeepAlive) | ||
t.DisableKeepAlives = disableKeepAlive | ||
c.HTTPClient.Transport = t |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since http.DefaultTransport
is made from http.Transport
, we can cast it here.
https://pkg.go.dev/net/http#:~:text=DefaultTransport%20is%20the,lowercase%20versions%20thereof
mackerel/api.go
Outdated
c, err := mkr.NewClientWithOptions(apiKey, rawurl, verbose) | ||
if err != nil { | ||
return nil, err | ||
} | ||
c.PrioritizedLogger = logger | ||
t := http.DefaultTransport.(*http.Transport).Clone() | ||
print(disableKeepAlive) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You forgot to delete your print debugging.
Could you marge (or rebase) master branch onto your |
d0b2804
to
c127806
Compare
@rmatsuoka Thank you, I've rebased it and passed the CI |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
good! I added a note, but you can make changes or not.
command/command_api_test.go
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[may]
In all the tests that call NewMackerelClient, you set the disableKeepAlive parameter to true. However, in the previous version, this parameter was implicitly set to false.
While I believe this change does not introduce any issues, it is preferable not to introduce such changes unnecessarily.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I changed it 7022f7c
Have you run the modified mackerel-agent and confirmed whether it sends metrics to Mackerel when disableKeepAlive is set to both true and false? If not, please test it. |
I've captured the packets between mackerel api and mackerel agent with mitmproxy. Without
|
12e1b6e
to
05dcf6b
Compare
command/command.go
Outdated
@@ -693,8 +693,8 @@ func buildUA(ver, rev string) string { | |||
} | |||
|
|||
// NewMackerelClient returns Mackerel API client for mackerel-agent | |||
func NewMackerelClient(apibase, apikey, ver, rev string, verbose bool) (*mackerel.API, error) { | |||
api, err := mackerel.NewAPI(apibase, apikey, verbose) | |||
func NewMackerelClient(apibase, apikey, ver, rev string, verbose bool, disableHttpKeepAlive bool) (*mackerel.API, error) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
According to Go conventions, all letters in acronyms should be uppercase. Therefore, it is preferable to use disableHTTPKeepAlive
across all your changes.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I changed it 4474546
config/config.go
Outdated
if !config.DisableHttpKeepAlive { | ||
config.DisableHttpKeepAlive = DefaultConfig.DisableHttpKeepAlive | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The line is redundant: if config.DisableHTTPKeepAlive
is already false, there is no need to set it to false (from DefaultConfig.DisableHTTPKeepAlive
) again.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I changed it 78589bd
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
disable_http_keep_alive
optiondisable_http_keep_alive
is falsedisable_http_keep_alive
is true, mkr requests mackerel without KeepAlive