Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement a SessionSubscriber for Firebase Performance #6683

Merged
merged 13 commits into from
Feb 11, 2025

Conversation

tejasd
Copy link
Contributor

@tejasd tejasd commented Feb 7, 2025

This is a follow up for: #6678

This PR doesn't change the use of session ID to AQS - except in GaugeMetadata. I've added TODOs to identify the missing locations.

Copy link
Contributor

github-actions bot commented Feb 7, 2025

Release note changes

No release note changes were detected. If you made changes that should be
present in the next release, ensure you've added an entry in the appropriate
CHANGELOG.md file(s).

Copy link
Contributor

github-actions bot commented Feb 7, 2025

Vertex AI Mock Responses Check ⚠️

A newer major version of the mock responses for Vertex AI unit tests is available. update_responses.sh should be updated to clone the latest version of the responses: v6.1

@google-oss-bot
Copy link
Contributor

1 Warning
⚠️ Did you forget to add a changelog entry? (Add the 'no-changelog' label to the PR to silence this warning.)

Generated by 🚫 Danger

@tejasd tejasd changed the base branch from main to fireperf-aqs February 7, 2025 20:24
@google-oss-bot
Copy link
Contributor

google-oss-bot commented Feb 7, 2025

Coverage Report 1

Affected Products

  • firebase-perf

    Overall coverage changed from ? (9c03b7b) to 70.32% (5d9dabf) by ?.

    105 individual files with coverage change

    FilenameBase (9c03b7b)Merge (5d9dabf)Diff
    AddTrace.java?0.00%?
    AndroidApplicationInfo.java?34.71%?
    AndroidApplicationInfoOrBuilder.java?0.00%?
    AndroidLogger.java?100.00%?
    AndroidMemoryReading.java?38.36%?
    AndroidMemoryReadingOrBuilder.java?0.00%?
    ApplicationInfo.java?45.00%?
    ApplicationInfoOrBuilder.java?0.00%?
    ApplicationProcessState.java?73.91%?
    AppStartTrace.java?77.55%?
    AppStateMonitor.java?84.97%?
    AppStateUpdateHandler.java?89.29%?
    Clock.java?100.00%?
    ConfigResolver.java?90.33%?
    ConfigurationConstants.java?97.93%?
    ConfigurationFlag.java?80.00%?
    ConsoleUrlGenerator.java?37.50%?
    Constants.java?95.65%?
    Counter.java?90.91%?
    CpuGaugeCollector.java?93.83%?
    CpuMetricReading.java?39.33%?
    CpuMetricReadingOrBuilder.java?0.00%?
    DaggerFirebasePerformanceComponent.java?100.00%?
    DeviceCacheManager.java?76.42%?
    FirebasePerfApplicationInfoValidator.java?92.86%?
    FirebasePerfEarly.java?76.92%?
    FirebasePerfGaugeMetricValidator.java?100.00%?
    FirebasePerfHttpClient.java?93.85%?
    FirebasePerfMetricProto.java?0.00%?
    FirebasePerfNetworkValidator.java?86.67%?
    FirebasePerfOkHttpClient.java?44.90%?
    FirebasePerformance.java?78.65%?
    FirebasePerformanceAttributable.java?0.00%?
    FirebasePerformanceComponent.java?0.00%?
    FirebasePerformanceInitializer.java?28.57%?
    FirebasePerformanceModule.java?100.00%?
    FirebasePerformanceModule_ProvidesConfigResolverFactory.java?0.00%?
    FirebasePerformanceModule_ProvidesFirebaseAppFactory.java?0.00%?
    FirebasePerformanceModule_ProvidesFirebaseInstallationsFactory.java?0.00%?
    FirebasePerformanceModule_ProvidesRemoteConfigComponentFactory.java?0.00%?
    FirebasePerformanceModule_ProvidesRemoteConfigManagerFactory.java?0.00%?
    FirebasePerformanceModule_ProvidesSessionManagerFactory.java?0.00%?
    FirebasePerformanceModule_ProvidesTransportFactoryProviderFactory.java?0.00%?
    FirebasePerformanceSessionSubscriber.kt?14.29%?
    FirebasePerformance_Factory.java?0.00%?
    FirebasePerfRegistrar.java?100.00%?
    FirebasePerfTraceValidator.java?85.87%?
    FirebasePerfUrlConnection.java?44.44%?
    FirstDrawDoneListener.java?85.71%?
    FlgTransport.java?83.33%?
    FragmentStateMonitor.java?94.87%?
    FrameMetricsCalculator.java?96.77%?
    FrameMetricsRecorder.java?76.32%?
    GaugeManager.java?98.37%?
    GaugeMetadata.java?26.17%?
    GaugeMetadataManager.java?100.00%?
    GaugeMetadataOrBuilder.java?0.00%?
    GaugeMetric.java?39.47%?
    GaugeMetricOrBuilder.java?0.00%?
    HttpMetric.java?92.65%?
    ImmutableBundle.java?100.00%?
    InstrHttpInputStream.java?92.86%?
    InstrHttpOutputStream.java?98.00%?
    InstrHttpsURLConnection.java?94.32%?
    InstrHttpURLConnection.java?93.42%?
    InstrumentApacheHttpResponseHandler.java?100.00%?
    InstrumentOkHttpEnqueueCallback.java?100.00%?
    InstrURLConnectionBase.java?94.86%?
    LogWrapper.java?23.08%?
    MemoryGaugeCollector.java?89.66%?
    NetworkConnectionInfo.java?0.00%?
    NetworkConnectionInfoOrBuilder.java?0.00%?
    NetworkRequestMetric.java?49.16%?
    NetworkRequestMetricBuilder.java?95.97%?
    NetworkRequestMetricBuilderUtil.java?75.00%?
    NetworkRequestMetricOrBuilder.java?0.00%?
    Optional.java?86.67%?
    PendingPerfEvent.java?100.00%?
    PerfMetric.java?33.67%?
    PerfMetricOrBuilder.java?0.00%?
    PerfMetricValidator.java?93.55%?
    Performance.kt?7.14%?
    PerfSession.java?87.30%?
    PerfSessionOrBuilder.java?0.00%?
    PreDrawListener.java?94.12%?
    Rate.java?100.00%?
    RateLimiter.java?90.77%?
    RemoteConfigManager.java?90.28%?
    ResourceType.java?0.00%?
    ScreenTraceUtil.java?94.12%?
    SessionAwareObject.java?0.00%?
    SessionManager.java?100.00%?
    SessionVerbosity.java?68.42%?
    StorageUnit.java?57.89%?
    Timer.java?90.63%?
    Trace.java?95.83%?
    TraceMetric.java?43.14%?
    TraceMetricBuilder.java?100.00%?
    TraceMetricOrBuilder.java?0.00%?
    TransportInfo.java?0.00%?
    TransportInfoOrBuilder.java?0.00%?
    TransportManager.java?94.88%?
    URLAllowlist.java?94.44%?
    URLWrapper.java?0.00%?
    Utils.java?78.57%?

  • firebase-sessions

    Overall coverage changed from ? (9c03b7b) to 72.74% (5d9dabf) by ?.

    29 individual files with coverage change

    FilenameBase (9c03b7b)Merge (5d9dabf)Diff
    ApplicationInfo.kt?100.00%?
    AutoSessionEventEncoder.java?100.00%?
    Comparisons.kt?100.00%?
    Emitters.kt?0.00%?
    EventGDTLogger.kt?75.00%?
    FirebaseSessions.kt?0.00%?
    FirebaseSessionsDependencies.kt?92.00%?
    FirebaseSessionsRegistrar.kt?0.00%?
    InstallationId.kt?100.00%?
    LocalOverrideSettings.kt?100.00%?
    ProcessDetailsProvider.kt?76.67%?
    RemoteSettings.kt?88.41%?
    RemoteSettingsFetcher.kt?68.29%?
    SafeCollector.common.kt?0.00%?
    SessionDatastore.kt?2.50%?
    SessionDataStoreConfigs.kt?100.00%?
    SessionEvent.kt?100.00%?
    SessionEvents.kt?98.00%?
    SessionFirelogPublisher.kt?83.78%?
    SessionGenerator.kt?91.67%?
    SessionLifecycleClient.kt?91.78%?
    SessionLifecycleService.kt?81.48%?
    SessionLifecycleServiceBinder.kt?0.00%?
    SessionsActivityLifecycleCallbacks.kt?55.56%?
    SessionsSettings.kt?94.64%?
    SessionSubscriber.kt?100.00%?
    SettingsCache.kt?90.48%?
    SettingsProvider.kt?50.00%?
    TimeProvider.kt?50.00%?

Test Logs

  1. https://storage.googleapis.com/firebase-sdk-metric-reports/f0Sx8zv2Pm.html

Copy link
Contributor

github-actions bot commented Feb 7, 2025

Test Results

  148 files    148 suites   3m 7s ⏱️
1 054 tests 1 054 ✅ 0 💤 0 ❌
2 116 runs  2 116 ✅ 0 💤 0 ❌

Results for commit afb0804.

♻️ This comment has been updated with latest results.

@google-oss-bot
Copy link
Contributor

google-oss-bot commented Feb 7, 2025

Size Report 1

Affected Products

  • base

    TypeBase (9c03b7b)Merge (5d9dabf)Diff
    apk (aggressive)?8.80 kB? (?)
    apk (release)?9.77 kB? (?)
  • firebase-perf

    TypeBase (9c03b7b)Merge (5d9dabf)Diff
    aar?316 kB? (?)
    apk (aggressive)?1.63 MB? (?)
    apk (release)?10.1 MB? (?)
  • firebase-sessions

    TypeBase (9c03b7b)Merge (5d9dabf)Diff
    aar?168 kB? (?)
    apk (aggressive)?559 kB? (?)
    apk (release)?5.52 MB? (?)

Test Logs

  1. https://storage.googleapis.com/firebase-sdk-metric-reports/gTjuvlQvnI.html

@tejasd tejasd requested a review from mrober February 10, 2025 22:31
@tejasd tejasd marked this pull request as ready for review February 10, 2025 22:31

class FirebasePerformanceSessionSubscriber(private val dataCollectionEnabled: Boolean) :
SessionSubscriber {
override val isDataCollectionEnabled: Boolean
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you just put override val isDataCollectionEnabled: Boolean in the ctor?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

get() = dataCollectionEnabled

override val sessionSubscriberName: SessionSubscriber.Name
get() = SessionSubscriber.Name.PERFORMANCE
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think you need the explicit getter. Can you just say something like override val sessionSubscriberName = SessionSubscriber.Name.PERFORMANCE?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you copied this from Crashlytics, it's likely a result of Java Kotlin interop

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

@@ -0,0 +1,49 @@
/*
* Copyright 2024 Google LLC
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's 2025 yo

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done 😄

}

/** Returns the AQS sessionId for the given session. */
public void setAQSId(SessionSubscriber.SessionDetails aqs) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we want the Perf session to have the id of the current AQS session when the Perf session starts, but then allow AQS to have different sessions due to background foreground etc? Because Crashlytics will have the current AQS session id at crash time added to the report.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

AQS knows the "first session id" and the current session id. If that is your concern, I think it's better to have the current aqs session id as the perf session id, and then if we need to do lookups we can join it to aqs data and know the first session id.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I changed the behaviour a little compared to #6665.

This retains the PerfSession ID as is, which is used to identify sessions for gauge collection.

However, my plan is to use the AQS session ID to log the gauges. Whenever there is an AQS change, it will also result in a new PerfSession.

return aqsSessionId;
}

/** Returns the AQS sessionId for the given session. */
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sets

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

public String sessionId() {
return sessionId;
}

/** Returns the AQS sessionId for the given session. */
public String aqsSessionId() {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Nullable

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

@tejasd tejasd merged commit b9816ff into fireperf-aqs Feb 11, 2025
37 checks passed
@tejasd tejasd deleted the td/aqs-subscriber branch February 11, 2025 18:06
mrober pushed a commit that referenced this pull request Mar 7, 2025
This PR doesn't change the use of session ID to AQS - except in
GaugeMetadata. I've added TODOs to identify the missing locations.
@firebase firebase locked and limited conversation to collaborators Mar 14, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants