-
Notifications
You must be signed in to change notification settings - Fork 162
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #332 from walmartlabs/20200828-apollo-tracing
Convert ad-hoc timing to follow the standard for Apollo GraphQL tracing
- Loading branch information
Showing
22 changed files
with
606 additions
and
376 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
(ns tracing-demo | ||
(:require | ||
[com.walmartlabs.lacinia :as lacinia] | ||
[com.walmartlabs.lacinia.tracing :as tracing] | ||
[com.walmartlabs.lacinia-test :as lacinia-test] | ||
[com.walmartlabs.lacinia.resolve :as resolve] | ||
[com.walmartlabs.test-utils :refer [simplify]]) | ||
(:import (java.util.concurrent ThreadPoolExecutor TimeUnit SynchronousQueue))) | ||
|
||
(def star-wars-schema lacinia-test/default-schema) | ||
|
||
(comment | ||
(let [queue (SynchronousQueue.) | ||
thread-pool (ThreadPoolExecutor. 5 10 1 TimeUnit/SECONDS queue)] | ||
;; Ensure all core thread are started and ready, however, for the tiny | ||
;; resolvers in the example, it's hard to show parallel behavior. Need some I/O. | ||
(while (.prestartCoreThread thread-pool)) | ||
(try | ||
(binding [resolve/*callback-executor* thread-pool] | ||
|
||
(simplify | ||
(lacinia/execute | ||
star-wars-schema " | ||
{ | ||
luke: human(id: \"1000\") { friends { name }} | ||
leia: human(id: \"1003\") { name } | ||
}" | ||
nil | ||
(tracing/enable-tracing nil)))) | ||
(finally | ||
(.shutdown thread-pool)))) | ||
|
||
|
||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
(require '[com.walmartlabs.lacinia :as lacinia] | ||
[com.walmartlabs.lacinia.tracing :as tracing]) | ||
|
||
(def start-wars-schema ...) | ||
|
||
(lacinia/execute | ||
star-wars-schema " | ||
{ | ||
luke: human(id: \"1000\") { friends { name }} | ||
leia: human(id: \"1003\") { name } | ||
}" | ||
nil | ||
(tracing/enable-tracing nil)) | ||
=> | ||
{:data {:luke {:friends [{:name "Han Solo"} | ||
{:name "Leia Organa"} | ||
{:name "C-3PO"} | ||
{:name "R2-D2"}]}, | ||
:leia {:name "Leia Organa"}}, | ||
:extensions {:tracing {:version 1, | ||
:startTime "2020-08-31T22:14:25.401Z", | ||
:endTime "2020-08-31T22:14:25.449Z", | ||
:duration 47430231, | ||
:parsing {:startOffset 68824, :duration 38932608}, | ||
:validation {:startOffset 39099642, :duration 1941960}, | ||
:execution {:resolvers [{:path [:luke], | ||
:parentType :QueryRoot, | ||
:fieldName :human, | ||
:returnType "human!", | ||
:startOffset 42476480, | ||
:duration 303264} | ||
{:path [:luke :friends], | ||
:parentType :human, | ||
:fieldName :friends, | ||
:returnType "[character]", | ||
:startOffset 43183550, | ||
:duration 185802} | ||
{:path [:luke :friends 0 :name], | ||
:parentType :human, | ||
:fieldName :name, | ||
:returnType "String", | ||
:startOffset 43669784, | ||
:duration 16145} | ||
{:path [:luke :friends 1 :name], | ||
:parentType :human, | ||
:fieldName :name, | ||
:returnType "String", | ||
:startOffset 44205401, | ||
:duration 4629} | ||
{:path [:luke :friends 2 :name], | ||
:parentType :droid, | ||
:fieldName :name, | ||
:returnType "String", | ||
:startOffset 44346489, | ||
:duration 4563} | ||
{:path [:luke :friends 3 :name], | ||
:parentType :droid, | ||
:fieldName :name, | ||
:returnType "String", | ||
:startOffset 44477160, | ||
:duration 3971} | ||
{:path [:leia], | ||
:parentType :QueryRoot, | ||
:fieldName :human, | ||
:returnType "human!", | ||
:startOffset 46609256, | ||
:duration 130413} | ||
{:path [:leia :name], | ||
:parentType :human, | ||
:fieldName :name, | ||
:returnType "String", | ||
:startOffset 46866059, | ||
:duration 7833}]}}}} |
Oops, something went wrong.