Skip to content

Commit

Permalink
refactor(react-native): use constants for hex radix and trace id midp…
Browse files Browse the repository at this point in the history
…oint values
  • Loading branch information
yousif-bugsnag committed Dec 2, 2024
1 parent a29dfef commit 1b8f00e
Showing 1 changed file with 8 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,17 @@
import java.util.concurrent.Callable;

class ReactNativeSpanContext implements SpanContext {
private static final int HEX_RADIX = 16;
private static final int TRACE_ID_MIDPOINT = 16;

private final long nativeSpanId;
private final UUID nativeTraceId;

public ReactNativeSpanContext(String spanId, String traceId) {
nativeSpanId = Long.parseUnsignedLong(spanId, 16);
ReactNativeSpanContext(String spanId, String traceId) {
nativeSpanId = Long.parseUnsignedLong(spanId, HEX_RADIX);
nativeTraceId = new UUID(
Long.parseUnsignedLong(traceId.substring(0, 16), 16),
Long.parseUnsignedLong(traceId.substring(16), 16)
Long.parseUnsignedLong(traceId.substring(0, TRACE_ID_MIDPOINT), HEX_RADIX),
Long.parseUnsignedLong(traceId.substring(TRACE_ID_MIDPOINT), HEX_RADIX)
);
}

Expand Down

0 comments on commit 1b8f00e

Please sign in to comment.