|
1 | 1 | package io.sentry.android.core; |
2 | 2 |
|
| 3 | +import static io.sentry.Sentry.getCurrentScopes; |
3 | 4 | import static io.sentry.SentryLevel.DEBUG; |
4 | 5 | import static io.sentry.SentryLevel.INFO; |
5 | 6 | import static io.sentry.SentryLevel.WARNING; |
|
13 | 14 | import io.sentry.IScopes; |
14 | 15 | import io.sentry.ISerializer; |
15 | 16 | import io.sentry.ObjectWriter; |
| 17 | +import io.sentry.PropagationContext; |
16 | 18 | import io.sentry.ScopeType; |
17 | 19 | import io.sentry.ScopesAdapter; |
18 | 20 | import io.sentry.SentryEnvelope; |
|
30 | 32 | import io.sentry.protocol.SentryId; |
31 | 33 | import io.sentry.protocol.User; |
32 | 34 | import io.sentry.util.MapObjectWriter; |
| 35 | +import io.sentry.util.TracingUtils; |
33 | 36 | import java.io.ByteArrayInputStream; |
34 | 37 | import java.io.File; |
35 | 38 | import java.io.InputStream; |
@@ -329,4 +332,22 @@ private static Session updateSession( |
329 | 332 | }); |
330 | 333 | return sessionRef.get(); |
331 | 334 | } |
| 335 | + |
| 336 | + /** |
| 337 | + * Allows a Hybrid SDK to set the trace on the native layer |
| 338 | + * |
| 339 | + * @param traceId the trace ID |
| 340 | + * @param spanId the trace origin's span ID |
| 341 | + * @param sampleRate the sample rate used by the origin of the trace |
| 342 | + * @param sampleRand the random value used to sample with by the origin of the trace |
| 343 | + */ |
| 344 | + public static void setTrace( |
| 345 | + final @NotNull String traceId, |
| 346 | + final @NotNull String spanId, |
| 347 | + final @Nullable Double sampleRate, |
| 348 | + final @Nullable Double sampleRand) { |
| 349 | + TracingUtils.setTrace( |
| 350 | + getCurrentScopes(), |
| 351 | + PropagationContext.fromExistingTrace(traceId, spanId, sampleRate, sampleRand)); |
| 352 | + } |
332 | 353 | } |
0 commit comments