Skip to content

Commit 85290ec

Browse files
author
Adam Tackett
committed
fix timestamps
Signed-off-by: Adam Tackett <tackadam@amazon.com>
1 parent bb11b95 commit 85290ec

File tree

2 files changed

+49
-4
lines changed

2 files changed

+49
-4
lines changed

.cypress/integration/apm_test/apm_services.spec.js

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -204,9 +204,48 @@ describe('APM Services Page', () => {
204204
cy.get('.euiModal').should('not.exist');
205205
cy.get('[data-test-subj="globalLoadingIndicator"]').should('not.exist');
206206

207+
// Intercept all network requests to capture what the UI actually calls
208+
cy.intercept('**/api/**').as('apiCall');
209+
cy.intercept('POST', '**/observability/**').as('observabilityCall');
210+
cy.intercept('**/prometheus/**').as('prometheusCall');
211+
207212
// Set time range
208213
setAPMTimeRange(startTime, endTime);
209214

215+
// Wait for loading to complete after time range change
216+
cy.get('[data-test-subj="globalLoadingIndicator"]', { timeout: 10000 }).should('not.exist');
217+
218+
// Capture and log all API calls made by the UI
219+
cy.get('@apiCall.all').then((interceptions) => {
220+
cy.task('log', `=== UI Made ${interceptions.length} API Calls ===`);
221+
interceptions.forEach((interception, index) => {
222+
const url = interception.request.url;
223+
const method = interception.request.method;
224+
const status = interception.response && interception.response.statusCode
225+
? interception.response.statusCode
226+
: 'pending';
227+
228+
// Log all calls but focus on those that might be related to our widgets
229+
if (url.includes('prometheus') ||
230+
url.includes('query') ||
231+
url.includes('observability') ||
232+
url.includes('ppl') ||
233+
url.includes('dataconnections')) {
234+
cy.task('log', `\n[${index + 1}] ${method} ${url}`);
235+
cy.task('log', ` Status: ${status}`);
236+
237+
if (interception.request.body) {
238+
cy.task('log', ` Request Body: ${JSON.stringify(interception.request.body).substring(0, 500)}`);
239+
}
240+
241+
if (interception.response && interception.response.body) {
242+
const respBody = JSON.stringify(interception.response.body);
243+
cy.task('log', ` Response: ${respBody.substring(0, 500)}`);
244+
}
245+
}
246+
});
247+
});
248+
210249
// Debug: Check Prometheus metrics and actual UI queries
211250
cy.log('=== DEBUG: Checking Prometheus metrics and queries ===');
212251
cy.task('log', `Test time range: ${startTime} to ${endTime}`);

.cypress/utils/apm_data_helpers.js

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,12 @@ const adjustTimestampToNow = (isoString, baseTime, currentTime) => {
2828
*/
2929
export const uploadAPMDataToOpenSearch = () => {
3030
const BASE_TIMESTAMP = 1770252300; // Base time from the data (Feb 5, 2026 00:45:00 UTC)
31+
const MAX_TIMESTAMP = 1770253200; // Maximum timestamp (15 minutes after base)
3132
const currentTime = getCurrentUnixTime();
3233

34+
// Use MAX_TIMESTAMP as reference so latest data appears as "now" (matching metrics_server.js)
35+
const baseTime = MAX_TIMESTAMP;
36+
3337
const apmDataSets = [
3438
{
3539
index: 'otel_v1_apm_span_explore',
@@ -98,7 +102,7 @@ export const uploadAPMDataToOpenSearch = () => {
98102
documents.forEach((doc) => {
99103
timestampFields.forEach((field) => {
100104
if (doc[field]) {
101-
doc[field] = adjustTimestampToNow(doc[field], BASE_TIMESTAMP, currentTime);
105+
doc[field] = adjustTimestampToNow(doc[field], baseTime, currentTime);
102106
}
103107
});
104108
});
@@ -265,12 +269,14 @@ export const verifyPrometheusReady = (prometheusUrl) => {
265269
*/
266270
export const getAPMTestTimeRange = () => {
267271
const BASE_TIMESTAMP = 1770252300; // Base time from the data (Feb 5, 2026 00:45:00 UTC)
272+
const MAX_TIMESTAMP = 1770253200; // Maximum timestamp (15 minutes after base)
268273
const currentTime = getCurrentUnixTime();
269-
const timeOffset = currentTime - BASE_TIMESTAMP;
274+
const timeOffset = currentTime - MAX_TIMESTAMP;
270275

271276
// Data spans approximately 15 minutes, use 24 hour buffer for range queries
272-
const startTime = new Date((BASE_TIMESTAMP + timeOffset - 86400) * 1000); // 1 day before
273-
const endTime = new Date((BASE_TIMESTAMP + timeOffset + 86400) * 1000); // 1 day after
277+
// Center the range around MAX_TIMESTAMP (latest data) so it appears as "now"
278+
const startTime = new Date((MAX_TIMESTAMP + timeOffset - 86400) * 1000); // 1 day before
279+
const endTime = new Date((MAX_TIMESTAMP + timeOffset + 86400) * 1000); // 1 day after
274280

275281
return {
276282
start: startTime,

0 commit comments

Comments
 (0)