All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.eg.agent.android.activity.BaseMeasurer Maven / Gradle / Ivy

The newest version!
package com.eg.agent.android.activity;


import com.eg.agent.android.logging.EGAgentLog;
import com.eg.agent.android.logging.EGAgentLogManager;
import com.eg.agent.android.measurement.Metrics;
import com.eg.agent.android.measurement.MetricsException;
import com.eg.agent.android.measurement.MetricsPool;
import com.eg.agent.android.measurement.ThreadData;
import com.eg.agent.android.trace.TracerMachine;

public class BaseMeasurer implements Measurer {
    private static final EGAgentLog log = EGAgentLogManager.getAgentLog();
    private boolean autoInstrumented;
    private long endTime;
    private Metrics endingMeasurement;
    private ThreadData endingThread;
    private boolean finished;
    private MetricsPool measurementPool;
    private String name;
    private long startTime;
    private Metrics startingMeasurement;
    private ThreadData startingThread;

    public String getName() {
        return this.name;
    }

    public String getMetricName() {
        return TracerMachine.formatActivityMetricName(this.name);
    }

    public String getBackgroundMetricName() {
        return TracerMachine.formatActivityBackgroundMetricName(this.name);
    }

    public long getStartTime() {
        return this.startTime;
    }

    public long getEndTime() {
        return this.endTime;
    }

    public ThreadData getStartingThread() {
        return this.startingThread;
    }

    public ThreadData getEndingThread() {
        return this.endingThread;
    }

    public boolean isAutoInstrumented() {
        return this.autoInstrumented;
    }

    public Metrics getStartingMeasurement() {
        return this.startingMeasurement;
    }

    public Metrics getEndingMeasurement() {
        return this.endingMeasurement;
    }

    public MetricsPool getMeasurementPool() {
        return this.measurementPool;
    }

    public void setName(String name) {
        if (!logIfFinished()) {
            this.name = name;
        }
    }

    public void setStartTime(long startTime) {
        if (!logIfFinished()) {
            this.startTime = startTime;
        }
    }

    public void setEndTime(long endTime) {
        if (!logIfFinished()) {
            this.endTime = endTime;
        }
    }

    public void setStartingThread(ThreadData startingThread) {
        if (!logIfFinished()) {
            this.startingThread = startingThread;
        }
    }

    public void setEndingThread(ThreadData endingThread) {
        if (!logIfFinished()) {
            this.endingThread = endingThread;
        }
    }

    public void setAutoInstrumented(boolean autoInstrumented) {
        if (!logIfFinished()) {
            this.autoInstrumented = autoInstrumented;
        }
    }

    public void setStartingMeasurement(Metrics startingMeasurement) {
        if (!logIfFinished()) {
            this.startingMeasurement = startingMeasurement;
        }
    }

    public void setEndingMeasurement(Metrics endingMeasurement) {
        if (!logIfFinished()) {
            this.endingMeasurement = endingMeasurement;
        }
    }

    public void setMeasurementPool(MetricsPool measurementPool) {
        if (!logIfFinished()) {
            this.measurementPool = measurementPool;
        }
    }

    public void finish() {
        this.finished = true;
    }

    public boolean isFinished() {
        return this.finished;
    }

    private void throwIfFinished() {
        if (this.finished) {
            throw new MetricsException("Attempted to modify finished Measurement");
        }
    }

    private boolean logIfFinished() {
        if (this.finished) {
            log.warning("BaseMeasuredActivity: cannot modify finished Activity");
        }
        return this.finished;
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy