evanxuhe opened a new pull request #3167: Fix bug: Agent never update its 
Instance HeartbeatTime
URL: https://github.com/apache/skywalking/pull/3167
 
 
   Please answer these questions before submitting pull request
   
   - Why submit this pull request?
   - [ ] Bug fix
   
   - Related issues
   
   ___
   ### Bug fix
   - Bug description.
   Agent never update its Instance HeartbeatTime
   
   Beacause the judgment statement in 
```org.apache.skywalking.apm.agent.core.remote.AppAndServiceRegisterClient```that
 compares current timestamp with lastSegmentUpdateTime will be always negative 
and never works 
   ```java
   if (lastSegmentTime - System.currentTimeMillis() > 60 * 1000) {
                                   
instanceDiscoveryServiceBlockingStub.heartbeat(ApplicationInstanceHeartbeat.newBuilder()
                                       
.setApplicationInstanceId(RemoteDownstreamConfig.Agent.APPLICATION_INSTANCE_ID)
                                       
.setHeartbeatTime(System.currentTimeMillis())
                                       .build());
                               }
   ```
   - How to fix?
   Fix the judgement sequence putting  System.currentTimeMillis() before
   ```java
                               if ( System.currentTimeMillis() - 
lastSegmentTime > 60 * 1000) {
                                   
instanceDiscoveryServiceBlockingStub.heartbeat(ApplicationInstanceHeartbeat.newBuilder()
                                       
.setApplicationInstanceId(RemoteDownstreamConfig.Agent.APPLICATION_INSTANCE_ID)
                                       
.setHeartbeatTime(System.currentTimeMillis())
                                       .build());
                               }
   ```
   ___
   ### New feature or improvement
   - Describe the details and related test reports.
   

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
[email protected]


With regards,
Apache Git Services

Reply via email to