Skip to content

Commit

Permalink
Merge "File: handle stats for recursive transformation calls"
Browse files Browse the repository at this point in the history
  • Loading branch information
jenkins-bot authored and Gerrit Code Review committed Jun 20, 2024
2 parents 9fcd969 + 1d22bf1 commit 5fdc4f7
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions includes/filerepo/file/File.php
Original file line number Diff line number Diff line change
Expand Up @@ -1320,15 +1320,20 @@ public function generateAndSaveThumb( $tmpFile, $transformParams, $flags ) {
$this->generateBucketsIfNeeded( $normalisedParams, $flags );
}

$timer = $statsFactory->getTiming( 'media_thumbnail_generate_transform_seconds' )
->copyToStatsdAt( 'media.thumbnail.generate.transform' );
$timer->start();
# T367110
# Calls to doTransform() can recur back on $this->transform()
# depending on implementation. One such example is PagedTiffHandler.
# TimingMetric->start() and stop() cannot be used in this situation
# so we will track the time manually.
$starttime = microtime( true );

// Actually render the thumbnail...
$thumb = $handler->doTransform( $this, $tmpThumbPath, $thumbUrl, $transformParams );
$tmpFile->bind( $thumb ); // keep alive with $thumb

$timer->stop();
$statsFactory->getTiming( 'media_thumbnail_generate_transform_seconds' )
->copyToStatsdAt( 'media.thumbnail.generate.transform' )
->observe( ( microtime( true ) - $starttime ) * 1000 );

if ( !$thumb ) { // bad params?
$thumb = false;
Expand Down

0 comments on commit 5fdc4f7

Please sign in to comment.