Tracing/ Metrics/ Logs: Improve empty states
What does this MR do and why?
Update empty states when on data is found for traces, logs and metrics.
Part of Tracing/ Metrics/ Logs: Empty states (gitlab-org/opstrace/opstrace#2834 - closed)
MR acceptance checklist
Please evaluate this MR against the MR acceptance checklist. It helps you analyze changes to reduce risks in quality, performance, reliability, security, and maintainability.
Screenshots or screen recordings
How to set up and validate locally
- Prerequisites: be logged in and running GDK with Ultimate license
- Enable
:observability_tracing
feature flag - Enable
:observability_logs
feature flag - Enable
:observability_metrics
feature flag
Apply patch to load mocks ( copy the patch content below and run in your terminal: pbpaste | git apply
)
pbpaste | git apply
)diff --git a/app/assets/javascripts/observability/client.js b/app/assets/javascripts/observability/client.js
index 57efb690804e..ba7eeab702ea 100644
--- a/app/assets/javascripts/observability/client.js
+++ b/app/assets/javascripts/observability/client.js
@@ -1,3 +1,4 @@
+/* eslint-disable @gitlab/require-i18n-strings */
import { isValidDate } from '~/lib/utils/datetime_utility';
import * as Sentry from '~/sentry/sentry_browser_wrapper';
import axios from '~/lib/utils/axios_utils';
@@ -15,15 +16,17 @@ function reportErrorAndThrow(e) {
* Provisioning API
*
* ***** */
+function mockReturnDataWithDelay(data) {
+ return new Promise((resolve) => {
+ setTimeout(() => resolve(data), 1000);
+ });
+}
// Provisioning API spec: https://gitlab.com/gitlab-org/opstrace/opstrace/-/blob/main/provisioning-api/pkg/provisioningapi/routes.go#L59
async function enableObservability(provisioningUrl) {
try {
- // Note: axios.put(url, undefined, {withCredentials: true}) does not send cookies properly, so need to use the API below for the correct behaviour
- return await axios(provisioningUrl, {
- method: 'put',
- withCredentials: true,
- });
+ console.log('[DEBUG] Enabling Observability');
+ return mockReturnDataWithDelay();
} catch (e) {
return reportErrorAndThrow(e);
}
@@ -32,19 +35,14 @@ async function enableObservability(provisioningUrl) {
// Provisioning API spec: https://gitlab.com/gitlab-org/opstrace/opstrace/-/blob/main/provisioning-api/pkg/provisioningapi/routes.go#L37
async function isObservabilityEnabled(provisioningUrl) {
try {
- const { data } = await axios.get(provisioningUrl, { withCredentials: true });
- if (data && data.status) {
- // we currently ignore the 'status' payload and just check if the request was successful
- // We might improve this as part of https://gitlab.com/gitlab-org/opstrace/opstrace/-/issues/2315
- return true;
- }
+ console.log('[DEBUG] Checking Observability provisioning');
+ return mockReturnDataWithDelay(true);
} catch (e) {
if (e.response.status === 404) {
return false;
}
return reportErrorAndThrow(e);
}
- return reportErrorAndThrow(new Error('Failed to check provisioning')); // eslint-disable-line @gitlab/require-i18n-strings
}
/** ****
@@ -265,15 +263,7 @@ async function fetchTraces(
params.append('sort', sortOrder);
try {
- const { data } = await axios.get(tracingUrl, {
- withCredentials: true,
- params,
- signal: abortController?.signal,
- });
- if (!Array.isArray(data.traces)) {
- throw new Error('traces are missing/invalid in the response'); // eslint-disable-line @gitlab/require-i18n-strings
- }
- return data;
+ return mockReturnDataWithDelay({ traces: [] });
} catch (e) {
return reportErrorAndThrow(e);
}
@@ -292,12 +282,7 @@ async function fetchTracesAnalytics(tracingAnalyticsUrl, { filters = {}, abortCo
}
try {
- const { data } = await axios.get(tracingAnalyticsUrl, {
- withCredentials: true,
- params,
- signal: abortController?.signal,
- });
- return data.results ?? [];
+ return mockReturnDataWithDelay([]);
} catch (e) {
return reportErrorAndThrow(e);
}
@@ -378,14 +363,7 @@ async function fetchMetrics(metricsUrl, { filters = {}, limit } = {}) {
handleMetricsAttributeFilters(filters.attribute, params);
}
- const { data } = await axios.get(metricsUrl, {
- withCredentials: true,
- params,
- });
- if (!Array.isArray(data.metrics)) {
- throw new Error('metrics are missing/invalid in the response'); // eslint-disable-line @gitlab/require-i18n-strings
- }
- return data;
+ return mockReturnDataWithDelay({ metrics: [] });
} catch (e) {
return reportErrorAndThrow(e);
}
@@ -485,11 +463,7 @@ async function fetchMetricSearchMetadata(searchMetadataUrl, name, type) {
mname: name,
mtype: type,
});
- const { data } = await axios.get(searchMetadataUrl, {
- params,
- withCredentials: true,
- });
- return data;
+ return mockReturnDataWithDelay({});
} catch (e) {
return reportErrorAndThrow(e);
}
@@ -595,18 +569,12 @@ export async function fetchLogs(
if (pageSize) {
params.append('page_size', pageSize);
}
- const { data } = await axios.get(logsSearchUrl, {
- withCredentials: true,
- params,
- signal: abortController?.signal,
+
+ console.log(`[DEBUG] Fetching logs with params: ${params.toString()}`);
+
+ return mockReturnDataWithDelay({
+ logs: [],
});
- if (!Array.isArray(data.results)) {
- throw new Error('logs are missing/invalid in the response'); // eslint-disable-line @gitlab/require-i18n-strings
- }
- return {
- logs: data.results,
- nextPageToken: data.next_page_token,
- };
} catch (e) {
return reportErrorAndThrow(e);
}
@@ -628,12 +596,7 @@ export async function fetchLogsSearchMetadata(
addLogsAttributesFiltersToQueryParams(attributes, params);
}
- const { data } = await axios.get(logsSearchMetadataUrl, {
- withCredentials: true,
- params,
- signal: abortController?.signal,
- });
- return data;
+ return mockReturnDataWithDelay({});
} catch (e) {
return reportErrorAndThrow(e);
}
diff --git a/app/assets/javascripts/observability/components/observability_container.vue b/app/assets/javascripts/observability/components/observability_container.vue
index d0902505ca73..f6cbf7ee771f 100644
--- a/app/assets/javascripts/observability/components/observability_container.vue
+++ b/app/assets/javascripts/observability/components/observability_container.vue
@@ -27,12 +27,12 @@ export default {
// TODO: Improve local GDK dev experience with tracing https://gitlab.com/gitlab-org/opstrace/opstrace/-/issues/2308
// Uncomment the lines below to to test this locally
- // setTimeout(() => {
- // this.messageHandler({
- // data: { type: 'AUTH_COMPLETION', status: 'success' },
- // origin: new URL(this.apiConfig.oauthUrl).origin,
- // });
- // }, 2000);
+ setTimeout(() => {
+ this.messageHandler({
+ data: { type: 'AUTH_COMPLETION', status: 'success' },
+ origin: new URL(this.apiConfig.oauthUrl).origin,
+ });
+ }, 2000);
},
destroyed() {
window.removeEventListener('message', this.messageHandler);
Edited by Daniele Rossetti