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

Improve the logs when the heartbeat response indicates failure #1303

Merged
merged 40 commits into from
Mar 4, 2020
Merged

Improve the logs when the heartbeat response indicates failure #1303

merged 40 commits into from
Mar 4, 2020

Conversation

linlinisme
Copy link
Collaborator

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

Lin.Liang and others added 30 commits May 9, 2019 14:54
using the LongAdder rather than AtomicInteger to Provides better performance
@codecov-io
Copy link

codecov-io commented Feb 24, 2020

Codecov Report

Merging #1303 into master will decrease coverage by 0.02%.
The diff coverage is 40.27%.

Impacted file tree graph

@@             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
Impacted Files Coverage Δ Complexity Δ
.../sentinel/adapter/dubbo/DubboAppContextFilter.java 100% <ø> (ø) 3 <0> (ø) ⬇️
...erver/envoy/rls/flow/SimpleClusterFlowChecker.java 0% <0%> (ø) 0 <0> (ø) ⬇️
...inel/adapter/gateway/zuul/filters/EntryHolder.java 0% <0%> (ø) 0 <0> (ø) ⬇️
...a/csp/sentinel/slots/HotParamSlotChainBuilder.java 0% <0%> (ø) 0 <0> (ø) ⬇️
...sp/sentinel/slots/system/SystemStatusListener.java 37.03% <0%> (ø) 3 <0> (ø) ⬇️
.../rls/datasource/EnvoyRlsRuleDataSourceService.java 0% <0%> (ø) 0 <0> (ø) ⬇️
...apter/gateway/zuul/filters/SentinelEntryUtils.java 13.63% <0%> (ø) 1 <0> (ø) ⬇️
...a/csp/sentinel/datasource/etcd/EtcdDataSource.java 0% <0%> (ø) 0 <0> (ø) ⬇️
...er/gateway/zuul/filters/SentinelZuulPreFilter.java 14.28% <0%> (ø) 3 <0> (ø) ⬇️
...com/alibaba/csp/sentinel/log/CommandCenterLog.java 0% <0%> (ø) 0 <0> (ø) ⬇️
... and 117 more

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 7a4391d...d39d090. Read the comment docs.

@sczyh30 sczyh30 added kind/enhancement Category issues or prs related to enhancement. to-review To review labels Feb 24, 2020
@sczyh30 sczyh30 added this to the 1.7.2 milestone Feb 24, 2020
@sczyh30
Copy link
Member

sczyh30 commented Feb 24, 2020

#926 brought some conflicts. Could you please resolve it?

Comment on lines 98 to 99
RecordLog.warn("[HttpHeartbeatSender] Failed to send heartbeat to "
+ consoleHost + ":" + consolePort + ", response : ", response);
Copy link
Collaborator

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.

Copy link
Member

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?

Copy link
Collaborator Author

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.

Copy link
Collaborator

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.

Copy link
Collaborator Author

@linlinisme linlinisme Feb 27, 2020

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);

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

any suggestion?

Copy link
Collaborator

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().

Copy link
Collaborator Author

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().

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 ?

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 that 3 need to check.To verify it, we can throw Exception in MachineRegistryController#receiveHeartBeat of dashboard, and call SimpleHttpResponse#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 :)

Copy link
Collaborator

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 the SimpleHttpResponseParser 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.

@linlinisme
Copy link
Collaborator Author

friendly ping :)

Copy link
Collaborator

@cdfive cdfive left a comment

Choose a reason for hiding this comment

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

LGTM

Copy link
Member

@sczyh30 sczyh30 left a comment

Choose a reason for hiding this comment

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

LGTM

@sczyh30 sczyh30 merged commit 72bfe87 into alibaba:master Mar 4, 2020
@sczyh30
Copy link
Member

sczyh30 commented Mar 4, 2020

Thanks!

@sczyh30 sczyh30 removed the to-review To review label Mar 4, 2020
hughpearse pushed a commit to hughpearse/Sentinel that referenced this pull request Jun 2, 2021
CST11021 pushed a commit to CST11021/Sentinel that referenced this pull request Nov 3, 2021
…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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/enhancement Category issues or prs related to enhancement.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Improve the logs when the heartbeat response indicates failure (e.g. 404, 502)
4 participants