Skip to content

Commit

Permalink
Move tracing to contrib
Browse files Browse the repository at this point in the history
  • Loading branch information
Adam Scarr committed Nov 2, 2018
1 parent a3a9277 commit f0dbce5
Show file tree
Hide file tree
Showing 19 changed files with 1 addition and 3,083 deletions.
28 changes: 1 addition & 27 deletions Gopkg.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 0 additions & 3 deletions example/chat/server/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import (

"github.com/99designs/gqlgen/example/chat"
"github.com/99designs/gqlgen/handler"
gqlopentracing "github.com/99designs/gqlgen/opentracing"
"github.com/gorilla/websocket"
"github.com/opentracing/opentracing-go"
"sourcegraph.com/sourcegraph/appdash"
Expand All @@ -21,8 +20,6 @@ func main() {

http.Handle("/", handler.Playground("Todo", "/query"))
http.Handle("/query", handler.GraphQL(chat.NewExecutableSchema(chat.New()),
handler.ResolverMiddleware(gqlopentracing.ResolverMiddleware()),
handler.RequestMiddleware(gqlopentracing.RequestMiddleware()),
handler.WebsocketUpgrader(websocket.Upgrader{
CheckOrigin: func(r *http.Request) bool {
return true
Expand Down
51 changes: 0 additions & 51 deletions example/dataloader/server/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,72 +3,21 @@ package main
import (
"log"
"net/http"
"net/url"
"time"

"github.com/99designs/gqlgen/example/dataloader"
"github.com/99designs/gqlgen/handler"
gqlopentracing "github.com/99designs/gqlgen/opentracing"
"github.com/go-chi/chi"
"github.com/opentracing-contrib/go-stdlib/nethttp"
"github.com/opentracing/opentracing-go"
"sourcegraph.com/sourcegraph/appdash"
appdashtracer "sourcegraph.com/sourcegraph/appdash/opentracing"
"sourcegraph.com/sourcegraph/appdash/traceapp"
)

func main() {
tracer := startAppdashServer()

router := chi.NewRouter()
router.Use(Opentracing(tracer))
router.Use(dataloader.LoaderMiddleware)

router.Handle("/", handler.Playground("Dataloader", "/query"))
router.Handle("/query", handler.GraphQL(
dataloader.NewExecutableSchema(dataloader.Config{Resolvers: &dataloader.Resolver{}}),
handler.ResolverMiddleware(gqlopentracing.ResolverMiddleware()),
handler.RequestMiddleware(gqlopentracing.RequestMiddleware()),
))

log.Println("connect to http://localhost:8082/ for graphql playground")
log.Fatal(http.ListenAndServe(":8082", router))
}

func Opentracing(tracer opentracing.Tracer) func(next http.Handler) http.Handler {
return func(next http.Handler) http.Handler {
return nethttp.Middleware(tracer, next)
}
}

func startAppdashServer() opentracing.Tracer {
memStore := appdash.NewMemoryStore()
store := &appdash.RecentStore{
MinEvictAge: 5 * time.Minute,
DeleteStore: memStore,
}

url, err := url.Parse("http://localhost:8700")
if err != nil {
log.Fatal(err)
}
tapp, err := traceapp.New(nil, url)
if err != nil {
log.Fatal(err)
}
tapp.Store = store
tapp.Queryer = memStore

go func() {
log.Fatal(http.ListenAndServe(":8700", tapp))
}()
tapp.Store = store
tapp.Queryer = memStore

collector := appdash.NewLocalCollector(store)
tracer := appdashtracer.NewTracer(collector)
opentracing.InitGlobalTracer(tracer)

log.Println("Appdash web UI running on HTTP :8700")
return tracer
}
62 changes: 0 additions & 62 deletions gqlapollotracing/extension.go

This file was deleted.

Loading

0 comments on commit f0dbce5

Please sign in to comment.