| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -362,6 +362,24 @@ public final class io/sentry/android/core/NetworkBreadcrumbsIntegration : io/sen | |||
| 362 | 362 | public fun register (Lio/sentry/IScopes;Lio/sentry/SentryOptions;)V | |
| 363 | 363 | } | |
| 364 | 364 | ||
| 365 | + public class io/sentry/android/core/PerfettoContinuousProfiler : io/sentry/IContinuousProfiler, io/sentry/transport/RateLimiter$IRateLimitObserver { | ||
| 366 | + public fun <init> (Lio/sentry/ILogger;Lio/sentry/android/core/internal/util/SentryFrameMetricsCollector;Lio/sentry/util/LazyEvaluator$Evaluator;Ljava/util/function/Supplier;)V | ||
| 367 | + public fun close (Z)V | ||
| 368 | + public fun getChunkId ()Lio/sentry/protocol/SentryId; | ||
| 369 | + public fun getProfilerId ()Lio/sentry/protocol/SentryId; | ||
| 370 | + public fun isRunning ()Z | ||
| 371 | + public fun onRateLimitChanged (Lio/sentry/transport/RateLimiter;)V | ||
| 372 | + public fun reevaluateSampling ()V | ||
| 373 | + public fun startProfiler (Lio/sentry/ProfileLifecycle;Lio/sentry/TracesSampler;)V | ||
| 374 | + public fun stopProfiler (Lio/sentry/ProfileLifecycle;)V | ||
| 375 | + } | ||
| 376 | + | ||
| 377 | + public class io/sentry/android/core/PerfettoProfiler { | ||
| 378 | + public fun <init> (Landroid/content/Context;Lio/sentry/ILogger;Lio/sentry/ISentryExecutorService;)V | ||
| 379 | + public fun endAndCollect (Ljava/util/function/Consumer;)V | ||
| 380 | + public fun start (J)Z | ||
| 381 | + } | ||
| 382 | + | ||
| 365 | 383 | public final class io/sentry/android/core/ScreenshotEventProcessor : io/sentry/EventProcessor { | |
| 366 | 384 | public fun <init> (Lio/sentry/android/core/SentryAndroidOptions;Lio/sentry/android/core/BuildInfoProvider;Z)V | |
| 367 | 385 | public fun getOrder ()Ljava/lang/Long; | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -38,6 +38,11 @@ | |||
| 38 | 38 | import org.jetbrains.annotations.Nullable; | |
| 39 | 39 | import org.jetbrains.annotations.VisibleForTesting; | |
| 40 | 40 | ||
| 41 | + /** | ||
| 42 | + * Legacy Android implementation of {@link IContinuousProfiler}, using Android's {@code | ||
| 43 | + * Debug.startMethodTracingSampling} See {@link PerfettoContinuousProfiler} for the new | ||
| 44 | + * implementation using {@code ProfilingManager}, available on API 35+. | ||
| 45 | + */ | ||
| 41 | 46 | @ApiStatus.Internal | |
| 42 | 47 | public class AndroidContinuousProfiler | |
| 43 | 48 | implements IContinuousProfiler, RateLimiter.IRateLimitObserver { | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -2,6 +2,7 @@ | |||
| 2 | 2 | ||
| 3 | 3 | import static io.sentry.android.core.NdkIntegration.SENTRY_NDK_CLASS_NAME; | |
| 4 | 4 | ||
| 5 | + import android.annotation.SuppressLint; | ||
| 5 | 6 | import android.app.Application; | |
| 6 | 7 | import android.content.Context; | |
| 7 | 8 | import android.content.pm.PackageInfo; | |
@@ -294,6 +295,7 @@ static void initializeIntegrationsAndProcessors( | |||
| 294 | 295 | } | |
| 295 | 296 | ||
| 296 | 297 | /** Setup the correct profiler (transaction or continuous) based on the options. */ | |
| 298 | + @SuppressLint("NewApi") | ||
| 297 | 299 | private static void setupProfiler( | |
| 298 | 300 | final @NotNull SentryAndroidOptions options, | |
| 299 | 301 | final @NotNull Context context, | |
@@ -336,16 +338,36 @@ private static void setupProfiler( | |||
| 336 | 338 | performanceCollector.start(chunkId.toString()); | |
| 337 | 339 | } | |
| 338 | 340 | } else { | |
| 339 | - options.setContinuousProfiler( | ||
| 340 | - new AndroidContinuousProfiler( | ||
| 341 | - buildInfoProvider, | ||
| 342 | - Objects.requireNonNull( | ||
| 343 | - options.getFrameMetricsCollector(), | ||
| 344 | - "options.getFrameMetricsCollector is required"), | ||
| 345 | - options.getLogger(), | ||
| 346 | - options.getProfilingTracesDirPath(), | ||
| 347 | - options.getProfilingTracesHz(), | ||
| 348 | - () -> options.getExecutorService())); | ||
| 341 | + final @NotNull SentryFrameMetricsCollector frameMetricsCollector = | ||
| 342 | + Objects.requireNonNull( | ||
| 343 | + options.getFrameMetricsCollector(), "options.getFrameMetricsCollector is required"); | ||
| 344 | + if (buildInfoProvider.getSdkInfoVersion() >= Build.VERSION_CODES.VANILLA_ICE_CREAM) { | ||
| 345 | + final @NotNull Context appContext = context.getApplicationContext(); | ||
| 346 | + options.setContinuousProfiler( | ||
| 347 | + new PerfettoContinuousProfiler( | ||
| 348 | + options.getLogger(), | ||
| 349 | + frameMetricsCollector, | ||
| 350 | + () -> options.getExecutorService(), | ||
| 351 | + () -> | ||
| 352 | + new PerfettoProfiler( | ||
| 353 | + appContext, options.getLogger(), options.getExecutorService()))); | ||
| 354 | + } else if (options.isEnableLegacyProfiling()) { | ||
| 355 | + options.setContinuousProfiler( | ||
| 356 | + new AndroidContinuousProfiler( | ||
| 357 | + buildInfoProvider, | ||
| 358 | + frameMetricsCollector, | ||
| 359 | + options.getLogger(), | ||
| 360 | + options.getProfilingTracesDirPath(), | ||
| 361 | + options.getProfilingTracesHz(), | ||
| 362 | + () -> options.getExecutorService())); | ||
| 363 | + } else { | ||
| 364 | + options | ||
| 365 | + .getLogger() | ||
| 366 | + .log( | ||
| 367 | + SentryLevel.WARNING, | ||
| 368 | + "enableLegacyProfiling is disabled and device is below API 35. " | ||
| 369 | + + "No profiling data will be collected."); | ||
| 370 | + } | ||
| 349 | 371 | } | |
| 350 | 372 | } | |
| 351 | 373 | } | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -119,6 +119,8 @@ final class ManifestMetadataReader { | |||
| 119 | 119 | ||
| 120 | 120 | static final String ENABLE_APP_START_PROFILING = "io.sentry.profiling.enable-app-start"; | |
| 121 | 121 | ||
| 122 | + static final String ENABLE_LEGACY_PROFILING = "io.sentry.profiling.enable-legacy-profiling"; | ||
| 123 | + | ||
| 122 | 124 | static final String ENABLE_SCOPE_PERSISTENCE = "io.sentry.enable-scope-persistence"; | |
| 123 | 125 | ||
| 124 | 126 | static final String REPLAYS_SESSION_SAMPLE_RATE = "io.sentry.session-replay.session-sample-rate"; | |
@@ -542,6 +544,9 @@ static void applyMetadata( | |||
| 542 | 544 | readBool( | |
| 543 | 545 | metadata, logger, ENABLE_APP_START_PROFILING, options.isEnableAppStartProfiling())); | |
| 544 | 546 | ||
| 547 | + options.setEnableLegacyProfiling( | ||
| 548 | + readBool(metadata, logger, ENABLE_LEGACY_PROFILING, options.isEnableLegacyProfiling())); | ||
| 549 | + | ||
| 545 | 550 | options.setEnableScopePersistence( | |
| 546 | 551 | readBool( | |
| 547 | 552 | metadata, logger, ENABLE_SCOPE_PERSISTENCE, options.isEnableScopePersistence())); | |
| Back | FazBrowse Home | New Git URL |
0 commit comments