Commit 26b44e2f by 张乐 Committed by GitHub

Merge pull request #503 from nobodyiam/client-log-error-as-event

log error as event for apollo-client
parents 67efe969 c24f2a85
...@@ -23,6 +23,7 @@ public abstract class AbstractConfigRepository implements ConfigRepository { ...@@ -23,6 +23,7 @@ public abstract class AbstractConfigRepository implements ConfigRepository {
sync(); sync();
return true; return true;
} catch (Throwable ex) { } catch (Throwable ex) {
Tracer.logEvent("ApolloConfigException", ExceptionUtil.getDetailMessage(ex));
logger logger
.warn("Sync config failed, will retry. Repository {}, reason: {}", this.getClass(), ExceptionUtil .warn("Sync config failed, will retry. Repository {}, reason: {}", this.getClass(), ExceptionUtil
.getDetailMessage(ex)); .getDetailMessage(ex));
......
...@@ -14,6 +14,7 @@ import com.ctrip.framework.apollo.exceptions.ApolloConfigException; ...@@ -14,6 +14,7 @@ import com.ctrip.framework.apollo.exceptions.ApolloConfigException;
import com.ctrip.framework.apollo.tracer.Tracer; import com.ctrip.framework.apollo.tracer.Tracer;
import com.ctrip.framework.apollo.tracer.spi.Transaction; import com.ctrip.framework.apollo.tracer.spi.Transaction;
import com.ctrip.framework.apollo.util.ConfigUtil; import com.ctrip.framework.apollo.util.ConfigUtil;
import com.ctrip.framework.apollo.util.ExceptionUtil;
import com.ctrip.framework.apollo.util.http.HttpRequest; import com.ctrip.framework.apollo.util.http.HttpRequest;
import com.ctrip.framework.apollo.util.http.HttpResponse; import com.ctrip.framework.apollo.util.http.HttpResponse;
import com.ctrip.framework.apollo.util.http.HttpUtil; import com.ctrip.framework.apollo.util.http.HttpUtil;
...@@ -122,6 +123,7 @@ public class ConfigServiceLocator implements Initializable { ...@@ -122,6 +123,7 @@ public class ConfigServiceLocator implements Initializable {
logConfigServicesToCat(services); logConfigServicesToCat(services);
return; return;
} catch (Throwable ex) { } catch (Throwable ex) {
Tracer.logEvent("ApolloConfigException", ExceptionUtil.getDetailMessage(ex));
transaction.setStatus(ex); transaction.setStatus(ex);
exception = ex; exception = ex;
} finally { } finally {
......
...@@ -141,6 +141,7 @@ public class LocalFileConfigRepository extends AbstractConfigRepository ...@@ -141,6 +141,7 @@ public class LocalFileConfigRepository extends AbstractConfigRepository
m_fileProperties = this.loadFromLocalCacheFile(m_baseDir, m_namespace); m_fileProperties = this.loadFromLocalCacheFile(m_baseDir, m_namespace);
transaction.setStatus(Transaction.SUCCESS); transaction.setStatus(Transaction.SUCCESS);
} catch (Throwable ex) { } catch (Throwable ex) {
Tracer.logEvent("ApolloConfigException", ExceptionUtil.getDetailMessage(ex));
transaction.setStatus(ex); transaction.setStatus(ex);
exception = ex; exception = ex;
//ignore //ignore
......
...@@ -180,6 +180,7 @@ public class RemoteConfigLongPollService implements Initializable { ...@@ -180,6 +180,7 @@ public class RemoteConfigLongPollService implements Initializable {
transaction.setStatus(Transaction.SUCCESS); transaction.setStatus(Transaction.SUCCESS);
} catch (Throwable ex) { } catch (Throwable ex) {
lastServiceDto = null; lastServiceDto = null;
Tracer.logEvent("ApolloConfigException", ExceptionUtil.getDetailMessage(ex));
transaction.setStatus(ex); transaction.setStatus(ex);
long sleepTimeInSecond = m_longPollFailSchedulePolicyInSecond.fail(); long sleepTimeInSecond = m_longPollFailSchedulePolicyInSecond.fail();
logger.warn( logger.warn(
......
...@@ -18,6 +18,7 @@ import com.ctrip.framework.apollo.exceptions.ApolloConfigStatusCodeException; ...@@ -18,6 +18,7 @@ import com.ctrip.framework.apollo.exceptions.ApolloConfigStatusCodeException;
import com.ctrip.framework.apollo.tracer.Tracer; import com.ctrip.framework.apollo.tracer.Tracer;
import com.ctrip.framework.apollo.tracer.spi.Transaction; import com.ctrip.framework.apollo.tracer.spi.Transaction;
import com.ctrip.framework.apollo.util.ConfigUtil; import com.ctrip.framework.apollo.util.ConfigUtil;
import com.ctrip.framework.apollo.util.ExceptionUtil;
import com.ctrip.framework.apollo.util.http.HttpRequest; import com.ctrip.framework.apollo.util.http.HttpRequest;
import com.ctrip.framework.apollo.util.http.HttpResponse; import com.ctrip.framework.apollo.util.http.HttpResponse;
import com.ctrip.framework.apollo.util.http.HttpUtil; import com.ctrip.framework.apollo.util.http.HttpUtil;
...@@ -213,9 +214,11 @@ public class RemoteConfigRepository extends AbstractConfigRepository { ...@@ -213,9 +214,11 @@ public class RemoteConfigRepository extends AbstractConfigRepository {
statusCodeException = new ApolloConfigStatusCodeException(ex.getStatusCode(), statusCodeException = new ApolloConfigStatusCodeException(ex.getStatusCode(),
message); message);
} }
Tracer.logEvent("ApolloConfigException", ExceptionUtil.getDetailMessage(statusCodeException));
transaction.setStatus(statusCodeException); transaction.setStatus(statusCodeException);
exception = statusCodeException; exception = statusCodeException;
} catch (Throwable ex) { } catch (Throwable ex) {
Tracer.logEvent("ApolloConfigException", ExceptionUtil.getDetailMessage(ex));
transaction.setStatus(ex); transaction.setStatus(ex);
exception = ex; exception = ex;
} finally { } finally {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment