diff --git a/NEXT_CHANGELOG.md b/NEXT_CHANGELOG.md index 363fdc518c..c562cdce0e 100644 --- a/NEXT_CHANGELOG.md +++ b/NEXT_CHANGELOG.md @@ -42,6 +42,13 @@ It defaults to 30 seconds. By [@o0Ignition0o](https://github.com/o0Ignition0o) in https://github.com/apollographql/router/pull/2271 ## 🐛 Fixes + +### Change log level when we can't get the schema from GCP ([Issue #2004](https://github.com/apollographql/router/issues/2004)) + +Set the log level for this specific log to `debug`. + +By [@bnjjj](https://github.com/bnjjj) in https://github.com/apollographql/router/pull/2215 + ### Traces won't cause missing field-stats ([Issue #2267](https://github.com/apollographql/router/issues/2267)) Previously if a request was sampled for tracing it was not contributing to metrics correctly. This was a particular problem for users with a high sampling rate. diff --git a/apollo-router/src/uplink/mod.rs b/apollo-router/src/uplink/mod.rs index b73b38f452..e9318bdacb 100644 --- a/apollo-router/src/uplink/mod.rs +++ b/apollo-router/src/uplink/mod.rs @@ -64,7 +64,9 @@ pub(crate) fn stream_supergraph( let mut current_url_idx = 0; loop { + let mut nb_errors = 0usize; match fetch_supergraph( + &mut nb_errors, api_key.to_string(), graph_ref.to_string(), composition_id.clone(), @@ -122,7 +124,6 @@ pub(crate) fn stream_supergraph( } }, Err(err) => { - tracing::error!("error fetching supergraph from Uplink: {:?}", err); if let Some(urls) = &urls { current_url_idx = (current_url_idx + 1) % urls.len(); } @@ -139,6 +140,7 @@ pub(crate) fn stream_supergraph( } pub(crate) async fn fetch_supergraph( + nb_errors: &mut usize, api_key: String, graph_ref: String, composition_id: Option, @@ -155,9 +157,20 @@ pub(crate) async fn fetch_supergraph( let response = match url { Some(url) => http_request(url.as_str(), &request_body, timeout).await?, None => match http_request(GCP_URL, &request_body, timeout).await { - Ok(response) => response, + Ok(response) => { + if *nb_errors > 0 { + *nb_errors = 0; + tracing::info!("successfully retrieved the schema from GCP"); + } + response + } Err(e) => { - tracing::error!("could not get schema from GCP, trying AWS: {:?}", e); + if *nb_errors == 3 { + tracing::error!("could not get schema from GCP, trying AWS: {:?}", e); + } else { + tracing::debug!("could not get schema from GCP, trying AWS: {:?}", e); + } + *nb_errors += 1; http_request(AWS_URL, &request_body, timeout).await? } },