From 42f08bdb795657af7a94557a06cb7df3f9fd6760 Mon Sep 17 00:00:00 2001 From: Yousif Ahmed Date: Mon, 2 Dec 2024 11:49:10 +0000 Subject: [PATCH] refactor(react-native): use constants for hex radix and trace id midpoint values --- .../android/performance/ReactNativeSpanContext.java | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/packages/platforms/react-native/android/src/main/java/com/bugsnag/android/performance/ReactNativeSpanContext.java b/packages/platforms/react-native/android/src/main/java/com/bugsnag/android/performance/ReactNativeSpanContext.java index 40192ac97..6dc536d59 100644 --- a/packages/platforms/react-native/android/src/main/java/com/bugsnag/android/performance/ReactNativeSpanContext.java +++ b/packages/platforms/react-native/android/src/main/java/com/bugsnag/android/performance/ReactNativeSpanContext.java @@ -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) ); }