Only check one part of trace ID is valid since it guarantees a value … (#3291)
* Only check one part of trace ID is valid since it guarantees a value full ID. * Valid 64-bit IDs.
This commit is contained in:
parent
81e2777114
commit
7ecb2e260e
|
|
@ -31,12 +31,11 @@ enum AndroidFriendlyRandomIdGenerator implements IdGenerator {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String generateTraceId() {
|
public String generateTraceId() {
|
||||||
long idHi;
|
long idHi = random.nextLong();
|
||||||
long idLo;
|
long idLo;
|
||||||
do {
|
do {
|
||||||
idHi = random.nextLong();
|
|
||||||
idLo = random.nextLong();
|
idLo = random.nextLong();
|
||||||
} while (idHi == INVALID_ID && idLo == INVALID_ID);
|
} while (idLo == INVALID_ID);
|
||||||
return TraceId.fromLongs(idHi, idLo);
|
return TraceId.fromLongs(idHi, idLo);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -26,13 +26,12 @@ enum RandomIdGenerator implements IdGenerator {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String generateTraceId() {
|
public String generateTraceId() {
|
||||||
long idHi;
|
|
||||||
long idLo;
|
|
||||||
ThreadLocalRandom random = ThreadLocalRandom.current();
|
ThreadLocalRandom random = ThreadLocalRandom.current();
|
||||||
|
long idHi = random.nextLong();
|
||||||
|
long idLo;
|
||||||
do {
|
do {
|
||||||
idHi = random.nextLong();
|
|
||||||
idLo = random.nextLong();
|
idLo = random.nextLong();
|
||||||
} while (idHi == INVALID_ID && idLo == INVALID_ID);
|
} while (idLo == INVALID_ID);
|
||||||
return TraceId.fromLongs(idHi, idLo);
|
return TraceId.fromLongs(idHi, idLo);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue