public interface

ProviderStatsLogger

 androidx.wear.protolayout.renderer.common.ProviderStatsLogger

Subclasses:

NoOpProviderStatsLogger

Gradle dependencies

compile group: 'androidx.wear.protolayout', name: 'protolayout-renderer', version: '1.2.0'

  • groupId: androidx.wear.protolayout
  • artifactId: protolayout-renderer
  • version: 1.2.0

Artifact androidx.wear.protolayout:protolayout-renderer:1.2.0 it located at Google repository (https://maven.google.com/)

Overview

Logger used for collecting metrics.

Summary

Fields
public static final intIGNORED_FAILURE_ANIMATION_QUOTA_EXCEEDED

Failure caused by exceeding animation quota.

public static final intIGNORED_FAILURE_APPLY_MUTATION_EXCEPTION

Failure applying the diff mutation.

public static final intIGNORED_FAILURE_DIFFING_FAILURE

Failure diffing the layout.

public static final intIGNORED_FAILURE_UNKNOWN

Unknown failure.

public static final intINFLATION_FAILURE_REASON_EXPRESSION_NODE_COUNT_EXCEEDED

Failure caused by exceeding maximum expression node count.

public static final intINFLATION_FAILURE_REASON_LAYOUT_DEPTH_EXCEEDED

Failure caused by exceeding maximum layout depth.

public static final intINFLATION_FAILURE_REASON_UNKNOWN

Unknown failure.

Methods
public ProviderStatsLogger.InflaterStatsLoggercreateInflaterStatsLogger()

Creates an ProviderStatsLogger.InflaterStatsLogger and marks the start of inflation.

public voidlogIgnoredFailure(int failure)

Log the occurrence of an ignored failure.

public voidlogInflationFailed(int failureReason)

Log the reason for inflation failure.

public voidlogInflationFinished(ProviderStatsLogger.InflaterStatsLogger inflaterStatsLogger)

Makes the end of inflation and log the inflation results.

public voidlogLayoutSchemaVersion(int major, int minor)

Log the schema version of the received layout.

public voidlogStateStructure(StateProto.State state, boolean isInitialState)

Log Protolayout state structure.

public voidlogTileRequestReason(int updateRequestReason)

Log tile request reason.

Fields

public static final int IGNORED_FAILURE_UNKNOWN

Unknown failure.

public static final int IGNORED_FAILURE_APPLY_MUTATION_EXCEPTION

Failure applying the diff mutation.

public static final int IGNORED_FAILURE_ANIMATION_QUOTA_EXCEEDED

Failure caused by exceeding animation quota.

public static final int IGNORED_FAILURE_DIFFING_FAILURE

Failure diffing the layout.

public static final int INFLATION_FAILURE_REASON_UNKNOWN

Unknown failure.

public static final int INFLATION_FAILURE_REASON_LAYOUT_DEPTH_EXCEEDED

Failure caused by exceeding maximum layout depth.

public static final int INFLATION_FAILURE_REASON_EXPRESSION_NODE_COUNT_EXCEEDED

Failure caused by exceeding maximum expression node count.

Methods

public void logLayoutSchemaVersion(int major, int minor)

Log the schema version of the received layout.

public void logStateStructure(StateProto.State state, boolean isInitialState)

Log Protolayout state structure.

public void logIgnoredFailure(int failure)

Log the occurrence of an ignored failure.

public void logInflationFailed(int failureReason)

Log the reason for inflation failure.

public ProviderStatsLogger.InflaterStatsLogger createInflaterStatsLogger()

Creates an ProviderStatsLogger.InflaterStatsLogger and marks the start of inflation. The atoms will be logged to statsd only when ProviderStatsLogger.logInflationFinished(ProviderStatsLogger.InflaterStatsLogger) is called.

public void logInflationFinished(ProviderStatsLogger.InflaterStatsLogger inflaterStatsLogger)

Makes the end of inflation and log the inflation results.

public void logTileRequestReason(int updateRequestReason)

Log tile request reason.

Source

/*
 * Copyright 2023 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package androidx.wear.protolayout.renderer.common;

import android.graphics.drawable.Drawable;

import androidx.annotation.IntDef;
import androidx.annotation.NonNull;
import androidx.annotation.RestrictTo;
import androidx.annotation.UiThread;
import androidx.wear.protolayout.proto.StateProto.State;
import androidx.wear.protolayout.renderer.common.Constants.UpdateRequestReason;

import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;

/** Logger used for collecting metrics. */
@RestrictTo(RestrictTo.Scope.LIBRARY_GROUP)
public interface ProviderStatsLogger {

    /** Failures that doesn't cause the inflation to fail. */
    @IntDef({
        IGNORED_FAILURE_UNKNOWN,
        IGNORED_FAILURE_APPLY_MUTATION_EXCEPTION,
        IGNORED_FAILURE_ANIMATION_QUOTA_EXCEEDED,
        IGNORED_FAILURE_DIFFING_FAILURE
    })
    @Retention(RetentionPolicy.SOURCE)
    @interface IgnoredFailure {}

    /** Unknown failure. */
    int IGNORED_FAILURE_UNKNOWN = 0;

    /** Failure applying the diff mutation. */
    int IGNORED_FAILURE_APPLY_MUTATION_EXCEPTION = 1;

    /** Failure caused by exceeding animation quota. */
    int IGNORED_FAILURE_ANIMATION_QUOTA_EXCEEDED = 2;

    /** Failure diffing the layout. */
    int IGNORED_FAILURE_DIFFING_FAILURE = 3;

    /** Failures that causes the inflation to fail. */
    @IntDef({
        INFLATION_FAILURE_REASON_UNKNOWN,
        INFLATION_FAILURE_REASON_LAYOUT_DEPTH_EXCEEDED,
        INFLATION_FAILURE_REASON_EXPRESSION_NODE_COUNT_EXCEEDED
    })
    @Retention(RetentionPolicy.SOURCE)
    @interface InflationFailureReason {}

    /** Unknown failure. */
    int INFLATION_FAILURE_REASON_UNKNOWN = 0;

    /** Failure caused by exceeding maximum layout depth. */
    int INFLATION_FAILURE_REASON_LAYOUT_DEPTH_EXCEEDED = 1;

    /** Failure caused by exceeding maximum expression node count. */
    int INFLATION_FAILURE_REASON_EXPRESSION_NODE_COUNT_EXCEEDED = 2;

    /** Log the schema version of the received layout. */
    void logLayoutSchemaVersion(int major, int minor);

    /** Log Protolayout state structure. */
    void logStateStructure(@NonNull State state, boolean isInitialState);

    /** Log the occurrence of an ignored failure. */
    @UiThread
    void logIgnoredFailure(@IgnoredFailure int failure);

    /** Log the reason for inflation failure. */
    @UiThread
    void logInflationFailed(@InflationFailureReason int failureReason);

    /**
     * Creates an {@link InflaterStatsLogger} and marks the start of inflation. The atoms will be
     * logged to statsd only when {@link #logInflationFinished} is called.
     */
    @UiThread
    @NonNull
    InflaterStatsLogger createInflaterStatsLogger();

    /** Makes the end of inflation and log the inflation results. */
    @UiThread
    void logInflationFinished(@NonNull InflaterStatsLogger inflaterStatsLogger);

    /** Log tile request reason. */
    void logTileRequestReason(@UpdateRequestReason int updateRequestReason);

    /** Logger used for logging inflation stats. */
    interface InflaterStatsLogger {
        /** log the mutation changed nodes count for the ongoing inflation. */
        @UiThread
        void logMutationChangedNodes(int changedNodesCount);

        /** Log the total nodes count for the ongoing inflation. */
        @UiThread
        void logTotalNodeCount(int totalNodesCount);

        /**
         * Log the usage of a drawable. This method should be called between {@link
         * #createInflaterStatsLogger()} and {@link #logInflationFinished(InflaterStatsLogger)}.
         */
        @UiThread
        void logDrawableUsage(@NonNull Drawable drawable);

        /**
         * Log the occurrence of an ignored failure. The usage of this method is not restricted to
         * inflation start or end.
         */
        @UiThread
        void logIgnoredFailure(@IgnoredFailure int failure);

        /**
         * Log the reason for inflation failure. This will make any future call {@link
         * #logInflationFinished(InflaterStatsLogger)} a Noop.
         */
        @UiThread
        void logInflationFailed(@InflationFailureReason int failureReason);
    }
}