Skip to content

Commit

Permalink
contrib/99designs/gqlgen: avoid having example dependencies to our go…
Browse files Browse the repository at this point in the history
….mod

The gqlgen example was leading to github.com/BurntSushi/toml being upgraded
to v1 and forcing our dd-trace-go users to do so, leading to breaking changes.

Such code examples shouldn't introduce breaking changes to dd-trace-go's go.mod
file.So the example was moved into the package godoc to avoid adding its dependencies
into dd-trace-go's go.mod file
  • Loading branch information
Julio-Guerra committed Oct 7, 2022
1 parent 713ff81 commit 33214ea
Show file tree
Hide file tree
Showing 4 changed files with 44 additions and 76 deletions.
28 changes: 3 additions & 25 deletions contrib/99designs/gqlgen/example_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,28 +6,6 @@
// Package gqlgen provides functions to trace the 99designs/gqlgen package (https://github.com/99designs/gqlgen).
package gqlgen_test

import (
"log"
"net/http"

"github.com/99designs/gqlgen/_examples/todo"
"github.com/99designs/gqlgen/graphql/handler"

"gopkg.in/DataDog/dd-trace-go.v1/ddtrace/tracer"

gqlgentrace "gopkg.in/DataDog/dd-trace-go.v1/contrib/99designs/gqlgen"
)

func Example() {
tracer.Start()
defer tracer.Stop()

t := gqlgentrace.NewTracer(
gqlgentrace.WithAnalytics(true),
gqlgentrace.WithServiceName("todo.server"),
)
h := handler.NewDefaultServer(todo.NewExecutableSchema(todo.New()))
h.Use(t)
http.Handle("/query", h)
log.Fatal(http.ListenAndServe(":8080", nil))
}
// The example was moved into the package godoc to avoid adding its dependencies into dd-trace-go's go.mod file,
// where github.com/BurntSushi/toml would be upgraded to v1, which breaks existing users of the v0, like this is the
// case at Datadog's backend. Such code examples shouldn't introduce breaking changes to dd-trace-go's go.mod file.
26 changes: 26 additions & 0 deletions contrib/99designs/gqlgen/tracer.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,32 @@
// any sensitive data in the query will be sent to Datadog as the resource name
// of the span. To ensure no sensitive data is included in your spans, always
// use parameterized graphql queries with sensitive data in variables.
//
// Usage example:
// import (
// "log"
// "net/http"
//
// "github.com/99designs/gqlgen/_examples/todo"
// "github.com/99designs/gqlgen/graphql/handler"
//
// "gopkg.in/DataDog/dd-trace-go.v1/ddtrace/tracer"
// gqlgentrace "gopkg.in/DataDog/dd-trace-go.v1/contrib/99designs/gqlgen"
// )
//
// func Example() {
// tracer.Start()
// defer tracer.Stop()
//
// t := gqlgentrace.NewTracer(
// gqlgentrace.WithAnalytics(true),
// gqlgentrace.WithServiceName("todo.server"),
// )
// h := handler.NewDefaultServer(todo.NewExecutableSchema(todo.New()))
// h.Use(t)
// http.Handle("/query", h)
// log.Fatal(http.ListenAndServe(":8080", nil))
// }
package gqlgen

import (
Expand Down
15 changes: 7 additions & 8 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,7 @@ go 1.17

require (
cloud.google.com/go/pubsub v1.4.0
github.com/99designs/gqlgen v0.17.16
github.com/99designs/gqlgen/_examples v0.0.0-20220829154420-b66fff16de0b
github.com/99designs/gqlgen v0.16.0
github.com/DataDog/datadog-agent/pkg/obfuscate v0.0.0-20211129110424-6491aa3bf583
github.com/DataDog/datadog-go/v5 v5.0.2
github.com/DataDog/gostackparse v0.5.0
Expand Down Expand Up @@ -38,7 +37,7 @@ require (
github.com/gomodule/redigo v1.7.0
github.com/google/pprof v0.0.0-20210423192551-a2663126120b
github.com/google/uuid v1.3.0
github.com/gorilla/mux v1.8.0
github.com/gorilla/mux v1.7.1
github.com/graph-gophers/graphql-go v1.3.0
github.com/hashicorp/consul/api v1.0.0
github.com/hashicorp/vault/api v1.1.0
Expand All @@ -62,7 +61,7 @@ require (
github.com/twitchtv/twirp v8.1.1+incompatible
github.com/urfave/negroni v1.0.0
github.com/valyala/fasthttp v1.34.0 // indirect
github.com/vektah/gqlparser/v2 v2.5.0
github.com/vektah/gqlparser/v2 v2.2.0
github.com/vmihailenco/msgpack/v5 v5.3.4 // indirect
github.com/vmihailenco/tagparser v0.1.2 // indirect
github.com/zenazn/goji v1.0.1
Expand All @@ -89,11 +88,11 @@ require (

require (
cloud.google.com/go v0.57.0 // indirect
github.com/BurntSushi/toml v1.1.0 // indirect
github.com/BurntSushi/toml v0.3.1 // indirect
github.com/DataDog/datadog-go v4.8.2+incompatible // indirect
github.com/DataDog/zstd v1.3.5 // indirect
github.com/Microsoft/go-winio v0.5.1 // indirect
github.com/agnivade/levenshtein v1.1.1 // indirect
github.com/agnivade/levenshtein v1.1.0 // indirect
github.com/andybalholm/brotli v1.0.4 // indirect
github.com/armon/go-metrics v0.3.0 // indirect
github.com/aws/aws-sdk-go-v2/credentials v1.0.0 // indirect
Expand Down Expand Up @@ -125,7 +124,7 @@ require (
github.com/google/gofuzz v1.2.0 // indirect
github.com/googleapis/gax-go/v2 v2.0.5 // indirect
github.com/googleapis/gnostic v0.0.0-20170729233727-0c5108395e2d // indirect
github.com/gorilla/websocket v1.5.0 // indirect
github.com/gorilla/websocket v1.4.2 // indirect
github.com/hailocab/go-hostpool v0.0.0-20160125115350-e80d13ce29ed // indirect
github.com/hashicorp/errwrap v1.1.0 // indirect
github.com/hashicorp/go-cleanhttp v0.5.2 // indirect
Expand Down Expand Up @@ -158,7 +157,7 @@ require (
github.com/labstack/gommon v0.3.1 // indirect
github.com/leodido/go-urn v1.2.0 // indirect
github.com/mailru/easyjson v0.7.7 // indirect
github.com/mattn/go-colorable v0.1.12 // indirect
github.com/mattn/go-colorable v0.1.11 // indirect
github.com/mattn/go-isatty v0.0.14 // indirect
github.com/mitchellh/go-homedir v1.1.0 // indirect
github.com/mitchellh/mapstructure v1.4.2 // indirect
Expand Down

0 comments on commit 33214ea

Please sign in to comment.