|
|
@@ -221,10 +221,15 @@ public class ProfilerOffsetServiceImpl extends ServiceImpl<ProfilerOffsetMapper,
|
|
|
|
|
|
|
|
|
//从系统参数中获取配置信息
|
|
|
- String sql = "select param_value from blade_param where param_key = 'profiler.isPush' and is_deleted = 0";
|
|
|
- Integer isPush = jdbcTemplate.queryForObject(sql, Integer.class);
|
|
|
- //判断是否上传数据
|
|
|
- if(isPush != null && isPush == 0){
|
|
|
+ String sql = null;
|
|
|
+ try {
|
|
|
+ sql = "select param_value from blade_param where param_key = 'profiler.isPush' and is_deleted = 0";
|
|
|
+ Integer isPush = jdbcTemplate.queryForObject(sql, Integer.class);
|
|
|
+ //判断是否上传数据
|
|
|
+ if(isPush != null && isPush == 0){
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ } catch (DataAccessException e) {
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
@@ -237,36 +242,75 @@ public class ProfilerOffsetServiceImpl extends ServiceImpl<ProfilerOffsetMapper,
|
|
|
log.error("系统参数未找到 profiler.baseUrl");
|
|
|
}
|
|
|
|
|
|
- String clientKey = null;
|
|
|
+ String clientLeftKey = null;
|
|
|
try {
|
|
|
- sql = "select param_value from blade_param where param_key = 'profiler.clientKey' and is_deleted = 0";
|
|
|
+ sql = "select param_value from blade_param where param_key = 'profiler.left.clientKey' and is_deleted = 0";
|
|
|
//第三方提供的key
|
|
|
- clientKey = jdbcTemplate.queryForObject(sql, String.class);
|
|
|
+ clientLeftKey = jdbcTemplate.queryForObject(sql, String.class);
|
|
|
} catch (DataAccessException e) {
|
|
|
log.error("系统参数未找到 profiler.clientKey");
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
- String secret = null;
|
|
|
+ String secretLeft = null;
|
|
|
+ try {
|
|
|
+ sql = "select param_value from blade_param where param_key = 'profiler.left.secret' and is_deleted = 0";
|
|
|
+ //第三方提供的key
|
|
|
+ secretLeft = jdbcTemplate.queryForObject(sql, String.class);
|
|
|
+ } catch (DataAccessException e) {
|
|
|
+ log.error("系统参数未找到 profiler.secret");
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ String protocolLeftApiId = null;
|
|
|
+ try {
|
|
|
+ sql = "select param_value from blade_param where param_key = 'profiler.left.protocolApiId' and is_deleted = 0";
|
|
|
+ //第三方提供的key
|
|
|
+ protocolLeftApiId = jdbcTemplate.queryForObject(sql, String.class);
|
|
|
+ } catch (DataAccessException e) {
|
|
|
+ log.error("系统参数未找到 profiler.protocolApiId");
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ String clientRightKey = null;
|
|
|
try {
|
|
|
- sql = "select param_value from blade_param where param_key = 'profiler.secret' and is_deleted = 0";
|
|
|
+ sql = "select param_value from blade_param where param_key = 'profiler.right.clientKey' and is_deleted = 0";
|
|
|
//第三方提供的key
|
|
|
- secret = jdbcTemplate.queryForObject(sql, String.class);
|
|
|
+ clientRightKey = jdbcTemplate.queryForObject(sql, String.class);
|
|
|
+ } catch (DataAccessException e) {
|
|
|
+ log.error("系统参数未找到 profiler.clientKey");
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ String secretRight = null;
|
|
|
+ try {
|
|
|
+ sql = "select param_value from blade_param where param_key = 'profiler.right.secret' and is_deleted = 0";
|
|
|
+ //第三方提供的key
|
|
|
+ secretRight = jdbcTemplate.queryForObject(sql, String.class);
|
|
|
} catch (DataAccessException e) {
|
|
|
log.error("系统参数未找到 profiler.secret");
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
- String protocolApiId = null;
|
|
|
+
|
|
|
+
|
|
|
+ String protocolRightApiId = null;
|
|
|
try {
|
|
|
- sql = "select param_value from blade_param where param_key = 'profiler.protocolApiId' and is_deleted = 0";
|
|
|
+ sql = "select param_value from blade_param where param_key = 'profiler.right.protocolApiId' and is_deleted = 0";
|
|
|
//第三方提供的key
|
|
|
- protocolApiId = jdbcTemplate.queryForObject(sql, String.class);
|
|
|
+ protocolRightApiId = jdbcTemplate.queryForObject(sql, String.class);
|
|
|
} catch (DataAccessException e) {
|
|
|
log.error("系统参数未找到 profiler.protocolApiId");
|
|
|
return;
|
|
|
}
|
|
|
- if(StringUtil.isBlank(baseUrl) || StringUtil.isBlank(clientKey) || StringUtil.isBlank(secret) || StringUtil.isBlank(protocolApiId)){
|
|
|
+ if(StringUtil.isBlank(baseUrl)
|
|
|
+ || StringUtil.isBlank(clientLeftKey)
|
|
|
+ || StringUtil.isBlank(clientRightKey)
|
|
|
+ || StringUtil.isBlank(secretLeft)
|
|
|
+ || StringUtil.isBlank(secretRight)
|
|
|
+ || StringUtil.isBlank(protocolLeftApiId)
|
|
|
+ || StringUtil.isBlank(protocolRightApiId)
|
|
|
+ ){
|
|
|
log.error("系统参数未找到配置项");
|
|
|
return;
|
|
|
}
|
|
|
@@ -294,7 +338,7 @@ public class ProfilerOffsetServiceImpl extends ServiceImpl<ProfilerOffsetMapper,
|
|
|
//设置不忽略空值
|
|
|
JSONConfig config = JSONConfig.create().setIgnoreNullValue(false);
|
|
|
JSONObject jsonObject = new JSONObject(config);
|
|
|
- jsonObject.set("protocolApiId", protocolApiId);
|
|
|
+ jsonObject.set("protocolApiId", f.getChannelName().contains("左洞") ? protocolLeftApiId : protocolRightApiId);
|
|
|
jsonObject.set("data", profilerOffsetPush);
|
|
|
|
|
|
//数据json字符串
|
|
|
@@ -307,13 +351,13 @@ public class ProfilerOffsetServiceImpl extends ServiceImpl<ProfilerOffsetMapper,
|
|
|
HashMap<String, String> catLogHeaders = new HashMap<>();
|
|
|
catLogHeaders.put("Content-Type", "application/json");
|
|
|
//应用ID
|
|
|
- catLogHeaders.put("Sec-API-Key", clientKey);
|
|
|
+ catLogHeaders.put("Sec-API-Key", f.getChannelName().contains("左洞") ? clientLeftKey : clientRightKey);
|
|
|
//当前时间 毫秒值
|
|
|
catLogHeaders.put("Sec-Timestamp", secTimestamp);
|
|
|
//请求发起时的随机字符串,需要保证唯一性
|
|
|
catLogHeaders.put("Sec-Nonce", secNonce);
|
|
|
//签名
|
|
|
- catLogHeaders.put("Sec-Signature", new HmacUtils(HmacAlgorithms.HMAC_SHA_256, secret).hmacHex(sign));
|
|
|
+ catLogHeaders.put("Sec-Signature", new HmacUtils(HmacAlgorithms.HMAC_SHA_256, f.getChannelName().contains("左洞") ? secretLeft : secretRight).hmacHex(sign));
|
|
|
|
|
|
try {
|
|
|
String catLogBody = post.addHeaders(catLogHeaders).body(catLog).contentType("application/json").execute().body();
|