gqlgen

package module
v0.0.0-...-7ebff8f Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 20, 2024 License: Apache-2.0, BSD-3-Clause Imports: 13 Imported by: 0

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/DataDog/dd-trace-go/v2/ddtrace/tracer"
	gqlgentrace "github.com/DataDog/dd-trace-go/v2/contrib/99designs/gqlgen"
)

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

	t := gqlgentrace.NewTracer(
		gqlgentrace.WithAnalytics(true),
		gqlgentrace.WithService("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 interface {
	// contains filtered or unexported methods
}

An Option describes options for the gqlgen integration.

type OptionFn

type OptionFn func(*config)

OptionFn represents an option that can be passed to gqlgen tracer.

func WithAnalytics

func WithAnalytics(on bool) OptionFn

WithAnalytics enables or disables Trace Analytics for all started spans.

func WithAnalyticsRate

func WithAnalyticsRate(rate float64) OptionFn

WithAnalyticsRate sets the sampling rate for Trace Analytics events correlated to started spans.

func WithCustomTag

func WithCustomTag(key string, value interface{}) OptionFn

WithCustomTag will attach the value to the span tagged by the key.

func WithService

func WithService(name string) OptionFn

WithService sets the given service name for the gqlgen server.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL