修复埋点数据中中文乱码问题

This commit is contained in:
zhangxin10 2016-01-05 11:02:03 +08:00
parent 15bfbc0355
commit 0103a3dd37
3 changed files with 9 additions and 1 deletions

View File

@ -4,6 +4,8 @@ skywalking.user_id=123
skywalking.application_code=test
#skywalking auth的环境变量名字
skywalking.auth_system_env_name=SKYWALKING_RUN
#skywalking数据编码
skywalking.charset=UTF-8
#是否打印数据
buriedpoint.printf=false

View File

@ -10,6 +10,8 @@ public class Config {
public static String AUTH_SYSTEM_ENV_NAME = "SKYWALKING_RUN";
public static boolean AUTH_OVERRIDE = false;
public static String CHARSET = "UTF-8";
}
public static class BuriedPoint {

View File

@ -1,12 +1,16 @@
package com.ai.cloud.skywalking.sender.protocol;
import com.ai.cloud.skywalking.conf.Config;
import java.nio.charset.Charset;
public class ProtocolBuilder {
//协议格式:
// xx xx xx xx | xx xx xx xx xxx xxx xxx
// header(4) | content
public static byte[] builder(String data) {
byte[] content = data.getBytes();
byte[] content = data.getBytes(Charset.forName(Config.SkyWalking.CHARSET));
byte[] header = intToByteArray(content.length);
byte[] des = new byte[header.length + content.length];
System.arraycopy(header, 0, des, 0, header.length);