AdManager API : Responding very slow to generate report.

425 views
Skip to first unread message

Manish Saraf

unread,
Jan 9, 2019, 2:05:19 AM1/9/19
to Google Ad Manager API Forum
I am using AdManager API to generate revenue report.
Over the past few days, we noticed that Google AdManager APIs showed a very slow response for generating requested data.
Earlier it was just 2 min job to complete, however now sometime it take +60mins to complete same job.

Why this slowness observed? Is any other way to achieve it
<?php
require 'vendor/autoload.php';
use Google\AdsApi\Common\OAuth2TokenBuilder;
use Google\AdsApi\AdManager\v201711\Dimension;
use Google\AdsApi\AdManager\AdManagerServices;
use Google\AdsApi\AdManager\AdManagerSession;
use Google\AdsApi\AdManager\AdManagerSessionBuilder;
use Google\AdsApi\AdManager\Util\v201802\ReportDownloader;
use Google\AdsApi\AdManager\Util\v201802\StatementBuilder;
use Google\AdsApi\AdManager\v201711\DateRangeType;
use Google\AdsApi\AdManager\v201802\ExportFormat;
use Google\AdsApi\AdManager\v201802\ReportJob;
use Google\AdsApi\AdManager\v201802\ReportQueryAdUnitView;
use Google\AdsApi\AdManager\v201802\ReportService;
use UnexpectedValueException;

class RunSavedQuery

{
    const SAVED_QUERY_ID = 'xxxxxxx';
    public static function runExample(
        AdManagerServices $AdManagerServices,
        AdManagerSession $session,
        $savedQueryId, $fileID
    ) {
$reportService = $AdManagerServices->get($session, ReportService::class);

        // Create statement to retrieve the saved query.
        $statementBuilder = (new StatementBuilder())->where('id = :id')
            ->orderBy('id ASC')
            ->limit(1)
            ->withBindVariableValue('id', $savedQueryId);
        $savedQueryPage = $reportService->getSavedQueriesByStatement(
            $statementBuilder->toStatement()
        );
        $savedQuery = $savedQueryPage->getResults()[0];
        if ($savedQuery->getIsCompatibleWithApiVersion() === false) {
            throw new UnexpectedValueException(
                'The saved query is not compatible with this API version.'
            );
        }
        // Optionally modify the query.
        $reportQuery = $savedQuery->getReportQuery();
        $reportQuery->setAdUnitView(ReportQueryAdUnitView::HIERARCHICAL);
        // Create report job using the saved query.
        $reportJob = new ReportJob();
        $reportJob->setReportQuery($reportQuery);
        $reportJob = $reportService->runReportJob($reportJob);
        // Create report downloader to poll report's status and download when ready.
        $reportDownloader = new ReportDownloader($reportService, $reportJob->getId());
        if ($reportDownloader->waitForReportToFinish()) {
            // Write to system temp directory by default.

            $filePath = 'googleRevenue.csv.gz';
            shell_exec('gunzip $filePath');
            printf("Downloading report to %s ...\n", $filePath);

            // Download the report.
            $reportDownloader->downloadReport(ExportFormat::CSV_DUMP, $filePath);
            print "done.\n";

        } else {

            print "Report failed.\n";
        }
    }

    public static function main()
    {
        global $argc, $argv;
        $oAuth2Credential = (new OAuth2TokenBuilder())->fromFile()
            ->build();

        $session = (new AdManagerSessionBuilder())->fromFile()
            ->withOAuth2Credential($oAuth2Credential)
            ->build();
        $fileID = $argv[1];
        self::runExample(new AdManagerServices(), $session, intval(self::SAVED_QUERY_ID),$fileID);
    }
}


RunSavedQuery::main();



Message has been deleted
Message has been deleted

Vincent Racaza (DFP API Team)

unread,
Jan 9, 2019, 3:41:03 AM1/9/19
to Google Ad Manager API Forum
Hi Manish,

The error that you encountered seems to be related to an ongoing issue on Ad Manager API reports and we are currently investigating this. In the meantime, can you provide the complete SOAP request and response logs with your network code so we can further check? You may use the Reply privately to author option when providing these details.

Thanks,
Vincent Racaza, Ad Manager API Team

Vincent Racaza (DFP API Team)

unread,
Jan 9, 2019, 10:58:25 PM1/9/19
to Google Ad Manager API Forum
Hi Manish,

Thank you for providing more details privately. There was a reporting latency issue recently and it has just been fixed today. Can you try to re-run the reports on your end and let me know if you're still encountering any issues? 

Thanks,
Vincent Racaza, Ad Manager API Team

Manish Saraf

unread,
Jan 10, 2019, 8:19:19 AM1/10/19
to dfpapi-advi...@google.com, Google Ad Manager API Forum
Hi Vincent,

Thanks a lot for the update. Reporting system works for me.

Best regards,
Manish


--
You received this message because you are subscribed to the Google Groups "Google Ad Manager API Forum" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-doubleclick-for-p...@googlegroups.com.
To post to this group, send email to google-doubleclick...@googlegroups.com.
Visit this group at https://groups.google.com/group/google-doubleclick-for-publishers-api.
For more options, visit https://groups.google.com/d/optout.

admanagerapi...@google.com

unread,
Jan 17, 2019, 9:36:50 PM1/17/19
to google-doubleclick...@googlegroups.com
Hi Manish,

My apologies for back and forth. Could you please provide the latest and complete SOAP request and response as it will help me to investigate the issue? You may use the Reply privately to author option when providing these details. If you haven't enabled SOAP logging, you can refer here on how to do it in the PHP client library.

Also, kindly note that there was an issue recently with reports that includes sales dimensions which causes it to fail, however, this should now be resolved as you can see in the Ads Status Dashboard. Kindly confirm if this is the scenario so I can provide you updates about this.

Thanks,
Kevin Soriano, Ad Manager API Team

On 01/09/19 15:12:09 manish....@gmail.com wrote:
Added Message
I continuously received below message for +60 mins

DFP_SOAP.INFO: networkCode=34230109 service=ReportService method=getReportJobStatus responseTime=115 requestId=5eb7872eb46dc7421a43604d23cdb4da server=ads.google.com isFault=0 faultMessage=
DFP_REPORT_DOWNLOADER.INFO: Report job ID 11085257360 has status IN_PROGRESS. Sleeping for 30 seconds before polling again for report status.
 
Reply all
Reply to author
Forward
0 new messages