Documentation ¶
Overview ¶
Package gqlgen contains an implementation of a gqlgen tracer, and functions to construct and configure the tracer. The tracer can be passed to the gqlgen handler (see package github.com/99designs/gqlgen/handler)
Warning: Data obfuscation hasn't been implemented for graphql queries yet, 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" "github.com/0angelic0/dd-trace-go/ddtrace/tracer" gqlgentrace "github.com/0angelic0/dd-trace-go/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)) }
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func NewTracer ¶
func NewTracer(opts ...Option) graphql.HandlerExtension
NewTracer creates a graphql.HandlerExtension instance that can be used with a graphql.handler.Server. Options can be passed in for further configuration.
Types ¶
type Option ¶
type Option func(cfg *config)
An Option configures the gqlgen integration.
func WithAnalytics ¶
WithAnalytics enables or disables Trace Analytics for all started spans.
func WithAnalyticsRate ¶
WithAnalyticsRate sets the sampling rate for Trace Analytics events correlated to started spans.
func WithCustomTag ¶
WithCustomTag will attach the value to the span tagged by the key.
func WithServiceName ¶
WithServiceName sets the given service name for the gqlgen server.
func WithoutTraceIntrospectionQuery ¶
func WithoutTraceIntrospectionQuery() Option
WithoutTraceIntrospectionQuery skips creating spans for fields when the operation name is IntrospectionQuery.
func WithoutTraceTrivialResolvedFields ¶
func WithoutTraceTrivialResolvedFields() Option
WithoutTraceTrivialResolvedFields skips creating spans for fields that have a trivial resolver. For example, a field resolved from an object w/o requiring a custom method is considered trivial.