-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' into feat-complexity
- Loading branch information
Showing
14 changed files
with
2,899 additions
and
118 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,62 @@ | ||
package gqlapollotracing | ||
|
||
import ( | ||
"sync" | ||
"time" | ||
) | ||
|
||
type tracingData struct { | ||
mu sync.Mutex | ||
|
||
StartTime time.Time `json:"startTime"` | ||
EndTime time.Time `json:"endTime"` | ||
Duration time.Duration `json:"duration"` | ||
Parsing *startOffset `json:"parsing"` | ||
Validation *startOffset `json:"validation"` | ||
Execution *execution `json:"execution"` | ||
} | ||
|
||
func (td *tracingData) prepare() { | ||
td.Duration = td.EndTime.Sub(td.StartTime) | ||
if td.Parsing != nil { | ||
td.Parsing.prepare(td) | ||
} | ||
if td.Validation != nil { | ||
td.Validation.prepare(td) | ||
} | ||
if td.Execution != nil { | ||
td.Execution.prepare(td) | ||
} | ||
} | ||
|
||
type startOffset struct { | ||
StartTime time.Time `json:"-"` | ||
EndTime time.Time `json:"-"` | ||
|
||
StartOffset time.Duration `json:"startOffset"` | ||
Duration time.Duration `json:"duration"` | ||
} | ||
|
||
func (so *startOffset) prepare(td *tracingData) { | ||
so.StartOffset = so.StartTime.Sub(td.StartTime) | ||
so.Duration = so.EndTime.Sub(so.StartTime) | ||
} | ||
|
||
type execution struct { | ||
Resolvers []*executionSpan `json:"resolvers"` | ||
} | ||
|
||
func (e *execution) prepare(td *tracingData) { | ||
for _, es := range e.Resolvers { | ||
es.prepare(td) | ||
} | ||
} | ||
|
||
type executionSpan struct { | ||
startOffset | ||
|
||
Path []interface{} `json:"path"` | ||
ParentType string `json:"parentType"` | ||
FieldName string `json:"fieldName"` | ||
ReturnType string `json:"returnType"` | ||
} |
Oops, something went wrong.