|
45 | 45 | import java.util.List; |
46 | 46 | import java.util.Map; |
47 | 47 | import java.util.logging.Logger; |
| 48 | +import java.util.regex.Pattern; |
48 | 49 | import java.util.stream.Collectors; |
49 | 50 |
|
50 | 51 | public class DataProxy { |
51 | 52 | private static final Logger logger = Logger.getLogger(DataProxy.class.getName()); |
52 | 53 | private static UDPDataSendThread udpCollect = UDPDataSendThread.getInstance(); |
53 | 54 | private static IntIntLinkedMap sqlHash = new IntIntLinkedMap().setMax(5000); |
| 55 | + private static final Pattern WHITE_SPACE = Pattern.compile("\\s\\s+"); |
54 | 56 |
|
55 | 57 | private static int getSqlHash(String sql) { |
56 | 58 | if (sql.length() < 100) |
@@ -298,7 +300,6 @@ private static SpanPack makeSpanPack(Span span) { |
298 | 300 | } |
299 | 301 | } |
300 | 302 |
|
301 | | - pack.name = sendServiceName(span.name()); |
302 | 303 | String error = span.tags().get("error"); |
303 | 304 | if (StringUtil.isNotEmpty(error)) { |
304 | 305 | pack.error = sendError(error); |
@@ -329,6 +330,17 @@ private static SpanPack makeSpanPack(Span span) { |
329 | 330 |
|
330 | 331 | pack.tags = MapValue.ofStringValueMap(span.tags()); |
331 | 332 |
|
| 333 | + String serviceName = StringUtil.emptyToDefault(span.name(), "").trim(); |
| 334 | + if (pack.spanType == SpanTypes.CLIENT) { |
| 335 | + if (pack.tags.getText("sql.query") != null) { |
| 336 | + //serviceName = pack.tags.getText("sql.query").replaceAll("[\r\n]+", " "); |
| 337 | + serviceName = WHITE_SPACE.matcher(pack.tags.getText("sql.query")).replaceAll(" "); |
| 338 | + } else if (pack.tags.getText("http.path") != null) { |
| 339 | + serviceName = pack.tags.getText("http.method") + " " + pack.tags.getText("http.path"); |
| 340 | + } |
| 341 | + } |
| 342 | + pack.name = sendServiceName(serviceName); |
| 343 | + |
332 | 344 | return pack; |
333 | 345 | } |
334 | 346 |
|
|
0 commit comments