Skip to content

Commit c24f2a8

Browse files
committed
log error as event for apollo-client
1 parent 67efe96 commit c24f2a8

File tree

5 files changed

+8
-0
lines changed

5 files changed

+8
-0
lines changed

apollo-client/src/main/java/com/ctrip/framework/apollo/internals/AbstractConfigRepository.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ protected boolean trySync() {
2323
sync();
2424
return true;
2525
} catch (Throwable ex) {
26+
Tracer.logEvent("ApolloConfigException", ExceptionUtil.getDetailMessage(ex));
2627
logger
2728
.warn("Sync config failed, will retry. Repository {}, reason: {}", this.getClass(), ExceptionUtil
2829
.getDetailMessage(ex));

apollo-client/src/main/java/com/ctrip/framework/apollo/internals/ConfigServiceLocator.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
import com.ctrip.framework.apollo.tracer.Tracer;
1515
import com.ctrip.framework.apollo.tracer.spi.Transaction;
1616
import com.ctrip.framework.apollo.util.ConfigUtil;
17+
import com.ctrip.framework.apollo.util.ExceptionUtil;
1718
import com.ctrip.framework.apollo.util.http.HttpRequest;
1819
import com.ctrip.framework.apollo.util.http.HttpResponse;
1920
import com.ctrip.framework.apollo.util.http.HttpUtil;
@@ -122,6 +123,7 @@ private synchronized void updateConfigServices() {
122123
logConfigServicesToCat(services);
123124
return;
124125
} catch (Throwable ex) {
126+
Tracer.logEvent("ApolloConfigException", ExceptionUtil.getDetailMessage(ex));
125127
transaction.setStatus(ex);
126128
exception = ex;
127129
} finally {

apollo-client/src/main/java/com/ctrip/framework/apollo/internals/LocalFileConfigRepository.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,7 @@ protected void sync() {
141141
m_fileProperties = this.loadFromLocalCacheFile(m_baseDir, m_namespace);
142142
transaction.setStatus(Transaction.SUCCESS);
143143
} catch (Throwable ex) {
144+
Tracer.logEvent("ApolloConfigException", ExceptionUtil.getDetailMessage(ex));
144145
transaction.setStatus(ex);
145146
exception = ex;
146147
//ignore

apollo-client/src/main/java/com/ctrip/framework/apollo/internals/RemoteConfigLongPollService.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -180,6 +180,7 @@ private void doLongPollingRefresh(String appId, String cluster, String dataCente
180180
transaction.setStatus(Transaction.SUCCESS);
181181
} catch (Throwable ex) {
182182
lastServiceDto = null;
183+
Tracer.logEvent("ApolloConfigException", ExceptionUtil.getDetailMessage(ex));
183184
transaction.setStatus(ex);
184185
long sleepTimeInSecond = m_longPollFailSchedulePolicyInSecond.fail();
185186
logger.warn(

apollo-client/src/main/java/com/ctrip/framework/apollo/internals/RemoteConfigRepository.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
import com.ctrip.framework.apollo.tracer.Tracer;
1919
import com.ctrip.framework.apollo.tracer.spi.Transaction;
2020
import com.ctrip.framework.apollo.util.ConfigUtil;
21+
import com.ctrip.framework.apollo.util.ExceptionUtil;
2122
import com.ctrip.framework.apollo.util.http.HttpRequest;
2223
import com.ctrip.framework.apollo.util.http.HttpResponse;
2324
import com.ctrip.framework.apollo.util.http.HttpUtil;
@@ -213,9 +214,11 @@ private ApolloConfig loadApolloConfig() {
213214
statusCodeException = new ApolloConfigStatusCodeException(ex.getStatusCode(),
214215
message);
215216
}
217+
Tracer.logEvent("ApolloConfigException", ExceptionUtil.getDetailMessage(statusCodeException));
216218
transaction.setStatus(statusCodeException);
217219
exception = statusCodeException;
218220
} catch (Throwable ex) {
221+
Tracer.logEvent("ApolloConfigException", ExceptionUtil.getDetailMessage(ex));
219222
transaction.setStatus(ex);
220223
exception = ex;
221224
} finally {

0 commit comments

Comments
 (0)