-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor(react-native): add ReactNativeSpanContext class
- Loading branch information
1 parent
dec156d
commit 8d55f2c
Showing
2 changed files
with
60 additions
and
53 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
42 changes: 42 additions & 0 deletions
42
...-native/android/src/main/java/com/bugsnag/android/performance/ReactNativeSpanContext.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
package com.bugsnag.reactnative.performance; | ||
|
||
import androidx.annotation.NonNull; | ||
import com.bugsnag.android.performance.SpanContext; | ||
import java.util.UUID; | ||
import java.util.concurrent.Callable; | ||
|
||
class ReactNativeSpanContext implements SpanContext { | ||
private final long nativeSpanId; | ||
private final UUID nativeTraceId; | ||
|
||
public ReactNativeSpanContext(String spanId, String traceId) { | ||
nativeSpanId = Long.parseUnsignedLong(spanId, 16); | ||
nativeTraceId = new UUID( | ||
Long.parseUnsignedLong(traceId.substring(0, 16), 16), | ||
Long.parseUnsignedLong(traceId.substring(16), 16) | ||
); | ||
} | ||
|
||
@Override | ||
public long getSpanId() { | ||
return nativeSpanId; | ||
} | ||
|
||
@NonNull | ||
@Override | ||
public UUID getTraceId() { | ||
return nativeTraceId; | ||
} | ||
|
||
@NonNull | ||
@Override | ||
public Runnable wrap(@NonNull Runnable runnable) { | ||
return SpanContext.DefaultImpls.wrap(this, runnable); | ||
} | ||
|
||
@NonNull | ||
@Override | ||
public <T> Callable<T> wrap(@NonNull Callable<T> callable) { | ||
return SpanContext.DefaultImpls.wrap(this, callable); | ||
} | ||
} |