Skip to content

Commit c76f20c

Browse files
committed
graphql: Use a query's hash and shape_hash as the query_id for timing logs
1 parent 80d916e commit c76f20c

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

graphql/src/query/mod.rs

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
use graph::prelude::{info, o, EthereumBlockPointer, Logger, QueryExecutionError};
22
use graphql_parser::query as q;
3+
use std::collections::hash_map::DefaultHasher;
34
use std::collections::BTreeMap;
5+
use std::hash::{Hash, Hasher};
46
use std::sync::{atomic::AtomicBool, Arc};
57
use std::time::Instant;
6-
use uuid::Uuid;
78

89
use graph::data::graphql::effort::LoadManager;
910

@@ -46,7 +47,12 @@ pub fn execute_query<R>(
4647
where
4748
R: Resolver,
4849
{
49-
let query_id = Uuid::new_v4().to_string();
50+
let query_hash = {
51+
let mut hasher = DefaultHasher::new();
52+
query.query_text.hash(&mut hasher);
53+
hasher.finish()
54+
};
55+
let query_id = format!("{:x}-{:x}", query.shape_hash, query_hash);
5056
let query_logger = options.logger.new(o!(
5157
"subgraph_id" => (*query.schema.id).clone(),
5258
"query_id" => query_id

0 commit comments

Comments
 (0)