Do not log image if it fails lifecycle assert in getWillRequestUrlTime

Reviewed By: sammy-SC

Differential Revision: D24990452

fbshipit-source-id: ce4d5ec9e3cf237c6edbd17368f2dcf3aecbec2b
This commit is contained in:
Paige Sun
2020-11-16 12:39:00 -08:00
committed by Facebook GitHub Bot
parent f1f7168795
commit 0937f13cc3
3 changed files with 5 additions and 17 deletions
@@ -10,17 +10,11 @@
namespace facebook {
namespace react {
void ImageTelemetry::willRequestUrl() {
assert(willRequestUrlTime_ == kTelemetryUndefinedTimePoint);
willRequestUrlTime_ = telemetryTimePointNow();
}
SurfaceId ImageTelemetry::getSurfaceId() const {
return surfaceId_;
}
TelemetryTimePoint ImageTelemetry::getWillRequestUrlTime() const {
assert(willRequestUrlTime_ != kTelemetryUndefinedTimePoint);
return willRequestUrlTime_;
}
@@ -15,25 +15,20 @@ namespace react {
/*
* Represents telemetry data associated with a image request
* where the willRequestUrlTime is the time at ImageTelemetry's creation.
*/
class ImageTelemetry final {
public:
ImageTelemetry(SurfaceId const surfaceId) : surfaceId_(surfaceId) {}
ImageTelemetry(SurfaceId const surfaceId) : surfaceId_(surfaceId) {
willRequestUrlTime_ = telemetryTimePointNow();
}
/*
* Signaling
*/
void willRequestUrl();
/*
* Reading
*/
TelemetryTimePoint getWillRequestUrlTime() const;
SurfaceId getSurfaceId() const;
private:
TelemetryTimePoint willRequestUrlTime_{kTelemetryUndefinedTimePoint};
TelemetryTimePoint willRequestUrlTime_;
const SurfaceId surfaceId_;
};
@@ -44,7 +44,6 @@ using namespace facebook::react;
std::shared_ptr<ImageTelemetry> telemetry;
if ([self->_imageLoader shouldEnablePerfLoggingForRequestUrl:request.URL]) {
telemetry = std::make_shared<ImageTelemetry>(surfaceId);
telemetry->willRequestUrl();
} else {
telemetry = nullptr;
}