优化
This commit is contained in:
@@ -55,6 +55,14 @@ public record TraceParent(String traceId, String parentId, String traceFlags) {
|
||||
return new TraceParent(traceId, randomNonZero(8), "00");
|
||||
}
|
||||
|
||||
/** Creates a sampled outbound child for a trusted current trace ID. */
|
||||
public static TraceParent outboundChild(String currentTraceId) {
|
||||
if (!validLegacyTraceId(currentTraceId)) {
|
||||
throw new IllegalArgumentException("Current trace ID is invalid");
|
||||
}
|
||||
return new TraceParent(currentTraceId.toLowerCase(java.util.Locale.ROOT), randomNonZero(8), "01");
|
||||
}
|
||||
|
||||
public static boolean validLegacyTraceId(String value) {
|
||||
return value != null && LEGACY_TRACE_ID.matcher(value).matches()
|
||||
&& !ZERO_TRACE_ID.equalsIgnoreCase(value);
|
||||
|
||||
Reference in New Issue
Block a user