-
Notifications
You must be signed in to change notification settings - Fork 8.1k
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
Improve the logs when the heartbeat response indicates failure #1303
Conversation
using the LongAdder rather than AtomicInteger to Provides better performance
merge master
…perties directory
merge online
…cator to load log config
merge onlie
merge online
This reverts commit d401c2f
merge online
merge remote master
merge online
Codecov Report
@@ Coverage Diff @@
## master #1303 +/- ##
============================================
- Coverage 42.74% 42.71% -0.03%
+ Complexity 1604 1603 -1
============================================
Files 344 344
Lines 10186 10186
Branches 1380 1380
============================================
- Hits 4354 4351 -3
- Misses 5287 5290 +3
Partials 545 545
Continue to review full report at Codecov.
|
#926 brought some conflicts. Could you please resolve it? |
...tty-http/src/main/java/com/alibaba/csp/sentinel/transport/heartbeat/HttpHeartbeatSender.java
Outdated
Show resolved
Hide resolved
RecordLog.warn("[HttpHeartbeatSender] Failed to send heartbeat to " | ||
+ consoleHost + ":" + consolePort + ", response : ", response); |
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.
Here we may need use placeholder for log: RecordLog.warn("xxx{},{}", arg1,arg2);
.
Or just concat all message string.
Besides, I found that SimpleHttpResponse#toString
may throws NPE, when body is null,
In SimpleHttpResponse#108L
, maybe need add checking logic.
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.
Yes. Maybe just logging the response status code is enough?
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.
emm. I check the response Headers. It is a supplement of the server version、location 、name, may be it is not necessary to print.
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.
How about else branch, do we need to add some log? The NPE remains in SimpleHttpResponse#getBodyAsString()
at line 108, when body is null it throws.
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.
emm.. it seems there more than one point need to handle the NPE
1.com.alibaba.csp.sentinel.transport.heartbeat.client.SimpleHttpResponseParser#parse
2.com.alibaba.csp.sentinel.transport.heartbeat.client.SimpleHttpResponse#parseCharset
3.com.alibaba.csp.sentinel.transport.heartbeat.client.SimpleHttpResponse#getBodyAsString、 return new String(body, charset);
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.
any suggestion?
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 think that 3 need to check.To verify it, we can throw Exception in MachineRegistryController#receiveHeartBeat
of dashboard, and call SimpleHttpResponse#toString()
.
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 think that 3 need to check.To verify it, we can throw Exception in
MachineRegistryController#receiveHeartBeat
of dashboard, and callSimpleHttpResponse#toString()
.
It still will return http 200 ok response code, even though throw ex. It seems SimpleHttpResponseParser
don't check the response data, which may need to be checked. How about we open another issue to discuss ?
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 think that 3 need to check.To verify it, we can throw Exception in
MachineRegistryController#receiveHeartBeat
of dashboard, and callSimpleHttpResponse#toString()
.It still will return http 200 ok response code, even though throw ex. It seems
SimpleHttpResponseParser
don't check the response data, which may need to be checked. How about we open another issue to discuss ?
Yeah, we could open another issue to discuss how to improve it :)
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.
Yes, one issue one PR is clean and consistent.
It still will return http 200 ok response code, even though throw ex. It seems SimpleHttpResponseParser don't check the response data
I got http 500 and theSimpleHttpResponseParser
checked the response.
Add this in MachineRegistryController#receiveHeartBeat
if (true) {
throw new RuntimeException("test");
}
Then add in SimpleHttpHeartbeatSender#sendHeartbeat
try {
System.out.println(response);
} catch (Exception e) {
e.printStackTrace();
}
Then the response code 500 got, and NPE occured.
friendly ping :) |
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.
LGTM
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.
LGTM
Thanks! |
…in the same process can trace only one (alibaba#1275) (alibaba#1303) * fix trace problem when multi produce/consumer in the same process * uniform parameter manner * variable rename * consumer groups may be same with the producer group Co-authored-by: zhengwen zhu <ahuazhu@gmail.com>
Describe what this PR does / why we need it
Does this pull request fix one issue?
fix #1194
Describe how you did it
Describe how to verify it
Special notes for reviews