Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add more Cirrus error logging info #5483

Merged
merged 7 commits into from
Jan 14, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions src/app/functions/server/getExperimentationId.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,9 @@ export function getExperimentationId(
// If the user is logged in, use the Subscriber ID.
const namespace = process.env.NIMBUS_UUID_NAMESPACE;
if (!namespace) {
logger.error(
"NIMBUS_UUID_NAMESPACE environment variable is missing. Cannot generate experimentationId.",
);
throw new Error(
"NIMBUS_UUID_NAMESPACE not set, cannot create experimentationId",
);
Expand All @@ -47,6 +50,9 @@ export function getExperimentationId(
);
return "guest-no-experimentation-id-set-by-monitor-middleware";
}
logger.info("Using experimentationId from header for guest user", {
experimentationId,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Likewise here, let's just lot that this is being set without logging the ID.

});
return experimentationId as ExperimentationId;
}
}
20 changes: 19 additions & 1 deletion src/app/functions/server/getExperiments.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,11 @@ export async function getExperiments(params: {
serverUrl.searchParams.set("nimbus_preview", "true");
}

logger.info("Sending request to Cirrus", {
serverUrl: serverUrl.toString(),
previewMode: params.previewMode,
});

const response = await fetch(serverUrl, {
headers: {
"Content-Type": "application/json",
Expand All @@ -65,6 +70,14 @@ export async function getExperiments(params: {
}),
});

if (!response.ok) {
logger.error("Cirrus request failed", {
status: response.status,
url: serverUrl.toString(),
});
throw new Error(`Cirrus request failed: ${response.statusText}`);
}

const json = await response.json();

let experimentData;
Expand All @@ -76,7 +89,12 @@ export async function getExperiments(params: {

return (experimentData as ExperimentData) ?? defaultExperimentData;
} catch (ex) {
logger.error("Could not connect to Cirrus", { serverUrl, ex });
logger.error("Could not connect to Cirrus", {
serverUrl,
ex,
flags,
params,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think in this case it's OK (since we could be sending invalid params)

});
captureException(ex);
return defaultExperimentData;
}
Expand Down
Loading