Skip to content

Expose correlation ID to Apollo client

Elwyn Benson requested to merge elwyn-expose-correlation-id into master

What does this MR do and why?

Exposes the X-Request-Id header (containing the correlation id for the current request) and hooks up an ApolloLink to read it, and inject it into each response.

This means any frontend component using Apollo client will be able to easily get at the current correlation ID, and use it to associate (error logs, tracking events etc) with the rest of the request logging.

This MR is being done in anticipation of using the correlation ID in Collect feedback on natural language querying f... (!148354 - merged)

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

No visual differences.

How to set up and validate locally

This isn't being consumed anywhere yet, so your best bet for verification is using devtools.

If you have product analytics and gitlab duo running locally, you can see the intended future usage with this console.log patch:

patch
diff --git a/ee/app/assets/javascripts/analytics/analytics_dashboards/components/visualization_designer/ai_cube_query_generator.vue b/ee/app/assets/javascripts/analytics/analytics_dashboards/components/visualization_designer/ai_cube_query_generator.vue
index 6026c86c3419..f733efacdd5e 100644
--- a/ee/app/assets/javascripts/analytics/analytics_dashboards/components/visualization_designer/ai_cube_query_generator.vue
+++ b/ee/app/assets/javascripts/analytics/analytics_dashboards/components/visualization_designer/ai_cube_query_generator.vue
@@ -82,7 +82,7 @@ export default {
       this.error = null;
 
       try {
-        await this.$apollo.mutate({
+        const { correlationId } = await this.$apollo.mutate({
           mutation: generateCubeQuery,
           variables: {
             question: this.prompt,
@@ -91,6 +91,7 @@ export default {
             htmlResponse: false,
           },
         });
+        console.log('Ding! Got correlation ID: ', correlationId);
       } catch (error) {
         this.handleErrors([error]);
         this.submitting = false;

Otherwise try debugging/logging in some other feature in a similar way

Edited by Elwyn Benson

Merge request reports