Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Move tracing to contrib #410

Merged
merged 1 commit into from
Nov 2, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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