David/devel/debug graph (#82)

* now should also group by archive_needed (turns out this was wanted)

* influxdb query also groups by archive_needed now

* updated error_response

* updated error_response
This commit is contained in:
David 2023-05-22 20:08:35 -04:00 committed by GitHub
parent ddfd1dbff1
commit 27333a0028
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 30 additions and 33 deletions

View File

@ -5,4 +5,4 @@
# https://github.com/INFURA/versus # https://github.com/INFURA/versus
# ./ethspam | ./versus --stop-after 100 "http://localhost:8544/" # Pipe into the endpoint ..., add a bearer token and all that # ./ethspam | ./versus --stop-after 100 "http://localhost:8544/" # Pipe into the endpoint ..., add a bearer token and all that
./ethspam http://127.0.0.1:8544 | ./versus --stop-after 100 http://localhost:8544 ./ethspam http://127.0.0.1:8544/rpc/01H0ZZJDNNEW49FRFS4D9SPR8B | ./versus --concurrency=4 --stop-after 100 http://localhost:8544/rpc/01H0ZZJDNNEW49FRFS4D9SPR8B

View File

@ -24,14 +24,14 @@ curl -X POST http://127.0.0.1:8544/user/login \
-H 'Content-Type: application/json' \ -H 'Content-Type: application/json' \
-d '{ -d '{
"address": "0xeb3e928a2e54be013ef8241d4c9eaf4dfae94d5a", "address": "0xeb3e928a2e54be013ef8241d4c9eaf4dfae94d5a",
"msg": "0x6c6c616d616e6f6465732e636f6d2077616e747320796f7520746f207369676e20696e207769746820796f757220457468657265756d206163636f756e743a0a3078654233453932384132453534424530313345463832343164344339456146344466414539344435610a0af09fa699f09fa699f09fa699f09fa699f09fa6990a0a5552493a2068747470733a2f2f6c6c616d616e6f6465732e636f6d2f0a56657273696f6e3a20310a436861696e2049443a20310a4e6f6e63653a203031475a4b384b4847305259474737514e5132475037464444470a4973737565642041743a20323032332d30352d30345431313a33333a32312e3533363734355a0a45787069726174696f6e2054696d653a20323032332d30352d30345431313a35333a32312e3533363734355a", "msg": "0x6c6c616d616e6f6465732e636f6d2077616e747320796f7520746f207369676e20696e207769746820796f757220457468657265756d206163636f756e743a0a3078654233453932384132453534424530313345463832343164344339456146344466414539344435610a0af09fa699f09fa699f09fa699f09fa699f09fa6990a0a5552493a2068747470733a2f2f6c6c616d616e6f6465732e636f6d2f0a56657273696f6e3a20310a436861696e2049443a20310a4e6f6e63653a20303148305a5a48434356324b32324738544850535758485131480a4973737565642041743a20323032332d30352d32315432303a32303a34332e3033353539315a0a45787069726174696f6e2054696d653a20323032332d30352d32315432303a34303a34332e3033353539315a",
"sig": "cebd9effff15f4517e53522dbe91798d59dc0df0299faaec25d3f6443fa121f847e4311d5ca7386e75b87d6d45df92b8ced58c822117519c666ab1a6b2fc7bd21b", "sig": "7591251840bf75d2ab7c895bc566a49d2f4c3ad6bb14d7256258a59e52055fc94c11f8f3836f5311b52fc18aca40867cd85802636645e1d757494800631cad381c",
"version": "3", "version": "3",
"signer": "MEW" "signer": "MEW"
}' }'
# bearer token is: 01GZK8MHHGQWK4VPGF97HS91MB # bearer token is: 01H0ZZJDQ2F02MAXZR5K1X5NCP
# scret key is: 01GZK65YNV0P0WN2SCXYTW3R9S # scret key is: 01H0ZZJDNNEW49FRFS4D9SPR8B
# 01GZH2PS89EJJY6V8JFCVTQ4BX # 01GZH2PS89EJJY6V8JFCVTQ4BX
# 01GZH2PS7CTHA3TAZ4HXCTX6KQ # 01GZH2PS7CTHA3TAZ4HXCTX6KQ
@ -42,7 +42,7 @@ curl -X POST http://127.0.0.1:8544/user/login \
# Check the balance of the user # Check the balance of the user
# Balance seems to be returning properly (0, in this test case) # Balance seems to be returning properly (0, in this test case)
curl \ curl \
-H "Authorization: Bearer 01GZK8MHHGQWK4VPGF97HS91MB" \ -H "Authorization: Bearer 01H0ZZJDQ2F02MAXZR5K1X5NCP" \
-X GET "127.0.0.1:8544/user/balance" -X GET "127.0.0.1:8544/user/balance"
@ -73,10 +73,10 @@ curl \
## Check if calling an RPC endpoint logs the stats ## Check if calling an RPC endpoint logs the stats
## This one does already even it seems ## This one does already even it seems
for i in {1..100} for i in {1..300}
do do
curl \ curl \
-X POST "127.0.0.1:8544/rpc/01GZK65YNV0P0WN2SCXYTW3R9S" \ -X POST "127.0.0.1:8544/rpc/01H0ZZJDNNEW49FRFS4D9SPR8B" \
-H "Content-Type: application/json" \ -H "Content-Type: application/json" \
--data '{"method":"eth_blockNumber","params":[],"id":1,"jsonrpc":"2.0"}' --data '{"method":"eth_blockNumber","params":[],"id":1,"jsonrpc":"2.0"}'
done done

View File

@ -73,7 +73,9 @@ pub async fn query_user_stats<'a>(
let mut join_candidates: Vec<String> = vec![ let mut join_candidates: Vec<String> = vec![
"_time".to_string(), "_time".to_string(),
"_measurement".to_string(), "_measurement".to_string(),
"archive_needed".to_string(),
"chain_id".to_string(), "chain_id".to_string(),
"error_response".to_string(),
]; ];
// Include a hashmap to go from rpc_secret_key_id to the rpc_secret_key // Include a hashmap to go from rpc_secret_key_id to the rpc_secret_key
@ -184,35 +186,18 @@ pub async fn query_user_stats<'a>(
{filter_chain_id} {filter_chain_id}
{drop_method} {drop_method}
// cumsum = base
base base
|> aggregateWindow(every: {query_window_seconds}s, fn: sum, createEmpty: false) |> aggregateWindow(every: {query_window_seconds}s, fn: sum, createEmpty: false)
|> pivot(rowKey: ["_time"], columnKey: ["_field"], valueColumn: "_value") |> pivot(rowKey: ["_time"], columnKey: ["_field"], valueColumn: "_value")
|> drop(columns: ["balance"]) |> drop(columns: ["balance"])
|> map(fn: (r) => ({{ r with "archive_needed": if r.archive_needed == "true" then r.frontend_requests else 0}})) |> group(columns: ["_time", "_measurement", "archive_needed", "chain_id", "error_response", "method", "rpc_secret_key_id"])
|> map(fn: (r) => ({{ r with "error_response": if r.error_response == "true" then r.frontend_requests else 0}}))
|> group(columns: ["_time", "_measurement", "chain_id", "method", "rpc_secret_key_id"])
|> sort(columns: ["frontend_requests"]) |> sort(columns: ["frontend_requests"])
|> map(fn:(r) => ({{ r with "sum_credits_used": float(v: r["sum_credits_used"]) }})) |> map(fn:(r) => ({{ r with "sum_credits_used": float(v: r["sum_credits_used"]) }}))
|> cumulativeSum(columns: ["archive_needed", "error_response", "backend_requests", "cache_hits", "cache_misses", "frontend_requests", "sum_credits_used", "sum_request_bytes", "sum_response_bytes", "sum_response_millis"]) |> cumulativeSum(columns: ["backend_requests", "cache_hits", "cache_misses", "frontend_requests", "sum_credits_used", "sum_request_bytes", "sum_response_bytes", "sum_response_millis"])
|> sort(columns: ["frontend_requests"], desc: true) |> sort(columns: ["frontend_requests"], desc: true)
|> limit(n: 1) |> limit(n: 1)
|> group() |> group()
|> sort(columns: ["_time", "_measurement", "chain_id", "method", "rpc_secret_key_id"], desc: true) |> sort(columns: ["_time", "_measurement", "archive_needed", "chain_id", "error_response", "method", "rpc_secret_key_id"], desc: true)
// balance = base
// |> toFloat()
// |> aggregateWindow(every: {query_window_seconds}s, fn: mean, createEmpty: false)
// |> pivot(rowKey: ["_time"], columnKey: ["_field"], valueColumn: "_value")
// |> group(columns: ["_time", "_measurement", "chain_id", "method", "rpc_secret_key_id"])
// |> mean(column: "balance")
// |> group()
// |> sort(columns: ["_time", "_measurement", "chain_id", "method", "rpc_secret_key_id"], desc: true)
// join(
// tables: {{cumsum, balance}},
// on: {join_candidates}
// )
"#); "#);
info!("Raw query to db is: {:?}", query); info!("Raw query to db is: {:?}", query);
@ -438,22 +423,34 @@ pub async fn query_user_stats<'a>(
} }
} else if key == "archive_needed" { } else if key == "archive_needed" {
match value { match value {
influxdb2_structmap::value::Value::Long(inner) => { influxdb2_structmap::value::Value::String(inner) => {
out.insert( out.insert(
"archive_needed".to_owned(), "archive_needed".to_owned(),
serde_json::Value::Number(inner.into()), if inner == "true" {
serde_json::Value::Bool(true)
} else if inner == "false" {
serde_json::Value::Bool(false)
} else {
serde_json::Value::String("error".to_owned())
},
); );
} }
_ => { _ => {
error!("archive_needed should always be a Long!"); error!("archive_needed should always be a String!");
} }
} }
} else if key == "error_response" { } else if key == "error_response" {
match value { match value {
influxdb2_structmap::value::Value::Long(inner) => { influxdb2_structmap::value::Value::String(inner) => {
out.insert( out.insert(
"error_response".to_owned(), "error_response".to_owned(),
serde_json::Value::Number(inner.into()), if inner == "true" {
serde_json::Value::Bool(true)
} else if inner == "false" {
serde_json::Value::Bool(false)
} else {
serde_json::Value::String("error".to_owned())
},
); );
} }
_ => { _ => {