如何检查我的响应是否包含采样数据

How to check if my response contains sampled data

我正在使用 Google.Apis.AnalyticsReporting.v4 下载两天之间的视图。我想知道在我的回复中哪里可以看到数据是否包含采样数据?

这是我的请求代码,我们在下面的 response 对象中捕获数据:

using (var analytics = new AnalyticsReportingService(new BaseClientService.Initializer { HttpClientInitializer = credential }))
{
    while (nextPageToken != null)
    {
        var reportRequest = new ReportRequest
        {
            ViewId = "123456",
            DateRanges = new[] { new DateRange { StartDate = "2021-06-01", EndDate = "2021-11-30" } },
            Dimensions = new List<Dimension>() {
                new Dimension { Name = "ga:transactionId" },
                new Dimension { Name = "ga:campaign" },
                new Dimension { Name = "ga:sourceMedium" }
            },
            Metrics = new[] { new Metric { Expression = "ga:users" }, new Metric { Expression = "ga:sessions" } },
                       
        };
        var requests = new List<ReportRequest>();
        requests.Add(reportRequest);
        // Create the GetReportsRequest object.
        var getReport = new GetReportsRequest() { ReportRequests = requests };

        // Call the batchGet method.
        var response = analytics.Reports.BatchGet(getReport).Execute();
    }
}

它不对通过Google.Apis.AnalyticsReporting.v4请求的数据进行采样。但是,如果您的查询过于复杂,则会 return 出现 5xx 错误。看起来它会阻止其后端执行查询的时间过长以避免高负载。在这种情况下,您需要将您的请求分成几个部分。