Skip to content
Merged
7 changes: 7 additions & 0 deletions NEXT_CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
19 changes: 16 additions & 3 deletions apollo-router/src/uplink/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
Expand Down Expand Up @@ -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();
}
Expand All @@ -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<String>,
Expand All @@ -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?
}
},
Expand Down