| | |
| | | |
| | | private static Logger logger = LoggerFactory.getLogger(Java110TraceFactory.class); |
| | | |
| | | // trace-id |
| | | public static final String TRACE_ID = "TRACE-ID"; |
| | | |
| | | //SPAN-ID |
| | | public static final String SPAN_ID = "SPAN-ID"; |
| | | |
| | | //SPAN-ID |
| | | public static final String PARENT_SPAN_ID = "PARENT-SPAN-ID"; |
| | | public static final String PARENT_SPAN_ID = "parent-span-id"; |
| | | |
| | | public static final String LOG_TRACE_TOPIC = "logTrace"; |
| | | |
| | |
| | | public static String createTrace(String name, Map<String, Object> headers) { |
| | | String traceId = ""; |
| | | String parentId = ""; |
| | | if (headers.containsKey(CommonConstant.TRANSACTION_ID)) { |
| | | if (headers.containsKey(CommonConstant.TRACE_ID)) { //先取trace Id |
| | | traceId = headers.get(CommonConstant.TRACE_ID).toString(); |
| | | }else if (headers.containsKey(CommonConstant.TRANSACTION_ID)) { |
| | | traceId = headers.get(CommonConstant.TRANSACTION_ID).toString(); |
| | | } else { |
| | | traceId = GenerateCodeFactory.getUUID(); |
| | |
| | | ip = "127.0.0.1"; |
| | | } |
| | | traceEndpointDto.setIpv4(ip); |
| | | traceAnnotationsDto.setTraceEndpoint(traceEndpointDto); |
| | | traceAnnotationsDto.setEndpoint(traceEndpointDto); |
| | | traceAnnotationsDto.setTimestamp(DateUtil.getCurrentDate().getTime()); |
| | | traceAnnotationsDto.setValue(event); |
| | | |
| | | List<TraceAnnotationsDto> traceAnnotationsDtos = new ArrayList<>(); |
| | | traceAnnotationsDtos.add(traceAnnotationsDto); |
| | | traceDto.setTraceAnnotations(traceAnnotationsDtos); |
| | | traceDto.setAnnotations(traceAnnotationsDtos); |
| | | traceDto.setTraceId(traceId); |
| | | put(traceDto.getId(), traceDto); |
| | | putSpanId(SPAN_ID, traceDto.getId()); |
| | |
| | | ip = "127.0.0.1"; |
| | | } |
| | | traceEndpointDto.setIpv4(ip); |
| | | traceAnnotationsDto.setTraceEndpoint(traceEndpointDto); |
| | | traceAnnotationsDto.setEndpoint(traceEndpointDto); |
| | | traceAnnotationsDto.setTimestamp(DateUtil.getCurrentDate().getTime()); |
| | | traceAnnotationsDto.setValue(event); |
| | | |
| | | List<TraceAnnotationsDto> traceAnnotationsDtos = traceDto.getTraceAnnotations(); |
| | | List<TraceAnnotationsDto> traceAnnotationsDtos = traceDto.getAnnotations(); |
| | | traceAnnotationsDtos.add(traceAnnotationsDto); |
| | | traceDto.setTraceAnnotations(traceAnnotationsDtos); |
| | | traceDto.setAnnotations(traceAnnotationsDtos); |
| | | put(getSpanId(SPAN_ID), traceDto); |
| | | //判断是否为cr |
| | | if (!TraceAnnotationsDto.VALUE_CLIENT_RECEIVE.equals(traceAnnotationsDto.getValue())) { |