Skip to content

Commit

Permalink
Revert "Feature: Enable report exception for center & agent (#563)"
Browse files Browse the repository at this point in the history
This reverts commit fbe056f.
  • Loading branch information
zhou9584 committed Aug 21, 2023
1 parent a155cd9 commit 7f029dd
Show file tree
Hide file tree
Showing 25 changed files with 38 additions and 501 deletions.
16 changes: 8 additions & 8 deletions agent/doc/UML/hydra_lab_exception_monitor_design.puml
Original file line number Diff line number Diff line change
@@ -1,27 +1,27 @@
@startuml exception_monitor
interface ExceptionReporter {
+ void reportException(Exception e, boolean fatal)
+ void reportException(Exception e, Thread thread, boolean fatal)
+ void reportException(Exception e)
+ void reportException(Exception e ,Thread thread)
}

class ExceptionReporterManager {
List<ExceptionReporter> reporters
+ void registerExceptionReporter(ExceptionReporter reporter)
+ void reportException(Exception e, boolean fatal)
+ void reportException(Exception e, Thread thread, boolean fatal)
+ void reportException(Exception e)
+ void reportException(Exception e ,Thread thread)
}

class AppCenterReporter implements ExceptionReporter {
AppCenterClient appCenterClient;

+ void reportException(Exception e, boolean fatal)
+ void reportException(Exception e, Thread thread, boolean fatal)
+ void reportException(Exception e)
+ void reportException(Exception e ,Thread thread)
}


class FileReporter implements ExceptionReporter {
+ void reportException(Exception e, boolean fatal)
+ void reportException(Exception e, Thread thread, boolean fatal)
+ void reportException(Exception e)
+ void reportException(Exception e ,Thread thread)
+ void writeToFile(String message, StackTraceElement[] stackTrace)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,6 @@
import com.microsoft.hydralab.agent.runner.smart.SmartTestUtil;
import com.microsoft.hydralab.agent.service.AgentWebSocketClientService;
import com.microsoft.hydralab.agent.socket.AgentWebSocketClient;
import com.microsoft.hydralab.common.exception.reporter.AppCenterReporter;
import com.microsoft.hydralab.common.exception.reporter.ExceptionReporterManager;
import com.microsoft.hydralab.common.exception.reporter.FileReporter;
import com.microsoft.hydralab.common.entity.agent.LLMProperties;
import com.microsoft.hydralab.common.file.StorageServiceClientProxy;
import com.microsoft.hydralab.common.management.AgentManagementService;
Expand Down Expand Up @@ -219,20 +216,6 @@ public StorageServiceClientProxy storageServiceClientProxy(ApplicationContext ap
return new StorageServiceClientProxy(applicationContext);
}

@Bean
public FileReporter fileReporter() {
FileReporter fileReporter = new FileReporter(appOptions.getErrorStorageLocation());
ExceptionReporterManager.registerExceptionReporter(fileReporter);
return fileReporter;
}

@Bean
public AppCenterReporter appCenterReporter() {
AppCenterReporter appCenterReporter = new AppCenterReporter();
ExceptionReporterManager.registerExceptionReporter(appCenterReporter);
return appCenterReporter;
}

@Bean
@ConfigurationProperties(prefix = "runner.smart.llm")
public LLMProperties llmProperties(){
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,4 @@ public String getTestCaseResultLocation() {
public void setLocation(String location) {
this.location = location;
}

public String getErrorStorageLocation() {
return location + "/storage/errorOutput/";
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,6 @@ public void scheduleCleanBuildSource() {
clearFile(appOptions.getTestPackageLocation());
logger.info("schedule clean test result");
clearFile(appOptions.getTestCaseResultLocation());
logger.info("schedule clean error output");
clearFile(appOptions.getErrorStorageLocation());
}

public void clearFile(String folderPath) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
import com.microsoft.hydralab.common.entity.common.TestRunDevice;
import com.microsoft.hydralab.common.entity.common.TestTask;
import com.microsoft.hydralab.common.entity.common.TestTaskSpec;
import com.microsoft.hydralab.common.exception.reporter.AppCenterReporter;
import com.microsoft.hydralab.common.file.StorageServiceClientProxy;
import com.microsoft.hydralab.common.management.AgentManagementService;
import com.microsoft.hydralab.common.monitor.MetricPushGateway;
Expand All @@ -34,7 +33,6 @@
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
import org.springframework.util.Assert;
import org.springframework.util.StringUtils;

import javax.annotation.Resource;
import java.io.File;
Expand Down Expand Up @@ -78,8 +76,6 @@ public class AgentWebSocketClientService implements TestTaskRunCallback {
@Resource
private AgentManagementService agentManagementService;
boolean isAgentInit = false;
@Resource
private AppCenterReporter appCenterReporter;

public void onMessage(Message message) {
log.info("onMessage Receive bytes message {}", message);
Expand Down Expand Up @@ -208,7 +204,6 @@ private void heartbeatResponse(Message message) {
storageServiceClientProxy.updateAccessToken(agentMetadata.getAccessToken());
syncAgentStatus(agentMetadata.getAgentUser());
prometheusPushgatewayInit(agentMetadata);
appCenterReporterInit(agentMetadata);
}

private void syncAgentStatus(AgentUser passedAgent) {
Expand Down Expand Up @@ -295,13 +290,6 @@ public void registerAgentMetrics() {
registerAgentRunningTestTaskNum();
}

private void appCenterReporterInit(AgentMetadata agentMetadata) {
if (appCenterReporter.isAppCenterEnabled() || StringUtils.isEmpty(agentMetadata.getAppCenterSecret())) {
return;
}
appCenterReporter.initAppCenterReporter(agentMetadata.getAppCenterSecret(), agentUser.getName(), agentUser.getVersionName(), agentUser.getVersionCode());
}

public void registerAgentDiskUsageRatio() {
meterRegistry.gauge(GlobalConstant.PROMETHEUS_METRIC_DISK_USAGE_RATIO,
Tags.empty().and("disk", appOptions.getLocation().substring(0, 2)),
Expand Down
16 changes: 0 additions & 16 deletions agent/src/main/resources/logback-common.xml
Original file line number Diff line number Diff line change
Expand Up @@ -42,18 +42,6 @@
</encoder>
</appender>

<appender name="errorAlarm" class="com.microsoft.hydralab.common.exception.handler.LogbackExceptionHandler">
<filter class="ch.qos.logback.classic.filter.ThresholdFilter">
<level>ERROR</level>
</filter>
</appender>

<appender name="warnAlarm" class="com.microsoft.hydralab.common.exception.handler.LogbackExceptionHandler">
<filter class="ch.qos.logback.classic.filter.ThresholdFilter">
<level>WARN</level>
</filter>
</appender>

<root level="info">
<appender-ref ref="STDOUT"/>
</root>
Expand All @@ -64,14 +52,10 @@
<logger name="com.microsoft" level="debug" additivity="false">
<appender-ref ref="syslog"/>
<appender-ref ref="STDOUT"/>
<appender-ref ref="errorAlarm"/>
<appender-ref ref="warnAlarm"/>
</logger>
<logger name="logger.devices" level="debug" additivity="false">
</logger>
<logger name="access" level="info" additivity="false">
<appender-ref ref="accessLog"/>
<appender-ref ref="errorAlarm"/>
<appender-ref ref="warnAlarm"/>
</logger>
</configuration>

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,8 @@
import com.alibaba.fastjson.serializer.SerializerFeature;
import com.alibaba.fastjson.support.config.FastJsonConfig;
import com.alibaba.fastjson.support.spring.FastJsonHttpMessageConverter;
import com.microsoft.hydralab.center.util.CenterConstant;
import com.microsoft.hydralab.common.exception.reporter.AppCenterReporter;
import com.microsoft.hydralab.common.exception.reporter.ExceptionReporterManager;
import com.microsoft.hydralab.common.exception.reporter.FileReporter;
import com.microsoft.hydralab.common.file.StorageServiceClientProxy;
import com.microsoft.hydralab.common.monitor.MetricPushGateway;
import com.microsoft.hydralab.common.file.StorageServiceClientProxy;
import io.prometheus.client.CollectorRegistry;
import io.prometheus.client.exporter.BasicAuthHttpConnectionFactory;
import io.prometheus.client.exporter.PushGateway;
Expand Down Expand Up @@ -46,14 +42,6 @@ public class AppConfig {
private String pushgatewayPassword;
@Value("${app.storage.type}")
private String storageType;
@Value("${app.app-center.center.enabled: false}")
private boolean appCenterEnabled;
@Value("${app.app-center.center.secret:}")
private String appCenterSecret;
@Value("${center.version}")
private String versionName;
@Value("${center.versionCode}")
private String versionCode;

@Bean
@ConditionalOnClass({JSON.class})
Expand Down Expand Up @@ -138,21 +126,4 @@ public PrometheusPushGatewayManager monitorPrometheusPushGatewayManager(PushGate
return new PrometheusPushGatewayManager(pushGateway, registry,
pushRate, job, groupingKey, shutdownOperation);
}

@Bean
public FileReporter fileReporter() {
FileReporter fileReporter = new FileReporter(CenterConstant.ERROR_OUTPUT_DIR);
ExceptionReporterManager.registerExceptionReporter(fileReporter);
return fileReporter;
}

@Bean
public AppCenterReporter appCenterReporter() {
AppCenterReporter appCenterReporter = new AppCenterReporter();
if (appCenterEnabled && appCenterSecret != null && !appCenterSecret.isEmpty()) {
appCenterReporter.initAppCenterReporter(appCenterSecret, "center", versionName, versionCode);
}
ExceptionReporterManager.registerExceptionReporter(appCenterReporter);
return appCenterReporter;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -122,10 +122,6 @@ public class DeviceAgentManagementService {
private String pushgatewayUsername;
@Value("${management.metrics.export.prometheus.pushgateway.password}")
private String pushgatewayPassword;
@Value("${app.app-center.agent.enabled: false}")
private boolean appCenterEnabled;
@Value("${app.app-center.agent.secret: ''}")
private String appCenterSecret;

public void onOpen(Session session) {
onlineCount.incrementAndGet();
Expand Down Expand Up @@ -161,9 +157,6 @@ private void sendAgentMetadata(Session session, AgentUser agentUser, String sign
data.setAgentUser(agentUser);
data.setPushgatewayUsername(pushgatewayUsername);
data.setPushgatewayPassword(pushgatewayPassword);
if (appCenterEnabled && appCenterSecret != null && !appCenterSecret.isEmpty()) {
data.setAppCenterSecret(appCenterSecret);
}

Message message = new Message();
message.setPath(signalName);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
public final class CenterConstant {
public static final String CENTER_FILE_BASE_DIR = "storage/test/package/";
public static final String CENTER_TEMP_FILE_DIR = "storage/temp/";
public static final String ERROR_OUTPUT_DIR = "storage/errorOutput/";

private CenterConstant() {

Expand Down
7 changes: 0 additions & 7 deletions center/src/main/resources/application.yml
Original file line number Diff line number Diff line change
Expand Up @@ -70,13 +70,6 @@ app:
endpoint: ${LOCAL_STORAGE_ENDPOINT:http://localhost:9886/}
fileExpiryDay: ${fileExpiryDay:-1}
location: ${user.dir}
app-center:
center:
enabled: ${AC_CENTER_ENABLED:false}
secret: ${AC_CENTER_SECRET:}
agent:
enabled: ${AC_AGENT_ENABLED:false}
secret: ${AC_AGENT_SECRET:}
management:
endpoints:
web:
Expand Down
16 changes: 0 additions & 16 deletions center/src/main/resources/logback-common.xml
Original file line number Diff line number Diff line change
Expand Up @@ -42,18 +42,6 @@
</encoder>
</appender>

<appender name="errorAlarm" class="com.microsoft.hydralab.common.exception.handler.LogbackExceptionHandler">
<filter class="ch.qos.logback.classic.filter.ThresholdFilter">
<level>ERROR</level>
</filter>
</appender>

<appender name="warnAlarm" class="com.microsoft.hydralab.common.exception.handler.LogbackExceptionHandler">
<filter class="ch.qos.logback.classic.filter.ThresholdFilter">
<level>WARN</level>
</filter>
</appender>

<root level="info">
<appender-ref ref="STDOUT"/>
</root>
Expand All @@ -64,14 +52,10 @@
<logger name="com.microsoft" level="debug" additivity="false">
<appender-ref ref="syslog"/>
<appender-ref ref="STDOUT"/>
<appender-ref ref="errorAlarm"/>
<appender-ref ref="warnAlarm"/>
</logger>
<logger name="logger.devices" level="debug" additivity="false">
</logger>
<logger name="access" level="info" additivity="false">
<appender-ref ref="accessLog"/>
<appender-ref ref="errorAlarm"/>
<appender-ref ref="warnAlarm"/>
</logger>
</configuration>
Original file line number Diff line number Diff line change
Expand Up @@ -47,16 +47,16 @@ public class AppCenterClient {
AppCenterErrorLogHandler appCenterErrorLogHandler;


public AppCenterClient(String appSecret, String name, String versionName, String versionCode) {
public AppCenterClient(String appSecret, String name) {
this.appSecret = appSecret;
installId = UUID.randomUUID().toString();
sid = UUID.randomUUID();
appInitializeTimestamp = System.currentTimeMillis();
appCenterErrorLogHandler = new AppCenterErrorLogHandler(getDevice(name, versionName, versionCode), installId);
appCenterErrorLogHandler = new AppCenterErrorLogHandler(getDevice(name), installId);
}

@NotNull
private static Device getDevice(String name, String versionName, String versionCode) {
private static Device getDevice(String name) {
Device device = new Device();

// System info
Expand All @@ -72,11 +72,11 @@ private static Device getDevice(String name, String versionName, String versionC
// App Center App info
device.setSdkName("appcenter.android");
device.setSdkVersion("4.4.4");
device.setAppNamespace("com.microsoft.hydralab");
device.setAppNamespace("com.microsoft.hydralab.agent");

// Hydra Lab Center/Agent info
device.setAppVersion(versionName);
device.setAppBuild(versionCode);
// Hydra Lab Agent info, TODO read from app version config
device.setAppVersion("1.0.0");
device.setAppBuild("110");

// Mock value
device.setOsApiLevel(30);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,4 @@ public class AgentMetadata {
AgentUser agentUser;
String pushgatewayUsername;
String pushgatewayPassword;
String appCenterSecret;
}
Loading

0 comments on commit 7f029dd

Please sign in to comment.