Skip to content

Commit

Permalink
feat: add domain field to subscriptions kafka msg (#382)
Browse files Browse the repository at this point in the history
  • Loading branch information
Theodus authored Aug 29, 2023
1 parent 8973013 commit d7c0c2a
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 2 deletions.
2 changes: 1 addition & 1 deletion graph-gateway/src/auth.rs
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ impl AuthHandler {
.flat_map(|s| s.split(','))
.collect(),
};
tracing::debug!(%domain, ?allowed_domains);
tracing::debug!(?allowed_domains);
let allow_domain =
allowed_domains.is_empty() || is_domain_authorized(&allowed_domains, domain);
ensure!(allow_domain, "Domain not authorized by user");
Expand Down
2 changes: 1 addition & 1 deletion graph-gateway/src/client_query.rs
Original file line number Diff line number Diff line change
Expand Up @@ -402,7 +402,7 @@ async fn handle_client_query_inner(
.last()
.map(|deployment| deployment.manifest.network.clone())
.ok_or_else(|| Error::InvalidSubgraph("No matching deployments".to_string()))?;
tracing::info!(target: reports::CLIENT_QUERY_TARGET, subgraph_chain);
tracing::info!(target: reports::CLIENT_QUERY_TARGET, subgraph_chain, domain);
// Make sure we only select from deployments indexing the same chain. This simplifies dealing
// with block constraints later.
deployments.retain(|deployment| deployment.manifest.network == subgraph_chain);
Expand Down
4 changes: 4 additions & 0 deletions graph-gateway/src/reports.rs
Original file line number Diff line number Diff line change
Expand Up @@ -214,6 +214,7 @@ fn report_client_query(
indexer_fees_grt: Option<f32>,
query: Option<String>,
variables: Option<String>,
domain: Option<String>,
}
let fields = match serde_json::from_value::<Fields>(fields.into()) {
Ok(fields) => fields,
Expand Down Expand Up @@ -260,6 +261,7 @@ fn report_client_query(
query_count: fields.query_count,
query_budget: fields.budget_grt,
indexer_fees: fields.indexer_fees_grt,
domain: fields.domain.filter(|d| !d.is_empty()),
};
kafka.send(subscriptions_topic, &payload.encode_to_vec());
}
Expand Down Expand Up @@ -452,6 +454,8 @@ pub struct GatewaySubscriptionQueryResult {
pub query_budget: Option<f32>,
#[prost(float, optional, tag = "11")]
pub indexer_fees: Option<f32>,
#[prost(string, optional, tag = "12")]
pub domain: Option<String>,
}

#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord, prost::Enumeration)]
Expand Down

0 comments on commit d7c0c2a

Please sign in to comment.