From 322f62b08ac3dca52b95262b2074d86765daad12 Mon Sep 17 00:00:00 2001 From: Jayesh Bapu Ahire Date: Mon, 24 Aug 2020 15:27:20 +0530 Subject: [PATCH 1/7] added general purpose queries in readme along with one line description --- README.md | 162 +++++++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 161 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index b326fb14..9bdaf2c6 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,5 @@ # Hypertrace GraphQL - +Hypertrace GraphQL service serves the GraphQL API which will be used by Hypertrace UI. ## Testing @@ -13,3 +13,163 @@ GraphQL Service runs on port 23431 at `/graphql` by default + +## Queries +Here are some of the important graphql queries: + +### 1. Get all traces in provided time range + +```curl +curl 'http://localhost:2020/graphql' -H 'Content-Type: application/graphql' -d\ +'{ + traces( + type: API_TRACE + between: { + startTime: "2015-01-01T00:00:00.000Z" + endTime: "2025-01-01T00:00:00.000Z" + } + ) { + results { + id + } + } +}' +``` + +### 2. Find trace using TraceID + +```curl +curl 'http://localhost:2020/graphql' -H 'Content-Type: application/graphql' -d \ +'{ + traces( + type: API_TRACE + between: { + startTime: "2015-01-01T00:00:00.000Z" + endTime: "2025-01-01T00:00:00.000Z" + } + filterBy: [ + { + operator: EQUALS + value: "431fd38511f63001" + type: ID + idType: API_TRACE + } + ] + ) { + results { + id + } + } +}' +``` + +### 3. Get all services your application is using + +```curl +curl 'http://localhost:2020/graphql' -H 'Content-Type: application/graphql' -d \ +'{ + entities( + type: SERVICE + between: { + startTime: "2015-01-01T00:00:00Z" + endTime: "2025-01-01T00:00:00Z" + } + offset: 0 + ) { + results { + id + name: attribute(key: "name") + } + total + } +}' +``` + +### 4. Get all backends your application is using + +```curl +curl 'http://localhost:2020/graphql' -H 'Content-Type: application/graphql' -d \ +'{ + entities( + type: BACKEND + between: { + startTime: "2015-01-01T00:00:00Z" + endTime: "2025-01-01T00:00:00Z" + } + offset: 0 + ) { + results { + id + name: attribute(key: "name") + } + total + } +}' +``` + +### 5. Get all API's your application is using + +```curl +curl 'http://localhost:2020/graphql' -H 'Content-Type: application/graphql' -d \ +'{ + entities( + type: API + between: { + startTime: "2015-01-01T00:00:00Z" + endTime: "2025-01-01T00:00:00Z" + } + offset: 0 + ) { + results { + id + name: attribute(key: "name") + } + total + } +}' +``` + +### 6. Get service and backend dependency graph + +```curl +curl 'http://localhost:2020/graphql' -H 'Content-Type: application/graphql' -d \ +'{ + entities( + type: SERVICE + limit: 100 + between: { + startTime: "2015-01-01T00:00:00.000Z" + endTime: "2025-01-01T00:00:00.000Z" + } + ) { + results { + id + name: attribute(key: "name") + outgoingEdges_SERVICE: outgoingEdges(neighborType: SERVICE) { + results { + neighbor { + id + name: attribute(key: "name") + } + } + } + outgoingEdges_BACKEND: outgoingEdges(neighborType: BACKEND) { + results { + neighbor { + id + name: attribute(key: "name") + } + } + } + incomingEdges_SERVICE: incomingEdges(neighborType: SERVICE) { + results { + neighbor { + id + name: attribute(key: "name") + } + } + } + } + } +}' +``` \ No newline at end of file From 3fab1440076079ab8ef7eb11abc0598c51fc832c Mon Sep 17 00:00:00 2001 From: Jayesh Bapu Ahire Date: Mon, 24 Aug 2020 15:30:06 +0530 Subject: [PATCH 2/7] updated formatting --- README.md | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index 9bdaf2c6..3823654e 100644 --- a/README.md +++ b/README.md @@ -19,7 +19,7 @@ Here are some of the important graphql queries: ### 1. Get all traces in provided time range -```curl +```graphql curl 'http://localhost:2020/graphql' -H 'Content-Type: application/graphql' -d\ '{ traces( @@ -38,7 +38,7 @@ curl 'http://localhost:2020/graphql' -H 'Content-Type: application/graphql' -d\ ### 2. Find trace using TraceID -```curl +```graphql curl 'http://localhost:2020/graphql' -H 'Content-Type: application/graphql' -d \ '{ traces( @@ -65,7 +65,7 @@ curl 'http://localhost:2020/graphql' -H 'Content-Type: application/graphql' -d \ ### 3. Get all services your application is using -```curl +```graphql curl 'http://localhost:2020/graphql' -H 'Content-Type: application/graphql' -d \ '{ entities( @@ -87,7 +87,7 @@ curl 'http://localhost:2020/graphql' -H 'Content-Type: application/graphql' -d \ ### 4. Get all backends your application is using -```curl +```graphql curl 'http://localhost:2020/graphql' -H 'Content-Type: application/graphql' -d \ '{ entities( @@ -109,7 +109,7 @@ curl 'http://localhost:2020/graphql' -H 'Content-Type: application/graphql' -d \ ### 5. Get all API's your application is using -```curl +```graphql curl 'http://localhost:2020/graphql' -H 'Content-Type: application/graphql' -d \ '{ entities( @@ -131,7 +131,7 @@ curl 'http://localhost:2020/graphql' -H 'Content-Type: application/graphql' -d \ ### 6. Get service and backend dependency graph -```curl +```graphql curl 'http://localhost:2020/graphql' -H 'Content-Type: application/graphql' -d \ '{ entities( From 0b13c58f26efdeac992123f9b5a7eccce6aa4db4 Mon Sep 17 00:00:00 2001 From: Jayesh Bapu Ahire Date: Tue, 25 Aug 2020 08:36:05 +0530 Subject: [PATCH 3/7] updated queries as per suggestions --- README.md | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index 3823654e..a1c49a15 100644 --- a/README.md +++ b/README.md @@ -20,7 +20,7 @@ Here are some of the important graphql queries: ### 1. Get all traces in provided time range ```graphql -curl 'http://localhost:2020/graphql' -H 'Content-Type: application/graphql' -d\ +curl -s http://localhost:2020/graphql -H 'Content-Type: application/graphql' -d\ '{ traces( type: API_TRACE @@ -39,7 +39,7 @@ curl 'http://localhost:2020/graphql' -H 'Content-Type: application/graphql' -d\ ### 2. Find trace using TraceID ```graphql -curl 'http://localhost:2020/graphql' -H 'Content-Type: application/graphql' -d \ +curl -s http://localhost:2020/graphql -H 'Content-Type: application/graphql' -d \ '{ traces( type: API_TRACE @@ -50,7 +50,7 @@ curl 'http://localhost:2020/graphql' -H 'Content-Type: application/graphql' -d \ filterBy: [ { operator: EQUALS - value: "431fd38511f63001" + value: "348bae39282251a5" type: ID idType: API_TRACE } @@ -58,6 +58,7 @@ curl 'http://localhost:2020/graphql' -H 'Content-Type: application/graphql' -d \ ) { results { id + apiName: attribute(key: "apiName") } } }' @@ -66,7 +67,7 @@ curl 'http://localhost:2020/graphql' -H 'Content-Type: application/graphql' -d \ ### 3. Get all services your application is using ```graphql -curl 'http://localhost:2020/graphql' -H 'Content-Type: application/graphql' -d \ +curl -s http://localhost:2020/graphql -H 'Content-Type: application/graphql' -d \ '{ entities( type: SERVICE @@ -88,7 +89,7 @@ curl 'http://localhost:2020/graphql' -H 'Content-Type: application/graphql' -d \ ### 4. Get all backends your application is using ```graphql -curl 'http://localhost:2020/graphql' -H 'Content-Type: application/graphql' -d \ +curl -s http://localhost:2020/graphql -H 'Content-Type: application/graphql' -d \ '{ entities( type: BACKEND @@ -110,7 +111,7 @@ curl 'http://localhost:2020/graphql' -H 'Content-Type: application/graphql' -d \ ### 5. Get all API's your application is using ```graphql -curl 'http://localhost:2020/graphql' -H 'Content-Type: application/graphql' -d \ +curl -s http://localhost:2020/graphql -H 'Content-Type: application/graphql' -d \ '{ entities( type: API @@ -132,7 +133,7 @@ curl 'http://localhost:2020/graphql' -H 'Content-Type: application/graphql' -d \ ### 6. Get service and backend dependency graph ```graphql -curl 'http://localhost:2020/graphql' -H 'Content-Type: application/graphql' -d \ +curl -s http://localhost:2020/graphql -H 'Content-Type: application/graphql' -d \ '{ entities( type: SERVICE From b4f105abb8fae5a3a112e2c0a1c7bf514f49cce4 Mon Sep 17 00:00:00 2001 From: Jayesh Bapu Ahire Date: Tue, 25 Aug 2020 11:29:50 +0530 Subject: [PATCH 4/7] updated queries --- README.md | 20 +++++++------------- 1 file changed, 7 insertions(+), 13 deletions(-) diff --git a/README.md b/README.md index a1c49a15..c81ac2cb 100644 --- a/README.md +++ b/README.md @@ -15,12 +15,12 @@ GraphQL Service runs on port 23431 at `/graphql` by default ## Queries -Here are some of the important graphql queries: +Here are some of the important GraphQL queries: ### 1. Get all traces in provided time range ```graphql -curl -s http://localhost:2020/graphql -H 'Content-Type: application/graphql' -d\ +curl -s localhost:2020/graphql -H 'Content-Type: application/graphql' -d\ '{ traces( type: API_TRACE @@ -39,7 +39,7 @@ curl -s http://localhost:2020/graphql -H 'Content-Type: application/graphql' -d\ ### 2. Find trace using TraceID ```graphql -curl -s http://localhost:2020/graphql -H 'Content-Type: application/graphql' -d \ +curl -s localhost:2020/graphql -H 'Content-Type: application/graphql' -d \ '{ traces( type: API_TRACE @@ -67,7 +67,7 @@ curl -s http://localhost:2020/graphql -H 'Content-Type: application/graphql' -d ### 3. Get all services your application is using ```graphql -curl -s http://localhost:2020/graphql -H 'Content-Type: application/graphql' -d \ +curl -s localhost:2020/graphql -H 'Content-Type: application/graphql' -d \ '{ entities( type: SERVICE @@ -78,7 +78,6 @@ curl -s http://localhost:2020/graphql -H 'Content-Type: application/graphql' -d offset: 0 ) { results { - id name: attribute(key: "name") } total @@ -89,7 +88,7 @@ curl -s http://localhost:2020/graphql -H 'Content-Type: application/graphql' -d ### 4. Get all backends your application is using ```graphql -curl -s http://localhost:2020/graphql -H 'Content-Type: application/graphql' -d \ +curl -s localhost:2020/graphql -H 'Content-Type: application/graphql' -d \ '{ entities( type: BACKEND @@ -100,7 +99,6 @@ curl -s http://localhost:2020/graphql -H 'Content-Type: application/graphql' -d offset: 0 ) { results { - id name: attribute(key: "name") } total @@ -111,7 +109,7 @@ curl -s http://localhost:2020/graphql -H 'Content-Type: application/graphql' -d ### 5. Get all API's your application is using ```graphql -curl -s http://localhost:2020/graphql -H 'Content-Type: application/graphql' -d \ +curl -s localhost:2020/graphql -H 'Content-Type: application/graphql' -d \ '{ entities( type: API @@ -122,7 +120,6 @@ curl -s http://localhost:2020/graphql -H 'Content-Type: application/graphql' -d offset: 0 ) { results { - id name: attribute(key: "name") } total @@ -133,7 +130,7 @@ curl -s http://localhost:2020/graphql -H 'Content-Type: application/graphql' -d ### 6. Get service and backend dependency graph ```graphql -curl -s http://localhost:2020/graphql -H 'Content-Type: application/graphql' -d \ +curl -s localhost:2020/graphql -H 'Content-Type: application/graphql' -d \ '{ entities( type: SERVICE @@ -149,7 +146,6 @@ curl -s http://localhost:2020/graphql -H 'Content-Type: application/graphql' -d outgoingEdges_SERVICE: outgoingEdges(neighborType: SERVICE) { results { neighbor { - id name: attribute(key: "name") } } @@ -157,7 +153,6 @@ curl -s http://localhost:2020/graphql -H 'Content-Type: application/graphql' -d outgoingEdges_BACKEND: outgoingEdges(neighborType: BACKEND) { results { neighbor { - id name: attribute(key: "name") } } @@ -165,7 +160,6 @@ curl -s http://localhost:2020/graphql -H 'Content-Type: application/graphql' -d incomingEdges_SERVICE: incomingEdges(neighborType: SERVICE) { results { neighbor { - id name: attribute(key: "name") } } From e5a773008cc51eae93eb51ebabbe3fc1474aa81e Mon Sep 17 00:00:00 2001 From: Jayesh Bapu Ahire Date: Tue, 25 Aug 2020 12:48:48 +0530 Subject: [PATCH 5/7] added limit to find all traces query --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index c81ac2cb..b357a8a2 100644 --- a/README.md +++ b/README.md @@ -24,6 +24,7 @@ curl -s localhost:2020/graphql -H 'Content-Type: application/graphql' -d\ '{ traces( type: API_TRACE + limit: 10 between: { startTime: "2015-01-01T00:00:00.000Z" endTime: "2025-01-01T00:00:00.000Z" From 6b96d0caee931c3a18903ff0a3be09c39977d44f Mon Sep 17 00:00:00 2001 From: Jayesh Bapu Ahire Date: Tue, 25 Aug 2020 14:42:26 +0530 Subject: [PATCH 6/7] addressed SJ's and Adrian's comments --- README.md | 16 +++------------- 1 file changed, 3 insertions(+), 13 deletions(-) diff --git a/README.md b/README.md index b357a8a2..e23c09f3 100644 --- a/README.md +++ b/README.md @@ -9,11 +9,6 @@ Hypertrace GraphQL service serves the GraphQL API which will be used by Hypertra `./gradlew run` -## Ports - -GraphQL Service runs on port 23431 at `/graphql` by default - - ## Queries Here are some of the important GraphQL queries: @@ -58,14 +53,13 @@ curl -s localhost:2020/graphql -H 'Content-Type: application/graphql' -d \ ] ) { results { - id apiName: attribute(key: "apiName") } } }' ``` -### 3. Get all services your application is using +### 3. Get all service names ```graphql curl -s localhost:2020/graphql -H 'Content-Type: application/graphql' -d \ @@ -76,7 +70,6 @@ curl -s localhost:2020/graphql -H 'Content-Type: application/graphql' -d \ startTime: "2015-01-01T00:00:00Z" endTime: "2025-01-01T00:00:00Z" } - offset: 0 ) { results { name: attribute(key: "name") @@ -86,7 +79,7 @@ curl -s localhost:2020/graphql -H 'Content-Type: application/graphql' -d \ }' ``` -### 4. Get all backends your application is using +### 4. Get all backend names ```graphql curl -s localhost:2020/graphql -H 'Content-Type: application/graphql' -d \ @@ -97,7 +90,6 @@ curl -s localhost:2020/graphql -H 'Content-Type: application/graphql' -d \ startTime: "2015-01-01T00:00:00Z" endTime: "2025-01-01T00:00:00Z" } - offset: 0 ) { results { name: attribute(key: "name") @@ -107,7 +99,7 @@ curl -s localhost:2020/graphql -H 'Content-Type: application/graphql' -d \ }' ``` -### 5. Get all API's your application is using +### 5. Get all API names ```graphql curl -s localhost:2020/graphql -H 'Content-Type: application/graphql' -d \ @@ -118,7 +110,6 @@ curl -s localhost:2020/graphql -H 'Content-Type: application/graphql' -d \ startTime: "2015-01-01T00:00:00Z" endTime: "2025-01-01T00:00:00Z" } - offset: 0 ) { results { name: attribute(key: "name") @@ -135,7 +126,6 @@ curl -s localhost:2020/graphql -H 'Content-Type: application/graphql' -d \ '{ entities( type: SERVICE - limit: 100 between: { startTime: "2015-01-01T00:00:00.000Z" endTime: "2025-01-01T00:00:00.000Z" From 871bed3f29e7a5e8f2b5bb20369392cba609da3b Mon Sep 17 00:00:00 2001 From: Jayesh Bapu Ahire Date: Tue, 25 Aug 2020 14:44:44 +0530 Subject: [PATCH 7/7] addressed Adrian's comments --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index e23c09f3..7d498908 100644 --- a/README.md +++ b/README.md @@ -32,7 +32,7 @@ curl -s localhost:2020/graphql -H 'Content-Type: application/graphql' -d\ }' ``` -### 2. Find trace using TraceID +### 2. Verify trace exists ```graphql curl -s localhost:2020/graphql -H 'Content-Type: application/graphql' -d \